From 0889877e267b737f8ac44eb11624c2896b68a007 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 9 Apr 2019 15:42:00 +0200 Subject: [PATCH] Tweaks to selection from 3D scene --- src/slic3r/GUI/GLCanvas3D.cpp | 3 +-- src/slic3r/GUI/GUI_ObjectList.cpp | 4 ++-- src/slic3r/GUI/Selection.cpp | 11 ++++++----- src/slic3r/GUI/Selection.hpp | 3 ++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9296e8169..29c64b9a5 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -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(); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 6c02dd29b..b5615f6f1 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -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); diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 6f148ca24..dedf55a45 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -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; diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index ae121f942..b03a8e89a 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -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;