From 447a51a3c8355e8a7e3e7069dbdd3f3bc3f0606c Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 2 Jan 2019 08:55:56 +0100 Subject: [PATCH] Constrained camera target set as default --- src/libslic3r/Technologies.hpp | 2 -- src/slic3r/GUI/GLCanvas3D.cpp | 46 ---------------------------------- src/slic3r/GUI/GLCanvas3D.hpp | 15 ----------- 3 files changed, 63 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index aa1e49e83..16c610517 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -34,8 +34,6 @@ #define ENABLE_SLA_SUPPORT_GIZMO_MOD (1 && ENABLE_1_42_0) // Removes the wxNotebook from plater #define ENABLE_REMOVE_TABS_FROM_PLATER (1 && ENABLE_1_42_0) -// Constrains the camera target into the scene bounding box -#define ENABLE_CONSTRAINED_CAMERA_TARGET (1 && ENABLE_1_42_0) // Use wxDataViewRender instead of wxDataViewCustomRenderer #define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0) // Adds background texture to toolbars diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 4069ec6a0..0529eeb72 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -280,13 +280,8 @@ GLCanvas3D::Camera::Camera() , zoom(1.0f) , phi(45.0f) // , distance(0.0f) -#if !ENABLE_CONSTRAINED_CAMERA_TARGET - , target(0.0, 0.0, 0.0) -#endif // !ENABLE_CONSTRAINED_CAMERA_TARGET , m_theta(45.0f) -#if ENABLE_CONSTRAINED_CAMERA_TARGET , m_target(Vec3d::Zero()) -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET { } @@ -309,7 +304,6 @@ void GLCanvas3D::Camera::set_theta(float theta) m_theta = clamp(0.0f, GIMBALL_LOCK_THETA_MAX, theta); } -#if ENABLE_CONSTRAINED_CAMERA_TARGET void GLCanvas3D::Camera::set_target(const Vec3d& target, GLCanvas3D& canvas) { m_target = target; @@ -328,7 +322,6 @@ void GLCanvas3D::Camera::set_scene_box(const BoundingBoxf3& box, GLCanvas3D& can canvas.viewport_changed(); } } -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET GLCanvas3D::Bed::Bed() : m_type(Custom) @@ -4083,14 +4076,12 @@ BoundingBoxf3 GLCanvas3D::volumes_bounding_box() const return bb; } -#if ENABLE_CONSTRAINED_CAMERA_TARGET BoundingBoxf3 GLCanvas3D::scene_bounding_box() const { BoundingBoxf3 bb = volumes_bounding_box(); bb.merge(m_bed.get_bounding_box()); return bb; } -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET bool GLCanvas3D::is_layers_editing_enabled() const { @@ -4226,12 +4217,8 @@ void GLCanvas3D::set_viewport_from_scene(const GLCanvas3D& other) { m_camera.phi = other.m_camera.phi; m_camera.set_theta(other.m_camera.get_theta()); -#if ENABLE_CONSTRAINED_CAMERA_TARGET m_camera.set_scene_box(other.m_camera.get_scene_box(), *this); m_camera.set_target(other.m_camera.get_target(), *this); -#else - m_camera.target = other.m_camera.target; -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET m_camera.zoom = other.m_camera.zoom; m_dirty = true; } @@ -4783,10 +4770,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re // restore to default value m_regenerate_volumes = true; -#if ENABLE_CONSTRAINED_CAMERA_TARGET m_camera.set_scene_box(scene_bounding_box(), *this); m_camera.set_target(m_camera.get_target(), *this); -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET // and force this canvas to be redrawn. m_dirty = true; @@ -5343,11 +5328,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) float z = 0.0f; const Vec3d& cur_pos = _mouse_to_3d(pos, &z); Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z); -#if ENABLE_CONSTRAINED_CAMERA_TARGET m_camera.set_target(m_camera.get_target() + orig - cur_pos, *this); -#else - m_camera.target += orig - cur_pos; -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET viewport_changed(); @@ -5433,10 +5414,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // Let the platter know that the dragging finished, so a delayed refresh // of the scene with the background processing data should be performed. post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED)); -#if ENABLE_CONSTRAINED_CAMERA_TARGET m_camera.set_scene_box(scene_bounding_box(), *this); set_camera_zoom(0.0f); -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET } m_moving = false; @@ -6075,11 +6054,7 @@ void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox) { m_camera.zoom = zoom; // center view around bounding box center -#if ENABLE_CONSTRAINED_CAMERA_TARGET m_camera.set_target(bbox.center(), *this); -#else - m_camera.target = bbox.center(); -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET viewport_changed(); @@ -6201,12 +6176,8 @@ void GLCanvas3D::_camera_tranform() const ::glRotatef(-m_camera.get_theta(), 1.0f, 0.0f, 0.0f); // pitch ::glRotatef(m_camera.phi, 0.0f, 0.0f, 1.0f); // yaw -#if ENABLE_CONSTRAINED_CAMERA_TARGET Vec3d target = -m_camera.get_target(); ::glTranslated(target(0), target(1), target(2)); -#else - ::glTranslated(-m_camera.target(0), -m_camera.target(1), -m_camera.target(2)); -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET } void GLCanvas3D::_picking_pass() const @@ -6555,7 +6526,6 @@ void GLCanvas3D::_render_camera_target() const ::glLineWidth(2.0f); ::glBegin(GL_LINES); -#if ENABLE_CONSTRAINED_CAMERA_TARGET const Vec3d& target = m_camera.get_target(); // draw line for x axis ::glColor3f(1.0f, 0.0f, 0.0f); @@ -6569,22 +6539,6 @@ void GLCanvas3D::_render_camera_target() const ::glColor3f(0.0f, 0.0f, 1.0f); ::glVertex3d(target(0), target(1), target(2) - half_length); ::glVertex3d(target(0), target(1), target(2) + half_length); -#else - // draw line for x axis - ::glColor3f(1.0f, 0.0f, 0.0f); - ::glVertex3d(m_camera.target(0) - half_length, m_camera.target(1), m_camera.target(2)); - ::glVertex3d(m_camera.target(0) + half_length, m_camera.target(1), m_camera.target(2)); - // draw line for y axis - ::glColor3f(0.0f, 1.0f, 0.0f); - ::glVertex3d(m_camera.target(0), m_camera.target(1) - half_length, m_camera.target(2)); - ::glVertex3d(m_camera.target(0), m_camera.target(1) + half_length, m_camera.target(2)); - ::glEnd(); - - ::glBegin(GL_LINES); - ::glColor3f(0.0f, 0.0f, 1.0f); - ::glVertex3d(m_camera.target(0), m_camera.target(1), m_camera.target(2) - half_length); - ::glVertex3d(m_camera.target(0), m_camera.target(1), m_camera.target(2) + half_length); -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET ::glEnd(); } #endif // ENABLE_SHOW_CAMERA_TARGET diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 4666fcd05..63296dac3 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -157,15 +157,10 @@ class GLCanvas3D float zoom; float phi; // float distance; -#if !ENABLE_CONSTRAINED_CAMERA_TARGET - Vec3d target; -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET private: -#if ENABLE_CONSTRAINED_CAMERA_TARGET Vec3d m_target; BoundingBoxf3 m_scene_box; -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET float m_theta; public: @@ -176,13 +171,11 @@ class GLCanvas3D float get_theta() const { return m_theta; } void set_theta(float theta); -#if ENABLE_CONSTRAINED_CAMERA_TARGET const Vec3d& get_target() const { return m_target; } void set_target(const Vec3d& target, GLCanvas3D& canvas); const BoundingBoxf3& get_scene_box() const { return m_scene_box; } void set_scene_box(const BoundingBoxf3& box, GLCanvas3D& canvas); -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET }; class Bed @@ -865,10 +858,6 @@ private: wxWindow *m_external_gizmo_widgets_parent; #endif // not ENABLE_IMGUI -#if !ENABLE_CONSTRAINED_CAMERA_TARGET - void viewport_changed(); -#endif // !ENABLE_CONSTRAINED_CAMERA_TARGET - public: GLCanvas3D(wxGLCanvas* canvas); ~GLCanvas3D(); @@ -933,9 +922,7 @@ public: float get_camera_zoom() const; BoundingBoxf3 volumes_bounding_box() const; -#if ENABLE_CONSTRAINED_CAMERA_TARGET BoundingBoxf3 scene_bounding_box() const; -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET bool is_layers_editing_enabled() const; bool is_layers_editing_allowed() const; @@ -1026,9 +1013,7 @@ public: void update_gizmos_on_off_state(); -#if ENABLE_CONSTRAINED_CAMERA_TARGET void viewport_changed(); -#endif // ENABLE_CONSTRAINED_CAMERA_TARGET void handle_sidebar_focus_event(const std::string& opt_key, bool focus_on);