FIX: gcode viewer: always update top_layer_endpoints if top_layer_only is enabled

jira: STUDIO-11141

Change-Id: I1c8eb3234401ee64576212a08764170577855a8c
(cherry picked from commit 2c718bb376c4d26249f1942e9f076bf6e99d9f23)
This commit is contained in:
jun.zhang
2025-03-28 11:38:00 +08:00
committed by Noisyfox
parent 38a71f527e
commit 649eacd801

View File

@@ -3367,6 +3367,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;
@@ -3380,19 +3393,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);
}
}
}
}
}