QoL: Add auto perspective (#8312)

* ImGuizmo: Comment out unused code

* 3DNav: Avoid gimbal lock by using polar coordinates

* 3DNav: Make sure top and bottom are oriented correctly

* Add auto perspective

* Add options

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Noisyfox 2025-03-09 14:04:46 +08:00 committed by GitHub
parent 1558edf827
commit 345ab82f91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 173 additions and 87 deletions

View file

@ -2676,10 +2676,19 @@ void MainFrame::init_menubar_as_editor()
wxGetApp().app_config->set_bool("use_perspective_camera", false);
wxGetApp().update_ui_from_settings();
}, nullptr);
if (wxGetApp().app_config->get("use_perspective_camera").compare("true") == 0)
viewMenu->Check(wxID_CAMERA_PERSPECTIVE + camera_id_base, true);
else
viewMenu->Check(wxID_CAMERA_ORTHOGONAL + camera_id_base, true);
this->Bind(wxEVT_UPDATE_UI, [viewMenu, camera_id_base](wxUpdateUIEvent& evt) {
if (wxGetApp().app_config->get("use_perspective_camera").compare("true") == 0)
viewMenu->Check(wxID_CAMERA_PERSPECTIVE + camera_id_base, true);
else
viewMenu->Check(wxID_CAMERA_ORTHOGONAL + camera_id_base, true);
}, wxID_ANY);
append_menu_check_item(viewMenu, wxID_ANY, _L("Auto Perspective"), _L("Automatically switch between orthographic and perspective when changing from top/bottom/side views"),
[this](wxCommandEvent&) {
wxGetApp().app_config->set_bool("auto_perspective", !wxGetApp().app_config->get_bool("auto_perspective"));
m_plater->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT));
},
this, [this]() { return m_tabpanel->GetSelection() == TabPosition::tp3DEditor || m_tabpanel->GetSelection() == TabPosition::tpPreview; },
[this]() { return wxGetApp().app_config->get_bool("auto_perspective"); }, this);
viewMenu->AppendSeparator();
append_menu_check_item(viewMenu, wxID_ANY, _L("Show &G-code Window") + "\tC", _L("Show g-code window in Preview scene"),