diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp index d277fc095..12302a5dc 100644 --- a/src/slic3r/GUI/AppConfig.cpp +++ b/src/slic3r/GUI/AppConfig.cpp @@ -87,6 +87,11 @@ void AppConfig::set_defaults() if (get("use_perspective_camera").empty()) set("use_perspective_camera", "1"); +#if ENABLE_6DOF_CAMERA + if (get("use_free_camera").empty()) + set("use_free_camera", "0"); +#endif // ENABLE_6DOF_CAMERA + // Remove legacy window positions/sizes erase("", "main_frame_maximized"); erase("", "main_frame_pos"); diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp index b22d27326..49246dbb9 100644 --- a/src/slic3r/GUI/Camera.cpp +++ b/src/slic3r/GUI/Camera.cpp @@ -6,6 +6,11 @@ #endif // !ENABLE_THUMBNAIL_GENERATOR #include "GUI_App.hpp" #include "AppConfig.hpp" +#if ENABLE_CAMERA_STATISTICS +#if ENABLE_6DOF_CAMERA +#include "Mouse3DController.hpp" +#endif // ENABLE_6DOF_CAMERA +#endif // ENABLE_CAMERA_STATISTICS #include <GL/glew.h> @@ -373,6 +378,12 @@ void Camera::debug_render() const imgui.begin(std::string("Camera statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); std::string type = get_type_as_string(); +#if ENABLE_6DOF_CAMERA + if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1")) + type += "/free"; + else + type += "/constrained"; +#endif // ENABLE_6DOF_CAMERA Vec3f position = get_position().cast<float>(); Vec3f target = m_target.cast<float>(); float distance = (float)get_distance(); @@ -420,7 +431,7 @@ void Camera::translate_world(const Vec3d& displacement) } } -void Camera::rotate_on_sphere(double delta_azimut_rad, double delta_zenit_rad, bool apply_limit) +void Camera::rotate_on_sphere(double delta_azimut_rad, double delta_zenit_rad) { Vec3d target = m_target; translate_world(-target); diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp index cfb0fd797..67c97c0b4 100644 --- a/src/slic3r/GUI/Camera.hpp +++ b/src/slic3r/GUI/Camera.hpp @@ -130,7 +130,7 @@ public: // rotate the camera on a sphere having center == m_target and radius == m_distance // using the given variations of spherical coordinates - void rotate_on_sphere(double delta_azimut_rad, double delta_zenit_rad, bool apply_limit); + void rotate_on_sphere(double delta_azimut_rad, double delta_zenit_rad); // rotate the camera around three axes parallel to the camera local axes and passing through m_target void rotate_local_around_target(const Vec3d& rotation_rad); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 860eab0fb..1c383841e 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3290,9 +3290,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) { const Vec3d& orig = m_mouse.drag.start_position_3D; #if ENABLE_6DOF_CAMERA - m_camera.rotate_on_sphere(Geometry::deg2rad((pos(0) - orig(0))* (double)TRACKBALLSIZE), - Geometry::deg2rad((pos(1) - orig(1))* (double)TRACKBALLSIZE), - wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA); + double x = Geometry::deg2rad(pos(0) - orig(0)) * (double)TRACKBALLSIZE; + double y = Geometry::deg2rad(pos(1) - orig(1)) * (double)TRACKBALLSIZE; + if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1")) + m_camera.rotate_local_around_target(Vec3d(y, x, 0.0)); + else + m_camera.rotate_on_sphere(x, y); #else float sign = m_camera.inverted_phi ? -1.0f : 1.0f; m_camera.phi += sign * ((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE; diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 295c1a6ec..d0686677d 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -124,6 +124,15 @@ void PreferencesDialog::build() option = Option(def, "use_perspective_camera"); m_optgroup->append_single_option_line(option); +#if ENABLE_6DOF_CAMERA + def.label = L("Use free camera"); + def.type = coBool; + def.tooltip = L("If enabled, use free camera. If not enabled, use constrained camera."); + def.set_default_value(new ConfigOptionBool(app_config->get("use_free_camera") == "1")); + option = Option(def, "use_free_camera"); + m_optgroup->append_single_option_line(option); +#endif // ENABLE_6DOF_CAMERA + def.label = L("Use custom size for toolbar icons"); def.type = coBool; def.tooltip = L("If enabled, you can change size of toolbar icons manually.");