diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp index 2113de4996..df7a668745 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp @@ -58,7 +58,9 @@ bool GLGizmoBrimEars::on_init() 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["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"); return true; } @@ -330,6 +332,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(); @@ -474,14 +480,38 @@ bool GLGizmoBrimEars::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_p } // mouse wheel up - if (action == SLAGizmoEventType::MouseWheelUp && control_down) { + 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); 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); @@ -547,6 +577,41 @@ 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() +{ + 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; + 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; @@ -600,29 +665,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); @@ -732,7 +782,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", "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 aed331eaa5..d9fd5cc141 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 0a45b86d4d..ab22e338a1 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -882,13 +882,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());