Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2018-09-19 16:39:54 +0300
committerEnrico Turri <enricoturri@seznam.cz>2018-09-19 16:39:54 +0300
commitc9acd1252aa59236ed4a76edc73f29379e5c8e32 (patch)
tree89bdfa2032301b8b808d62ec47cb9c5b1da9f0db /xs
parent3f0968fb0274956ad7fa84b0fa35de3821e8d114 (diff)
reset transformation components to their default value by double clicking on gizmos' grabbers
Diffstat (limited to 'xs')
-rw-r--r--xs/src/libslic3r/Technologies.hpp2
-rw-r--r--xs/src/slic3r/GUI/GLCanvas3D.cpp44
-rw-r--r--xs/src/slic3r/GUI/GLCanvas3D.hpp3
-rw-r--r--xs/src/slic3r/GUI/GLGizmo.cpp14
-rw-r--r--xs/src/slic3r/GUI/GLGizmo.hpp20
5 files changed, 83 insertions, 0 deletions
diff --git a/xs/src/libslic3r/Technologies.hpp b/xs/src/libslic3r/Technologies.hpp
index 5c4f8617d..0343bb00c 100644
--- a/xs/src/libslic3r/Technologies.hpp
+++ b/xs/src/libslic3r/Technologies.hpp
@@ -6,6 +6,8 @@
// Add z coordinate to model instances' offset
#define ENABLE_MODELINSTANCE_3D_OFFSET (1 && ENABLE_1_42_0)
+// Add double click on gizmo grabbers to reset transformation components to their default value
+#define ENABLE_GIZMOS_RESET (1 && ENABLE_1_42_0)
#endif // _technologies_h_
diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp
index cb3250916..c62652994 100644
--- a/xs/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp
@@ -1349,6 +1349,18 @@ void GLCanvas3D::Gizmos::update(const Linef3& mouse_ray)
curr->update(mouse_ray);
}
+#if ENABLE_GIZMOS_RESET
+void GLCanvas3D::Gizmos::process_double_click()
+{
+ if (!m_enabled)
+ return;
+
+ GLGizmoBase* curr = _get_current();
+ if (curr != nullptr)
+ curr->process_double_click();
+}
+#endif // ENABLE_GIZMOS_RESET
+
GLCanvas3D::Gizmos::EType GLCanvas3D::Gizmos::get_current_type() const
{
return m_current;
@@ -3043,6 +3055,38 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_toolbar_action_running = true;
m_toolbar.do_action((unsigned int)toolbar_contains_mouse);
}
+#if ENABLE_GIZMOS_RESET
+ else if (evt.LeftDClick() && m_gizmos.grabber_contains_mouse())
+ {
+ m_gizmos.process_double_click();
+ switch (m_gizmos.get_current_type())
+ {
+ case Gizmos::Scale:
+ {
+ m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
+ update_scale_values();
+ m_dirty = true;
+ break;
+ }
+ case Gizmos::Rotate:
+ {
+#if ENABLE_MODELINSTANCE_3D_ROTATION
+ const Vec3d& rotation = m_gizmos.get_rotation();
+ m_on_gizmo_rotate_3D_callback.call(rotation(0), rotation(1), rotation(2));
+#else
+ m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
+#endif //ENABLE_MODELINSTANCE_3D_ROTATION
+ update_rotation_values();
+ m_dirty = true;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+#endif // ENABLE_GIZMOS_RESET
else if (evt.LeftDown() || evt.RightDown())
{
// If user pressed left or right button we first check whether this happened
diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp
index 528f73fc1..2c830f58e 100644
--- a/xs/src/slic3r/GUI/GLCanvas3D.hpp
+++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp
@@ -366,6 +366,9 @@ class GLCanvas3D
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const;
bool grabber_contains_mouse() const;
void update(const Linef3& mouse_ray);
+#if ENABLE_GIZMOS_RESET
+ void process_double_click();
+#endif // ENABLE_GIZMOS_RESET
EType get_current_type() const;
diff --git a/xs/src/slic3r/GUI/GLGizmo.cpp b/xs/src/slic3r/GUI/GLGizmo.cpp
index e23958c1d..1890a7bf8 100644
--- a/xs/src/slic3r/GUI/GLGizmo.cpp
+++ b/xs/src/slic3r/GUI/GLGizmo.cpp
@@ -759,6 +759,20 @@ void GLGizmoScale3D::on_update(const Linef3& mouse_ray)
do_scale_uniform(mouse_ray);
}
+#if ENABLE_GIZMOS_RESET
+void GLGizmoScale3D::on_process_double_click()
+{
+ if ((m_hover_id == 0) || (m_hover_id == 1))
+ m_scale(0) = 1.0;
+ else if ((m_hover_id == 2) || (m_hover_id == 3))
+ m_scale(1) = 1.0;
+ else if ((m_hover_id == 4) || (m_hover_id == 5))
+ m_scale(2) = 1.0;
+ else if (m_hover_id >= 6)
+ m_scale = Vec3d::Ones();
+}
+#endif // ENABLE_GIZMOS_RESET
+
void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
{
if (m_grabbers[0].dragging || m_grabbers[1].dragging)
diff --git a/xs/src/slic3r/GUI/GLGizmo.hpp b/xs/src/slic3r/GUI/GLGizmo.hpp
index 2430b5af5..bf5838f72 100644
--- a/xs/src/slic3r/GUI/GLGizmo.hpp
+++ b/xs/src/slic3r/GUI/GLGizmo.hpp
@@ -94,6 +94,10 @@ public:
void update(const Linef3& mouse_ray);
+#if ENABLE_GIZMOS_RESET
+ void process_double_click() { on_process_double_click(); }
+#endif // ENABLE_GIZMOS_RESET
+
void render(const BoundingBoxf3& box) const { on_render(box); }
void render_for_picking(const BoundingBoxf3& box) const { on_render_for_picking(box); }
@@ -106,6 +110,9 @@ protected:
virtual void on_start_dragging(const BoundingBoxf3& box) {}
virtual void on_stop_dragging() {}
virtual void on_update(const Linef3& mouse_ray) = 0;
+#if ENABLE_GIZMOS_RESET
+ virtual void on_process_double_click() {}
+#endif // ENABLE_GIZMOS_RESET
virtual void on_render(const BoundingBoxf3& box) const = 0;
virtual void on_render_for_picking(const BoundingBoxf3& box) const = 0;
@@ -155,6 +162,9 @@ protected:
virtual bool on_init();
virtual void on_start_dragging(const BoundingBoxf3& box);
virtual void on_update(const Linef3& mouse_ray);
+#if ENABLE_GIZMOS_RESET
+ virtual void on_process_double_click() { m_angle = 0.0; }
+#endif // ENABLE_GIZMOS_RESET
virtual void on_render(const BoundingBoxf3& box) const;
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
@@ -222,6 +232,13 @@ protected:
g.update(mouse_ray);
}
}
+#if ENABLE_GIZMOS_RESET
+ virtual void on_process_double_click()
+ {
+ if (m_hover_id != -1)
+ m_gizmos[m_hover_id].process_double_click();
+ }
+#endif // ENABLE_GIZMOS_RESET
virtual void on_render(const BoundingBoxf3& box) const;
virtual void on_render_for_picking(const BoundingBoxf3& box) const
{
@@ -265,6 +282,9 @@ protected:
virtual void on_start_dragging(const BoundingBoxf3& box);
virtual void on_stop_dragging() { m_show_starting_box = false; }
virtual void on_update(const Linef3& mouse_ray);
+#if ENABLE_GIZMOS_RESET
+ virtual void on_process_double_click();
+#endif // ENABLE_GIZMOS_RESET
virtual void on_render(const BoundingBoxf3& box) const;
virtual void on_render_for_picking(const BoundingBoxf3& box) const;