diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp
index 66ca4fca27..2872694fc0 100644
--- a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp
+++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp
@@ -166,8 +166,16 @@ public:
void render_input_window(float x, float y, float bottom_limit);
virtual std::string get_tooltip() const { return ""; }
+
+ ///
+ /// Implement when you want process mouse events in gizmo
+ /// Click, Right click, move, drag, ...
+ ///
+ /// Keep information about mouse + some action key like alt, shift, ...
+ /// Return True when Gizmo use the information and don't want to propagate it. Otherwise False.
+ virtual bool on_mouse(const wxMouseEvent &mouse_event) { return false; }
-protected:
+ protected:
virtual bool on_init() = 0;
virtual void on_load(cereal::BinaryInputArchive& ar) {}
virtual void on_save(cereal::BinaryOutputArchive& ar) const {}
diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp
index 4349eb8947..ee8afe7666 100644
--- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp
+++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp
@@ -201,7 +201,13 @@ GLGizmoEmboss::GLGizmoEmboss(GLCanvas3D &parent)
, m_volume(nullptr)
, m_exist_notification(false)
, m_is_initialized(false) // initialize on first opening gizmo
- , m_rotate_gizmo(parent, GLGizmoRotate::Axis::Z)
+ , m_rotate_gizmo(parent, GLGizmoRotate::Axis::Z) // grab id = 2 (Z axis)
+ , m_move_grabber(
+ GLModel(),
+ 0, // grab id
+ DEFAULT_BASE_COLOR,
+ DEFAULT_DRAG_COLOR
+ )
{
m_rotate_gizmo.set_group_id(0);
// TODO: add suggestion to use https://fontawesome.com/
@@ -280,33 +286,43 @@ void GLGizmoEmboss::create_volume(ModelVolumeType volume_type, const Vec2d& mous
selection.get_object_idx());
}
+bool GLGizmoEmboss::on_mouse(const wxMouseEvent &evt)
+{
+ if (m_dragging) {
+ // temporary rotation
+ TransformationType transformation_type(TransformationType::Local_Relative_Independent);
+ Vec3d rotation(0., 0., m_rotate_gizmo.get_angle());
+ m_parent.get_selection().rotate(rotation, transformation_type);
+ }
+ if (evt.LeftUp() && m_dragging) {
+ // apply rotation
+ m_parent.do_rotate(L("Text-Rotate"));
+ }
+ return false;
+}
+
bool GLGizmoEmboss::on_init()
{
m_rotate_gizmo.init();
std::array gray_color = {.6f, .6f, .6f, .3f};
m_rotate_gizmo.set_highlight_color(gray_color);
- // m_grabbers.emplace_back();
+
+ m_move_grabber.shape.init_from(its_make_cube(1., 1., 1.));
+
m_shortcut_key = WXK_CONTROL_T;
return true;
}
std::string GLGizmoEmboss::on_get_name() const { return _u8L("Emboss"); }
-template static void render_rotate_gizmo(Tfnc fnc) {
- //ObjectManipulation *manipul = wxGetApp().obj_manipul();
- //auto tmp = manipul->get_coordinates_type();
- //manipul->set_coordinates_type(ECoordinatesType::Local);
- fnc();
- //manipul->set_coordinates_type(tmp);
-}
-
void GLGizmoEmboss::on_render() {
// no volume selected
if (m_volume == nullptr) return;
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
- render_rotate_gizmo([&gizmo = m_rotate_gizmo]() { gizmo.render(); });
+ m_rotate_gizmo.render();
+ m_move_grabber.shape.render();
if (!m_preview.is_initialized()) return;
@@ -323,7 +339,7 @@ void GLGizmoEmboss::on_render() {
}
void GLGizmoEmboss::on_render_for_picking() {
- render_rotate_gizmo([&gizmo = m_rotate_gizmo]() { gizmo.render_for_picking(); });
+ m_rotate_gizmo.render_for_picking();
}
void GLGizmoEmboss::on_render_input_window(float x, float y, float bottom_limit)
@@ -424,7 +440,15 @@ CommonGizmosDataID GLGizmoEmboss::on_get_requirements() const
}
void GLGizmoEmboss::on_start_dragging() { m_rotate_gizmo.start_dragging(); }
-void GLGizmoEmboss::on_stop_dragging() { m_rotate_gizmo.start_dragging(); }
+void GLGizmoEmboss::on_stop_dragging()
+{
+ m_rotate_gizmo.stop_dragging();
+
+ // TODO: when start second rotatiton previous rotation rotate draggers
+ // This is fast fix for second try to rotate
+ // When fixing, move grabber above text (not on side)
+ m_rotate_gizmo.set_angle(0);
+}
void GLGizmoEmboss::initialize()
{
@@ -709,7 +733,7 @@ std::optional GLGizmoEmboss::transform_on_surface(
Selection &selection = m_parent.get_selection();
// check selection has volume
if (selection.volumes_count() < 0) return {};
- assert(selection.volumes_count() == (int)raycasters.size());
+ assert(selection.volumes_count() == (unsigned int)raycasters.size());
const Camera &camera = wxGetApp().plater()->get_camera();
@@ -890,7 +914,7 @@ void GLGizmoEmboss::draw_font_list()
store_font_list();
ImGui::CloseCurrentPopup();
} else if (ImGui::IsItemHovered())
- ImGui::SetTooltip(
+ ImGui::SetTooltip("%s",
_u8L("Choose from installed font inside dialog.").c_str());
#ifdef ALLOW_DEBUG_MODE
@@ -900,7 +924,8 @@ void GLGizmoEmboss::draw_font_list()
choose_true_type_file();
store_font_list();
ImGui::CloseCurrentPopup();
- } else if (ImGui::IsItemHovered()) ImGui::SetTooltip(_u8L("add file with font(.ttf, .ttc)").c_str());
+ } else if (ImGui::IsItemHovered())
+ ImGui::SetTooltip("%s",_u8L("add file with font(.ttf, .ttc)").c_str());
#endif // ALLOW_DEBUG_MODE
ImGui::Separator();
@@ -921,7 +946,7 @@ void GLGizmoEmboss::draw_font_list()
process();
}
} else if (ImGui::IsItemHovered())
- ImGui::SetTooltip(f.name.c_str());
+ ImGui::SetTooltip("%s", f.name.c_str());
// draw buttons rename and delete
ImGui::SameLine();
@@ -1029,7 +1054,7 @@ void GLGizmoEmboss::draw_advanced()
if (ImGui::BeginCombo(_u8L("Font collection").c_str(),
std::to_string(m_font->index).c_str())) {
for (unsigned int i = 0; i < m_font->count; ++i) {
- ImGui::PushID(1 << 10 + i);
+ ImGui::PushID(1 << (10 + i));
if (ImGui::Selectable(std::to_string(i).c_str(),
i == m_font->index)) {
m_font->index = i;
@@ -1477,7 +1502,7 @@ bool GLGizmoEmboss::draw_button(IconType icon, bool disable)
if (disable) {
draw_icon(icon, IconState::disabled);
if (ImGui::IsItemHovered() && icon == IconType::erase)
- ImGui::SetTooltip(_u8L("Active font can't be removed").c_str());
+ ImGui::SetTooltip("%s",_u8L("Active font can't be removed").c_str());
return false;
}
@@ -1488,10 +1513,10 @@ bool GLGizmoEmboss::draw_button(IconType icon, bool disable)
if (ImGui::IsItemHovered()) {
switch (icon) {
case IconType::rename:
- ImGui::SetTooltip(_u8L("rename").c_str());
+ ImGui::SetTooltip("%s", _u8L("rename").c_str());
break;
case IconType::erase:
- ImGui::SetTooltip(_u8L("delete").c_str());
+ ImGui::SetTooltip("%s", _u8L("delete").c_str());
break;
default: break;
}
diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp
index b79a99a1a3..e8692b49f2 100644
--- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp
+++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp
@@ -32,6 +32,13 @@ public:
void create_volume(ModelVolumeType volume_type, const Vec2d &mouse_pos = Vec2d(-1,-1));
void set_fine_position();
+
+ ///
+ /// Rotate by text on dragging rotate grabers
+ ///
+ /// Information about mouse
+ /// Propagete normaly return false.
+ bool on_mouse(const wxMouseEvent &mouse_event) override;
protected:
bool on_init() override;
std::string on_get_name() const override;
@@ -137,6 +144,30 @@ private:
// Rotation gizmo
GLGizmoRotate m_rotate_gizmo;
+
+ struct MyGrabber
+ {
+ GLModel shape;
+ int grab_id;
+ std::array color;
+ std::array hovered_color;
+
+ MyGrabber(GLModel shape,
+ int grab_id,
+ std::array color,
+ std::array hovered_color)
+ : shape(shape)
+ , grab_id(grab_id)
+ , color(color)
+ , hovered_color(hovered_color)
+ {}
+
+ void render() {
+
+ }
+ };
+ // Translate on surface of model
+ MyGrabber m_move_grabber;
// preview position
GLModel m_preview;
diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp
index 620fd0c591..55ab580870 100644
--- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp
+++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp
@@ -537,6 +537,9 @@ bool GLGizmosManager::on_mouse_wheel(wxMouseEvent& evt)
bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
{
+ if (m_current != Undefined && m_gizmos[m_current]->on_mouse(evt))
+ return true;
+
// used to set a right up event as processed when needed
static bool pending_right_up = false;