mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	InstancesHider implementation
Any gizmo can now ask for hiding all but the active instance by returning proper value from on_get_requirements
This commit is contained in:
		
							parent
							
								
									593e7a1546
								
							
						
					
					
						commit
						3db3a61520
					
				
					 3 changed files with 48 additions and 9 deletions
				
			
		|  | @ -14,7 +14,7 @@ CommonGizmosDataPool::CommonGizmosDataPool(GLCanvas3D* canvas) | |||
| { | ||||
|     using c = CommonGizmosDataID; | ||||
|     m_data[c::SelectionInfo].reset(       new SelectionInfo(this)); | ||||
|     //m_data[c::InstancesHider].reset(      new InstancesHider(this));
 | ||||
|     m_data[c::InstancesHider].reset(      new InstancesHider(this)); | ||||
|     //m_data[c::HollowedMesh].reset(        new HollowedMesh(this));
 | ||||
|     //m_data[c::ClippingPlaneWrapper].reset(new ClippingPlaneWrapper(this));
 | ||||
|     //m_data[c::SupportsClipper].reset(     new SupportsClipper(this));
 | ||||
|  | @ -27,8 +27,10 @@ void CommonGizmosDataPool::update(CommonGizmosDataID required) | |||
|     for (auto& [id, data] : m_data) { | ||||
|         if (int(required) & int(CommonGizmosDataID(id))) | ||||
|             data->update(); | ||||
|         else if (data->is_valid()) | ||||
|             data->release(); | ||||
|         else | ||||
|             if (data->is_valid()) | ||||
|                 data->release(); | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -36,6 +38,7 @@ void CommonGizmosDataPool::update(CommonGizmosDataID required) | |||
| SelectionInfo* CommonGizmosDataPool::selection_info() | ||||
| { | ||||
|     SelectionInfo* sel_info = dynamic_cast<SelectionInfo*>(m_data[CommonGizmosDataID::SelectionInfo].get()); | ||||
|     assert(sel_info->is_valid()); | ||||
|     return sel_info; | ||||
| } | ||||
| 
 | ||||
|  | @ -54,7 +57,7 @@ bool CommonGizmosDataPool::check_dependencies(CommonGizmosDataID required) const | |||
| 
 | ||||
| void SelectionInfo::on_update() | ||||
| { | ||||
|     Selection selection = m_common->get_canvas()->get_selection(); | ||||
|     const Selection& selection = m_common->get_canvas()->get_selection(); | ||||
|     if (selection.is_single_full_instance()) | ||||
|         m_model_object = selection.get_model()->objects[selection.get_object_idx()]; | ||||
|     else | ||||
|  | @ -66,5 +69,36 @@ void SelectionInfo::on_release() | |||
|     m_model_object = nullptr; | ||||
| } | ||||
| 
 | ||||
| int SelectionInfo::get_active_instance() | ||||
| { | ||||
|     const Selection& selection = m_common->get_canvas()->get_selection(); | ||||
|     return selection.get_instance_idx(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| void InstancesHider::on_update() | ||||
| { | ||||
|     const ModelObject* mo = m_common->selection_info()->model_object(); | ||||
|     int active_inst = m_common->selection_info()->get_active_instance(); | ||||
|     GLCanvas3D* canvas = m_common->get_canvas(); | ||||
| 
 | ||||
|     if (mo && active_inst != -1) { | ||||
|         canvas->toggle_model_objects_visibility(false); | ||||
|         canvas->toggle_model_objects_visibility(true, mo, active_inst); | ||||
|     } | ||||
|     else | ||||
|         canvas->toggle_model_objects_visibility(true); | ||||
| } | ||||
| 
 | ||||
| void InstancesHider::on_release() | ||||
| { | ||||
|     m_common->get_canvas()->toggle_model_objects_visibility(true); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } // namespace GUI
 | ||||
| } // namespace Slic3r
 | ||||
|  |  | |||
|  | @ -119,19 +119,21 @@ private: | |||
|     int m_active_inst = -1; | ||||
| }; | ||||
| 
 | ||||
| /*
 | ||||
| 
 | ||||
| class InstancesHider : public CommonGizmosDataBase | ||||
| { | ||||
| public: | ||||
|     explicit InstancesHider(CommonGizmosDataPool* cgdp) | ||||
|         : CommonGizmosDataBase(cgdp) {} | ||||
|     void update(bool required) override; | ||||
| protected: | ||||
|     void on_update() override; | ||||
|     void on_release() override; | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /*
 | ||||
| 
 | ||||
| 
 | ||||
| class HollowedMesh : public CommonGizmosDataBase | ||||
|  |  | |||
|  | @ -1196,10 +1196,13 @@ void GLGizmosManager::activate_gizmo(EType type) | |||
|             return; // gizmo refused to be turned off, do nothing.
 | ||||
|     } | ||||
| 
 | ||||
|     m_current = type; | ||||
|     m_common_gizmos_data->update(get_current() | ||||
|                            ? get_current()->get_requirements() | ||||
|                            : CommonGizmosDataID(0)); | ||||
| 
 | ||||
|     if (type != Undefined) | ||||
|         m_gizmos[type]->set_state(GLGizmoBase::On); | ||||
| 
 | ||||
|     m_current = type; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Matena
						Lukas Matena