From 4ad42d617138919d95d4abffe2737215e9bf54b8 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 11 Nov 2020 16:22:09 +0100 Subject: [PATCH 1/3] WIP - Sequential print visualization using vertical slider in preview (missing travel moves) --- src/libslic3r/Technologies.hpp | 8 +++ src/slic3r/GUI/GCodeViewer.cpp | 102 ++++++++++++++++++++++++++++++++- src/slic3r/GUI/GCodeViewer.hpp | 49 ++++++++++++++++ src/slic3r/GUI/GLCanvas3D.cpp | 10 ++++ src/slic3r/GUI/GLCanvas3D.hpp | 3 + src/slic3r/GUI/GUI_Preview.cpp | 12 ++-- 6 files changed, 176 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 3ee299e61..aa1889435 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -64,4 +64,12 @@ #define ENABLE_CTRL_M_ON_WINDOWS (0 && ENABLE_2_3_0_ALPHA3) + +//=================== +// 2.3.0.alpha4 techs +//=================== +#define ENABLE_2_3_0_ALPHA4 1 + +#define ENABLE_SEQUENTIAL_VSLIDER (1 && ENABLE_GCODE_VIEWER && ENABLE_2_3_0_ALPHA4) + #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 0b5bb23aa..dab7acda3 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -300,8 +300,13 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print& reset(); load_toolpaths(gcode_result); +#if ENABLE_SEQUENTIAL_VSLIDER + if (m_layers.empty()) + return; +#else if (m_layers_zs.empty()) return; +#endif // ENABLE_SEQUENTIAL_VSLIDER m_settings_ids = gcode_result.settings_ids; @@ -428,7 +433,12 @@ void GCodeViewer::reset() m_extrusions.reset_role_visibility_flags(); m_extrusions.reset_ranges(); m_shells.volumes.clear(); +#if ENABLE_SEQUENTIAL_VSLIDER + m_layers.reset(); + m_layers_z_range_2 = { 0, 0 }; +#else m_layers_zs = std::vector(); +#endif // ENABLE_SEQUENTIAL_VSLIDER m_layers_z_range = { 0.0, 0.0 }; m_roles = std::vector(); m_time_statistics.reset(); @@ -599,6 +609,16 @@ void GCodeViewer::set_options_visibility_from_flags(unsigned int flags) enable_legend(is_flag_set(static_cast(Preview::OptionType::Legend))); } +#if ENABLE_SEQUENTIAL_VSLIDER +void GCodeViewer::set_layers_z_range(const std::array& layers_z_range) +{ + bool keep_sequential_current_first = layers_z_range[0] >= m_layers_z_range_2[0]; + bool keep_sequential_current_last = layers_z_range[1] <= m_layers_z_range_2[1]; + m_layers_z_range_2 = layers_z_range; + refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last); + wxGetApp().plater()->update_preview_moves_slider(); +} +#else void GCodeViewer::set_layers_z_range(const std::array& layers_z_range) { bool keep_sequential_current_first = layers_z_range[0] >= m_layers_z_range[0]; @@ -607,6 +627,7 @@ void GCodeViewer::set_layers_z_range(const std::array& layers_z_range refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last); wxGetApp().plater()->update_preview_moves_slider(); } +#endif // ENABLE_SEQUENTIAL_VSLIDER void GCodeViewer::export_toolpaths_to_obj(const char* filename) const { @@ -1531,11 +1552,39 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) // dismiss indices data, no more needed std::vector().swap(indices); +#if ENABLE_SEQUENTIAL_VSLIDER + // layers zs / roles / extruder ids / cp color ids -> extract from result + std::vector> averages; + for (size_t i = 0; i < m_moves_count; ++i) { + const GCodeProcessor::MoveVertex& move = gcode_result.moves[i]; + if (move.type == EMoveType::Extrude) { + // layers zs + const double* const last_z = m_layers.empty() ? nullptr : &m_layers.get_zs().back(); + double z = static_cast(move.position[2]); + if (last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z) + m_layers.append(z, { i - 1, i }); + else + m_layers.get_endpoints().back().last = i; + // extruder ids + m_extruder_ids.emplace_back(move.extruder_id); + // roles + if (i > 0) + m_roles.emplace_back(move.extrusion_role); + } + } + + // set layers z range + if (!m_layers.empty()) { + m_layers_z_range = { m_layers.get_zs().front(), m_layers.get_zs().back() }; + m_layers_z_range_2 = { 0, static_cast(m_layers.size() - 1) }; + } +#else // layers zs -> extract from result for (const Path& path : m_buffers[buffer_id(EMoveType::Extrude)].paths) { m_layers_zs.emplace_back(static_cast(path.first.position[2])); // m_layers_zs.emplace_back(static_cast(path.last.position[2])); } + // roles / extruder ids / cp color ids -> extract from result for (size_t i = 0; i < m_moves_count; ++i) { const GCodeProcessor::MoveVertex& move = gcode_result.moves[i]; @@ -1544,6 +1593,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) m_roles.emplace_back(move.extrusion_role); } + // layers zs -> replace intervals of layers with similar top positions with their average value. std::sort(m_layers_zs.begin(), m_layers_zs.end()); int n = int(m_layers_zs.size()); @@ -1560,9 +1610,11 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) m_layers_zs.shrink_to_fit(); } + // set layers z range if (!m_layers_zs.empty()) m_layers_z_range = { m_layers_zs.front(), m_layers_zs.back() }; +#endif // ENABLE_SEQUENTIAL_VSLIDER // roles -> remove duplicates std::sort(m_roles.begin(), m_roles.end()); @@ -1671,9 +1723,19 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool Travel_Colors[0] /* Move */); }; +#if ENABLE_SEQUENTIAL_VSLIDER + auto is_in_layers_range = [this](const Path& path, size_t min_id, size_t max_id) { + auto in_layers_range = [this, min_id, max_id](size_t id) { + return m_layers.get_endpoints_at(min_id).first <= id && id <= m_layers.get_endpoints_at(max_id).last; + }; + + return in_layers_range(path.first.s_id) || in_layers_range(path.last.s_id); + }; +#endif // ENABLE_SEQUENTIAL_VSLIDER + auto is_in_z_range = [](const Path& path, double min_z, double max_z) { auto in_z_range = [min_z, max_z](double z) { - return z > min_z - EPSILON && z < max_z + EPSILON; + return min_z - EPSILON < z && z < max_z + EPSILON; }; return in_z_range(path.first.position[2]) || in_z_range(path.last.position[2]); @@ -1727,8 +1789,13 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool if (!is_travel_in_z_range(i, m_layers_z_range[0], m_layers_z_range[1])) continue; } +#if ENABLE_SEQUENTIAL_VSLIDER + else if (!is_in_layers_range(path, m_layers_z_range_2[0], m_layers_z_range_2[1])) + continue; +#else else if (!is_in_z_range(path, m_layers_z_range[0], m_layers_z_range[1])) continue; +#endif // ENABLE_SEQUENTIAL_VSLIDER if (path.type == EMoveType::Extrude && !is_visible(path)) continue; @@ -1746,10 +1813,17 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); } } +#if ENABLE_SEQUENTIAL_VSLIDER + else if (is_in_layers_range(path, m_layers_z_range_2[1], m_layers_z_range_2[1])) { + top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); + top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); + } +#else else if (is_in_z_range(path, m_layers_z_range[1], m_layers_z_range[1])) { top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); } +#endif // ENABLE_SEQUENTIAL_VSLIDER } } } @@ -1803,7 +1877,13 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool switch (path.type) { case EMoveType::Extrude: { +#if ENABLE_SEQUENTIAL_VSLIDER + if (!top_layer_only || + m_sequential_view.current.last == global_endpoints.last || + is_in_layers_range(path, m_layers_z_range_2[1], m_layers_z_range_2[1])) +#else if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_in_z_range(path, m_layers_z_range[1], m_layers_z_range[1])) +#endif // ENABLE_SEQUENTIAL_VSLIDER color = extrusion_color(path); else color = { 0.25f, 0.25f, 0.25f }; @@ -2197,13 +2277,23 @@ void GCodeViewer::render_legend() const if (item.type != ColorChange) continue; +#if ENABLE_SEQUENTIAL_VSLIDER + const std::vector zs = m_layers.get_zs(); + auto lower_b = std::lower_bound(zs.begin(), zs.end(), item.print_z - Slic3r::DoubleSlider::epsilon()); + if (lower_b == zs.end()) + continue; +#else auto lower_b = std::lower_bound(m_layers_zs.begin(), m_layers_zs.end(), item.print_z - Slic3r::DoubleSlider::epsilon()); - if (lower_b == m_layers_zs.end()) continue; +#endif // ENABLE_SEQUENTIAL_VSLIDER double current_z = *lower_b; +#if ENABLE_SEQUENTIAL_VSLIDER + double previous_z = (lower_b == zs.begin()) ? 0.0 : *(--lower_b); +#else double previous_z = lower_b == m_layers_zs.begin() ? 0.0 : *(--lower_b); +#endif // ENABLE_SEQUENTIAL_VSLIDER // to avoid duplicate values, check adding values if (ret.empty() || !(ret.back().second.first == previous_z && ret.back().second.second == current_z)) @@ -2794,10 +2884,18 @@ void GCodeViewer::log_memory_used(const std::string& label, long long additional render_paths_size += SLIC3R_STDVEC_MEMSIZE(path.offsets, size_t); } } +#if ENABLE_SEQUENTIAL_VSLIDER + long long layers_size = SLIC3R_STDVEC_MEMSIZE(m_layers.get_zs(), double); + layers_size += SLIC3R_STDVEC_MEMSIZE(m_layers.get_endpoints(), Layers::Endpoints); + BOOST_LOG_TRIVIAL(trace) << label + << format_memsize_MB(additional + paths_size + render_paths_size + layers_size) + << log_memory_info(); +#else long long layers_zs_size = SLIC3R_STDVEC_MEMSIZE(m_layers_zs, double); BOOST_LOG_TRIVIAL(trace) << label << format_memsize_MB(additional + paths_size + render_paths_size + layers_zs_size) << log_memory_info(); +#endif // ENABLE_SEQUENTIAL_VSLIDER } } diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 93eb86932..3ed7cb5b2 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -272,6 +272,42 @@ class GCodeViewer void reset_ranges() { ranges.reset(); } }; +#if ENABLE_SEQUENTIAL_VSLIDER + class Layers + { + public: + struct Endpoints + { + size_t first{ 0 }; + size_t last{ 0 }; + }; + + private: + std::vector m_zs; + std::vector m_endpoints; + + public: + void append(double z, Endpoints endpoints) + { + m_zs.emplace_back(z); + m_endpoints.emplace_back(endpoints); + } + + void reset() + { + m_zs = std::vector(); + m_endpoints = std::vector(); + } + + size_t size() const { return m_zs.size(); } + bool empty() const { return m_zs.empty(); } + const std::vector& get_zs() const { return m_zs; } + const std::vector& get_endpoints() const { return m_endpoints; } + std::vector& get_endpoints() { return m_endpoints; } + Endpoints get_endpoints_at(unsigned int id) const { return (id < m_endpoints.size()) ? m_endpoints[id] : Endpoints(); } + }; +#endif // ENABLE_SEQUENTIAL_VSLIDER + #if ENABLE_GCODE_VIEWER_STATISTICS struct Statistics { @@ -397,7 +433,12 @@ private: // bounding box of toolpaths + marker tools BoundingBoxf3 m_max_bounding_box; std::vector m_tool_colors; +#if ENABLE_SEQUENTIAL_VSLIDER + Layers m_layers; + std::array m_layers_z_range_2; +#else std::vector m_layers_zs; +#endif // ENABLE_SEQUENTIAL_VSLIDER std::array m_layers_z_range; std::vector m_roles; size_t m_extruders_count; @@ -431,7 +472,11 @@ public: const BoundingBoxf3& get_paths_bounding_box() const { return m_paths_bounding_box; } const BoundingBoxf3& get_max_bounding_box() const { return m_max_bounding_box; } +#if ENABLE_SEQUENTIAL_VSLIDER + const std::vector& get_layers_zs() const { return m_layers.get_zs(); }; +#else const std::vector& get_layers_zs() const { return m_layers_zs; }; +#endif // ENABLE_SEQUENTIAL_VSLIDER const SequentialView& get_sequential_view() const { return m_sequential_view; } void update_sequential_view_current(unsigned int first, unsigned int last); @@ -450,7 +495,11 @@ public: void set_toolpath_role_visibility_flags(unsigned int flags) { m_extrusions.role_visibility_flags = flags; } unsigned int get_options_visibility_flags() const; void set_options_visibility_from_flags(unsigned int flags); +#if ENABLE_SEQUENTIAL_VSLIDER + void set_layers_z_range(const std::array& layers_z_range); +#else void set_layers_z_range(const std::array& layers_z_range); +#endif // ENABLE_SEQUENTIAL_VSLIDER bool is_legend_enabled() const { return m_legend_enabled; } void enable_legend(bool enable) { m_legend_enabled = enable; } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index bd5b2414c..2b969f219 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2182,9 +2182,19 @@ void GLCanvas3D::set_toolpath_view_type(GCodeViewer::EViewType type) void GLCanvas3D::set_toolpaths_z_range(const std::array& range) { m_volumes.set_range(range[0] - 1e-6, range[1] + 1e-6); +#if !ENABLE_SEQUENTIAL_VSLIDER + if (m_gcode_viewer.has_data()) + m_gcode_viewer.set_layers_z_range(range); +#endif // !ENABLE_SEQUENTIAL_VSLIDER +} + +#if ENABLE_SEQUENTIAL_VSLIDER +void GLCanvas3D::set_toolpaths_z_range_2(const std::array& range) +{ if (m_gcode_viewer.has_data()) m_gcode_viewer.set_layers_z_range(range); } +#endif // ENABLE_SEQUENTIAL_VSLIDER #else std::vector GLCanvas3D::get_current_print_zs(bool active_only) const { diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 5351e99fa..667243133 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -652,6 +652,9 @@ public: void set_toolpath_role_visibility_flags(unsigned int flags); void set_toolpath_view_type(GCodeViewer::EViewType type); void set_toolpaths_z_range(const std::array& range); +#if ENABLE_SEQUENTIAL_VSLIDER + void set_toolpaths_z_range_2(const std::array& range); +#endif // ENABLE_SEQUENTIAL_VSLIDER #else std::vector get_current_print_zs(bool active_only) const; #endif // ENABLE_GCODE_VIEWER diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 1b7fc79c6..02bdd71a2 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -1427,13 +1427,14 @@ void Preview::on_layers_slider_scroll_changed(wxCommandEvent& event) void Preview::on_sliders_scroll_changed(wxCommandEvent& event) #endif // ENABLE_GCODE_VIEWER { - if (IsShown()) - { + if (IsShown()) { PrinterTechnology tech = m_process->current_printer_technology(); - if (tech == ptFFF) - { + if (tech == ptFFF) { #if ENABLE_GCODE_VIEWER m_canvas->set_toolpaths_z_range({ m_layers_slider->GetLowerValueD(), m_layers_slider->GetHigherValueD() }); +#if ENABLE_SEQUENTIAL_VSLIDER + m_canvas->set_toolpaths_z_range_2({ static_cast(m_layers_slider->GetLowerValue()), static_cast(m_layers_slider->GetHigherValue()) }); +#endif // ENABLE_SEQUENTIAL_VSLIDER m_canvas->set_as_dirty(); #else m_canvas->set_toolpaths_range(m_slider->GetLowerValueD() - 1e-6, m_slider->GetHigherValueD() + 1e-6); @@ -1441,8 +1442,7 @@ void Preview::on_sliders_scroll_changed(wxCommandEvent& event) m_canvas->set_use_clipping_planes(false); #endif // ENABLE_GCODE_VIEWER } - else if (tech == ptSLA) - { + else if (tech == ptSLA) { #if ENABLE_GCODE_VIEWER m_canvas->set_clipping_plane(0, ClippingPlane(Vec3d::UnitZ(), -m_layers_slider->GetLowerValueD())); m_canvas->set_clipping_plane(1, ClippingPlane(-Vec3d::UnitZ(), m_layers_slider->GetHigherValueD())); From 9e4cb893f7e97d653bdea2da712afde79579fcd3 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 12 Nov 2020 16:29:44 +0100 Subject: [PATCH 2/3] Sequential print visualization using vertical slider in preview -> Added travel moves --- src/slic3r/GUI/GCodeViewer.cpp | 85 ++++++++++++++++++++++++++++------ src/slic3r/GUI/GCodeViewer.hpp | 5 +- 2 files changed, 74 insertions(+), 16 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index dab7acda3..87a5a944d 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -435,11 +435,11 @@ void GCodeViewer::reset() m_shells.volumes.clear(); #if ENABLE_SEQUENTIAL_VSLIDER m_layers.reset(); - m_layers_z_range_2 = { 0, 0 }; + m_layers_z_range = { 0, 0 }; #else m_layers_zs = std::vector(); -#endif // ENABLE_SEQUENTIAL_VSLIDER m_layers_z_range = { 0.0, 0.0 }; +#endif // ENABLE_SEQUENTIAL_VSLIDER m_roles = std::vector(); m_time_statistics.reset(); m_time_estimate_mode = PrintEstimatedTimeStatistics::ETimeMode::Normal; @@ -612,9 +612,9 @@ void GCodeViewer::set_options_visibility_from_flags(unsigned int flags) #if ENABLE_SEQUENTIAL_VSLIDER void GCodeViewer::set_layers_z_range(const std::array& layers_z_range) { - bool keep_sequential_current_first = layers_z_range[0] >= m_layers_z_range_2[0]; - bool keep_sequential_current_last = layers_z_range[1] <= m_layers_z_range_2[1]; - m_layers_z_range_2 = layers_z_range; + bool keep_sequential_current_first = layers_z_range[0] >= m_layers_z_range[0]; + bool keep_sequential_current_last = layers_z_range[1] <= m_layers_z_range[1]; + m_layers_z_range = layers_z_range; refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last); wxGetApp().plater()->update_preview_moves_slider(); } @@ -1554,7 +1554,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) #if ENABLE_SEQUENTIAL_VSLIDER // layers zs / roles / extruder ids / cp color ids -> extract from result - std::vector> averages; + size_t last_travel_s_id = 0; for (size_t i = 0; i < m_moves_count; ++i) { const GCodeProcessor::MoveVertex& move = gcode_result.moves[i]; if (move.type == EMoveType::Extrude) { @@ -1562,7 +1562,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) const double* const last_z = m_layers.empty() ? nullptr : &m_layers.get_zs().back(); double z = static_cast(move.position[2]); if (last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z) - m_layers.append(z, { i - 1, i }); + m_layers.append(z, { last_travel_s_id, i }); else m_layers.get_endpoints().back().last = i; // extruder ids @@ -1571,12 +1571,17 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) if (i > 0) m_roles.emplace_back(move.extrusion_role); } + else if (move.type == EMoveType::Travel) { + if (i - last_travel_s_id > 1 && !m_layers.empty()) + m_layers.get_endpoints().back().last = i; + + last_travel_s_id = i; + } } // set layers z range if (!m_layers.empty()) { - m_layers_z_range = { m_layers.get_zs().front(), m_layers.get_zs().back() }; - m_layers_z_range_2 = { 0, static_cast(m_layers.size() - 1) }; + m_layers_z_range = { 0, static_cast(m_layers.size() - 1) }; } #else // layers zs -> extract from result @@ -1731,8 +1736,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool return in_layers_range(path.first.s_id) || in_layers_range(path.last.s_id); }; -#endif // ENABLE_SEQUENTIAL_VSLIDER - +#else auto is_in_z_range = [](const Path& path, double min_z, double max_z) { auto in_z_range = [min_z, max_z](double z) { return min_z - EPSILON < z && z < max_z + EPSILON; @@ -1740,7 +1744,43 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool return in_z_range(path.first.position[2]) || in_z_range(path.last.position[2]); }; +#endif // ENABLE_SEQUENTIAL_VSLIDER +#if ENABLE_SEQUENTIAL_VSLIDER + auto is_travel_in_layers_range = [this](size_t path_id, size_t min_id, size_t max_id) { + auto is_in_z_range = [](const Path& path, double min_z, double max_z) { + auto in_z_range = [min_z, max_z](double z) { + return min_z - EPSILON < z&& z < max_z + EPSILON; + }; + + return in_z_range(path.first.position[2]) || in_z_range(path.last.position[2]); + }; + + const TBuffer& buffer = m_buffers[buffer_id(EMoveType::Travel)]; + if (path_id >= buffer.paths.size()) + return false; + + Path path = buffer.paths[path_id]; + size_t first = path_id; + size_t last = path_id; + + // check adjacent paths + while (first > 0 && path.first.position.isApprox(buffer.paths[first - 1].last.position)) { + --first; + path.first = buffer.paths[first].first; + } + while (last < buffer.paths.size() - 1 && path.last.position.isApprox(buffer.paths[last + 1].first.position)) { + ++last; + path.last = buffer.paths[last].last; + } + + size_t min_s_id = m_layers.get_endpoints_at(min_id).first; + size_t max_s_id = m_layers.get_endpoints_at(max_id).last; + + return (min_s_id <= path.first.s_id && path.first.s_id <= max_s_id) || + (min_s_id <= path.last.s_id && path.last.s_id <= max_s_id); + }; +#else auto is_travel_in_z_range = [this, is_in_z_range](size_t path_id, double min_z, double max_z) { const TBuffer& buffer = m_buffers[buffer_id(EMoveType::Travel)]; if (path_id >= buffer.paths.size()) @@ -1762,6 +1802,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool return is_in_z_range(path, min_z, max_z); }; +#endif // ENABLE_SEQUENTIAL_VSLIDER #if ENABLE_GCODE_VIEWER_STATISTICS m_statistics.render_paths_size = 0; @@ -1786,11 +1827,16 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool for (size_t i = 0; i < buffer.paths.size(); ++i) { const Path& path = buffer.paths[i]; if (path.type == EMoveType::Travel) { +#if ENABLE_SEQUENTIAL_VSLIDER + if (!is_travel_in_layers_range(i, m_layers_z_range[0], m_layers_z_range[1])) + continue; +#else if (!is_travel_in_z_range(i, m_layers_z_range[0], m_layers_z_range[1])) continue; +#endif // ENABLE_SEQUENTIAL_VSLIDER } #if ENABLE_SEQUENTIAL_VSLIDER - else if (!is_in_layers_range(path, m_layers_z_range_2[0], m_layers_z_range_2[1])) + else if (!is_in_layers_range(path, m_layers_z_range[0], m_layers_z_range[1])) continue; #else else if (!is_in_z_range(path, m_layers_z_range[0], m_layers_z_range[1])) @@ -1808,13 +1854,20 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool if (top_layer_only) { if (path.type == EMoveType::Travel) { +#if ENABLE_SEQUENTIAL_VSLIDER + if (is_travel_in_layers_range(i, m_layers_z_range[1], m_layers_z_range[1])) { + top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); + top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); + } +#else if (is_travel_in_z_range(i, m_layers_z_range[1], m_layers_z_range[1])) { top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); } +#endif // ENABLE_SEQUENTIAL_VSLIDER } #if ENABLE_SEQUENTIAL_VSLIDER - else if (is_in_layers_range(path, m_layers_z_range_2[1], m_layers_z_range_2[1])) { + else if (is_in_layers_range(path, m_layers_z_range[1], m_layers_z_range[1])) { top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); } @@ -1880,7 +1933,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool #if ENABLE_SEQUENTIAL_VSLIDER if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || - is_in_layers_range(path, m_layers_z_range_2[1], m_layers_z_range_2[1])) + is_in_layers_range(path, m_layers_z_range[1], m_layers_z_range[1])) #else if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_in_z_range(path, m_layers_z_range[1], m_layers_z_range[1])) #endif // ENABLE_SEQUENTIAL_VSLIDER @@ -1891,7 +1944,11 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool break; } case EMoveType::Travel: { +#if ENABLE_SEQUENTIAL_VSLIDER + if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_travel_in_layers_range(path_id, m_layers_z_range[1], m_layers_z_range[1])) +#else if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_travel_in_z_range(path_id, m_layers_z_range[1], m_layers_z_range[1])) +#endif // ENABLE_SEQUENTIAL_VSLIDER color = (m_view_type == EViewType::Feedrate || m_view_type == EViewType::Tool || m_view_type == EViewType::ColorPrint) ? extrusion_color(path) : travel_color(path); else color = { 0.25f, 0.25f, 0.25f }; diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 3ed7cb5b2..5d996566f 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -304,6 +304,7 @@ class GCodeViewer const std::vector& get_zs() const { return m_zs; } const std::vector& get_endpoints() const { return m_endpoints; } std::vector& get_endpoints() { return m_endpoints; } + double get_z_at(unsigned int id) const { return (id < m_zs.size()) ? m_zs[id] : 0.0; } Endpoints get_endpoints_at(unsigned int id) const { return (id < m_endpoints.size()) ? m_endpoints[id] : Endpoints(); } }; #endif // ENABLE_SEQUENTIAL_VSLIDER @@ -435,11 +436,11 @@ private: std::vector m_tool_colors; #if ENABLE_SEQUENTIAL_VSLIDER Layers m_layers; - std::array m_layers_z_range_2; + std::array m_layers_z_range; #else std::vector m_layers_zs; -#endif // ENABLE_SEQUENTIAL_VSLIDER std::array m_layers_z_range; +#endif // ENABLE_SEQUENTIAL_VSLIDER std::vector m_roles; size_t m_extruders_count; std::vector m_extruder_ids; From 0688a76c73e3a78dcd76005dd400209d5f63fa4a Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 13 Nov 2020 11:50:52 +0100 Subject: [PATCH 3/3] Code cleanup --- src/libslic3r/Technologies.hpp | 7 -- src/slic3r/GUI/GCodeViewer.cpp | 142 --------------------------------- src/slic3r/GUI/GCodeViewer.hpp | 15 ---- src/slic3r/GUI/GLCanvas3D.cpp | 10 +-- src/slic3r/GUI/GLCanvas3D.hpp | 6 +- src/slic3r/GUI/GUI_Preview.cpp | 6 +- 6 files changed, 6 insertions(+), 180 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index aa1889435..a5d2d4682 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -65,11 +65,4 @@ #define ENABLE_CTRL_M_ON_WINDOWS (0 && ENABLE_2_3_0_ALPHA3) -//=================== -// 2.3.0.alpha4 techs -//=================== -#define ENABLE_2_3_0_ALPHA4 1 - -#define ENABLE_SEQUENTIAL_VSLIDER (1 && ENABLE_GCODE_VIEWER && ENABLE_2_3_0_ALPHA4) - #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 87a5a944d..383ef5eb0 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -300,13 +300,8 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print& reset(); load_toolpaths(gcode_result); -#if ENABLE_SEQUENTIAL_VSLIDER if (m_layers.empty()) return; -#else - if (m_layers_zs.empty()) - return; -#endif // ENABLE_SEQUENTIAL_VSLIDER m_settings_ids = gcode_result.settings_ids; @@ -433,13 +428,8 @@ void GCodeViewer::reset() m_extrusions.reset_role_visibility_flags(); m_extrusions.reset_ranges(); m_shells.volumes.clear(); -#if ENABLE_SEQUENTIAL_VSLIDER m_layers.reset(); m_layers_z_range = { 0, 0 }; -#else - m_layers_zs = std::vector(); - m_layers_z_range = { 0.0, 0.0 }; -#endif // ENABLE_SEQUENTIAL_VSLIDER m_roles = std::vector(); m_time_statistics.reset(); m_time_estimate_mode = PrintEstimatedTimeStatistics::ETimeMode::Normal; @@ -609,7 +599,6 @@ void GCodeViewer::set_options_visibility_from_flags(unsigned int flags) enable_legend(is_flag_set(static_cast(Preview::OptionType::Legend))); } -#if ENABLE_SEQUENTIAL_VSLIDER void GCodeViewer::set_layers_z_range(const std::array& layers_z_range) { bool keep_sequential_current_first = layers_z_range[0] >= m_layers_z_range[0]; @@ -618,16 +607,6 @@ void GCodeViewer::set_layers_z_range(const std::array& layers_z refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last); wxGetApp().plater()->update_preview_moves_slider(); } -#else -void GCodeViewer::set_layers_z_range(const std::array& layers_z_range) -{ - bool keep_sequential_current_first = layers_z_range[0] >= m_layers_z_range[0]; - bool keep_sequential_current_last = layers_z_range[1] <= m_layers_z_range[1]; - m_layers_z_range = layers_z_range; - refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last); - wxGetApp().plater()->update_preview_moves_slider(); -} -#endif // ENABLE_SEQUENTIAL_VSLIDER void GCodeViewer::export_toolpaths_to_obj(const char* filename) const { @@ -1552,7 +1531,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) // dismiss indices data, no more needed std::vector().swap(indices); -#if ENABLE_SEQUENTIAL_VSLIDER // layers zs / roles / extruder ids / cp color ids -> extract from result size_t last_travel_s_id = 0; for (size_t i = 0; i < m_moves_count; ++i) { @@ -1583,43 +1561,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) if (!m_layers.empty()) { m_layers_z_range = { 0, static_cast(m_layers.size() - 1) }; } -#else - // layers zs -> extract from result - for (const Path& path : m_buffers[buffer_id(EMoveType::Extrude)].paths) { - m_layers_zs.emplace_back(static_cast(path.first.position[2])); -// m_layers_zs.emplace_back(static_cast(path.last.position[2])); - } - - // roles / extruder ids / cp color ids -> extract from result - for (size_t i = 0; i < m_moves_count; ++i) { - const GCodeProcessor::MoveVertex& move = gcode_result.moves[i]; - m_extruder_ids.emplace_back(move.extruder_id); - if (i > 0) - m_roles.emplace_back(move.extrusion_role); - } - - - // layers zs -> replace intervals of layers with similar top positions with their average value. - std::sort(m_layers_zs.begin(), m_layers_zs.end()); - int n = int(m_layers_zs.size()); - int k = 0; - for (int i = 0; i < n;) { - int j = i + 1; - double zmax = m_layers_zs[i] + EPSILON; - for (; j < n && m_layers_zs[j] <= zmax; ++j); - m_layers_zs[k++] = (j > i + 1) ? (0.5 * (m_layers_zs[i] + m_layers_zs[j - 1])) : m_layers_zs[i]; - i = j; - } - if (k < n) { - m_layers_zs.erase(m_layers_zs.begin() + k, m_layers_zs.end()); - m_layers_zs.shrink_to_fit(); - } - - - // set layers z range - if (!m_layers_zs.empty()) - m_layers_z_range = { m_layers_zs.front(), m_layers_zs.back() }; -#endif // ENABLE_SEQUENTIAL_VSLIDER // roles -> remove duplicates std::sort(m_roles.begin(), m_roles.end()); @@ -1728,7 +1669,6 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool Travel_Colors[0] /* Move */); }; -#if ENABLE_SEQUENTIAL_VSLIDER auto is_in_layers_range = [this](const Path& path, size_t min_id, size_t max_id) { auto in_layers_range = [this, min_id, max_id](size_t id) { return m_layers.get_endpoints_at(min_id).first <= id && id <= m_layers.get_endpoints_at(max_id).last; @@ -1736,17 +1676,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool return in_layers_range(path.first.s_id) || in_layers_range(path.last.s_id); }; -#else - auto is_in_z_range = [](const Path& path, double min_z, double max_z) { - auto in_z_range = [min_z, max_z](double z) { - return min_z - EPSILON < z && z < max_z + EPSILON; - }; - return in_z_range(path.first.position[2]) || in_z_range(path.last.position[2]); - }; -#endif // ENABLE_SEQUENTIAL_VSLIDER - -#if ENABLE_SEQUENTIAL_VSLIDER auto is_travel_in_layers_range = [this](size_t path_id, size_t min_id, size_t max_id) { auto is_in_z_range = [](const Path& path, double min_z, double max_z) { auto in_z_range = [min_z, max_z](double z) { @@ -1780,29 +1710,6 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool return (min_s_id <= path.first.s_id && path.first.s_id <= max_s_id) || (min_s_id <= path.last.s_id && path.last.s_id <= max_s_id); }; -#else - auto is_travel_in_z_range = [this, is_in_z_range](size_t path_id, double min_z, double max_z) { - const TBuffer& buffer = m_buffers[buffer_id(EMoveType::Travel)]; - if (path_id >= buffer.paths.size()) - return false; - - Path path = buffer.paths[path_id]; - int first = static_cast(path_id); - unsigned int last = static_cast(path_id); - - // check adjacent paths - while (first > 0 && path.first.position.isApprox(buffer.paths[first - 1].last.position)) { - --first; - path.first = buffer.paths[first].first; - } - while (last < static_cast(buffer.paths.size() - 1) && path.last.position.isApprox(buffer.paths[last + 1].first.position)) { - ++last; - path.last = buffer.paths[last].last; - } - - return is_in_z_range(path, min_z, max_z); - }; -#endif // ENABLE_SEQUENTIAL_VSLIDER #if ENABLE_GCODE_VIEWER_STATISTICS m_statistics.render_paths_size = 0; @@ -1827,21 +1734,11 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool for (size_t i = 0; i < buffer.paths.size(); ++i) { const Path& path = buffer.paths[i]; if (path.type == EMoveType::Travel) { -#if ENABLE_SEQUENTIAL_VSLIDER if (!is_travel_in_layers_range(i, m_layers_z_range[0], m_layers_z_range[1])) continue; -#else - if (!is_travel_in_z_range(i, m_layers_z_range[0], m_layers_z_range[1])) - continue; -#endif // ENABLE_SEQUENTIAL_VSLIDER } -#if ENABLE_SEQUENTIAL_VSLIDER else if (!is_in_layers_range(path, m_layers_z_range[0], m_layers_z_range[1])) continue; -#else - else if (!is_in_z_range(path, m_layers_z_range[0], m_layers_z_range[1])) - continue; -#endif // ENABLE_SEQUENTIAL_VSLIDER if (path.type == EMoveType::Extrude && !is_visible(path)) continue; @@ -1854,29 +1751,15 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool if (top_layer_only) { if (path.type == EMoveType::Travel) { -#if ENABLE_SEQUENTIAL_VSLIDER if (is_travel_in_layers_range(i, m_layers_z_range[1], m_layers_z_range[1])) { top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); } -#else - if (is_travel_in_z_range(i, m_layers_z_range[1], m_layers_z_range[1])) { - top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); - top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); - } -#endif // ENABLE_SEQUENTIAL_VSLIDER } -#if ENABLE_SEQUENTIAL_VSLIDER else if (is_in_layers_range(path, m_layers_z_range[1], m_layers_z_range[1])) { top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); } -#else - else if (is_in_z_range(path, m_layers_z_range[1], m_layers_z_range[1])) { - top_layer_endpoints.first = std::min(top_layer_endpoints.first, path.first.s_id); - top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.last.s_id); - } -#endif // ENABLE_SEQUENTIAL_VSLIDER } } } @@ -1930,13 +1813,9 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool switch (path.type) { case EMoveType::Extrude: { -#if ENABLE_SEQUENTIAL_VSLIDER if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_in_layers_range(path, m_layers_z_range[1], m_layers_z_range[1])) -#else - if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_in_z_range(path, m_layers_z_range[1], m_layers_z_range[1])) -#endif // ENABLE_SEQUENTIAL_VSLIDER color = extrusion_color(path); else color = { 0.25f, 0.25f, 0.25f }; @@ -1944,11 +1823,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool break; } case EMoveType::Travel: { -#if ENABLE_SEQUENTIAL_VSLIDER if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_travel_in_layers_range(path_id, m_layers_z_range[1], m_layers_z_range[1])) -#else - if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last || is_travel_in_z_range(path_id, m_layers_z_range[1], m_layers_z_range[1])) -#endif // ENABLE_SEQUENTIAL_VSLIDER color = (m_view_type == EViewType::Feedrate || m_view_type == EViewType::Tool || m_view_type == EViewType::ColorPrint) ? extrusion_color(path) : travel_color(path); else color = { 0.25f, 0.25f, 0.25f }; @@ -2334,23 +2209,13 @@ void GCodeViewer::render_legend() const if (item.type != ColorChange) continue; -#if ENABLE_SEQUENTIAL_VSLIDER const std::vector zs = m_layers.get_zs(); auto lower_b = std::lower_bound(zs.begin(), zs.end(), item.print_z - Slic3r::DoubleSlider::epsilon()); if (lower_b == zs.end()) continue; -#else - auto lower_b = std::lower_bound(m_layers_zs.begin(), m_layers_zs.end(), item.print_z - Slic3r::DoubleSlider::epsilon()); - if (lower_b == m_layers_zs.end()) - continue; -#endif // ENABLE_SEQUENTIAL_VSLIDER double current_z = *lower_b; -#if ENABLE_SEQUENTIAL_VSLIDER double previous_z = (lower_b == zs.begin()) ? 0.0 : *(--lower_b); -#else - double previous_z = lower_b == m_layers_zs.begin() ? 0.0 : *(--lower_b); -#endif // ENABLE_SEQUENTIAL_VSLIDER // to avoid duplicate values, check adding values if (ret.empty() || !(ret.back().second.first == previous_z && ret.back().second.second == current_z)) @@ -2941,18 +2806,11 @@ void GCodeViewer::log_memory_used(const std::string& label, long long additional render_paths_size += SLIC3R_STDVEC_MEMSIZE(path.offsets, size_t); } } -#if ENABLE_SEQUENTIAL_VSLIDER long long layers_size = SLIC3R_STDVEC_MEMSIZE(m_layers.get_zs(), double); layers_size += SLIC3R_STDVEC_MEMSIZE(m_layers.get_endpoints(), Layers::Endpoints); BOOST_LOG_TRIVIAL(trace) << label << format_memsize_MB(additional + paths_size + render_paths_size + layers_size) << log_memory_info(); -#else - long long layers_zs_size = SLIC3R_STDVEC_MEMSIZE(m_layers_zs, double); - BOOST_LOG_TRIVIAL(trace) << label - << format_memsize_MB(additional + paths_size + render_paths_size + layers_zs_size) - << log_memory_info(); -#endif // ENABLE_SEQUENTIAL_VSLIDER } } diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 5d996566f..639a5b430 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -272,7 +272,6 @@ class GCodeViewer void reset_ranges() { ranges.reset(); } }; -#if ENABLE_SEQUENTIAL_VSLIDER class Layers { public: @@ -307,7 +306,6 @@ class GCodeViewer double get_z_at(unsigned int id) const { return (id < m_zs.size()) ? m_zs[id] : 0.0; } Endpoints get_endpoints_at(unsigned int id) const { return (id < m_endpoints.size()) ? m_endpoints[id] : Endpoints(); } }; -#endif // ENABLE_SEQUENTIAL_VSLIDER #if ENABLE_GCODE_VIEWER_STATISTICS struct Statistics @@ -434,13 +432,8 @@ private: // bounding box of toolpaths + marker tools BoundingBoxf3 m_max_bounding_box; std::vector m_tool_colors; -#if ENABLE_SEQUENTIAL_VSLIDER Layers m_layers; std::array m_layers_z_range; -#else - std::vector m_layers_zs; - std::array m_layers_z_range; -#endif // ENABLE_SEQUENTIAL_VSLIDER std::vector m_roles; size_t m_extruders_count; std::vector m_extruder_ids; @@ -473,11 +466,7 @@ public: const BoundingBoxf3& get_paths_bounding_box() const { return m_paths_bounding_box; } const BoundingBoxf3& get_max_bounding_box() const { return m_max_bounding_box; } -#if ENABLE_SEQUENTIAL_VSLIDER const std::vector& get_layers_zs() const { return m_layers.get_zs(); }; -#else - const std::vector& get_layers_zs() const { return m_layers_zs; }; -#endif // ENABLE_SEQUENTIAL_VSLIDER const SequentialView& get_sequential_view() const { return m_sequential_view; } void update_sequential_view_current(unsigned int first, unsigned int last); @@ -496,11 +485,7 @@ public: void set_toolpath_role_visibility_flags(unsigned int flags) { m_extrusions.role_visibility_flags = flags; } unsigned int get_options_visibility_flags() const; void set_options_visibility_from_flags(unsigned int flags); -#if ENABLE_SEQUENTIAL_VSLIDER void set_layers_z_range(const std::array& layers_z_range); -#else - void set_layers_z_range(const std::array& layers_z_range); -#endif // ENABLE_SEQUENTIAL_VSLIDER bool is_legend_enabled() const { return m_legend_enabled; } void enable_legend(bool enable) { m_legend_enabled = enable; } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 2df3b1bd3..495c165b5 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2176,22 +2176,16 @@ void GLCanvas3D::set_toolpath_view_type(GCodeViewer::EViewType type) m_gcode_viewer.set_view_type(type); } -void GLCanvas3D::set_toolpaths_z_range(const std::array& range) +void GLCanvas3D::set_volumes_z_range(const std::array& range) { m_volumes.set_range(range[0] - 1e-6, range[1] + 1e-6); -#if !ENABLE_SEQUENTIAL_VSLIDER - if (m_gcode_viewer.has_data()) - m_gcode_viewer.set_layers_z_range(range); -#endif // !ENABLE_SEQUENTIAL_VSLIDER } -#if ENABLE_SEQUENTIAL_VSLIDER -void GLCanvas3D::set_toolpaths_z_range_2(const std::array& range) +void GLCanvas3D::set_toolpaths_z_range(const std::array& range) { if (m_gcode_viewer.has_data()) m_gcode_viewer.set_layers_z_range(range); } -#endif // ENABLE_SEQUENTIAL_VSLIDER #else std::vector GLCanvas3D::get_current_print_zs(bool active_only) const { diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 667243133..cc3971c17 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -651,10 +651,8 @@ public: unsigned int get_toolpath_role_visibility_flags() const { return m_gcode_viewer.get_toolpath_role_visibility_flags(); } void set_toolpath_role_visibility_flags(unsigned int flags); void set_toolpath_view_type(GCodeViewer::EViewType type); - void set_toolpaths_z_range(const std::array& range); -#if ENABLE_SEQUENTIAL_VSLIDER - void set_toolpaths_z_range_2(const std::array& range); -#endif // ENABLE_SEQUENTIAL_VSLIDER + void set_volumes_z_range(const std::array& range); + void set_toolpaths_z_range(const std::array& range); #else std::vector get_current_print_zs(bool active_only) const; #endif // ENABLE_GCODE_VIEWER diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 3f31df3ce..c108f6946 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -1428,10 +1428,8 @@ void Preview::on_sliders_scroll_changed(wxCommandEvent& event) PrinterTechnology tech = m_process->current_printer_technology(); if (tech == ptFFF) { #if ENABLE_GCODE_VIEWER - m_canvas->set_toolpaths_z_range({ m_layers_slider->GetLowerValueD(), m_layers_slider->GetHigherValueD() }); -#if ENABLE_SEQUENTIAL_VSLIDER - m_canvas->set_toolpaths_z_range_2({ static_cast(m_layers_slider->GetLowerValue()), static_cast(m_layers_slider->GetHigherValue()) }); -#endif // ENABLE_SEQUENTIAL_VSLIDER + m_canvas->set_volumes_z_range({ m_layers_slider->GetLowerValueD(), m_layers_slider->GetHigherValueD() }); + m_canvas->set_toolpaths_z_range({ static_cast(m_layers_slider->GetLowerValue()), static_cast(m_layers_slider->GetHigherValue()) }); m_canvas->set_as_dirty(); #else m_canvas->set_toolpaths_range(m_slider->GetLowerValueD() - 1e-6, m_slider->GetHigherValueD() + 1e-6);