From e8ba79a0ad0859ccc794c598ccdc177931d52509 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 21 Sep 2023 13:59:45 +0200 Subject: [PATCH] SPE-1908: Fixed travel moves starting above the top layer not shown in preview --- src/slic3r/GUI/GCodeViewer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 5cc55be5ff..66670e8239 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -505,7 +505,7 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s } if (ftell(file.f) == file_size) - break; + break; res = read_next_block_header(*file.f, file_header, block_header, nullptr, 0); if (res != EResult::Success || block_header.type != (uint16_t)EBlockType::GCode) { @@ -2540,8 +2540,11 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool const size_t min_s_id = m_layers.get_range_at(min_id).first; const size_t max_s_id = m_layers.get_range_at(max_id).last; - return (min_s_id <= path.sub_paths.front().first.s_id && path.sub_paths.front().first.s_id <= max_s_id) || - (min_s_id <= path.sub_paths.back().last.s_id && path.sub_paths.back().last.s_id <= max_s_id); + const bool top_layer_shown = max_id == m_layers.size() - 1; + + return (min_s_id <= path.sub_paths.front().first.s_id && path.sub_paths.front().first.s_id <= max_s_id) || // the leading vertex is contained + (min_s_id <= path.sub_paths.back().last.s_id && path.sub_paths.back().last.s_id <= max_s_id) || // the trailing vertex is contained + (top_layer_shown && max_s_id < path.sub_paths.front().first.s_id); // the leading vertex is above the top layer and the top layer is shown }; #if ENABLE_GCODE_VIEWER_STATISTICS