Correct mixed_selection updating from 3dScene to ObjectList

This commit is contained in:
YuSanka 2018-11-30 11:21:25 +01:00
parent 4bb771683d
commit 054d202817
3 changed files with 38 additions and 0 deletions

View File

@ -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; }

View File

@ -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;

View File

@ -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);
}