FIX: add query_real_volume_idx_from_other_view api

Jira: STUDIO-6545
Change-Id: Ib8216981c5d2945a0221a5caa1fbc14ed74e930b
This commit is contained in:
zhou.xu 2024-03-28 11:28:38 +08:00 committed by Lane.Wei
parent fa53be3736
commit 11d711bc4b
3 changed files with 27 additions and 3 deletions

View File

@ -4575,8 +4575,12 @@ void Plater::priv::selection_changed()
}
// forces a frame render to update the view (to avoid a missed update if, for example, the context menu appears)
if (get_current_canvas3D()->get_canvas_type() == GLCanvas3D::CanvasAssembleView) {
assemble_view->render();
} else {
view3D->render();
}
}
void Plater::priv::object_list_changed()
{
@ -6037,7 +6041,11 @@ void Plater::priv::set_current_panel(wxPanel* panel, bool no_slice)
Selection& view3d_selection = view3D->get_canvas3d()->get_selection();
view3d_selection.clear();
for (unsigned int idx : select_idxs) {
view3d_selection.add(idx, false);
auto v = assemble_canvas->get_selection().get_volume(idx);
auto real_idx = view3d_selection.query_real_volume_idx_from_other_view(v->object_idx(), v->instance_idx(), v->volume_idx());
if (real_idx >= 0) {
view3d_selection.add(real_idx, false);
}
}
}
@ -6125,7 +6133,11 @@ void Plater::priv::set_current_panel(wxPanel* panel, bool no_slice)
Selection& assemble_selection = assemble_view->get_canvas3d()->get_selection();
assemble_selection.clear();
for (unsigned int idx : select_idxs) {
assemble_selection.add(idx, false);
auto v = view3D_canvas->get_selection().get_volume(idx);
auto real_idx = assemble_selection.query_real_volume_idx_from_other_view(v->object_idx(), v->instance_idx(), v->volume_idx());
if (real_idx >= 0) {
assemble_selection.add(real_idx, false);
}
}
}

View File

@ -149,6 +149,17 @@ void Selection::set_model(Model* model)
update_valid();
}
int Selection::query_real_volume_idx_from_other_view(unsigned int object_idx, unsigned int instance_idx, unsigned int model_volume_idx)
{
for (int i = 0; i < m_volumes->size(); i++) {
auto v = (*m_volumes)[i];
if (v->object_idx() == object_idx && instance_idx == v->instance_idx() && model_volume_idx == v->volume_idx()) {
return i;
}
}
return -1;
}
void Selection::add(unsigned int volume_idx, bool as_single_selection, bool check_for_already_contained)
{
if (!m_valid || (unsigned int)m_volumes->size() <= volume_idx)

View File

@ -282,6 +282,7 @@ public:
EMode get_mode() const { return m_mode; }
void set_mode(EMode mode) { m_mode = mode; }
int query_real_volume_idx_from_other_view(unsigned int object_idx, unsigned int instance_idx, unsigned int model_volume_idx);
void add(unsigned int volume_idx, bool as_single_selection = true, bool check_for_already_contained = false);
void remove(unsigned int volume_idx);