From 2c718bb376c4d26249f1942e9f076bf6e99d9f23 Mon Sep 17 00:00:00 2001 From: "jun.zhang" Date: Fri, 28 Mar 2025 11:38:00 +0800 Subject: [PATCH] FIX: gcode viewer: always update top_layer_endpoints if top_layer_only is enabled jira: STUDIO-11141 Change-Id: I1c8eb3234401ee64576212a08764170577855a8c --- src/slic3r/GUI/GCodeViewer.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 392106145..f89079331 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -3478,6 +3478,19 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool else if (!is_in_layers_range(path, m_layers_z_range[0], m_layers_z_range[1])) continue; + if (top_layer_only) { + if (path.type == EMoveType::Travel) { + 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.sub_paths.front().first.s_id); + top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.sub_paths.back().last.s_id); + } + } + 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.sub_paths.front().first.s_id); + top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.sub_paths.back().last.s_id); + } + } + if (path.type == EMoveType::Extrude && !is_visible(path)) continue; @@ -3491,19 +3504,6 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool global_endpoints.first = std::min(global_endpoints.first, path.sub_paths.front().first.s_id); global_endpoints.last = std::max(global_endpoints.last, path.sub_paths.back().last.s_id); - - if (top_layer_only) { - if (path.type == EMoveType::Travel) { - 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.sub_paths.front().first.s_id); - top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.sub_paths.back().last.s_id); - } - } - 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.sub_paths.front().first.s_id); - top_layer_endpoints.last = std::max(top_layer_endpoints.last, path.sub_paths.back().last.s_id); - } - } } } }