From b8323704213830284fb72c8336405d5745a487f1 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 1 Apr 2025 11:43:04 +0800 Subject: [PATCH 1/3] Change section view hotkey to alt+mouse wheel --- src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp index 5ee7bab7c8..533b2d2d25 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp @@ -57,8 +57,8 @@ bool GLGizmoBrimEars::on_init() m_desc["left_click"] = _L("Add a brim ear"); m_desc["right_click_caption"] = _L("Right click"); m_desc["right_click"] = _L("Delete a brim ear"); - m_desc["ctrl_mouse_wheel_caption"] = _L("Ctrl+Mouse wheel"); - m_desc["ctrl_mouse_wheel"] = _L("Adjust section view"); + m_desc["alt_mouse_wheel_caption"] = _L("Alt + Mouse wheel"); + m_desc["alt_mouse_wheel"] = _L("Adjust section view"); return true; } @@ -479,14 +479,14 @@ bool GLGizmoBrimEars::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_p } // mouse wheel up - if (action == SLAGizmoEventType::MouseWheelUp && control_down) { + if (action == SLAGizmoEventType::MouseWheelUp && alt_down) { double pos = m_c->object_clipper()->get_position(); pos = std::min(1., pos + 0.01); m_c->object_clipper()->set_position_by_ratio(pos, false, true); return true; } - if (action == SLAGizmoEventType::MouseWheelDown && control_down) { + if (action == SLAGizmoEventType::MouseWheelDown && alt_down) { double pos = m_c->object_clipper()->get_position(); pos = std::max(0., pos - 0.01); m_c->object_clipper()->set_position_by_ratio(pos, false, true); @@ -737,7 +737,7 @@ void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limi void GLGizmoBrimEars::show_tooltip_information(float x, float y) { - std::array info_array = std::array{"left_click", "right_click", "ctrl_mouse_wheel"}; + std::array info_array = std::array{"left_click", "right_click", "alt_mouse_wheel"}; float caption_max = 0.f; for (const auto &t : info_array) { caption_max = std::max(caption_max, m_imgui->calc_text_size(m_desc[t + "_caption"]).x); } From 00cf9be46e8262d0c69f8d2ea79549930fecae66 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 1 Apr 2025 11:43:22 +0800 Subject: [PATCH 2/3] Use ctrl+mouse wheel up/down to change brim size --- src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp | 83 ++++++++++++++++++----- src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp | 4 ++ src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 12 ++-- 3 files changed, 76 insertions(+), 23 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp index 533b2d2d25..2cd14f144d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp @@ -57,6 +57,8 @@ bool GLGizmoBrimEars::on_init() m_desc["left_click"] = _L("Add a brim ear"); m_desc["right_click_caption"] = _L("Right click"); m_desc["right_click"] = _L("Delete a brim ear"); + m_desc["ctrl_mouse_wheel_caption"] = _L("Ctrl+Mouse wheel"); + m_desc["ctrl_mouse_wheel"] = _L("Adjust head diameter"); m_desc["alt_mouse_wheel_caption"] = _L("Alt + Mouse wheel"); m_desc["alt_mouse_wheel"] = _L("Adjust section view"); @@ -334,6 +336,10 @@ bool GLGizmoBrimEars::on_mouse(const wxMouseEvent& mouse_event) // concludes that the event was not intended for it, it should return false. bool GLGizmoBrimEars::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_position, bool shift_down, bool alt_down, bool control_down) { + if (action != SLAGizmoEventType::MouseWheelDown || action != SLAGizmoEventType::MouseWheelUp || action != SLAGizmoEventType::Moving) { + apply_radius_change(); + } + ModelObject *mo = m_c->selection_info()->model_object(); int active_inst = m_c->selection_info()->get_active_instance(); @@ -479,6 +485,30 @@ bool GLGizmoBrimEars::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_p } // mouse wheel up + if (action == SLAGizmoEventType::MouseWheelUp) { + if (control_down) { + float initial_value = m_new_point_head_diameter; + begin_radius_change(initial_value); + m_new_point_head_diameter = std::min(20., initial_value + 0.1); + update_cache_radius(); + return true; + } + + apply_radius_change(); + } + + if (action == SLAGizmoEventType::MouseWheelDown) { + if (control_down) { + float initial_value = m_new_point_head_diameter; + begin_radius_change(initial_value); + m_new_point_head_diameter = std::max(5., initial_value - 0.1); + update_cache_radius(); + return true; + } + + apply_radius_change(); + } + if (action == SLAGizmoEventType::MouseWheelUp && alt_down) { double pos = m_c->object_clipper()->get_position(); pos = std::min(1., pos + 0.01); @@ -552,6 +582,38 @@ std::vector GLGizmoBrimEars::get_config_options(const std: return out; } +void GLGizmoBrimEars::begin_radius_change(float initial_value) +{ + if (m_old_point_head_diameter == 0.f) + m_old_point_head_diameter = initial_value; +} + +void GLGizmoBrimEars::update_cache_radius() +{ + for (auto &cache_entry : m_editing_cache) + if (cache_entry.selected) { + cache_entry.brim_point.head_front_radius = m_new_point_head_diameter / 2.f; + find_single(); + } + m_parent.set_as_dirty(); +} + +void GLGizmoBrimEars::apply_radius_change() +{ + if (m_old_point_head_diameter == 0.f) return; + + // momentarily restore the old value to take snapshot + for (auto& cache_entry : m_editing_cache) + if (cache_entry.selected) + cache_entry.brim_point.head_front_radius = m_old_point_head_diameter / 2.f; + float backup = m_new_point_head_diameter; + m_new_point_head_diameter = m_old_point_head_diameter; + Plater::TakeSnapshot snapshot(wxGetApp().plater(), "Change point head diameter"); + m_new_point_head_diameter = backup; + update_cache_radius(); + m_old_point_head_diameter = 0.f; +} + void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limit) { static float last_y = 0.0f; @@ -605,29 +667,14 @@ void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limi m_imgui->text(m_desc["head_diameter"]); ImGui::SameLine(caption_size); ImGui::PushItemWidth(slider_width); - auto update_cache_radius = [this]() { - for (auto &cache_entry : m_editing_cache) - if (cache_entry.selected) { - cache_entry.brim_point.head_front_radius = m_new_point_head_diameter / 2.f; - find_single(); - } - }; m_imgui->bbl_slider_float_style("##head_diameter", &m_new_point_head_diameter, 5, 20, "%.1f", 1.0f, true); if (m_imgui->get_last_slider_status().clicked) { - if (m_old_point_head_diameter == 0.f) m_old_point_head_diameter = initial_value; + begin_radius_change(initial_value); } if (m_imgui->get_last_slider_status().edited) update_cache_radius(); if (m_imgui->get_last_slider_status().deactivated_after_edit) { - // momentarily restore the old value to take snapshot - for (auto &cache_entry : m_editing_cache) - if (cache_entry.selected) cache_entry.brim_point.head_front_radius = m_old_point_head_diameter / 2.f; - float backup = m_new_point_head_diameter; - m_new_point_head_diameter = m_old_point_head_diameter; - Plater::TakeSnapshot snapshot(wxGetApp().plater(), "Change point head diameter"); - m_new_point_head_diameter = backup; - update_cache_radius(); - m_old_point_head_diameter = 0.f; + apply_radius_change(); } ImGui::SameLine(drag_left_width); ImGui::PushItemWidth(1.5 * slider_icon_width); @@ -737,7 +784,7 @@ void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limi void GLGizmoBrimEars::show_tooltip_information(float x, float y) { - std::array info_array = std::array{"left_click", "right_click", "alt_mouse_wheel"}; + std::array info_array = std::array{"left_click", "right_click", "ctrl_mouse_wheel", "alt_mouse_wheel"}; float caption_max = 0.f; for (const auto &t : info_array) { caption_max = std::max(caption_max, m_imgui->calc_text_size(m_desc[t + "_caption"]).x); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp index e316861dbd..d9d30b20fa 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.hpp @@ -144,6 +144,10 @@ private: void get_detection_radius_max(); void update_raycasters(); + void begin_radius_change(float initial_value); + void update_cache_radius(); + void apply_radius_change(); + protected: void on_set_state() override; void on_set_hover_id() override diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 91918fa147..0618919bec 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -849,13 +849,15 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt) if (gizmo_event(SLAGizmoEventType::AltUp) || (is_editing && is_rectangle_dragging)) processed = true; } - - // BBS - if (m_current == MmuSegmentation && keyCode > '0' && keyCode <= '9') { - // capture number key - processed = true; + else if (keyCode == WXK_CONTROL) { + gizmo_event(SLAGizmoEventType::CtrlUp); } } + // BBS + if (m_current == MmuSegmentation && keyCode > '0' && keyCode <= '9') { + // capture number key + processed = true; + } if (m_current == Measure || m_current == Assembly) { if (keyCode == WXK_CONTROL) gizmo_event(SLAGizmoEventType::CtrlUp, Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.CmdDown()); From 19e5ee3f42cf547a45e8d41c39ab753a20ea7c21 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 1 Apr 2025 15:51:01 +0800 Subject: [PATCH 3/3] Update current brim brush size --- src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp index 2cd14f144d..3fa9cc2c40 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp @@ -590,6 +590,9 @@ void GLGizmoBrimEars::begin_radius_change(float initial_value) void GLGizmoBrimEars::update_cache_radius() { + if (render_hover_point) + render_hover_point->brim_point.head_front_radius = m_new_point_head_diameter / 2.f; + for (auto &cache_entry : m_editing_cache) if (cache_entry.selected) { cache_entry.brim_point.head_front_radius = m_new_point_head_diameter / 2.f;