From 6e279cbec28b6faf2b65b1016341718e0a8bd287 Mon Sep 17 00:00:00 2001 From: enricoturri1966 <enricoturri@seznam.cz> Date: Fri, 22 May 2020 10:43:59 +0200 Subject: [PATCH] GCodeViewer -> Refactoring of sequential view marker positioning --- src/slic3r/GUI/GCodeViewer.cpp | 8 +++++++- src/slic3r/GUI/GCodeViewer.hpp | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 5d298c0ee..b72738846 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -156,6 +156,12 @@ void GCodeViewer::SequentialView::Marker::init() #endif // !ENABLE_SHADERS_MANAGER } +void GCodeViewer::SequentialView::Marker::set_world_position(const Vec3f& position) +{ + m_world_transform = (Geometry::assemble_transform(position.cast<double>()) * Geometry::assemble_transform(m_model.get_bounding_box().size()[2] * Vec3d::UnitZ(), { M_PI, 0.0, 0.0 })).cast<float>(); + m_world_bounding_box = m_model.get_bounding_box().transformed(m_world_transform.cast<double>()); +} + void GCodeViewer::SequentialView::Marker::render() const { #if ENABLE_SHADERS_MANAGER @@ -346,7 +352,7 @@ void GCodeViewer::render() const glsafe(::glEnable(GL_DEPTH_TEST)); render_toolpaths(); - m_sequential_view.marker.set_world_transform(Geometry::assemble_transform(m_sequential_view.current_position.cast<double>() + (0.5 + 12.0) * Vec3d::UnitZ(), { M_PI, 0.0, 0.0 }).cast<float>()); + m_sequential_view.marker.set_world_position(m_sequential_view.current_position + m_sequential_view_marker_z_offset * Vec3f::UnitZ()); m_sequential_view.marker.render(); render_shells(); render_legend(); diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index c1f9cfdd7..45a87a006 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -211,6 +211,7 @@ public: { GL_Model m_model; Transform3f m_world_transform; + BoundingBoxf3 m_world_bounding_box; std::array<float, 4> m_color{ 1.0f, 1.0f, 1.0f, 1.0f }; bool m_visible{ false }; #if !ENABLE_SHADERS_MANAGER @@ -220,9 +221,9 @@ public: public: void init(); - const BoundingBoxf3& get_bounding_box() const { return m_model.get_bounding_box(); } + const BoundingBoxf3& get_bounding_box() const { return m_world_bounding_box; } - void set_world_transform(const Transform3f& transform) { m_world_transform = transform; } + void set_world_position(const Vec3f& position); void set_color(const std::array<float, 4>& color) { m_color = color; } bool is_visible() const { return m_visible; } @@ -273,6 +274,7 @@ private: std::vector<unsigned char> m_extruder_ids; mutable Extrusions m_extrusions; mutable SequentialView m_sequential_view; + float m_sequential_view_marker_z_offset{ 0.5f }; Shells m_shells; EViewType m_view_type{ EViewType::FeatureType }; bool m_legend_enabled{ true };