From 8210d76449ed30aaed143f45ace2b515e023d3b2 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Mon, 31 Mar 2025 23:23:23 +0800 Subject: [PATCH 1/3] Fix issue that you cannot select multiple brim ears with shift+left click --- src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp index 5ee7bab7c8..9962060ebc 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp @@ -265,16 +265,12 @@ void GLGizmoBrimEars::data_changed(bool is_serializing) bool GLGizmoBrimEars::on_mouse(const wxMouseEvent& mouse_event) { - if (use_grabbers(mouse_event)) { - return true; - } - // wxCoord == int --> wx/types.h Vec2i32 mouse_coord(mouse_event.GetX(), mouse_event.GetY()); Vec2d mouse_pos = mouse_coord.cast(); if (mouse_event.Moving()) { - return gizmo_event(SLAGizmoEventType::Moving, mouse_pos, mouse_event.ShiftDown(), mouse_event.AltDown(), false); + gizmo_event(SLAGizmoEventType::Moving, mouse_pos, mouse_event.ShiftDown(), mouse_event.AltDown(), false); } // when control is down we allow scene pan and rotation even when clicking @@ -317,15 +313,15 @@ bool GLGizmoBrimEars::on_mouse(const wxMouseEvent& mouse_event) return false; } } else if (mouse_event.LeftUp()) { - if (!m_parent.is_mouse_dragging()) { + if (gizmo_event(SLAGizmoEventType::LeftUp, mouse_pos, mouse_event.ShiftDown(), mouse_event.AltDown(), control_down) + && !m_parent.is_mouse_dragging()) { // in case SLA/FDM gizmo is selected, we just pass the LeftUp // event and stop processing - neither object moving or selecting // is suppressed in that case - gizmo_event(SLAGizmoEventType::LeftUp, mouse_pos, mouse_event.ShiftDown(), mouse_event.AltDown(), control_down); return true; } } - return false; + return use_grabbers(mouse_event); } // Following function is called from GLCanvas3D to inform the gizmo about a mouse/keyboard event. From d31546b2aea294543b5d7db80d96b5a783422015 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Mon, 31 Mar 2025 23:37:49 +0800 Subject: [PATCH 2/3] Fix brim ear size preview when dragging the slide --- src/slic3r/GUI/ImGuiWrapper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 2229dd9a40..8b3cbbeaeb 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -768,6 +768,7 @@ bool ImGuiWrapper::bbl_slider_float(const std::string& label, float* v, float v_ bool ret = ImGui::BBLSliderFloat(str_label.c_str(), v, v_min, v_max, format, power); m_last_slider_status.hovered = ImGui::IsItemHovered(); + m_last_slider_status.edited = ImGui::IsItemEdited(); m_last_slider_status.clicked = ImGui::IsItemClicked(); m_last_slider_status.deactivated_after_edit = ImGui::IsItemDeactivatedAfterEdit(); From 64ac0ecd417b0b31d610b642c884588748d6605a Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 1 Apr 2025 16:07:38 +0800 Subject: [PATCH 3/3] Fix `render_hover_point` memory leaking by using `std::optional` --- src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp | 7 +++---- src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp index 9962060ebc..2113de4996 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp @@ -100,7 +100,7 @@ void GLGizmoBrimEars::on_render() void GLGizmoBrimEars::render_points(const Selection &selection) { auto editing_cache = m_editing_cache; - if (render_hover_point != nullptr) { editing_cache.push_back(*render_hover_point); } + if (render_hover_point) { editing_cache.push_back(*render_hover_point); } size_t cache_size = editing_cache.size(); @@ -344,10 +344,9 @@ bool GLGizmoBrimEars::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_p Transform3d inverse_trsf = volume->get_instance_transformation().get_matrix_no_offset().inverse(); std::pair pos_and_normal; if (unproject_on_mesh2(mouse_position, pos_and_normal)) { - render_hover_point = new CacheEntry(BrimPoint(pos_and_normal.first, m_new_point_head_diameter / 2.f), false, (inverse_trsf * m_world_normal).cast(), true); + render_hover_point = CacheEntry(BrimPoint(pos_and_normal.first, m_new_point_head_diameter / 2.f), false, (inverse_trsf * m_world_normal).cast(), true); } else { - delete render_hover_point; - render_hover_point = nullptr; + render_hover_point.reset(); } } else if (action == SLAGizmoEventType::LeftDown && (shift_down || alt_down || control_down)) { // left down with shift - show the selection rectangle: diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp index e316861dbd..db3c454e50 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp @@ -108,7 +108,7 @@ private: const Vec3d m_world_normal = {0, 0, 1}; std::map> m_mesh_raycaster_map; GLVolume* m_last_hit_volume; - CacheEntry* render_hover_point = nullptr; + std::optional render_hover_point; bool m_link_text_hover = false;