mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	Fix for deleted object after preview
This commit is contained in:
		
							parent
							
								
									95fc054590
								
							
						
					
					
						commit
						84f8ba9fb4
					
				
					 2 changed files with 26 additions and 10 deletions
				
			
		|  | @ -53,11 +53,12 @@ void GLGizmoSimplify::on_render_for_picking() {} | |||
| void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limit) | ||||
| { | ||||
|     create_gui_cfg(); | ||||
|     const Selection &selection = m_parent.get_selection(); | ||||
|     int object_idx = selection.get_object_idx(); | ||||
|     if (!is_selected_object(&object_idx)) return; | ||||
|     ModelObject *obj = wxGetApp().plater()->model().objects[object_idx]; | ||||
|     ModelVolume *act_volume = obj->volumes.front(); | ||||
|     int obj_index; | ||||
|     ModelVolume *act_volume = get_selected_volume(&obj_index); | ||||
|     if (act_volume == nullptr) {  | ||||
|         close();  | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     // Check selection of new volume
 | ||||
|     // Do not reselect object when processing 
 | ||||
|  | @ -68,7 +69,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi | |||
|             set_its(*m_original_its); | ||||
|         } | ||||
| 
 | ||||
|         m_obj_index = object_idx; // to remember correct object
 | ||||
|         m_obj_index = obj_index; // to remember correct object
 | ||||
|         m_volume = act_volume; | ||||
|         m_original_its = {}; | ||||
|         m_configuration.decimate_ratio = 50.; // default value
 | ||||
|  | @ -329,9 +330,10 @@ void GLGizmoSimplify::on_set_state() | |||
| { | ||||
|     // Closing gizmo. e.g. selecting another one
 | ||||
|     if (GLGizmoBase::m_state == GLGizmoBase::Off) { | ||||
|         bool exist_selected_object = is_selected_object(); | ||||
|         // refuse outgoing during simlification
 | ||||
|         // object is not selected when it is deleted(cancel and close gizmo)
 | ||||
|         if (m_state != State::settings && is_selected_object()) { | ||||
|         if (m_state != State::settings && exist_selected_object) { | ||||
|             GLGizmoBase::m_state = GLGizmoBase::On; | ||||
|             auto notification_manager = wxGetApp().plater()->get_notification_manager(); | ||||
|             notification_manager->push_notification( | ||||
|  | @ -342,7 +344,7 @@ void GLGizmoSimplify::on_set_state() | |||
|         } | ||||
| 
 | ||||
|         // revert preview
 | ||||
|         if (m_exist_preview) { | ||||
|         if (m_exist_preview && exist_selected_object) { | ||||
|             set_its(*m_original_its); | ||||
|             m_parent.reload_scene(true); | ||||
|             m_need_reload = false; | ||||
|  | @ -399,4 +401,17 @@ bool GLGizmoSimplify::is_selected_object(int *object_idx) | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| ModelVolume *GLGizmoSimplify::get_selected_volume(int *object_idx_ptr) | ||||
| { | ||||
|     const Selection &selection  = m_parent.get_selection(); | ||||
|     int object_idx = selection.get_object_idx(); | ||||
|     if (object_idx_ptr != nullptr) *object_idx_ptr = object_idx; | ||||
|     if (!is_selected_object(&object_idx)) return nullptr; | ||||
|     ModelObjectPtrs &objs = wxGetApp().plater()->model().objects; | ||||
|     if (objs.size() <= object_idx) return nullptr; | ||||
|     ModelObject *obj = objs[object_idx]; | ||||
|     if (obj->volumes.empty()) return nullptr; | ||||
|     return obj->volumes.front();     | ||||
| } | ||||
| 
 | ||||
| } // namespace Slic3r::GUI
 | ||||
|  |  | |||
|  | @ -38,13 +38,14 @@ private: | |||
|     void set_its(indexed_triangle_set &its); | ||||
|     void create_gui_cfg(); | ||||
|     void request_rerender(); | ||||
|     bool is_selected_object(int *object_idx = nullptr); | ||||
|     bool is_selected_object(int *object_idx_ptr = nullptr); | ||||
|     ModelVolume *get_selected_volume(int *object_idx = nullptr); | ||||
| 
 | ||||
|     std::atomic_bool m_is_valid_result; // differ what to do in apply
 | ||||
|     std::atomic_bool m_exist_preview;   // set when process end
 | ||||
| 
 | ||||
|     volatile int m_progress; // percent of done work
 | ||||
|     ModelVolume *m_volume; // 
 | ||||
|     ModelVolume *m_volume; // keep pointer to actual working volume
 | ||||
|     size_t m_obj_index; | ||||
| 
 | ||||
|     std::optional<indexed_triangle_set> m_original_its; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Filip Sykala
						Filip Sykala