diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp index 8fb6188ba..c540f03d8 100644 --- a/src/slic3r/GUI/Camera.cpp +++ b/src/slic3r/GUI/Camera.cpp @@ -333,6 +333,18 @@ void Camera::rotate_local_with_target(const Vec3d& rotation_rad, Vec3d target) } } +void Camera::calc_horizontal_rotate_rad(float &rotation_rad) { + if (is_looking_front()) { + auto right = get_dir_right(); + auto temp_rotation_rad = acos(right.dot(Vec3d(1, 0, 0))); + auto value = Vec3d(1, 0, 0).cross(right); + if (value.z() > 0.01) { + temp_rotation_rad = -temp_rotation_rad; + } + rotation_rad = temp_rotation_rad; + } +} + // Virtual trackball, rotate around an axis, where the eucledian norm of the axis gives the rotation angle in radians. void Camera::rotate_local_around_target(const Vec3d& rotation_rad) { diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp index 6eb44a927..64cecad42 100644 --- a/src/slic3r/GUI/Camera.hpp +++ b/src/slic3r/GUI/Camera.hpp @@ -128,7 +128,7 @@ public: // BBS rotate the camera on a sphere having center == target void rotate_on_sphere_with_target(double delta_azimut_rad, double delta_zenit_rad, bool apply_limits, Vec3d target); void rotate_local_with_target(const Vec3d& rotation_rad, Vec3d target); - + void calc_horizontal_rotate_rad(float &rotation_rad); // rotate the camera on a sphere having center == m_target and radius == m_distance // using the given variations of spherical coordinates // if apply_limits == true the camera stops rotating when its forward vector is parallel to the world Z axis diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index d289d8d2f..79d90606f 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3569,16 +3569,32 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) { select_view("bottom"); break; } case '3': case WXK_NUMPAD3: //3 on numpad - { select_view("front"); break; } + { + select_view("front"); + m_gizmos.update_paint_base_camera_rotate_rad(); + break; + } case '4': case WXK_NUMPAD4: //4 on numpad - { select_view("rear"); break; } + { + select_view("rear"); + m_gizmos.update_paint_base_camera_rotate_rad(); + break; + } case '5': case WXK_NUMPAD5: //5 on numpad - { select_view("left"); break; } + { + select_view("left"); + m_gizmos.update_paint_base_camera_rotate_rad(); + break; + } case '6': case WXK_NUMPAD6: //6 on numpad - { select_view("right"); break; } + { + select_view("right"); + m_gizmos.update_paint_base_camera_rotate_rad(); + break; + } case '7': case WXK_NUMPAD7: //7 on numpad { select_plate(); break; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index 549538a0c..ffc70d464 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -764,6 +764,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott if (m_vertical_only) { m_horizontal_only = false; m_is_front_view = true; + update_front_view_radian(); change_camera_view_angle(m_front_view_radian); } } @@ -776,6 +777,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott if (m_horizontal_only) { m_vertical_only = false; m_is_front_view = true; + update_front_view_radian(); change_camera_view_angle(m_front_view_radian); } } @@ -785,12 +787,13 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott if (m_is_front_view != is_front_view) { m_is_front_view = is_front_view; if (m_is_front_view) { + update_front_view_radian(); change_camera_view_angle(m_front_view_radian); } } m_imgui->disabled_begin(!m_is_front_view); - if (render_slider_double_input_by_format(slider_input_layout, _u8L("Rotate horizontally"), m_front_view_radian, 0.f, 360.f, 0, DoubleShowType::DEGREE)) { + if (render_slider_double_input_by_format(slider_input_layout, _u8L("Rotate horizontally"), m_front_view_radian, -180.f, 180.f, 0, DoubleShowType::DEGREE)) { change_camera_view_angle(m_front_view_radian); } m_imgui->disabled_end(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 1ad2f7749..a47d1a166 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -70,6 +70,11 @@ GLGizmoPainterBase::ClippingPlaneDataWrapper GLGizmoPainterBase::get_clipping_pl return clp_data_out; } +void GLGizmoPainterBase::update_front_view_radian() +{ + wxGetApp().plater()->get_camera().calc_horizontal_rotate_rad(m_front_view_radian); +} + void GLGizmoPainterBase::render_triangles(const Selection& selection) const { auto* shader = wxGetApp().get_shader("gouraud"); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp index 5c4a3491d..60943407f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp @@ -235,6 +235,7 @@ public: virtual const float get_cursor_height_min() const { return CursorHeightMin; } virtual const float get_cursor_height_max() const { return CursorHeightMax; } virtual const float get_cursor_height_step() const { return CursorHeightStep; } + void update_front_view_radian(); protected: virtual void render_triangles(const Selection& selection) const; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp index 71b702224..687fafa33 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp @@ -332,19 +332,21 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit) m_vertical_only = vertical_only; if (m_vertical_only) { m_is_front_view = true; + update_front_view_radian(); change_camera_view_angle(m_front_view_radian); } } auto is_front_view = m_is_front_view; m_imgui->bbl_checkbox(_L("View: keep horizontal"), is_front_view); - if (m_is_front_view != is_front_view) { + if (m_is_front_view != is_front_view){ m_is_front_view = is_front_view; - if (m_is_front_view) { + if (m_is_front_view) { + update_front_view_radian(); change_camera_view_angle(m_front_view_radian); } } m_imgui->disabled_begin(!m_is_front_view); - if (render_slider_double_input_by_format(slider_input_layout, _u8L("Rotate horizontally"), m_front_view_radian, 0.f, 360.f, 0, DoubleShowType::DEGREE)) { + if (render_slider_double_input_by_format(slider_input_layout, _u8L("Rotate horizontally"), m_front_view_radian, -180.f, 180.f, 0, DoubleShowType::DEGREE)) { change_camera_view_angle(m_front_view_radian); } m_imgui->disabled_end(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index d76ad1f53..5e5569bc0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -607,6 +607,14 @@ void GLGizmosManager::finish_cut_rotation() dynamic_cast(m_gizmos[Cut].get())->finish_rotation(); } +void GLGizmosManager::update_paint_base_camera_rotate_rad() +{ + if (m_current == MmuSegmentation || m_current == Seam) { + auto paint_gizmo = dynamic_cast(m_gizmos[m_current].get()); + paint_gizmo->update_front_view_radian(); + } +} + Vec3d GLGizmosManager::get_flattening_normal() const { if (!m_enabled || m_gizmos.empty()) @@ -1370,7 +1378,7 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt) // BBS else if (m_current == MmuSegmentation) { GLGizmoMmuSegmentation* mmu_seg = dynamic_cast(get_current()); - if (mmu_seg != nullptr) { + if (mmu_seg != nullptr && evt.ControlDown() == false) { if (keyCode >= WXK_NUMPAD0 && keyCode <= WXK_NUMPAD9) { keyCode = keyCode- WXK_NUMPAD0+'0'; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index 10d9070b8..7ffc2ca72 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -275,7 +275,7 @@ public: else return nullptr; } - + void update_paint_base_camera_rotate_rad(); Vec3d get_flattening_normal() const; void set_flattening_data(const ModelObject* model_object);