Code refactoring to avoid a call of update_ui_from_settings() every time when switching between "3D-View" and "Preview"

This commit is contained in:
YuSanka 2021-06-11 10:32:54 +02:00
parent 69b9beaec0
commit 87a996d0d5
6 changed files with 20 additions and 14 deletions

View file

@ -1586,7 +1586,8 @@ struct Plater::priv
void reset_gcode_toolpaths();
void reset_all_gizmos();
void update_ui_from_settings(bool apply_free_camera_correction = true);
void apply_free_camera_correction(bool apply = true);
void update_ui_from_settings();
void update_main_toolbar_tooltips();
std::shared_ptr<ProgressStatusBar> statusbar();
std::string get_config(const std::string &key) const;
@ -2064,6 +2065,13 @@ void Plater::priv::select_view(const std::string& direction)
preview->select_view(direction);
}
void Plater::priv::apply_free_camera_correction(bool apply/* = true*/)
{
camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
if (apply && wxGetApp().app_config->get("use_free_camera") != "1")
camera.recover_from_free_camera();
}
void Plater::priv::select_view_3D(const std::string& name)
{
if (name == "3D")
@ -2071,7 +2079,7 @@ void Plater::priv::select_view_3D(const std::string& name)
else if (name == "Preview")
set_current_panel(preview);
wxGetApp().update_ui_from_settings(false);
apply_free_camera_correction(false);
}
void Plater::priv::select_next_view_3D()
@ -2103,11 +2111,9 @@ void Plater::priv::reset_all_gizmos()
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
void Plater::priv::update_ui_from_settings(bool apply_free_camera_correction)
void Plater::priv::update_ui_from_settings()
{
camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
if (apply_free_camera_correction && wxGetApp().app_config->get("use_free_camera") != "1")
camera.recover_from_free_camera();
apply_free_camera_correction();
view3D->get_canvas3d()->update_ui_from_settings();
preview->get_canvas3d()->update_ui_from_settings();
@ -4942,7 +4948,7 @@ void Plater::update() { p->update(); }
void Plater::stop_jobs() { p->m_ui_jobs.stop_all(); }
void Plater::update_ui_from_settings(bool apply_free_camera_correction) { p->update_ui_from_settings(apply_free_camera_correction); }
void Plater::update_ui_from_settings() { p->update_ui_from_settings(); }
void Plater::select_view(const std::string& direction) { p->select_view(direction); }