mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-09 15:57:55 -06:00
ENH: add seam painting
Signed-off-by: yifan.wu <yifan.wu@bambulab.com> Change-Id: I5f2bcf8ffe87d8d6a311e3a601497da2fa82047e
This commit is contained in:
parent
ec8f1265f6
commit
16dc147d30
5 changed files with 1 additions and 186 deletions
|
@ -127,8 +127,6 @@ set(SLIC3R_GUI_SOURCES
|
||||||
GUI/Gizmos/GLGizmoFaceDetector.hpp
|
GUI/Gizmos/GLGizmoFaceDetector.hpp
|
||||||
GUI/Gizmos/GLGizmoSeam.cpp
|
GUI/Gizmos/GLGizmoSeam.cpp
|
||||||
GUI/Gizmos/GLGizmoSeam.hpp
|
GUI/Gizmos/GLGizmoSeam.hpp
|
||||||
GUI/Gizmos/GLGizmoModifier.cpp
|
|
||||||
GUI/Gizmos/GLGizmoModifier.hpp
|
|
||||||
GUI/GLSelectionRectangle.cpp
|
GUI/GLSelectionRectangle.cpp
|
||||||
GUI/GLSelectionRectangle.hpp
|
GUI/GLSelectionRectangle.hpp
|
||||||
GUI/Gizmos/GizmoObjectManipulation.cpp
|
GUI/Gizmos/GizmoObjectManipulation.cpp
|
||||||
|
|
|
@ -1,138 +0,0 @@
|
||||||
// Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code, which overrides our localization "L" macro.
|
|
||||||
#include "GLGizmoModifier.hpp"
|
|
||||||
#include "slic3r/GUI/GUI_App.hpp"
|
|
||||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
|
||||||
#include "slic3r/GUI/ImGuiWrapper.hpp"
|
|
||||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
|
|
||||||
|
|
||||||
#include "libslic3r/Geometry/ConvexHull.hpp"
|
|
||||||
#include "libslic3r/Model.hpp"
|
|
||||||
|
|
||||||
#include <numeric>
|
|
||||||
|
|
||||||
#include <GL/glew.h>
|
|
||||||
|
|
||||||
namespace Slic3r {
|
|
||||||
namespace GUI {
|
|
||||||
|
|
||||||
const int SHAPE_IMAGE_SIZE = 34;
|
|
||||||
|
|
||||||
const std::vector<std::pair<std::string, std::string>> GLGizmoModifier::MODIFIER_SHAPES = {
|
|
||||||
{L("Cube"), "toolbar_modifier_cube.svg" },
|
|
||||||
{L("Cylinder"), "toolbar_modifier_cylinder.svg" },
|
|
||||||
{L("Sphere"), "toolbar_modifier_sphere.svg" },
|
|
||||||
{L("Cone"), "toolbar_modifier_cone.svg" },
|
|
||||||
{L("Timelapse Wipe Tower"), "toolbar_modifier_cube.svg"},
|
|
||||||
};
|
|
||||||
|
|
||||||
GLGizmoModifier::GLGizmoModifier(GLCanvas3D &parent, const std::string &icon_filename, unsigned int sprite_id)
|
|
||||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLGizmoModifier::on_init()
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
texture_ids.clear();
|
|
||||||
for (auto item: MODIFIER_SHAPES) {
|
|
||||||
result = result && init_shape_texture(item.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
// BBS
|
|
||||||
m_shortcut_key = WXK_NONE;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLGizmoModifier::init_shape_texture(std::string image_name)
|
|
||||||
{
|
|
||||||
// init shapes image
|
|
||||||
bool compress = false;
|
|
||||||
GLint last_texture;
|
|
||||||
unsigned m_image_texture{0};
|
|
||||||
|
|
||||||
std::string path = resources_dir() + "/images/";
|
|
||||||
std::string file_name = path + image_name;
|
|
||||||
|
|
||||||
ThumbnailData data;
|
|
||||||
if (!get_data_from_svg(file_name, SHAPE_IMAGE_SIZE, data)) return false;
|
|
||||||
|
|
||||||
unsigned char *pixels = (unsigned char *) (&data.pixels[0]);
|
|
||||||
glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
|
||||||
glsafe(::glGenTextures(1, &m_image_texture));
|
|
||||||
glsafe(::glBindTexture(GL_TEXTURE_2D, m_image_texture));
|
|
||||||
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
|
||||||
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
|
||||||
glsafe(::glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
|
||||||
if (compress && GLEW_EXT_texture_compression_s3tc)
|
|
||||||
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, data.width, data.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
|
||||||
else
|
|
||||||
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data.width, data.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
|
||||||
|
|
||||||
// Store our identifier
|
|
||||||
ImTextureID texture_id = (ImTextureID) (intptr_t) m_image_texture;
|
|
||||||
texture_ids.push_back(texture_id);
|
|
||||||
// Restore state
|
|
||||||
glsafe(::glBindTexture(GL_TEXTURE_2D, last_texture));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoModifier::on_set_state()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoModifier::on_render_input_window(float x, float y, float bottom_limit)
|
|
||||||
{
|
|
||||||
// BBS: GUI refactor: move gizmo to the right
|
|
||||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always, 0.f, 0.0f);
|
|
||||||
|
|
||||||
// BBS
|
|
||||||
ImGuiWrapper::push_toolbar_style();
|
|
||||||
|
|
||||||
std::string name = "Add Modifier##Modifier";
|
|
||||||
m_imgui->begin(_L(name), ImGuiWrapper::TOOLBAR_WINDOW_FLAGS);
|
|
||||||
|
|
||||||
for (int i = 0; i < MODIFIER_SHAPES.size(); i++) {
|
|
||||||
if (ImGui::ImageButton(texture_ids[i], ImVec2(34.0f, 34.0f))) {
|
|
||||||
wxGetApp().obj_list()->load_generic_subobject(MODIFIER_SHAPES[i].first, ModelVolumeType::PARAMETER_MODIFIER);
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
}
|
|
||||||
m_imgui->end();
|
|
||||||
ImGuiWrapper::pop_toolbar_style();
|
|
||||||
}
|
|
||||||
|
|
||||||
CommonGizmosDataID GLGizmoModifier::on_get_requirements() const
|
|
||||||
{
|
|
||||||
return CommonGizmosDataID::SelectionInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GLGizmoModifier::on_get_name() const
|
|
||||||
{
|
|
||||||
return _u8L("Add Modifier");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLGizmoModifier::on_is_activable() const
|
|
||||||
{
|
|
||||||
return m_parent.get_selection().is_single_full_instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoModifier::on_start_dragging()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoModifier::on_render()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoModifier::on_render_for_picking()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace GUI
|
|
||||||
} // namespace Slic3r
|
|
|
@ -1,42 +0,0 @@
|
||||||
#ifndef slic3r_GLGizmoModifier_hpp_
|
|
||||||
#define slic3r_GLGizmoModifier_hpp_
|
|
||||||
|
|
||||||
#include "GLGizmoBase.hpp"
|
|
||||||
#include "slic3r/GUI/3DScene.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
|
||||||
|
|
||||||
enum class ModelVolumeType : int;
|
|
||||||
|
|
||||||
|
|
||||||
namespace GUI {
|
|
||||||
|
|
||||||
class GLGizmoModifier : public GLGizmoBase
|
|
||||||
{
|
|
||||||
// This gizmo does not use grabbers. The m_hover_id relates to polygon managed by the class itself.
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<void*> texture_ids;
|
|
||||||
public:
|
|
||||||
static const std::vector<std::pair<std::string, std::string>> MODIFIER_SHAPES;
|
|
||||||
GLGizmoModifier(GLCanvas3D &parent, const std::string &icon_filename, unsigned int sprite_id);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual bool on_init() override;
|
|
||||||
virtual std::string on_get_name() const override;
|
|
||||||
virtual bool on_is_activable() const override;
|
|
||||||
virtual void on_start_dragging() override;
|
|
||||||
virtual void on_render() override;
|
|
||||||
virtual void on_render_for_picking() override;
|
|
||||||
virtual void on_set_state() override;
|
|
||||||
virtual void on_render_input_window(float x, float y, float bottom_limit);
|
|
||||||
virtual CommonGizmosDataID on_get_requirements() const override;
|
|
||||||
|
|
||||||
bool init_shape_texture(std::string image_name);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GUI
|
|
||||||
} // namespace Slic3r
|
|
||||||
|
|
||||||
#endif // slic3r_GLGizmoFlatten_hpp_
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoSeam.hpp"
|
#include "slic3r/GUI/Gizmos/GLGizmoSeam.hpp"
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp"
|
#include "slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp"
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoSimplify.hpp"
|
#include "slic3r/GUI/Gizmos/GLGizmoSimplify.hpp"
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoModifier.hpp"
|
|
||||||
|
|
||||||
#include "libslic3r/format.hpp"
|
#include "libslic3r/format.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
|
@ -148,8 +147,7 @@ bool GLGizmosManager::init()
|
||||||
m_gizmos.emplace_back(new GLGizmoFdmSupports(m_parent, "toolbar_support.svg", EType::FdmSupports));
|
m_gizmos.emplace_back(new GLGizmoFdmSupports(m_parent, "toolbar_support.svg", EType::FdmSupports));
|
||||||
m_gizmos.emplace_back(new GLGizmoMmuSegmentation(m_parent, "mmu_segmentation.svg", EType::MmuSegmentation));
|
m_gizmos.emplace_back(new GLGizmoMmuSegmentation(m_parent, "mmu_segmentation.svg", EType::MmuSegmentation));
|
||||||
m_gizmos.emplace_back(new GLGizmoSimplify(m_parent, "reduce_triangles.svg", EType::Simplify));
|
m_gizmos.emplace_back(new GLGizmoSimplify(m_parent, "reduce_triangles.svg", EType::Simplify));
|
||||||
//m_gizmos.emplace_back(new GLGizmoModifier(m_parent, "toolbar_modifier.svg", EType::Modifier));
|
m_gizmos.emplace_back(new GLGizmoSeam(m_parent, "toolbar_seam.svg", EType::Seam));
|
||||||
//m_gizmos.emplace_back(new GLGizmoSeam(m_parent, "toolbar_seam.svg", EType::Seam));
|
|
||||||
//m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++));
|
//m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++));
|
||||||
//m_gizmos.emplace_back(new GLGizmoFaceDetector(m_parent, "face recognition.svg", sprite_id++));
|
//m_gizmos.emplace_back(new GLGizmoFaceDetector(m_parent, "face recognition.svg", sprite_id++));
|
||||||
//m_gizmos.emplace_back(new GLGizmoHollow(m_parent, "hollow.svg", sprite_id++));
|
//m_gizmos.emplace_back(new GLGizmoHollow(m_parent, "hollow.svg", sprite_id++));
|
||||||
|
|
|
@ -73,7 +73,6 @@ public:
|
||||||
FdmSupports,
|
FdmSupports,
|
||||||
MmuSegmentation,
|
MmuSegmentation,
|
||||||
Simplify,
|
Simplify,
|
||||||
Modifier,
|
|
||||||
Seam,
|
Seam,
|
||||||
SlaSupports,
|
SlaSupports,
|
||||||
// BBS
|
// BBS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue