mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 02:07:54 -06:00
Flattening gizmo now uses the new CommonDataPool to store pointer to active object
This commit is contained in:
parent
3b06332999
commit
593e7a1546
5 changed files with 71 additions and 44 deletions
|
@ -7,11 +7,11 @@
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
using namespace CommonGizmosDataObjects;
|
||||
|
||||
CommonGizmosDataPool::CommonGizmosDataPool(GLCanvas3D* canvas)
|
||||
: m_canvas(canvas)
|
||||
{
|
||||
using namespace CommonGizmosDataObjects;
|
||||
using c = CommonGizmosDataID;
|
||||
m_data[c::SelectionInfo].reset( new SelectionInfo(this));
|
||||
//m_data[c::InstancesHider].reset( new InstancesHider(this));
|
||||
|
@ -24,8 +24,19 @@ CommonGizmosDataPool::CommonGizmosDataPool(GLCanvas3D* canvas)
|
|||
void CommonGizmosDataPool::update(CommonGizmosDataID required)
|
||||
{
|
||||
assert(check_dependencies(required));
|
||||
for (auto& [id, data] : m_data)
|
||||
data->update(int(required) & int(CommonGizmosDataID(id)));
|
||||
for (auto& [id, data] : m_data) {
|
||||
if (int(required) & int(CommonGizmosDataID(id)))
|
||||
data->update();
|
||||
else if (data->is_valid())
|
||||
data->release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SelectionInfo* CommonGizmosDataPool::selection_info()
|
||||
{
|
||||
SelectionInfo* sel_info = dynamic_cast<SelectionInfo*>(m_data[CommonGizmosDataID::SelectionInfo].get());
|
||||
return sel_info;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -41,13 +52,19 @@ bool CommonGizmosDataPool::check_dependencies(CommonGizmosDataID required) const
|
|||
|
||||
|
||||
|
||||
void CommonGizmosDataObjects::SelectionInfo::update(bool required)
|
||||
void SelectionInfo::on_update()
|
||||
{
|
||||
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
|
||||
m_model_object = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void SelectionInfo::on_release()
|
||||
{
|
||||
m_model_object = nullptr;
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue