mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Constrained gizmo-scaling -> code cleanup and simplification
This commit is contained in:
		
							parent
							
								
									128da453d5
								
							
						
					
					
						commit
						d69c98b48d
					
				
					 16 changed files with 50 additions and 280 deletions
				
			
		|  | @ -185,10 +185,7 @@ void GLGizmoBase::disable_grabber(unsigned int id) | |||
|     on_disable_grabber(id); | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoBase::start_dragging(const Selection& selection, const UpdateData::Keys& keys) | ||||
| //void GLGizmoBase::start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoBase::start_dragging(const Selection& selection) | ||||
| { | ||||
|     m_dragging = true; | ||||
| 
 | ||||
|  | @ -197,10 +194,7 @@ void GLGizmoBase::start_dragging(const Selection& selection, const UpdateData::K | |||
|         m_grabbers[i].dragging = (m_hover_id == i); | ||||
|     } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     on_start_dragging(selection, keys); | ||||
| //    on_start_dragging(selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     on_start_dragging(selection); | ||||
| } | ||||
| 
 | ||||
| void GLGizmoBase::stop_dragging() | ||||
|  |  | |||
|  | @ -24,9 +24,7 @@ static const float DEFAULT_BASE_COLOR[3] = { 0.625f, 0.625f, 0.625f }; | |||
| static const float DEFAULT_DRAG_COLOR[3] = { 1.0f, 1.0f, 1.0f }; | ||||
| static const float DEFAULT_HIGHLIGHT_COLOR[3] = { 1.0f, 0.38f, 0.0f }; | ||||
| static const float AXES_COLOR[3][3] = { { 0.75f, 0.0f, 0.0f }, { 0.0f, 0.75f, 0.0f }, { 0.0f, 0.0f, 0.75f } }; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| static const float CONSTRAINED_COLOR[3] = { 0.5f, 0.5f, 0.5f }; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | @ -77,32 +75,11 @@ public: | |||
| 
 | ||||
|     struct UpdateData | ||||
|     { | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         struct Keys | ||||
|         { | ||||
|             bool shift; | ||||
|             bool ctrl; | ||||
|             bool alt; | ||||
| 
 | ||||
|             Keys() { reset(); } | ||||
|             Keys(bool shift, bool ctrl, bool alt) : shift(shift), ctrl(ctrl), alt(alt) {} | ||||
|             void reset() { shift = false; ctrl = false; alt = false; } | ||||
|         }; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|         const Linef3 mouse_ray; | ||||
|         const Point* mouse_pos; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         Keys keys; | ||||
| //        bool shift_down;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         UpdateData(const Linef3& mouse_ray, const Point* mouse_pos = nullptr, const Keys& keys = Keys()) | ||||
|             : mouse_ray(mouse_ray), mouse_pos(mouse_pos), keys(keys) | ||||
| //        UpdateData(const Linef3& mouse_ray, const Point* mouse_pos = nullptr, bool shift_down = false)
 | ||||
| //            : mouse_ray(mouse_ray), mouse_pos(mouse_pos), shift_down(shift_down)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         UpdateData(const Linef3& mouse_ray, const Point* mouse_pos = nullptr) | ||||
|             : mouse_ray(mouse_ray), mouse_pos(mouse_pos) | ||||
|         {} | ||||
|     }; | ||||
| 
 | ||||
|  | @ -162,10 +139,7 @@ public: | |||
|     void enable_grabber(unsigned int id); | ||||
|     void disable_grabber(unsigned int id); | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void start_dragging(const Selection& selection, const UpdateData::Keys& keys); | ||||
| //    void start_dragging(const Selection& selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void start_dragging(const Selection& selection); | ||||
|     void stop_dragging(); | ||||
| 
 | ||||
|     bool is_dragging() const { return m_dragging; } | ||||
|  | @ -185,10 +159,7 @@ protected: | |||
|     virtual bool on_is_selectable() const { return true; } | ||||
|     virtual void on_enable_grabber(unsigned int id) {} | ||||
|     virtual void on_disable_grabber(unsigned int id) {} | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) {} | ||||
| //    virtual void on_start_dragging(const Selection& selection) {}
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection) {} | ||||
|     virtual void on_stop_dragging() {} | ||||
|     virtual void on_update(const UpdateData& data, const Selection& selection) = 0; | ||||
|     virtual void on_render(const Selection& selection) const = 0; | ||||
|  |  | |||
|  | @ -101,10 +101,7 @@ bool GLGizmoCut::on_is_activable(const Selection& selection) const | |||
|     return selection.is_single_full_instance() && !selection.is_wipe_tower(); | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoCut::on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) | ||||
| //void GLGizmoCut::on_start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoCut::on_start_dragging(const Selection& selection) | ||||
| { | ||||
|     if (m_hover_id == -1) { return; } | ||||
| 
 | ||||
|  |  | |||
|  | @ -34,10 +34,7 @@ protected: | |||
|     virtual std::string on_get_name() const; | ||||
|     virtual void on_set_state(); | ||||
|     virtual bool on_is_activable(const Selection& selection) const; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection, const UpdateData::Keys& keys); | ||||
| //    virtual void on_start_dragging(const Selection& selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection); | ||||
|     virtual void on_update(const UpdateData& data, const Selection& selection); | ||||
|     virtual void on_render(const Selection& selection) const; | ||||
|     virtual void on_render_for_picking(const Selection& selection) const; | ||||
|  |  | |||
|  | @ -37,10 +37,7 @@ bool GLGizmoFlatten::on_is_activable(const Selection& selection) const | |||
|     return selection.is_single_full_instance(); | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoFlatten::on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) | ||||
| //void GLGizmoFlatten::on_start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoFlatten::on_start_dragging(const Selection& selection) | ||||
| { | ||||
|     if (m_hover_id != -1) | ||||
|     { | ||||
|  |  | |||
|  | @ -50,10 +50,7 @@ protected: | |||
|     virtual bool on_init(); | ||||
|     virtual std::string on_get_name() const; | ||||
|     virtual bool on_is_activable(const Selection& selection) const; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection, const UpdateData::Keys& keys); | ||||
| //    virtual void on_start_dragging(const Selection& selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection); | ||||
|     virtual void on_update(const UpdateData& data, const Selection& selection) {} | ||||
|     virtual void on_render(const Selection& selection) const; | ||||
|     virtual void on_render_for_picking(const Selection& selection) const; | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
| 
 | ||||
| #include <GL/glew.h> | ||||
| 
 | ||||
| #include <wx/utils.h>  | ||||
| 
 | ||||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
|  | @ -51,10 +52,7 @@ std::string GLGizmoMove3D::on_get_name() const | |||
|     return (_(L("Move")) + " [M]").ToUTF8().data(); | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoMove3D::on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) | ||||
| //void GLGizmoMove3D::on_start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoMove3D::on_start_dragging(const Selection& selection) | ||||
| { | ||||
|     if (m_hover_id != -1) | ||||
|     { | ||||
|  | @ -209,10 +207,7 @@ double GLGizmoMove3D::calc_projection(const UpdateData& data) const | |||
|         projection = inters_vec.dot(starting_vec.normalized()); | ||||
|     } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     if (data.keys.shift) | ||||
| //    if (data.shift_down)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     if (wxGetKeyState(WXK_SHIFT)) | ||||
|         projection = m_snap_step * (double)std::round(projection / m_snap_step); | ||||
| 
 | ||||
|     return projection; | ||||
|  |  | |||
|  | @ -37,10 +37,7 @@ public: | |||
| protected: | ||||
|     virtual bool on_init(); | ||||
|     virtual std::string on_get_name() const; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection, const UpdateData::Keys& keys); | ||||
| //    virtual void on_start_dragging(const Selection& selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection); | ||||
|     virtual void on_stop_dragging(); | ||||
|     virtual void on_update(const UpdateData& data, const Selection& selection); | ||||
|     virtual void on_render(const Selection& selection) const; | ||||
|  |  | |||
|  | @ -80,10 +80,7 @@ bool GLGizmoRotate::on_init() | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoRotate::on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) | ||||
| //void GLGizmoRotate::on_start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoRotate::on_start_dragging(const Selection& selection) | ||||
| { | ||||
|     const BoundingBoxf3& box = selection.get_bounding_box(); | ||||
|     m_center = box.center(); | ||||
|  | @ -461,16 +458,10 @@ std::string GLGizmoRotate3D::on_get_name() const | |||
|     return (_(L("Rotate")) + " [R]").ToUTF8().data(); | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoRotate3D::on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) | ||||
| //void GLGizmoRotate3D::on_start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoRotate3D::on_start_dragging(const Selection& selection) | ||||
| { | ||||
|     if ((0 <= m_hover_id) && (m_hover_id < 3)) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_gizmos[m_hover_id].start_dragging(selection, keys); | ||||
| //        m_gizmos[m_hover_id].start_dragging(selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_gizmos[m_hover_id].start_dragging(selection); | ||||
| } | ||||
| 
 | ||||
| void GLGizmoRotate3D::on_stop_dragging() | ||||
|  |  | |||
|  | @ -52,10 +52,7 @@ public: | |||
| protected: | ||||
|     virtual bool on_init(); | ||||
|     virtual std::string on_get_name() const { return ""; } | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection, const UpdateData::Keys& keys); | ||||
| //    virtual void on_start_dragging(const Selection& selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection); | ||||
|     virtual void on_update(const UpdateData& data, const Selection& selection); | ||||
|     virtual void on_render(const Selection& selection) const; | ||||
|     virtual void on_render_for_picking(const Selection& selection) const; | ||||
|  | @ -116,10 +113,7 @@ protected: | |||
|         if ((0 <= id) && (id < 3)) | ||||
|             m_gizmos[id].disable_grabber(0); | ||||
|     } | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection, const UpdateData::Keys& keys); | ||||
| //    virtual void on_start_dragging(const Selection& selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection); | ||||
|     virtual void on_stop_dragging(); | ||||
|     virtual void on_update(const UpdateData& data, const Selection& selection) | ||||
|     { | ||||
|  |  | |||
|  | @ -5,6 +5,8 @@ | |||
| 
 | ||||
| #include <GL/glew.h> | ||||
| 
 | ||||
| #include <wx/utils.h>  | ||||
| 
 | ||||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
| 
 | ||||
|  | @ -19,11 +21,8 @@ GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent, unsigned int sprite_id) | |||
|     : GLGizmoBase(parent, sprite_id) | ||||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_scale(Vec3d::Ones()) | ||||
|     , m_snap_step(0.05) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     , m_offset(Vec3d::Zero()) | ||||
| //    , m_starting_scale(Vec3d::Ones())
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     , m_snap_step(0.05) | ||||
| { | ||||
| } | ||||
| 
 | ||||
|  | @ -54,17 +53,12 @@ std::string GLGizmoScale3D::on_get_name() const | |||
|     return (_(L("Scale")) + " [S]").ToUTF8().data(); | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoScale3D::on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) | ||||
| //void GLGizmoScale3D::on_start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoScale3D::on_start_dragging(const Selection& selection) | ||||
| { | ||||
|     if (m_hover_id != -1) | ||||
|     { | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_starting.keys = keys; | ||||
|         m_starting.drag_position = m_grabbers[m_hover_id].center; | ||||
|         m_starting.box = m_starting.keys.ctrl ? m_box : selection.get_bounding_box(); | ||||
|         m_starting.box = (wxGetKeyState(WXK_CONTROL) && (m_hover_id < 6)) ? m_box : selection.get_bounding_box(); | ||||
| 
 | ||||
|         const Vec3d& center = m_starting.box.center(); | ||||
|         m_starting.pivots[0] = m_transform * Vec3d(m_starting.box.max(0), center(1), center(2)); | ||||
|  | @ -73,10 +67,6 @@ void GLGizmoScale3D::on_start_dragging(const Selection& selection, const UpdateD | |||
|         m_starting.pivots[3] = m_transform * Vec3d(center(0), m_starting.box.min(1), center(2)); | ||||
|         m_starting.pivots[4] = m_transform * Vec3d(center(0), center(1), m_starting.box.max(2)); | ||||
|         m_starting.pivots[5] = m_transform * Vec3d(center(0), center(1), m_starting.box.min(2)); | ||||
| 
 | ||||
| //        m_starting_drag_position = m_grabbers[m_hover_id].center;
 | ||||
| //        m_starting_box = selection.get_bounding_box();
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -131,17 +121,10 @@ void GLGizmoScale3D::on_render(const Selection& selection) const | |||
|     glsafe(::glClear(GL_DEPTH_BUFFER_BIT)); | ||||
|     glsafe(::glEnable(GL_DEPTH_TEST)); | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     m_box.reset(); | ||||
|     m_transform = Transform3d::Identity(); | ||||
|     m_offsets_transform = Transform3d::Identity(); | ||||
| //    BoundingBoxf3 box;
 | ||||
| //    Transform3d transform = Transform3d::Identity();
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     Vec3d angles = Vec3d::Zero(); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| //    Transform3d offsets_transform = Transform3d::Identity();
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|     if (single_instance) | ||||
|     { | ||||
|  | @ -150,112 +133,59 @@ void GLGizmoScale3D::on_render(const Selection& selection) const | |||
|         for (unsigned int idx : idxs) | ||||
|         { | ||||
|             const GLVolume* vol = selection.get_volume(idx); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|             m_box.merge(vol->bounding_box.transformed(vol->get_volume_transformation().get_matrix())); | ||||
| //            box.merge(vol->bounding_box.transformed(vol->get_volume_transformation().get_matrix()));
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         } | ||||
| 
 | ||||
|         // gets transform from first selected volume
 | ||||
|         const GLVolume* v = selection.get_volume(*idxs.begin()); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_transform = v->get_instance_transformation().get_matrix(); | ||||
| //        transform = v->get_instance_transformation().get_matrix();
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         // gets angles from first selected volume
 | ||||
|         angles = v->get_instance_rotation(); | ||||
|         // consider rotation+mirror only components of the transform for offsets
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror()); | ||||
| //        offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror());
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     } | ||||
|     else if (single_volume) | ||||
|     { | ||||
|         const GLVolume* v = selection.get_volume(*selection.get_volume_idxs().begin()); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_box = v->bounding_box; | ||||
|         m_transform = v->world_matrix(); | ||||
|         angles = Geometry::extract_euler_angles(m_transform); | ||||
| //        box = v->bounding_box;
 | ||||
| //        transform = v->world_matrix();
 | ||||
| //        angles = Geometry::extract_euler_angles(transform);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         // consider rotation+mirror only components of the transform for offsets
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror()); | ||||
| //        offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror());
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     } | ||||
|     else | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_box = selection.get_bounding_box(); | ||||
| //        box = selection.get_bounding_box();
 | ||||
| //
 | ||||
| //    m_box = box;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|     const Vec3d& center = m_box.center(); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     Vec3d offset_x = m_offsets_transform * Vec3d((double)Offset, 0.0, 0.0); | ||||
|     Vec3d offset_y = m_offsets_transform * Vec3d(0.0, (double)Offset, 0.0); | ||||
|     Vec3d offset_z = m_offsets_transform * Vec3d(0.0, 0.0, (double)Offset); | ||||
| //    Vec3d offset_x = offsets_transform * Vec3d((double)Offset, 0.0, 0.0);
 | ||||
| //    Vec3d offset_y = offsets_transform * Vec3d(0.0, (double)Offset, 0.0);
 | ||||
| //    Vec3d offset_z = offsets_transform * Vec3d(0.0, 0.0, (double)Offset);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|     bool ctrl_down = wxGetKeyState(WXK_CONTROL); | ||||
| 
 | ||||
|     // x axis
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     m_grabbers[0].center = m_transform * Vec3d(m_box.min(0), center(1), center(2)) - offset_x; | ||||
|     m_grabbers[1].center = m_transform * Vec3d(m_box.max(0), center(1), center(2)) + offset_x; | ||||
|     ::memcpy((void*)m_grabbers[0].color, (m_starting.keys.ctrl && (m_hover_id == 1)) ? (const void*)CONSTRAINED_COLOR : (const void*)&AXES_COLOR[0], 3 * sizeof(float)); | ||||
|     ::memcpy((void*)m_grabbers[1].color, (m_starting.keys.ctrl && (m_hover_id == 0)) ? (const void*)CONSTRAINED_COLOR : (const void*)&AXES_COLOR[0], 3 * sizeof(float)); | ||||
| /*
 | ||||
|     ::memcpy((void*)m_grabbers[0].color, (!m_dragging || !m_starting.keys.ctrl || (m_hover_id == 0)) ? (const void*)&AXES_COLOR[0] : (const void*)CONSTRAINED_COLOR, 3 * sizeof(float)); | ||||
|     ::memcpy((void*)m_grabbers[1].color, (!m_dragging || !m_starting.keys.ctrl || (m_hover_id == 1)) ? (const void*)&AXES_COLOR[0] : (const void*)CONSTRAINED_COLOR, 3 * sizeof(float)); | ||||
| */ | ||||
| //    m_grabbers[0].center = transform * Vec3d(m_box.min(0), center(1), center(2)) - offset_x;
 | ||||
| //    m_grabbers[1].center = transform * Vec3d(m_box.max(0), center(1), center(2)) + offset_x;
 | ||||
| //    ::memcpy((void*)m_grabbers[0].color, (const void*)&AXES_COLOR[0], 3 * sizeof(float));
 | ||||
| //    ::memcpy((void*)m_grabbers[1].color, (const void*)&AXES_COLOR[0], 3 * sizeof(float));
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     ::memcpy((void*)m_grabbers[0].color, (ctrl_down && (m_hover_id == 1)) ? (const void*)CONSTRAINED_COLOR : (const void*)&AXES_COLOR[0], 3 * sizeof(float)); | ||||
|     ::memcpy((void*)m_grabbers[1].color, (ctrl_down && (m_hover_id == 0)) ? (const void*)CONSTRAINED_COLOR : (const void*)&AXES_COLOR[0], 3 * sizeof(float)); | ||||
| 
 | ||||
|     // y axis
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     m_grabbers[2].center = m_transform * Vec3d(center(0), m_box.min(1), center(2)) - offset_y; | ||||
|     m_grabbers[3].center = m_transform * Vec3d(center(0), m_box.max(1), center(2)) + offset_y; | ||||
|     ::memcpy((void*)m_grabbers[2].color, (!m_dragging || !m_starting.keys.ctrl || (m_hover_id == 2)) ? (const void*)&AXES_COLOR[1] : (const void*)CONSTRAINED_COLOR, 3 * sizeof(float)); | ||||
|     ::memcpy((void*)m_grabbers[3].color, (!m_dragging || !m_starting.keys.ctrl || (m_hover_id == 3)) ? (const void*)&AXES_COLOR[1] : (const void*)CONSTRAINED_COLOR, 3 * sizeof(float)); | ||||
| //    m_grabbers[2].center = transform * Vec3d(center(0), m_box.min(1), center(2)) - offset_y;
 | ||||
| //    m_grabbers[3].center = transform * Vec3d(center(0), m_box.max(1), center(2)) + offset_y;
 | ||||
| //    ::memcpy((void*)m_grabbers[2].color, (const void*)&AXES_COLOR[1], 3 * sizeof(float));
 | ||||
| //    ::memcpy((void*)m_grabbers[3].color, (const void*)&AXES_COLOR[1], 3 * sizeof(float));
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     ::memcpy((void*)m_grabbers[2].color, (ctrl_down && (m_hover_id == 3)) ? (const void*)CONSTRAINED_COLOR : (const void*)&AXES_COLOR[1], 3 * sizeof(float)); | ||||
|     ::memcpy((void*)m_grabbers[3].color, (ctrl_down && (m_hover_id == 2)) ? (const void*)CONSTRAINED_COLOR : (const void*)&AXES_COLOR[1], 3 * sizeof(float)); | ||||
| 
 | ||||
|     // z axis
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     m_grabbers[4].center = m_transform * Vec3d(center(0), center(1), m_box.min(2)) - offset_z; | ||||
|     m_grabbers[5].center = m_transform * Vec3d(center(0), center(1), m_box.max(2)) + offset_z; | ||||
|     ::memcpy((void*)m_grabbers[4].color, (!m_dragging || !m_starting.keys.ctrl || (m_hover_id == 4)) ? (const void*)&AXES_COLOR[2] : (const void*)CONSTRAINED_COLOR, 3 * sizeof(float)); | ||||
|     ::memcpy((void*)m_grabbers[5].color, (!m_dragging || !m_starting.keys.ctrl || (m_hover_id == 5)) ? (const void*)&AXES_COLOR[2] : (const void*)CONSTRAINED_COLOR, 3 * sizeof(float)); | ||||
| //    m_grabbers[4].center = transform * Vec3d(center(0), center(1), m_box.min(2)) - offset_z;
 | ||||
| //    m_grabbers[5].center = transform * Vec3d(center(0), center(1), m_box.max(2)) + offset_z;
 | ||||
| //    ::memcpy((void*)m_grabbers[4].color, (const void*)&AXES_COLOR[2], 3 * sizeof(float));
 | ||||
| //    ::memcpy((void*)m_grabbers[5].color, (const void*)&AXES_COLOR[2], 3 * sizeof(float));
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     ::memcpy((void*)m_grabbers[4].color, (ctrl_down && (m_hover_id == 5)) ? (const void*)CONSTRAINED_COLOR : (const void*)&AXES_COLOR[2], 3 * sizeof(float)); | ||||
|     ::memcpy((void*)m_grabbers[5].color, (ctrl_down && (m_hover_id == 4)) ? (const void*)CONSTRAINED_COLOR : (const void*)&AXES_COLOR[2], 3 * sizeof(float)); | ||||
| 
 | ||||
|     // uniform
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     m_grabbers[6].center = m_transform * Vec3d(m_box.min(0), m_box.min(1), center(2)) - offset_x - offset_y; | ||||
|     m_grabbers[7].center = m_transform * Vec3d(m_box.max(0), m_box.min(1), center(2)) + offset_x - offset_y; | ||||
|     m_grabbers[8].center = m_transform * Vec3d(m_box.max(0), m_box.max(1), center(2)) + offset_x + offset_y; | ||||
|     m_grabbers[9].center = m_transform * Vec3d(m_box.min(0), m_box.max(1), center(2)) - offset_x + offset_y; | ||||
| //    m_grabbers[6].center = transform * Vec3d(m_box.min(0), m_box.min(1), center(2)) - offset_x - offset_y;
 | ||||
| //    m_grabbers[7].center = transform * Vec3d(m_box.max(0), m_box.min(1), center(2)) + offset_x - offset_y;
 | ||||
| //    m_grabbers[8].center = transform * Vec3d(m_box.max(0), m_box.max(1), center(2)) + offset_x + offset_y;
 | ||||
| //    m_grabbers[9].center = transform * Vec3d(m_box.min(0), m_box.max(1), center(2)) - offset_x + offset_y;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     for (int i = 6; i < 10; ++i) | ||||
|     { | ||||
|         ::memcpy((void*)m_grabbers[i].color, (const void*)m_highlight_color, 3 * sizeof(float)); | ||||
|  | @ -379,10 +309,9 @@ void GLGizmoScale3D::do_scale_x(const UpdateData& data) | |||
| { | ||||
|     double ratio = calc_ratio(data); | ||||
|     if (ratio > 0.0) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     { | ||||
|         m_scale(0) = m_starting.scale(0) * ratio; | ||||
|         if (m_starting.keys.ctrl) | ||||
|         if (wxGetKeyState(WXK_CONTROL)) | ||||
|         { | ||||
|             double local_offset = 0.5 * (m_scale(0) - m_starting.scale(0)) * m_starting.box.size()(0); | ||||
|             Vec3d local_offset_vec = Vec3d((m_hover_id == 0) ? -local_offset : local_offset, 0.0, 0.0); | ||||
|  | @ -391,18 +320,15 @@ void GLGizmoScale3D::do_scale_x(const UpdateData& data) | |||
|         else | ||||
|             m_offset = Vec3d::Zero(); | ||||
|     } | ||||
| //        m_scale(0) = m_starting_scale(0) * ratio;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| } | ||||
| 
 | ||||
| void GLGizmoScale3D::do_scale_y(const UpdateData& data) | ||||
| { | ||||
|     double ratio = calc_ratio(data); | ||||
|     if (ratio > 0.0) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     { | ||||
|         m_scale(1) = m_starting.scale(1) * ratio; | ||||
|         if (m_starting.keys.ctrl) | ||||
|         if (wxGetKeyState(WXK_CONTROL)) | ||||
|         { | ||||
|             double local_offset = 0.5 * (m_scale(1) - m_starting.scale(1)) * m_starting.box.size()(1); | ||||
|             Vec3d local_offset_vec = Vec3d(0.0, (m_hover_id == 2) ? -local_offset : local_offset, 0.0); | ||||
|  | @ -411,18 +337,15 @@ void GLGizmoScale3D::do_scale_y(const UpdateData& data) | |||
|         else | ||||
|             m_offset = Vec3d::Zero(); | ||||
|     } | ||||
| //        m_scale(1) = m_starting_scale(1) * ratio;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| } | ||||
| 
 | ||||
| void GLGizmoScale3D::do_scale_z(const UpdateData& data) | ||||
| { | ||||
|     double ratio = calc_ratio(data); | ||||
|     if (ratio > 0.0) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     { | ||||
|         m_scale(2) = m_starting.scale(2) * ratio; | ||||
|         if (m_starting.keys.ctrl) | ||||
|         if (wxGetKeyState(WXK_CONTROL)) | ||||
|         { | ||||
|             double local_offset = 0.5 * (m_scale(2) - m_starting.scale(2)) * m_starting.box.size()(2); | ||||
|             Vec3d local_offset_vec = Vec3d(0.0, 0.0, (m_hover_id == 4) ? -local_offset : local_offset); | ||||
|  | @ -431,33 +354,22 @@ void GLGizmoScale3D::do_scale_z(const UpdateData& data) | |||
|         else | ||||
|             m_offset = Vec3d::Zero(); | ||||
|     } | ||||
| //        m_scale(2) = m_starting_scale(2) * ratio;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| } | ||||
| 
 | ||||
| void GLGizmoScale3D::do_scale_uniform(const UpdateData& data) | ||||
| { | ||||
|     double ratio = calc_ratio(data); | ||||
|     if (ratio > 0.0) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_scale = m_starting.scale * ratio; | ||||
| //        m_scale = m_starting_scale * ratio;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| } | ||||
| 
 | ||||
| double GLGizmoScale3D::calc_ratio(const UpdateData& data) const | ||||
| { | ||||
|     double ratio = 0.0; | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     Vec3d pivot = (m_starting.keys.ctrl && (m_hover_id < 6)) ? m_starting.pivots[m_hover_id] : m_starting.box.center(); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     Vec3d pivot = (wxGetKeyState(WXK_CONTROL) && (m_hover_id < 6)) ? m_starting.pivots[m_hover_id] : m_starting.box.center(); | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     Vec3d starting_vec = m_starting.drag_position - pivot; | ||||
|     // vector from the center to the starting position
 | ||||
| //    Vec3d starting_vec = m_starting_drag_position - m_starting_box.center();
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     double len_starting_vec = starting_vec.norm(); | ||||
|     if (len_starting_vec != 0.0) | ||||
|     { | ||||
|  | @ -466,15 +378,9 @@ double GLGizmoScale3D::calc_ratio(const UpdateData& data) const | |||
|         // use ray-plane intersection see i.e. https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection algebric form
 | ||||
|         // in our case plane normal and ray direction are the same (orthogonal view)
 | ||||
|         // when moving to perspective camera the negative z unit axis of the camera needs to be transformed in world space and used as plane normal
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         Vec3d inters = data.mouse_ray.a + (m_starting.drag_position - data.mouse_ray.a).dot(mouse_dir) / mouse_dir.squaredNorm() * mouse_dir; | ||||
| //        Vec3d inters = data.mouse_ray.a + (m_starting_drag_position - data.mouse_ray.a).dot(mouse_dir) / mouse_dir.squaredNorm() * mouse_dir;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         // vector from the starting position to the found intersection
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         Vec3d inters_vec = inters - m_starting.drag_position; | ||||
| //        Vec3d inters_vec = inters - m_starting_drag_position;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|         // finds projection of the vector along the staring direction
 | ||||
|         double proj = inters_vec.dot(starting_vec.normalized()); | ||||
|  | @ -482,10 +388,7 @@ double GLGizmoScale3D::calc_ratio(const UpdateData& data) const | |||
|         ratio = (len_starting_vec + proj) / len_starting_vec; | ||||
|     } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     if (data.keys.shift) | ||||
| //    if (data.shift_down)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     if (wxGetKeyState(WXK_SHIFT)) | ||||
|         ratio = m_snap_step * (double)std::round(ratio / m_snap_step); | ||||
| 
 | ||||
|     return ratio; | ||||
|  |  | |||
|  | @ -11,37 +11,24 @@ class GLGizmoScale3D : public GLGizmoBase | |||
| { | ||||
|     static const float Offset; | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     struct StartingData | ||||
|     { | ||||
|         Vec3d scale; | ||||
|         Vec3d drag_position; | ||||
|         BoundingBoxf3 box; | ||||
|         Vec3d pivots[6]; | ||||
|         UpdateData::Keys keys; | ||||
| 
 | ||||
|         StartingData() : scale(Vec3d::Ones()), drag_position(Vec3d::Zero()) { for (int i = 0; i < 5; ++i) { pivots[i] = Vec3d::Zero(); } } | ||||
|     }; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|     mutable BoundingBoxf3 m_box; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     mutable Transform3d m_transform; | ||||
|     mutable Transform3d m_offsets_transform; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     Vec3d m_scale; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     Vec3d m_offset; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     double m_snap_step; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     StartingData m_starting; | ||||
| 
 | ||||
| //    Vec3d m_starting_scale;
 | ||||
| //    Vec3d m_starting_drag_position;
 | ||||
| //    BoundingBoxf3 m_starting_box;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| public: | ||||
| #if ENABLE_SVG_ICONS | ||||
|     GLGizmoScale3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); | ||||
|  | @ -53,24 +40,15 @@ public: | |||
|     void set_snap_step(double step) { m_snap_step = step; } | ||||
| 
 | ||||
|     const Vec3d& get_scale() const { return m_scale; } | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void set_scale(const Vec3d& scale) { m_starting.scale = scale; m_scale = scale; } | ||||
| //    void set_scale(const Vec3d& scale) { m_starting_scale = scale; m_scale = scale; }
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     const Vec3d& get_offset() const { return m_offset; } | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| protected: | ||||
|     virtual bool on_init(); | ||||
|     virtual std::string on_get_name() const; | ||||
|     virtual bool on_is_activable(const Selection& selection) const { return !selection.is_wipe_tower(); } | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection, const UpdateData::Keys& keys); | ||||
|     virtual void on_stop_dragging() { m_starting.keys.reset(); } | ||||
| //    virtual void on_start_dragging(const Selection& selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     virtual void on_start_dragging(const Selection& selection); | ||||
|     virtual void on_update(const UpdateData& data, const Selection& selection); | ||||
|     virtual void on_render(const Selection& selection) const; | ||||
|     virtual void on_render_for_picking(const Selection& selection) const; | ||||
|  |  | |||
|  | @ -1046,10 +1046,7 @@ void GLGizmoSlaSupports::on_set_state() | |||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoSlaSupports::on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) | ||||
| //void GLGizmoSlaSupports::on_start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmoSlaSupports::on_start_dragging(const Selection& selection) | ||||
| { | ||||
|     if (m_hover_id != -1) { | ||||
|         select_point(NoPoints); | ||||
|  |  | |||
|  | @ -127,10 +127,7 @@ private: | |||
| 
 | ||||
| protected: | ||||
|     void on_set_state() override; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void on_start_dragging(const Selection& selection, const UpdateData::Keys& keys) override; | ||||
| //    void on_start_dragging(const Selection& selection) override;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void on_start_dragging(const Selection& selection) override; | ||||
|     virtual void on_render_input_window(float x, float y, float bottom_limit, const Selection& selection) override; | ||||
| 
 | ||||
|     virtual std::string on_get_name() const; | ||||
|  |  | |||
|  | @ -247,20 +247,14 @@ void GLGizmosManager::enable_grabber(EType type, unsigned int id, bool enable) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmosManager::update(const Linef3& mouse_ray, const Selection& selection, const GLGizmoBase::UpdateData::Keys& keys, const Point* mouse_pos) | ||||
| //void GLGizmosManager::update(const Linef3& mouse_ray, const Selection& selection, bool shift_down, const Point* mouse_pos)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmosManager::update(const Linef3& mouse_ray, const Selection& selection, const Point* mouse_pos) | ||||
| { | ||||
|     if (!m_enabled) | ||||
|         return; | ||||
| 
 | ||||
|     GLGizmoBase* curr = get_current(); | ||||
|     if (curr != nullptr) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         curr->update(GLGizmoBase::UpdateData(mouse_ray, mouse_pos, keys), selection); | ||||
| //        curr->update(GLGizmoBase::UpdateData(mouse_ray, mouse_pos, shift_down), selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         curr->update(GLGizmoBase::UpdateData(mouse_ray, mouse_pos), selection); | ||||
| } | ||||
| 
 | ||||
| void GLGizmosManager::update_data(GLCanvas3D& canvas) | ||||
|  | @ -364,20 +358,14 @@ bool GLGizmosManager::is_dragging() const | |||
|     return (curr != nullptr) ? curr->is_dragging() : false; | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmosManager::start_dragging(const Selection& selection, const GLGizmoBase::UpdateData::Keys& keys) | ||||
| //void GLGizmosManager::start_dragging(const Selection& selection)
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| void GLGizmosManager::start_dragging(const Selection& selection) | ||||
| { | ||||
|     if (!m_enabled) | ||||
|         return; | ||||
| 
 | ||||
|     GLGizmoBase* curr = get_current(); | ||||
|     if (curr != nullptr) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         curr->start_dragging(selection, keys); | ||||
| //        curr->start_dragging(selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         curr->start_dragging(selection); | ||||
| } | ||||
| 
 | ||||
| void GLGizmosManager::stop_dragging() | ||||
|  | @ -418,16 +406,14 @@ void GLGizmosManager::set_scale(const Vec3d& scale) | |||
|         reinterpret_cast<GLGizmoScale3D*>(it->second)->set_scale(scale); | ||||
| } | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| Vec3d GLGizmosManager::get_scale_offset() const | ||||
| { | ||||
|     if (!m_enabled) | ||||
|         return Vec3d::Ones(); | ||||
|         return Vec3d::Zero(); | ||||
| 
 | ||||
|     GizmosMap::const_iterator it = m_gizmos.find(Scale); | ||||
|     return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoScale3D*>(it->second)->get_offset() : Vec3d::Zero(); | ||||
| } | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| Vec3d GLGizmosManager::get_rotation() const | ||||
| { | ||||
|  | @ -606,10 +592,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas) | |||
|             { | ||||
|                 update_data(canvas); | ||||
|                 selection.start_dragging(); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|                 start_dragging(selection, GLGizmoBase::UpdateData::Keys(evt.ShiftDown(), evt.ControlDown(), evt.AltDown())); | ||||
| //                start_dragging(selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|                 start_dragging(selection); | ||||
| 
 | ||||
|                 if (m_current == Flatten) | ||||
|                 { | ||||
|  | @ -641,10 +624,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas) | |||
|                 canvas.get_wxglcanvas()->CaptureMouse(); | ||||
| 
 | ||||
|             canvas.set_mouse_as_dragging(); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|             update(canvas.mouse_ray(pos), selection, GLGizmoBase::UpdateData::Keys(evt.ShiftDown(), evt.ControlDown(), evt.AltDown()), &pos); | ||||
| //            update(canvas.mouse_ray(pos), selection, evt.ShiftDown(), &pos);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|             update(canvas.mouse_ray(pos), selection, &pos); | ||||
| 
 | ||||
|             switch (m_current) | ||||
|             { | ||||
|  | @ -662,9 +642,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas) | |||
| 				if (evt.AltDown()) | ||||
| 					transformation_type.set_independent(); | ||||
| 				selection.scale(get_scale(), transformation_type); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|                 selection.translate(get_scale_offset(), true); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|                 wxGetApp().obj_manipul()->set_dirty(); | ||||
|                 break; | ||||
|             } | ||||
|  |  | |||
|  | @ -4,9 +4,6 @@ | |||
| #include "slic3r/GUI/GLTexture.hpp" | ||||
| #include "slic3r/GUI/GLToolbar.hpp" | ||||
| #include "slic3r/GUI/Gizmos/GLGizmos.hpp" | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #include "slic3r/GUI/Gizmos/GLGizmoBase.hpp" | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| #include <map> | ||||
| 
 | ||||
|  | @ -14,9 +11,7 @@ namespace Slic3r { | |||
| namespace GUI { | ||||
| 
 | ||||
| class Selection; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| //class GLGizmoBase;
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| class GLGizmoBase; | ||||
| class GLCanvas3D; | ||||
| class ClippingPlane; | ||||
| 
 | ||||
|  | @ -125,10 +120,7 @@ public: | |||
|     void set_hover_id(int id); | ||||
|     void enable_grabber(EType type, unsigned int id, bool enable); | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void update(const Linef3& mouse_ray, const Selection& selection, const GLGizmoBase::UpdateData::Keys& keys, const Point* mouse_pos = nullptr); | ||||
| //    void update(const Linef3& mouse_ray, const Selection& selection, bool shift_down, const Point* mouse_pos = nullptr);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void update(const Linef3& mouse_ray, const Selection& selection, const Point* mouse_pos = nullptr); | ||||
|     void update_data(GLCanvas3D& canvas); | ||||
| 
 | ||||
|     Rect get_reset_rect_viewport(const GLCanvas3D& canvas) const; | ||||
|  | @ -138,10 +130,7 @@ public: | |||
|     bool handle_shortcut(int key, const Selection& selection); | ||||
| 
 | ||||
|     bool is_dragging() const; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void start_dragging(const Selection& selection, const GLGizmoBase::UpdateData::Keys& keys); | ||||
| //    void start_dragging(const Selection& selection);
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     void start_dragging(const Selection& selection); | ||||
|     void stop_dragging(); | ||||
| 
 | ||||
|     Vec3d get_displacement() const; | ||||
|  | @ -149,9 +138,7 @@ public: | |||
|     Vec3d get_scale() const; | ||||
|     void set_scale(const Vec3d& scale); | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     Vec3d get_scale_offset() const; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|     Vec3d get_rotation() const; | ||||
|     void set_rotation(const Vec3d& rotation); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri