From 933b282c539f329638bd29af15052c95f1f975fa Mon Sep 17 00:00:00 2001 From: Graham Held Date: Sun, 30 Mar 2025 01:16:08 -0700 Subject: [PATCH] Add in a pref for camera orbit speed multiplier (#8725) Co-authored-by: Noisyfox --- src/libslic3r/AppConfig.cpp | 3 ++ src/slic3r/GUI/GLCanvas3D.cpp | 4 ++- src/slic3r/GUI/Preferences.cpp | 55 ++++++++++++++++++++++++++++++++++ src/slic3r/GUI/Preferences.hpp | 1 + 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 5e359eb774..9a09335e97 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -181,6 +181,9 @@ void AppConfig::set_defaults() if (get("reverse_mouse_wheel_zoom").empty()) set_bool("reverse_mouse_wheel_zoom", false); + if (get("camera_orbit_mult").empty()) + set("camera_orbit_mult", "1.0"); + if (get("zoom_to_mouse").empty()) set_bool("zoom_to_mouse", false); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 6945f3b19b..974b2f7f92 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4299,7 +4299,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // if dragging over blank area with left button, rotate if ((any_gizmo_active || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) { Camera& camera = wxGetApp().plater()->get_camera(); - const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.); + auto mult_pref = wxGetApp().app_config->get("camera_orbit_mult"); + const double mult = mult_pref.empty() ? 1.0 : std::stod(mult_pref); + const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.) * mult; if (this->m_canvas_type == ECanvasType::CanvasAssembleView || m_gizmos.get_current_type() == GLGizmosManager::FdmSupports || m_gizmos.get_current_type() == GLGizmosManager::Seam || m_gizmos.get_current_type() == GLGizmosManager::MmuSegmentation) { Vec3d rotate_target = Vec3d::Zero(); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 8bc00295bf..3851495b2b 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -512,6 +512,59 @@ wxBoxSizer *PreferencesDialog::create_item_input(wxString title, wxString title2 return sizer_input; } +wxBoxSizer *PreferencesDialog::create_camera_orbit_mult_input(wxString title, wxWindow *parent, wxString tooltip) +{ + wxBoxSizer *sizer_input = new wxBoxSizer(wxHORIZONTAL); + auto input_title = new wxStaticText(parent, wxID_ANY, title); + input_title->SetForegroundColour(DESIGN_GRAY900_COLOR); + input_title->SetFont(::Label::Body_13); + input_title->SetToolTip(tooltip); + input_title->Wrap(-1); + auto param = "camera_orbit_mult"; + + auto input = new ::TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, DESIGN_INPUT_SIZE, wxTE_PROCESS_ENTER); + StateColor input_bg(std::pair(wxColour("#F0F0F1"), StateColor::Disabled), std::pair(*wxWHITE, StateColor::Enabled)); + input->SetBackgroundColor(input_bg); + input->GetTextCtrl()->SetValue(app_config->get(param)); + wxTextValidator validator(wxFILTER_NUMERIC); + input->GetTextCtrl()->SetValidator(validator); + + sizer_input->Add(0, 0, 0, wxEXPAND | wxLEFT, 23); + sizer_input->Add(input_title, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3); + sizer_input->Add(input, 0, wxALIGN_CENTER_VERTICAL, 0); + sizer_input->Add(0, 0, 0, wxEXPAND | wxLEFT, 3); + + const double min = 0.05; + const double max = 2.0; + + input->GetTextCtrl()->Bind(wxEVT_TEXT_ENTER, [this, param, input, min, max](wxCommandEvent &e) { + auto value = input->GetTextCtrl()->GetValue(); + double conv = 1.0; + if (value.ToCDouble(&conv)) { + conv = conv < min ? min : conv > max ? max : conv; + auto strval = std::string(wxString::FromCDouble(conv, 2).mb_str()); + input->GetTextCtrl()->SetValue(strval); + app_config->set(param, strval); + app_config->save(); + } + e.Skip(); + }); + + input->GetTextCtrl()->Bind(wxEVT_KILL_FOCUS, [this, param, input, min, max](wxFocusEvent &e) { + auto value = input->GetTextCtrl()->GetValue(); + double conv = 1.0; + if (value.ToCDouble(&conv)) { + conv = conv < min ? min : conv > max ? max : conv; + auto strval = std::string(wxString::FromCDouble(conv, 2).mb_str()); + input->GetTextCtrl()->SetValue(strval); + app_config->set(param, strval); + } + e.Skip(); + }); + + return sizer_input; +} + wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow *parent, wxString tooltip, std::string param) { wxBoxSizer *m_sizer_input = new wxBoxSizer(wxHORIZONTAL); @@ -1164,6 +1217,7 @@ wxWindow* PreferencesDialog::create_general_page() auto item_mouse_zoom_settings = create_item_checkbox(_L("Zoom to mouse position"), page, _L("Zoom in towards the mouse pointer's position in the 3D view, rather than the 2D window center."), 50, "zoom_to_mouse"); auto item_use_free_camera_settings = create_item_checkbox(_L("Use free camera"), page, _L("If enabled, use free camera. If not enabled, use constrained camera."), 50, "use_free_camera"); auto reverse_mouse_zoom = create_item_checkbox(_L("Reverse mouse zoom"), page, _L("If enabled, reverses the direction of zoom with mouse wheel."), 50, "reverse_mouse_wheel_zoom"); + auto camera_orbit_mult = create_camera_orbit_mult_input(_L("Orbit speed multiplier"), page, _L("Multiplies the orbit speed for finer or coarser camera movement.")); auto item_show_splash_screen = create_item_checkbox(_L("Show splash screen"), page, _L("Show the splash screen during startup."), 50, "show_splash_screen"); auto item_hints = create_item_checkbox(_L("Show \"Tip of the day\" notification after start"), page, _L("If enabled, useful hints are displayed at startup."), 50, "show_hints"); @@ -1246,6 +1300,7 @@ wxWindow* PreferencesDialog::create_general_page() sizer_page->Add(item_mouse_zoom_settings, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_use_free_camera_settings, 0, wxTOP, FromDIP(3)); sizer_page->Add(reverse_mouse_zoom, 0, wxTOP, FromDIP(3)); + sizer_page->Add(camera_orbit_mult, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_show_splash_screen, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_calc_in_long_retract, 0, wxTOP, FromDIP(3)); diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp index c0df651cb4..5977397e16 100644 --- a/src/slic3r/GUI/Preferences.hpp +++ b/src/slic3r/GUI/Preferences.hpp @@ -115,6 +115,7 @@ public: wxBoxSizer *create_item_button(wxString title, wxString title2, wxWindow *parent, wxString tooltip, wxString tooltip2, std::function onclick, bool button_on_left = false); wxWindow* create_item_downloads(wxWindow* parent, int padding_left, std::string param); wxBoxSizer *create_item_input(wxString title, wxString title2, wxWindow *parent, wxString tooltip, std::string param, std::function onchange = {}); + wxBoxSizer *create_camera_orbit_mult_input(wxString title, wxWindow *parent, wxString tooltip); wxBoxSizer *create_item_backup_input(wxString title, wxWindow *parent, wxString tooltip, std::string param); wxBoxSizer *create_item_multiple_combobox( wxString title, wxWindow *parent, wxString tooltip, int padding_left, std::string parama, std::vector vlista, std::vector vlistb);