mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	New selection -> Improved gizmos activation
This commit is contained in:
		
							parent
							
								
									561bbf5a80
								
							
						
					
					
						commit
						af4570741c
					
				
					 4 changed files with 40 additions and 20 deletions
				
			
		|  | @ -1893,7 +1893,7 @@ void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2 | |||
|     float cnv_h = (float)canvas.get_canvas_size().get_height(); | ||||
|     float height = _get_total_overlay_height(); | ||||
|     float top_y = 0.5f * (cnv_h - height); | ||||
|     for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     { | ||||
|         if (it->second == nullptr) | ||||
|             continue; | ||||
|  | @ -1903,8 +1903,7 @@ void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2 | |||
| 
 | ||||
|         // we currently use circular icons for gizmo, so we check the radius
 | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|         bool no_wipe_tower = selection.is_wipe_tower() && !it->second->get_accept_wipe_tower(); | ||||
|         if (!no_wipe_tower && (it->second->get_state() != GLGizmoBase::On)) | ||||
|         if (it->second->is_activable(selection) && (it->second->get_state() != GLGizmoBase::On)) | ||||
| #else | ||||
|         if (it->second->get_state() != GLGizmoBase::On) | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
|  | @ -1928,7 +1927,7 @@ void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Vec | |||
|     float cnv_h = (float)canvas.get_canvas_size().get_height(); | ||||
|     float height = _get_total_overlay_height(); | ||||
|     float top_y = 0.5f * (cnv_h - height); | ||||
|     for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) | ||||
|     { | ||||
|         if (it->second == nullptr) | ||||
|             continue; | ||||
|  | @ -1938,18 +1937,17 @@ void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Vec | |||
| 
 | ||||
|         // we currently use circular icons for gizmo, so we check the radius
 | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|         bool no_wipe_tower = selection.is_wipe_tower() && !it->second->get_accept_wipe_tower(); | ||||
|         if (!no_wipe_tower && ((mouse_pos - Vec2d(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size)) | ||||
|         if (it->second->is_activable(selection) && ((mouse_pos - Vec2d(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size)) | ||||
| #else | ||||
|         if ((mouse_pos - Vec2d(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size) | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
|         { | ||||
|             if ((it->second->get_state() == GLGizmoBase::On)) | ||||
|             { | ||||
|                 it->second->set_state(GLGizmoBase::Off); | ||||
|                 it->second->set_state(GLGizmoBase::Hover); | ||||
|                 m_current = Undefined; | ||||
|             } | ||||
|             else | ||||
|             else if ((it->second->get_state() == GLGizmoBase::Hover)) | ||||
|             { | ||||
|                 it->second->set_state(GLGizmoBase::On); | ||||
|                 m_current = it->first; | ||||
|  | @ -1960,8 +1958,27 @@ void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Vec | |||
| 
 | ||||
|         top_y += (tex_size + OverlayGapY); | ||||
|     } | ||||
| 
 | ||||
|     GizmosMap::iterator it = m_gizmos.find(m_current); | ||||
|     if ((it != m_gizmos.end()) && (it->second != nullptr) && (it->second->get_state() != GLGizmoBase::On)) | ||||
|         it->second->set_state(GLGizmoBase::On); | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
| void GLCanvas3D::Gizmos::update_on_off_state(const Selection& selection) | ||||
| { | ||||
|     GizmosMap::iterator it = m_gizmos.find(m_current); | ||||
|     if ((it != m_gizmos.end()) && (it->second != nullptr)) | ||||
|     { | ||||
|         if (!it->second->is_activable(selection)) | ||||
|         { | ||||
|             it->second->set_state(GLGizmoBase::Off); | ||||
|             m_current = Undefined; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
| 
 | ||||
| void GLCanvas3D::Gizmos::reset_all_states() | ||||
| { | ||||
|     if (!m_enabled) | ||||
|  | @ -3928,6 +3945,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) | |||
|                     else | ||||
|                         m_selection.add(m_hover_volume_id, !evt.ShiftDown()); | ||||
| 
 | ||||
|                     m_gizmos.update_on_off_state(m_selection); | ||||
|                     update_gizmos_data(); | ||||
|                     wxGetApp().obj_manipul()->update_settings_value(m_selection); | ||||
|                     m_dirty = true; | ||||
|  |  | |||
|  | @ -552,6 +552,7 @@ private: | |||
| #if ENABLE_EXTENDED_SELECTION | ||||
|         void update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection); | ||||
|         void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection); | ||||
|         void update_on_off_state(const Selection& selection); | ||||
| #else | ||||
|         void update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos); | ||||
|         void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos); | ||||
|  |  | |||
|  | @ -219,9 +219,6 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent) | |||
|     : m_parent(parent) | ||||
|     , m_group_id(-1) | ||||
|     , m_state(Off) | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     , m_accept_wipe_tower(false) | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
|     , m_hover_id(-1) | ||||
|     , m_dragging(false) | ||||
| { | ||||
|  | @ -1216,10 +1213,6 @@ bool GLGizmoMove3D::on_init() | |||
|         m_grabbers.push_back(Grabber()); | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     m_accept_wipe_tower = true; | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
| 
 | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -59,9 +59,6 @@ protected: | |||
| 
 | ||||
|     int m_group_id; | ||||
|     EState m_state; | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     bool m_accept_wipe_tower; | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
|     // textures are assumed to be square and all with the same size in pixels, no internal check is done
 | ||||
|     GLTexture m_textures[Num_States]; | ||||
|     int m_hover_id; | ||||
|  | @ -84,8 +81,7 @@ public: | |||
|     void set_state(EState state) { m_state = state; on_set_state(); } | ||||
| 
 | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     bool get_accept_wipe_tower() { return m_accept_wipe_tower; } | ||||
|     void set_accept_wipe_tower(bool accept) { m_accept_wipe_tower = accept; } | ||||
|     bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); } | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
| 
 | ||||
|     unsigned int get_texture_id() const { return m_textures[m_state].get_id(); } | ||||
|  | @ -125,6 +121,9 @@ protected: | |||
|     virtual bool on_init() = 0; | ||||
|     virtual void on_set_state() {} | ||||
|     virtual void on_set_hover_id() {} | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return true; } | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
|     virtual void on_enable_grabber(unsigned int id) {} | ||||
|     virtual void on_disable_grabber(unsigned int id) {} | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|  | @ -249,6 +248,9 @@ protected: | |||
|             m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1); | ||||
|         } | ||||
|     } | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); } | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
|     virtual void on_enable_grabber(unsigned int id) | ||||
|     { | ||||
|         if ((0 <= id) && (id < 3)) | ||||
|  | @ -327,6 +329,9 @@ public: | |||
| 
 | ||||
| protected: | ||||
|     virtual bool on_init(); | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); } | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     virtual void on_start_dragging(const GLCanvas3D::Selection& selection); | ||||
| #else | ||||
|  | @ -449,6 +454,9 @@ public: | |||
| 
 | ||||
| protected: | ||||
|     virtual bool on_init(); | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return selection.is_single_full_instance(); } | ||||
| #endif // ENABLE_EXTENDED_SELECTION
 | ||||
| #if ENABLE_EXTENDED_SELECTION | ||||
|     virtual void on_start_dragging(const GLCanvas3D::Selection& selection); | ||||
| #else | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri