mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-05-23 06:39:23 -07:00
Flattening gizmo now uses the new CommonDataPool to store pointer to active object
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user