mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	SLA gizmo open/close should be saved on undo/redo stack
This commit is contained in:
		
							parent
							
								
									b6d35c9840
								
							
						
					
					
						commit
						409a7c7734
					
				
					 3 changed files with 44 additions and 25 deletions
				
			
		|  | @ -12,6 +12,7 @@ | |||
| #include "slic3r/GUI/GUI.hpp" | ||||
| #include "slic3r/GUI/GUI_ObjectSettings.hpp" | ||||
| #include "slic3r/GUI/GUI_ObjectList.hpp" | ||||
| #include "slic3r/GUI/Plater.hpp" | ||||
| #include "slic3r/GUI/PresetBundle.hpp" | ||||
| #include "libslic3r/Tesselate.hpp" | ||||
| 
 | ||||
|  | @ -1111,6 +1112,11 @@ void GLGizmoSlaSupports::on_set_state() | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (m_state == m_old_state) | ||||
|         return; | ||||
| 
 | ||||
|     Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo on/off"))); | ||||
| 
 | ||||
|     if (m_state == On && m_old_state != On) { // the gizmo was just turned on
 | ||||
|         Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned on"))); | ||||
|         if (is_mesh_update_necessary()) | ||||
|  |  | |||
|  | @ -151,8 +151,7 @@ void GLGizmosManager::refresh_on_off_state() | |||
|     { | ||||
|         if (!gizmo->is_activable()) | ||||
|         { | ||||
|             gizmo->set_state(GLGizmoBase::Off); | ||||
|             m_current = Undefined; | ||||
|             activate_gizmo(Undefined); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -165,7 +164,7 @@ void GLGizmosManager::reset_all_states() | |||
|     if (m_serializing) | ||||
|         return; | ||||
| 
 | ||||
|     m_current = Undefined; | ||||
|     activate_gizmo(Undefined); | ||||
|     m_hover = Undefined; | ||||
| } | ||||
| 
 | ||||
|  | @ -256,8 +255,9 @@ bool GLGizmosManager::is_running() const | |||
|     if (!m_enabled) | ||||
|         return false; | ||||
| 
 | ||||
|     GLGizmoBase* curr = get_current(); | ||||
|     return (curr != nullptr) ? (curr->get_state() == GLGizmoBase::On) : false; | ||||
|     //GLGizmoBase* curr = get_current();
 | ||||
|     //return (curr != nullptr) ? (curr->get_state() == GLGizmoBase::On) : false;
 | ||||
|     return m_current != Undefined; | ||||
| } | ||||
| 
 | ||||
| bool GLGizmosManager::handle_shortcut(int key) | ||||
|  | @ -280,13 +280,11 @@ bool GLGizmosManager::handle_shortcut(int key) | |||
|         if (gizmo->is_activable() && ((it_key == key - 64) || (it_key == key - 96))) | ||||
|         { | ||||
|             if (m_current == idx) { | ||||
|                 gizmo->set_state(GLGizmoBase::Off); | ||||
|                 m_current = Undefined; | ||||
|                 activate_gizmo(Undefined); | ||||
|                 handled = true; | ||||
|             } | ||||
|             else if (m_current != idx) { | ||||
|                 gizmo->set_state(GLGizmoBase::On); | ||||
|                 m_current = (EType)idx; | ||||
|                 activate_gizmo((EType)idx); | ||||
|                 handled = true; | ||||
|             } | ||||
|         } | ||||
|  | @ -953,7 +951,7 @@ void GLGizmosManager::do_render_overlay() const | |||
|         float u_right = u_left + u_icon_size; | ||||
| 
 | ||||
|         GLTexture::render_sub_texture(icons_texture_id, top_x, top_x + scaled_icons_size, top_y - scaled_icons_size, top_y, { { u_left, v_bottom }, { u_right, v_bottom }, { u_right, v_top }, { u_left, v_top } }); | ||||
|         if (gizmo->get_state() == GLGizmoBase::On) { | ||||
|         if (idx == m_current) { | ||||
|             float toolbar_top = (float)cnv_h - m_parent.get_view_toolbar_height(); | ||||
|             gizmo->render_input_window(width, 0.5f * cnv_h - top_y * zoom, toolbar_top); | ||||
|         } | ||||
|  | @ -1042,8 +1040,12 @@ void GLGizmosManager::update_on_off_state(const Vec2d& mouse_pos) | |||
|         if (gizmo->is_activable() && inside) | ||||
|         { | ||||
|             if (m_hover == idx) { | ||||
|                 gizmo->set_state(m_current == idx ? GLGizmoBase::Off : GLGizmoBase::On); | ||||
|                 m_current = (EType)(m_current == idx ? Undefined : idx); | ||||
|                 if (m_current == idx) | ||||
|                     activate_gizmo(Undefined); | ||||
|                 else | ||||
|                     activate_gizmo((EType)idx); | ||||
|                 //gizmo->set_state(m_current == idx ? GLGizmoBase::Off : GLGizmoBase::On);
 | ||||
|                 //m_current = (EType)(m_current == idx ? Undefined : idx);
 | ||||
|             } | ||||
|         } | ||||
|         top_y += scaled_stride_y; | ||||
|  | @ -1086,6 +1088,21 @@ std::string GLGizmosManager::update_hover_state(const Vec2d& mouse_pos) | |||
|     return name; | ||||
| } | ||||
| 
 | ||||
| void GLGizmosManager::activate_gizmo(EType type) | ||||
| { | ||||
|     if (m_gizmos.empty() || m_current == type) | ||||
|         return; | ||||
| 
 | ||||
|     if (m_current != Undefined) | ||||
|         m_gizmos[m_current]->set_state(GLGizmoBase::Off); | ||||
| 
 | ||||
|     if (type != Undefined) | ||||
|         m_gizmos[type]->set_state(GLGizmoBase::On); | ||||
| 
 | ||||
|     m_current = type; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| bool GLGizmosManager::overlay_contains_mouse(const Vec2d& mouse_pos) const | ||||
| { | ||||
|     if (!m_enabled) | ||||
|  |  | |||
|  | @ -76,6 +76,8 @@ private: | |||
|     EType m_current; | ||||
|     EType m_hover; | ||||
| 
 | ||||
|     void activate_gizmo(EType type); | ||||
| 
 | ||||
|     float m_overlay_icons_size; | ||||
|     float m_overlay_scale; | ||||
|     float m_overlay_border; | ||||
|  | @ -112,18 +114,13 @@ public: | |||
| 
 | ||||
|         m_serializing = true; | ||||
| 
 | ||||
|         EType current = m_current; | ||||
|         ar(m_current); | ||||
|         //std::swap(current, m_current); // undo the deserialization, let activate_gizmo do the change
 | ||||
|         //activate_gizmo(current);
 | ||||
| 
 | ||||
|         GLGizmoBase* curr = get_current(); | ||||
| /*		for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) {
 | ||||
| 			GLGizmoBase* gizmo = it->second; | ||||
| 			if (gizmo != nullptr) { | ||||
| 				gizmo->set_hover_id(-1); | ||||
| 				gizmo->set_state((it->second == curr) ? GLGizmoBase::On : GLGizmoBase::Off); | ||||
| 				if (gizmo == curr) | ||||
| 					gizmo->load(ar); | ||||
| 			} | ||||
|         }*/ | ||||
|         if (m_current != Undefined) | ||||
|             m_gizmos[m_current]->load(ar); | ||||
|     } | ||||
| 
 | ||||
|     template<class Archive> | ||||
|  | @ -134,9 +131,8 @@ public: | |||
| 
 | ||||
|         ar(m_current); | ||||
| 
 | ||||
|         /*GLGizmoBase* curr = get_current();
 | ||||
|         if (curr != nullptr) | ||||
|             curr->save(ar);*/ | ||||
|         if (m_current != Undefined && !m_gizmos.empty()) | ||||
|             m_gizmos[m_current]->save(ar); | ||||
|     } | ||||
| 
 | ||||
|     bool is_enabled() const { return m_enabled; } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Matena
						Lukas Matena