From 11d711bc4b60964d986c548682cf37ff620b79a5 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Thu, 28 Mar 2024 11:28:38 +0800 Subject: [PATCH] FIX: add query_real_volume_idx_from_other_view api Jira: STUDIO-6545 Change-Id: Ib8216981c5d2945a0221a5caa1fbc14ed74e930b --- src/slic3r/GUI/Plater.cpp | 18 +++++++++++++++--- src/slic3r/GUI/Selection.cpp | 11 +++++++++++ src/slic3r/GUI/Selection.hpp | 1 + 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index a9f3521c6..a5eea812c 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4575,7 +4575,11 @@ 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) - view3D->render(); + 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); + } } } diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 21b4689cf..c0b9be2a7 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -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) diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index 09189e33a..817a42354 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -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);