From 19759b4315c73bcf6ad28290d205161f0db97b61 Mon Sep 17 00:00:00 2001 From: Lukas Matena <lukasmatena@seznam.cz> Date: Wed, 17 Apr 2019 09:39:51 +0200 Subject: [PATCH 1/6] SLA gizmo clipping - changed color on the cuts of supports, turned their rendering in editing mode (when the supports are not shown) --- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 2285e2520..1338bbc4d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -198,8 +198,6 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const } // At this point we have the triangulated cuts for both the object and supports - let's render. - ::glColor3f(1.0f, 0.37f, 0.0f); - if (! m_triangles.empty()) { ::glPushMatrix(); ::glTranslated(0.0, 0.0, m_z_shift); @@ -208,7 +206,8 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const q.setFromTwoVectors(Vec3f::UnitZ(), up); Eigen::AngleAxisf aa(q); ::glRotatef(aa.angle() * (180./M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2)); - ::glTranslatef(0.f, 0.f, -0.001f); // to make sure the cut is safely beyond the near clipping plane + ::glTranslatef(0.f, 0.f, 0.1f); // to make sure the cut does not intersect the structure itself + ::glColor3f(1.0f, 0.37f, 0.0f); ::glBegin(GL_TRIANGLES); for (const Vec2f& point : m_triangles) ::glVertex3f(point(0), point(1), height_mesh); @@ -217,14 +216,16 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const ::glPopMatrix(); } - if (! m_supports_triangles.empty()) { + if (! m_supports_triangles.empty() && !m_editing_mode) { + // The supports are hidden in the editing mode, so it makes no sense to render the cuts. ::glPushMatrix(); ::glMultMatrixd(supports_trafo.data()); Eigen::Quaternionf q; q.setFromTwoVectors(Vec3f::UnitZ(), up_supports); Eigen::AngleAxisf aa(q); ::glRotatef(aa.angle() * (180./M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2)); - ::glTranslatef(0.f, 0.f, -0.001f); // to make sure the cut is safely beyond the near clipping plane + ::glTranslatef(0.f, 0.f, 0.1f); + ::glColor3f(1.0f, 0.f, 0.37f); ::glBegin(GL_TRIANGLES); for (const Vec2f& point : m_supports_triangles) ::glVertex3f(point(0), point(1), height_supports); From bbdc6a788146bd85594a8655aba24f3703a958e8 Mon Sep 17 00:00:00 2001 From: tamasmeszaros <meszaros.q@gmail.com> Date: Wed, 17 Apr 2019 10:08:54 +0200 Subject: [PATCH 2/6] Fix for incomplete validation condition on the allowable elevation. --- src/libslic3r/SLAPrint.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index b7191970d..b8d37edb2 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -598,8 +598,9 @@ std::string SLAPrint::validate() const for(SLAPrintObject * po : m_objects) { const ModelObject *mo = po->model_object(); + bool supports_en = po->config().supports_enable.getBool(); - if(po->config().supports_enable.getBool() && + if(supports_en && mo->sla_points_status == sla::PointsStatus::UserModified && mo->sla_support_points.empty()) return L("Cannot proceed without support points! " @@ -613,7 +614,7 @@ std::string SLAPrint::validate() const 2 * cfg.head_back_radius_mm - cfg.head_penetration_mm; - if(pinhead_width > cfg.object_elevation_mm) + if(supports_en && pinhead_width > cfg.object_elevation_mm) return L("Elevation is too low for object."); } From 50516e3b7d850d2305315c3df4fe424ee8eee073 Mon Sep 17 00:00:00 2001 From: Enrico Turri <enricoturri@seznam.cz> Date: Wed, 17 Apr 2019 09:44:46 +0200 Subject: [PATCH 3/6] Attempt to fix Ctrl+C from 3D scene on Mac --- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index cb2d6faed..4cc8c8cf1 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -794,7 +794,7 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas) } } - if (!processed) + if (!processed && !evt.HasModifiers()) { if (handle_shortcut(keyCode, canvas.get_selection())) { From 00ed0de815994eb03bebedd3334cc47b9381ca91 Mon Sep 17 00:00:00 2001 From: Vojtech Kral <vojtech@kral.hk> Date: Wed, 17 Apr 2019 14:25:37 +0200 Subject: [PATCH 4/6] Fix a format string in UpdateDialogs.cpp --- src/slic3r/GUI/UpdateDialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/UpdateDialogs.cpp b/src/slic3r/GUI/UpdateDialogs.cpp index d3638c1f5..99288488c 100644 --- a/src/slic3r/GUI/UpdateDialogs.cpp +++ b/src/slic3r/GUI/UpdateDialogs.cpp @@ -27,7 +27,7 @@ static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/prusa3d/Slic // MsgUpdateSlic3r MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_online) : - MsgDialog(nullptr, _(L("Update available")), wxString::Format(_(L("New version of % is available")), SLIC3R_APP_NAME)), + MsgDialog(nullptr, _(L("Update available")), wxString::Format(_(L("New version of %s is available")), SLIC3R_APP_NAME)), ver_current(ver_current), ver_online(ver_online) { From 8df2a19974b2031fed5753b50cfdc4e8dceec62d Mon Sep 17 00:00:00 2001 From: Lukas Matena <lukasmatena@seznam.cz> Date: Wed, 17 Apr 2019 10:16:39 +0200 Subject: [PATCH 5/6] SLA clipping plane can now be controlled by Ctrl + mouse wheel rotation --- src/slic3r/GUI/GLCanvas3D.cpp | 4 ++++ src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 12 ++++++++++++ src/slic3r/GUI/Gizmos/GLGizmos.hpp | 4 +++- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 17 +++++++++++++++++ src/slic3r/GUI/Gizmos/GLGizmosManager.hpp | 1 + 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index e656bec9b..8aa3205a7 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2374,6 +2374,10 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt) } } + // Inform gizmos about the event so they have the opportunity to react. + if (m_gizmos.on_mouse_wheel(evt, *this)) + return; + // Calculate the zoom delta and apply it to the current zoom factor float zoom = (float)evt.GetWheelRotation() / (float)evt.GetWheelDelta(); set_camera_zoom(zoom); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 1338bbc4d..1460f9e58 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -708,6 +708,18 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous } } + if (action == SLAGizmoEventType::MouseWheelUp && control_down) { + m_clipping_plane_distance = std::min(1.f, m_clipping_plane_distance + 0.01f); + m_parent.set_as_dirty(); + return true; + } + + if (action == SLAGizmoEventType::MouseWheelDown && control_down) { + m_clipping_plane_distance = std::max(0.f, m_clipping_plane_distance - 0.01f); + m_parent.set_as_dirty(); + return true; + } + return false; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmos.hpp b/src/slic3r/GUI/Gizmos/GLGizmos.hpp index 95c5754c1..4c2d2d30f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmos.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmos.hpp @@ -14,7 +14,9 @@ enum class SLAGizmoEventType { ApplyChanges, DiscardChanges, AutomaticGeneration, - ManualEditing + ManualEditing, + MouseWheelUp, + MouseWheelDown }; #include "slic3r/GUI/Gizmos/GLGizmoMove.hpp" diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 4cc8c8cf1..2c69b6407 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -520,6 +520,23 @@ void GLGizmosManager::render_overlay(const GLCanvas3D& canvas, const Selection& glsafe(::glPopMatrix()); } + + +bool GLGizmosManager::on_mouse_wheel(wxMouseEvent& evt, GLCanvas3D& canvas) +{ + bool processed = false; + + if (m_current == SlaSupports) { + float rot = (float)evt.GetWheelRotation() / (float)evt.GetWheelDelta(); + if (gizmo_event((rot > 0.f ? SLAGizmoEventType::MouseWheelUp : SLAGizmoEventType::MouseWheelDown), Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.ControlDown())) + processed = true; + } + + return processed; +} + + + bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas) { Point pos(evt.GetX(), evt.GetY()); diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index f7a1a980e..a04ced5fa 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -157,6 +157,7 @@ public: const std::string& get_tooltip() const { return m_tooltip; } bool on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas); + bool on_mouse_wheel(wxMouseEvent& evt, GLCanvas3D& canvas); bool on_char(wxKeyEvent& evt, GLCanvas3D& canvas); bool on_key(wxKeyEvent& evt, GLCanvas3D& canvas); From 0c1e223414983a1b7972c0af6806cd7da7557621 Mon Sep 17 00:00:00 2001 From: Lukas Matena <lukasmatena@seznam.cz> Date: Wed, 17 Apr 2019 12:24:46 +0200 Subject: [PATCH 6/6] SLA gizmo clipping plane is now not necessarily perpendicular to camera direction --- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 97 ++++++++++++-------- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp | 12 ++- src/slic3r/GUI/Gizmos/GLGizmos.hpp | 3 +- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 10 ++ 4 files changed, 78 insertions(+), 44 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 1460f9e58..ab3f7eb46 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -92,28 +92,29 @@ void GLGizmoSlaSupports::on_render(const Selection& selection) const glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_DEPTH_TEST)); - // we'll recover current look direction from the modelview matrix (in world coords): - Eigen::Matrix<double, 4, 4, Eigen::DontAlign> modelview_matrix; - ::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data()); - Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]); m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z(); if (m_quadric != nullptr && selection.is_from_single_instance()) - render_points(selection, direction_to_camera, false); + render_points(selection, false); render_selection_rectangle(); - render_clipping_plane(selection, direction_to_camera); + render_clipping_plane(selection); glsafe(::glDisable(GL_BLEND)); } -void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const Vec3d& direction_to_camera) const +void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection) const { if (m_clipping_plane_distance == 0.f) return; + if (m_clipping_plane_normal == Vec3d::Zero()) + reset_clipping_plane_normal(); + + const Vec3d& direction_to_camera = m_clipping_plane_normal; + // First cache instance transformation to be used later. const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin()); Transform3f instance_matrix = vol->get_instance_transformation().get_matrix().cast<float>(); @@ -137,9 +138,9 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const // In case either of these was recently changed, the cached triangulated ExPolygons are invalid now. // We are gonna recalculate them both for the object and for the support structures. if (m_clipping_plane_distance != m_old_clipping_plane_distance - || m_old_direction_to_camera != direction_to_camera) { + || m_old_clipping_plane_normal != direction_to_camera) { - m_old_direction_to_camera = direction_to_camera; + m_old_clipping_plane_normal = direction_to_camera; m_old_clipping_plane_distance = m_clipping_plane_distance; // Now initialize the TMS for the object, perform the cut and save the result. @@ -206,7 +207,7 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const q.setFromTwoVectors(Vec3f::UnitZ(), up); Eigen::AngleAxisf aa(q); ::glRotatef(aa.angle() * (180./M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2)); - ::glTranslatef(0.f, 0.f, 0.1f); // to make sure the cut does not intersect the structure itself + ::glTranslatef(0.f, 0.f, 0.01f); // to make sure the cut does not intersect the structure itself ::glColor3f(1.0f, 0.37f, 0.0f); ::glBegin(GL_TRIANGLES); for (const Vec2f& point : m_triangles) @@ -224,7 +225,7 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const q.setFromTwoVectors(Vec3f::UnitZ(), up_supports); Eigen::AngleAxisf aa(q); ::glRotatef(aa.angle() * (180./M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2)); - ::glTranslatef(0.f, 0.f, 0.1f); + ::glTranslatef(0.f, 0.f, 0.01f); ::glColor3f(1.0f, 0.f, 0.37f); ::glBegin(GL_TRIANGLES); for (const Vec2f& point : m_supports_triangles) @@ -285,16 +286,10 @@ void GLGizmoSlaSupports::render_selection_rectangle() const void GLGizmoSlaSupports::on_render_for_picking(const Selection& selection) const { glsafe(::glEnable(GL_DEPTH_TEST)); - - // we'll recover current look direction from the modelview matrix (in world coords): - Eigen::Matrix<double, 4, 4, Eigen::DontAlign> modelview_matrix; - ::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data()); - Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]); - - render_points(selection, direction_to_camera, true); + render_points(selection, true); } -void GLGizmoSlaSupports::render_points(const Selection& selection, const Vec3d& direction_to_camera, bool picking) const +void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const { if (!picking) glsafe(::glEnable(GL_LIGHTING)); @@ -313,7 +308,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, const Vec3d& const sla::SupportPoint& support_point = m_editing_mode_cache[i].support_point; const bool& point_selected = m_editing_mode_cache[i].selected; - if (is_point_clipped(support_point.pos.cast<double>(), direction_to_camera)) + if (is_point_clipped(support_point.pos.cast<double>())) continue; // First decide about the color of the point. @@ -387,8 +382,10 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, const Vec3d& -bool GLGizmoSlaSupports::is_point_clipped(const Vec3d& point, const Vec3d& direction_to_camera) const +bool GLGizmoSlaSupports::is_point_clipped(const Vec3d& point) const { + const Vec3d& direction_to_camera = m_clipping_plane_normal; + if (m_clipping_plane_distance == 0.f) return false; @@ -458,9 +455,6 @@ std::pair<Vec3f, Vec3f> GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse const Selection& selection = m_parent.get_selection(); const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); - // we'll recover current look direction from the modelview matrix (in world coords): - Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]); - point1(2) -= m_z_shift; point2(2) -= m_z_shift; @@ -487,7 +481,7 @@ std::pair<Vec3f, Vec3f> GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse a = (m_V.row(m_F(fid, 1)) - m_V.row(m_F(fid, 0))); b = (m_V.row(m_F(fid, 2)) - m_V.row(m_F(fid, 0))); result = bc(0) * m_V.row(m_F(fid, 0)) + bc(1) * m_V.row(m_F(fid, 1)) + bc(2)*m_V.row(m_F(fid, 2)); - if (m_clipping_plane_distance == 0.f || !is_point_clipped(result.cast<double>(), direction_to_camera)) + if (m_clipping_plane_distance == 0.f || !is_point_clipped(result.cast<double>())) break; } @@ -592,7 +586,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous ::gluProject((GLdouble)pos(0), (GLdouble)pos(1), (GLdouble)pos(2), (GLdouble*)modelview_matrix.data(), (GLdouble*)projection_matrix.data(), (GLint*)viewport.data(), &out_x, &out_y, &out_z); out_y = m_canvas_height - out_y; - if (rectangle.contains(Point(out_x, out_y)) && !is_point_clipped(support_point.pos.cast<double>(), direction_to_camera.cast<double>())) { + if (rectangle.contains(Point(out_x, out_y)) && !is_point_clipped(support_point.pos.cast<double>())) { bool is_obscured = false; // Cast a ray in the direction of the camera and look for intersection with the mesh: std::vector<igl::Hit> hits; @@ -616,7 +610,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous Vec3f bc = Vec3f(1-hit.u-hit.v, hit.u, hit.v); // barycentric coordinates of the hit Vec3f hit_pos = bc(0) * m_V.row(m_F(fid, 0)) + bc(1) * m_V.row(m_F(fid, 1)) + bc(2)*m_V.row(m_F(fid, 2)); - if (is_point_clipped(hit_pos.cast<double>(), direction_to_camera.cast<double>())) { + if (is_point_clipped(hit_pos.cast<double>())) { hits.erase(hits.begin()+j); --j; } @@ -720,6 +714,11 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous return true; } + if (action == SLAGizmoEventType::ResetClippingPlane) { + reset_clipping_plane_normal(); + return true; + } + return false; } @@ -803,11 +802,12 @@ ClippingPlane GLGizmoSlaSupports::get_sla_clipping_plane() const if (!m_model_object || m_state == Off) return ClippingPlane::ClipsNothing(); - Eigen::Matrix<GLdouble, 4, 4, Eigen::DontAlign> modelview_matrix; - ::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data()); - + //Eigen::Matrix<GLdouble, 4, 4, Eigen::DontAlign> modelview_matrix; + //::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data()); // we'll recover current look direction from the modelview matrix (in world coords): - Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]); + //Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]); + + const Vec3d& direction_to_camera = m_clipping_plane_normal; float dist = direction_to_camera.dot(m_model_object->instances[m_active_instance]->get_offset() + Vec3d(0., 0., m_z_shift)); return ClippingPlane(-direction_to_camera.normalized(),(dist - (-m_active_instance_bb_radius) - m_clipping_plane_distance * 2*m_active_instance_bb_radius)); @@ -966,18 +966,27 @@ RENDER_AGAIN: m_imgui->text(""); - m_imgui->text(m_model_object->sla_points_status == sla::PointsStatus::None ? "No points (will be autogenerated)" : - (m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated ? "Autogenerated points (no modifications)" : - (m_model_object->sla_points_status == sla::PointsStatus::UserModified ? "User-modified points" : - (m_model_object->sla_points_status == sla::PointsStatus::Generating ? "Generation in progress..." : "UNKNOWN STATUS")))); + m_imgui->text(m_model_object->sla_points_status == sla::PointsStatus::None ? _(L("No points (will be autogenerated)")) : + (m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated ? _(L("Autogenerated points (no modifications)")) : + (m_model_object->sla_points_status == sla::PointsStatus::UserModified ? _(L("User-modified points")) : + (m_model_object->sla_points_status == sla::PointsStatus::Generating ? _(L("Generation in progress...")) : "UNKNOWN STATUS")))); } // Following is rendered in both editing and non-editing mode: - m_imgui->text("Clipping of view: "); - ImGui::SameLine(); + if (m_clipping_plane_distance == 0.f) + m_imgui->text("Clipping of view: "); + else { + if (m_imgui->button(_(L("Reset direction [R] ")))) { + wxGetApp().CallAfter([this](){ + reset_clipping_plane_normal(); + }); + } + } + + ImGui::SameLine(140.f); ImGui::PushItemWidth(150.0f); - bool value_changed = ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f"); + ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f"); m_imgui->end(); @@ -1220,5 +1229,17 @@ void GLGizmoSlaSupports::switch_to_editing_mode() m_editing_mode = true; } + + +void GLGizmoSlaSupports::reset_clipping_plane_normal() const +{ + Eigen::Matrix<double, 4, 4, Eigen::DontAlign> modelview_matrix; + ::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data()); + m_clipping_plane_normal = Vec3d(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]); + m_parent.set_as_dirty(); +} + + + } // namespace GUI } // namespace Slic3r diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index a06a3502c..982f6c95d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -73,8 +73,8 @@ private: virtual void on_render_for_picking(const Selection& selection) const; void render_selection_rectangle() const; - void render_points(const Selection& selection, const Vec3d& direction_to_camera, bool picking = false) const; - void render_clipping_plane(const Selection& selection, const Vec3d& direction_to_camera) const; + void render_points(const Selection& selection, bool picking = false) const; + void render_clipping_plane(const Selection& selection) const; bool is_mesh_update_necessary() const; void update_mesh(); void update_cache_entry_normal(unsigned int i) const; @@ -87,7 +87,8 @@ private: mutable std::vector<CacheEntry> m_editing_mode_cache; // a support point and whether it is currently selected float m_clipping_plane_distance = 0.f; mutable float m_old_clipping_plane_distance = 0.f; - mutable Vec3d m_old_direction_to_camera; + mutable Vec3d m_old_clipping_plane_normal; + mutable Vec3d m_clipping_plane_normal = Vec3d::Zero(); enum SelectionRectangleStatus { srOff = 0, @@ -108,8 +109,8 @@ private: mutable std::unique_ptr<TriangleMeshSlicer> m_supports_tms; std::vector<const ConfigOption*> get_config_options(const std::vector<std::string>& keys) const; - bool is_point_clipped(const Vec3d& point, const Vec3d& direction_to_camera) const; - void find_intersecting_facets(const igl::AABB<Eigen::MatrixXf, 3>* aabb, const Vec3f& normal, double offset, std::vector<unsigned int>& out) const; + bool is_point_clipped(const Vec3d& point) const; + //void find_intersecting_facets(const igl::AABB<Eigen::MatrixXf, 3>* aabb, const Vec3f& normal, double offset, std::vector<unsigned int>& out) const; // Methods that do the model_object and editing cache synchronization, // editing mode selection, etc: @@ -125,6 +126,7 @@ private: void get_data_from_backend(); void auto_generate(); void switch_to_editing_mode(); + void reset_clipping_plane_normal() const; protected: void on_set_state() override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmos.hpp b/src/slic3r/GUI/Gizmos/GLGizmos.hpp index 4c2d2d30f..2e98899be 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmos.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmos.hpp @@ -16,7 +16,8 @@ enum class SLAGizmoEventType { AutomaticGeneration, ManualEditing, MouseWheelUp, - MouseWheelDown + MouseWheelDown, + ResetClippingPlane }; #include "slic3r/GUI/Gizmos/GLGizmoMove.hpp" diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 2c69b6407..5e37e42ad 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -778,6 +778,16 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas) break; } + + case 'r' : + case 'R' : + { + if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::ResetClippingPlane)) + processed = true; + + break; + } + #ifdef __APPLE__ case WXK_BACK: // the low cost Apple solutions are not equipped with a Delete key, use Backspace instead. #else /* __APPLE__ */