Tweaks to selection from 3D scene

This commit is contained in:
Enrico Turri 2019-04-09 15:42:00 +02:00
parent c17e8602ed
commit 0889877e26
4 changed files with 11 additions and 10 deletions

View File

@ -2569,8 +2569,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_selection.remove(m_hover_volume_id);
else
{
bool add_as_single = !already_selected && !ctrl_down;
m_selection.add(m_hover_volume_id, add_as_single);
m_selection.add(m_hover_volume_id, !ctrl_down);
m_mouse.drag.move_requires_threshold = !already_selected;
if (already_selected)
m_mouse.set_move_start_threshold_position_2D_as_invalid();

View File

@ -1979,7 +1979,7 @@ void ObjectList::update_selections()
if (selection.is_single_full_object() &&
m_objects_model->GetIdByItem(m_objects_model->GetParent(item)) == selection.get_object_idx())
return;
if (selection.is_single_volume() || selection.is_modifier()) {
if (selection.is_single_volume() || selection.is_any_modifier()) {
const auto gl_vol = selection.get_volume(*selection.get_volume_idxs().begin());
if (m_objects_model->GetVolumeIdByItem(m_objects_model->GetParent(item)) == gl_vol->volume_idx())
return;
@ -2014,7 +2014,7 @@ void ObjectList::update_selections()
}
}
}
else if (selection.is_single_volume() || selection.is_modifier() || selection.is_multiple_volume())
else if (selection.is_any_volume() || selection.is_any_modifier())
{
for (auto idx : selection.get_volume_idxs()) {
const auto gl_vol = selection.get_volume(idx);

View File

@ -109,19 +109,20 @@ void Selection::add(unsigned int volume_idx, bool as_single_selection)
if (is_wipe_tower() && volume->is_wipe_tower)
return;
bool keep_instance_mode = (m_mode == Instance) && !as_single_selection && (is_single_full_instance() || is_multiple_full_instance());
bool keep_instance_mode = (m_mode == Instance) && !as_single_selection;
bool already_contained = contains_volume(volume_idx);
// resets the current list if needed
bool needs_reset = as_single_selection;
bool needs_reset = as_single_selection && !already_contained;
needs_reset |= volume->is_wipe_tower;
needs_reset |= is_wipe_tower() && !volume->is_wipe_tower;
needs_reset |= !keep_instance_mode && !is_modifier() && volume->is_modifier;
needs_reset |= is_modifier() && !volume->is_modifier;
needs_reset |= as_single_selection && !is_any_modifier() && volume->is_modifier;
needs_reset |= is_any_modifier() && !volume->is_modifier;
if (needs_reset)
clear();
if (!contains_volume(volume_idx))
if (!already_contained || needs_reset)
{
if (!keep_instance_mode)
m_mode = volume->is_modifier ? Volume : Instance;

View File

@ -213,7 +213,7 @@ public:
bool is_empty() const { return m_type == Empty; }
bool is_wipe_tower() const { return m_type == WipeTower; }
bool is_modifier() const { return (m_type == SingleModifier) || (m_type == MultipleModifier); }
bool is_any_modifier() const { return is_single_modifier() || is_multiple_modifier(); }
bool is_single_modifier() const { return m_type == SingleModifier; }
bool is_multiple_modifier() const { return m_type == MultipleModifier; }
bool is_single_full_instance() const;
@ -222,6 +222,7 @@ public:
bool is_multiple_full_object() const { return m_type == MultipleFullObject; }
bool is_single_volume() const { return m_type == SingleVolume; }
bool is_multiple_volume() const { return m_type == MultipleVolume; }
bool is_any_volume() const { return is_single_volume() || is_multiple_volume(); }
bool is_mixed() const { return m_type == Mixed; }
bool is_from_single_instance() const { return get_instance_idx() != -1; }
bool is_from_single_object() const;