From 43ad9ff8b7507c3af6fa5415cbd09aa5e13c819d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 23 Apr 2019 10:45:41 +0200 Subject: [PATCH] Picking using rectangle selection WIP 2 --- src/libslic3r/Technologies.hpp | 5 +- src/slic3r/GUI/3DScene.cpp | 25 ++++- src/slic3r/GUI/3DScene.hpp | 6 +- src/slic3r/GUI/GLCanvas3D.cpp | 107 ++++++++++--------- src/slic3r/GUI/GLSelectionRectangle.cpp | 22 ++-- src/slic3r/GUI/GLSelectionRectangle.hpp | 15 ++- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 20 +++- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 4 +- 9 files changed, 127 insertions(+), 79 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 45f04b1df..e99741b84 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -12,7 +12,10 @@ // Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active #define ENABLE_RENDER_SELECTION_CENTER 0 // Shows an imgui dialog with render related data -#define ENABLE_RENDER_STATISTICS 0 +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#define ENABLE_RENDER_STATISTICS 1 +//#define ENABLE_RENDER_STATISTICS 0 +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //==================== diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 9038e388c..48c4ba545 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -223,7 +223,11 @@ void GLIndexedVertexArray::render( } const float GLVolume::SELECTED_COLOR[4] = { 0.0f, 1.0f, 0.0f, 1.0f }; -const float GLVolume::HOVER_COLOR[4] = { 0.4f, 0.9f, 0.1f, 1.0f }; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +const float GLVolume::HOVER_SELECT_COLOR[4] = { 0.4f, 0.9f, 0.1f, 1.0f }; +const float GLVolume::HOVER_UNSELECT_COLOR[4] = { 0.9f, 0.4f, 0.1f, 1.0f }; +//const float GLVolume::HOVER_COLOR[4] = { 0.4f, 0.9f, 0.1f, 1.0f }; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ const float GLVolume::OUTSIDE_COLOR[4] = { 0.0f, 0.38f, 0.8f, 1.0f }; const float GLVolume::SELECTED_OUTSIDE_COLOR[4] = { 0.19f, 0.58f, 1.0f, 1.0f }; const float GLVolume::DISABLED_COLOR[4] = { 0.25f, 0.25f, 0.25f, 1.0f }; @@ -291,16 +295,29 @@ void GLVolume::set_render_color() if (force_native_color) set_render_color(color, 4); else { - if (selected) +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + if (hover) + set_render_color(HOVER_SELECT_COLOR, 4); + else if (selected) set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4); - else if (hover) - set_render_color(HOVER_COLOR, 4); else if (disabled) set_render_color(DISABLED_COLOR, 4); else if (is_outside && shader_outside_printer_detection_enabled) set_render_color(OUTSIDE_COLOR, 4); else set_render_color(color, 4); + +// if (selected) +// set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4); +// else if (hover) +// set_render_color(HOVER_COLOR, 4); +// else if (disabled) +// set_render_color(DISABLED_COLOR, 4); +// else if (is_outside && shader_outside_printer_detection_enabled) +// set_render_color(OUTSIDE_COLOR, 4); +// else +// set_render_color(color, 4); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ } if (force_transparent) diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 88547359e..04fb211f9 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -225,7 +225,11 @@ private: class GLVolume { public: static const float SELECTED_COLOR[4]; - static const float HOVER_COLOR[4]; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + static const float HOVER_SELECT_COLOR[4]; + static const float HOVER_UNSELECT_COLOR[4]; +// static const float HOVER_COLOR[4]; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ static const float OUTSIDE_COLOR[4]; static const float SELECTED_OUTSIDE_COLOR[4]; static const float DISABLED_COLOR[4]; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 3edfabb58..4497306d6 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1605,7 +1605,7 @@ void GLCanvas3D::render() wxGetApp().imgui()->new_frame(); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - if (m_rectangle_selection.is_active()) + if (m_rectangle_selection.is_dragging()) // picking pass using rectangle selection _rectangular_selection_picking_pass(); else @@ -1649,7 +1649,7 @@ void GLCanvas3D::render() #endif // ENABLE_SHOW_CAMERA_TARGET //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - if (m_rectangle_selection.is_active()) + if (m_rectangle_selection.is_dragging()) m_rectangle_selection.render(*this); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -2366,7 +2366,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ else if (keyCode == WXK_SHIFT) { - if (m_rectangle_selection.is_active()) + if (m_rectangle_selection.is_dragging()) { m_rectangle_selection.stop_dragging(); m_dirty = true; @@ -2375,7 +2375,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) } else if (keyCode == WXK_ALT) { - if (m_rectangle_selection.is_active()) + if (m_rectangle_selection.is_dragging()) { m_rectangle_selection.stop_dragging(); m_dirty = true; @@ -2772,7 +2772,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - else if (evt.Dragging() && evt.LeftIsDown() && m_rectangle_selection.is_active()) + else if (evt.Dragging() && evt.LeftIsDown() && m_rectangle_selection.is_dragging()) { m_rectangle_selection.dragging(pos.cast()); m_dirty = true; @@ -2834,7 +2834,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED)); } //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - else if (evt.LeftUp() && m_rectangle_selection.is_active()) + else if (evt.LeftUp() && m_rectangle_selection.is_dragging()) { m_rectangle_selection.stop_dragging(); m_dirty = true; @@ -3684,7 +3684,10 @@ void GLCanvas3D::_picking_pass() const if (inside) { glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position(1) - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color)); - volume_id = color[0] + color[1] * 256 + color[2] * 256 * 256; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + volume_id = color[0] + (color[1] << 8) + (color[2] << 16); +// volume_id = color[0] + color[1] * 256 + color[2] * 256 * 256; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ } if ((0 <= volume_id) && (volume_id < (int)m_volumes.volumes.size())) { @@ -3704,6 +3707,11 @@ void GLCanvas3D::_picking_pass() const //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ void GLCanvas3D::_rectangular_selection_picking_pass() const { + m_hover_volume_id = -1; + m_gizmos.set_hover_id(-1); + + std::set idxs; + if (m_picking_enabled) { if (m_multisample_allowed) @@ -3721,63 +3729,60 @@ void GLCanvas3D::_rectangular_selection_picking_pass() const int width = (int)m_rectangle_selection.get_width(); int height = (int)m_rectangle_selection.get_height(); + int px_count = width * height; - if ((width > 0) && (height > 0)) + if (px_count > 0) { int left = (int)m_rectangle_selection.get_left(); int top = get_canvas_size().get_height() - (int)m_rectangle_selection.get_top(); if ((left >= 0) && (top >= 0)) { - std::vector> frame(width * height); -// std::vector frame(4 * width * height); + std::vector frame(4 * px_count); glsafe(::glReadPixels(left, top, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (void*)frame.data())); -#if 1 - std::sort(frame.begin(), frame.end()); - frame.resize(std::distance(frame.begin(), std::unique(frame.begin(), frame.end()))); - if (frame.size() > 1) + for (int i = 0; i < px_count; ++i) { - std::cout << frame.size() - 1 << std::endl; + int px_id = 4 * i; + int volume_id = frame[px_id] + (frame[px_id + 1] << 8) + (frame[px_id + 2] << 16); + if ((0 <= volume_id) && (volume_id < (int)m_volumes.volumes.size())) + idxs.insert(volume_id); } - -/* - std::set idxs; - for (int r = 0; r < height; ++r) - { - for (int c = 0; c < width; ++c) - { - int id_px = 4 * (r * width + c); - idxs.insert(frame[id_px] + frame[id_px + 1] * 256 + frame[id_px + 2] * 256 * 256); - } - } - - if (idxs.size() > 1) - { - std::cout << idxs.size() - 1 << std::endl; - } -*/ -#else - wxImage frame_image(width, height); - unsigned char* image_data = frame_image.GetData(); - for (int r = 0; r < height; ++r) - { - for (int c = 0; c < width; ++c) - { - int id_px = r * width + c; - ::memcpy((void*)(image_data + 3 * id_px), (const void*)&frame[4 * id_px], 3); - } - } - - wxImageHistogram frame_histogram; - unsigned long colors_count = frame_image.ComputeHistogram(frame_histogram); - if (colors_count > 1) - { - std::cout << colors_count - 1 << std::endl; - } -#endif } } } + + // see _update_volumes_hover_state() + for (GLVolume* v : m_volumes.volumes) + { + v->hover = false; + } + + if (!idxs.empty()) + { + GLSelectionRectangle::EState state = m_rectangle_selection.get_state(); + + for (int idx : idxs) + { + GLVolume* volume = m_volumes.volumes[idx]; +// if ((!volume->selected && (state == GLSelectionRectangle::Select)) || +// (volume->selected && (state == GLSelectionRectangle::Deselect))) +// { + if (volume->is_modifier) + volume->hover = true; + else + { + int object_idx = volume->object_idx(); + int instance_idx = volume->instance_idx(); + + for (GLVolume* v : m_volumes.volumes) + { + if ((v->object_idx() == object_idx) && (v->instance_idx() == instance_idx)) + v->hover = true; + } + } +// } + } + } } //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ diff --git a/src/slic3r/GUI/GLSelectionRectangle.cpp b/src/slic3r/GUI/GLSelectionRectangle.cpp index 08bc3fb20..e3d71389e 100644 --- a/src/slic3r/GUI/GLSelectionRectangle.cpp +++ b/src/slic3r/GUI/GLSelectionRectangle.cpp @@ -11,19 +11,19 @@ namespace Slic3r { namespace GUI { //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -void GLSelectionRectangle::start_dragging(const Vec2d& mouse_position, EState status) +void GLSelectionRectangle::start_dragging(const Vec2d& mouse_position, EState state) { - if (is_active() || (status == Off)) + if (is_dragging() || (state == Off)) return; - m_status = status; + m_state = state; m_start_corner = mouse_position; m_end_corner = mouse_position; } void GLSelectionRectangle::dragging(const Vec2d& mouse_position) { - if (!is_active()) + if (!is_dragging()) return; m_end_corner = mouse_position; @@ -33,10 +33,10 @@ std::vector GLSelectionRectangle::stop_dragging(const GLCanvas3D& { std::vector out; - if (!is_active()) + if (!is_dragging()) return out; - m_status = Off; + m_state = Off; const Camera& camera = canvas.get_camera(); const std::array& viewport = camera.get_viewport(); @@ -62,15 +62,15 @@ std::vector GLSelectionRectangle::stop_dragging(const GLCanvas3D& void GLSelectionRectangle::stop_dragging() { - if (!is_active()) + if (!is_dragging()) return; - m_status = Off; + m_state = Off; } void GLSelectionRectangle::render(const GLCanvas3D& canvas) const { - if (m_status == Off) + if (m_state == Off) return; float zoom = canvas.get_camera().zoom; @@ -92,8 +92,8 @@ void GLSelectionRectangle::render(const GLCanvas3D& canvas) const glsafe(::glLineWidth(1.5f)); float color[3]; - color[0] = (m_status == Select) ? 0.3f : 1.0f; - color[1] = (m_status == Select) ? 1.0f : 0.3f; + color[0] = (m_state == Select) ? 0.3f : 1.0f; + color[1] = (m_state == Select) ? 1.0f : 0.3f; color[2] = 0.3f; glsafe(::glColor3fv(color)); diff --git a/src/slic3r/GUI/GLSelectionRectangle.hpp b/src/slic3r/GUI/GLSelectionRectangle.hpp index 7cab96f41..9b29b2d5e 100644 --- a/src/slic3r/GUI/GLSelectionRectangle.hpp +++ b/src/slic3r/GUI/GLSelectionRectangle.hpp @@ -26,7 +26,7 @@ public: //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // Initiates the rectangle. - void start_dragging(const Vec2d& mouse_position, EState status); + void start_dragging(const Vec2d& mouse_position, EState state); // To be called on mouse move. void dragging(const Vec2d& mouse_position); @@ -53,8 +53,12 @@ public: // void render() const; //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - bool is_active() const { return m_status != Off; } - EState get_status() const { return m_status; } +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + bool is_dragging() const { return m_state != Off; } + EState get_state() const { return m_state; } +// bool is_active() const { return m_status != Off; } +// EState get_status() const { return m_status; } +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ float get_width() const { return std::abs(m_start_corner(0) - m_end_corner(0)); } @@ -66,7 +70,10 @@ public: //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ private: - EState m_status = Off; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + EState m_state = Off; +// EState m_status = Off; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Vec2d m_start_corner; Vec2d m_end_corner; //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index f278c944c..764fc259f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -491,7 +491,10 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous } // left down without selection rectangle - place point on the mesh: - if (action == SLAGizmoEventType::LeftDown && !m_selection_rectangle.is_active() && !shift_down) { +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + if (action == SLAGizmoEventType::LeftDown && !m_selection_rectangle.is_dragging() && !shift_down) { +// if (action == SLAGizmoEventType::LeftDown && !m_selection_rectangle.is_active() && !shift_down) { +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // If any point is in hover state, this should initiate its move - return control back to GLCanvas: if (m_hover_id != -1) return false; @@ -516,9 +519,15 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous } // left up with selection rectangle - select points inside the rectangle: - if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::ShiftUp || action == SLAGizmoEventType::AltUp) && m_selection_rectangle.is_active()) { +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::ShiftUp || action == SLAGizmoEventType::AltUp) && m_selection_rectangle.is_dragging()) { +// if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::ShiftUp || action == SLAGizmoEventType::AltUp) && m_selection_rectangle.is_active()) { +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // Is this a selection or deselection rectangle? - GLSelectionRectangle::EState rectangle_status = m_selection_rectangle.get_status(); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + GLSelectionRectangle::EState rectangle_status = m_selection_rectangle.get_state(); +// GLSelectionRectangle::EState rectangle_status = m_selection_rectangle.get_status(); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // First collect positions of all the points in world coordinates. const Transform3d& instance_matrix = m_model_object->instances[m_active_instance]->get_transformation().get_matrix(); @@ -613,7 +622,10 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous return true; // point has been placed and the button not released yet // this prevents GLCanvas from starting scene rotation - if (m_selection_rectangle.is_active()) { +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + if (m_selection_rectangle.is_dragging()) { +// if (m_selection_rectangle.is_active()) { +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ m_selection_rectangle.dragging(mouse_position); return true; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index 265310e5f..4e0edae9a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -70,7 +70,7 @@ public: //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ bool is_in_editing_mode() const { return m_editing_mode; } - bool is_selection_rectangle_active() const { return m_selection_rectangle.is_active(); } + bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); } //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ private: diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 0d0fbd9e6..142fd5f7e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -851,13 +851,13 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt, GLCanvas3D& canvas) if (keyCode == WXK_SHIFT) { // shift has been just released - SLA gizmo might want to close rectangular selection. - if (gizmo_event(SLAGizmoEventType::ShiftUp) || (gizmo->is_in_editing_mode() && gizmo->is_selection_rectangle_active())) + if (gizmo_event(SLAGizmoEventType::ShiftUp) || (gizmo->is_in_editing_mode() && gizmo->is_selection_rectangle_dragging())) processed = true; } else if (keyCode == WXK_ALT) { // alt has been just released - SLA gizmo might want to close rectangular selection. - if (gizmo_event(SLAGizmoEventType::AltUp) || (gizmo->is_in_editing_mode() && gizmo->is_selection_rectangle_active())) + if (gizmo_event(SLAGizmoEventType::AltUp) || (gizmo->is_in_editing_mode() && gizmo->is_selection_rectangle_dragging())) processed = true; } }