From 68f77f103165594ac0801bbce3ab8308d4b0484e Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 22 Oct 2018 08:54:04 +0200 Subject: [PATCH] New selection -> Changed selection logic == Use SHIFT for both add to selection and remove from selection --- src/slic3r/GUI/GLCanvas3D.cpp | 10 +++------- src/slic3r/GUI/GLCanvas3D.hpp | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 7ffd6e010..4bb0f499f 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3989,10 +3989,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) #if ENABLE_EXTENDED_SELECTION if (evt.LeftDown() && (m_hover_volume_id != -1)) { - if (evt.ControlDown()) - m_selection.remove(m_hover_volume_id); - else + if (!evt.ShiftDown() || !m_selection.contains_volume(m_hover_volume_id)) m_selection.add(m_hover_volume_id, !evt.ShiftDown()); + else + m_selection.remove(m_hover_volume_id); m_gizmos.update_on_off_state(m_selection); update_gizmos_data(); @@ -6644,9 +6644,6 @@ void GLCanvas3D::_on_move(const std::vector& volume_idxs) #if !ENABLE_EXTENDED_SELECTION void GLCanvas3D::_on_select(int volume_idx, int object_idx) { -#if ENABLE_EXTENDED_SELECTION - post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT)); -#else int vol_id = -1; int obj_id = -1; @@ -6675,7 +6672,6 @@ void GLCanvas3D::_on_select(int volume_idx, int object_idx) post_event(ObjectSelectEvent(obj_id, vol_id)); wxGetApp().obj_list()->select_current_volume(obj_id, vol_id); -#endif // !ENABLE_EXTENDED_SELECTION } #endif // !ENABLE_EXTENDED_SELECTION diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 844e826fe..c26dae098 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -485,6 +485,8 @@ public: bool is_from_single_instance() const { return get_instance_idx() != -1; } bool is_from_single_object() const { return get_object_idx() != -1; } + bool contains_volume(unsigned int volume_idx) const { return std::find(m_list.begin(), m_list.end(), volume_idx) != m_list.end(); } + // Returns the the object id if the selection is from a single object, otherwise is -1 int get_object_idx() const; // Returns the instance id if the selection is from a single object and from a single instance, otherwise is -1