diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index 515a95559..aef2094a7 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -128,6 +128,7 @@ public: Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {}; Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {}; + virtual ~Field() {} /// If you don't know what you are getting back, check both methods for nullptr. virtual wxSizer* getSizer() { return nullptr; } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 3caa3be3d..3cd62162a 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -519,6 +519,8 @@ public: const IndicesList& get_volume_idxs() const { return m_list; } const GLVolume* get_volume(unsigned int volume_idx) const; + const ObjectIdxsToInstanceIdxsMap& get_content() const { return m_cache.content; } + unsigned int volumes_count() const { return (unsigned int)m_list.size(); } const BoundingBoxf3& get_bounding_box() const; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 920db9581..3c8efbf22 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1358,6 +1358,41 @@ void ObjectList::update_selections() sels.Add(m_objects_model->GetItemByInstanceId(selection.get_object_idx(), idx)); } } + else if (selection.is_mixed()) + { + auto& objects_content_list = selection.get_content(); + + for (auto idx : selection.get_volume_idxs()) { + const auto gl_vol = selection.get_volume(idx); + const auto& glv_obj_idx = gl_vol->object_idx(); + const auto& glv_ins_idx = gl_vol->instance_idx(); + + bool is_selected = false; + + for (auto obj_ins : objects_content_list) { + if (obj_ins.first == glv_obj_idx) { + if (obj_ins.second.find(glv_ins_idx) != obj_ins.second.end()) { + if (glv_ins_idx == 0 && (*m_objects)[glv_obj_idx]->instances.size() == 1) + sels.Add(m_objects_model->GetItemById(glv_obj_idx)); + else + sels.Add(m_objects_model->GetItemByInstanceId(glv_obj_idx, glv_ins_idx)); + + is_selected = true; + break; + } + } + } + + if (is_selected) + continue; + + const auto& glv_vol_idx = gl_vol->volume_idx(); + if (glv_vol_idx == 0 && (*m_objects)[glv_obj_idx]->volumes.size() == 1) + sels.Add(m_objects_model->GetItemById(glv_obj_idx)); + else + sels.Add(m_objects_model->GetItemByVolumeId(glv_obj_idx, glv_vol_idx)); + } + } select_items(sels); }