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

jira: STUDIO-11141

Change-Id: I1c8eb3234401ee64576212a08764170577855a8c
This commit is contained in:
jun.zhang 2025-03-28 11:38:00 +08:00 committed by lane.wei
parent 7f91cd2349
commit 2c718bb376
1 changed files with 13 additions and 13 deletions

View File

@ -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);
}
}
}
}
}