diff --git a/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp b/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp index b0666f7181..41239f3667 100644 --- a/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp +++ b/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp @@ -750,11 +750,18 @@ void ViewerImpl::update_enabled_entities() { std::vector enabled_segments; std::vector enabled_options; - std::array range = m_view_range.get_current_range(); + + // when top layer only visualization is enabled, we need to render + // all the toolpaths in the other layers as grayed, so extend the range + // to contain them if (m_settings.top_layer_only_view) range[0] = m_view_range.get_global_range()[0]; + // to show the options at the current tool marker position we need to extend the range by one extra step + if (m_vertices[range[1]].is_option()) + ++range[1]; + for (uint32_t i = range[0]; i < range[1]; ++i) { const PathVertex& v = m_vertices[i]; @@ -1013,11 +1020,16 @@ void ViewerImpl::set_view_current_range(uint32_t min, uint32_t max) ++max_id; } - if (max_id < m_vertices_map.size() - 1 && + // adjust the max id to take in account the 'phantom' vertices added in load() + if (max_id < static_cast(m_vertices_map.size() - 1) && m_vertices[max_id + 1].type == m_vertices[max_id].type && m_vertices_map[max_id + 1] == m_vertices_map[max_id]) ++max_id; + // we show the seams when the endpoint of a closed path is reached, so we need to increase the max id by one + if (max_id < static_cast(m_vertices.size() - 1) && m_vertices[max_id + 1].type == EMoveType::Seam) + ++max_id; + Range new_range; new_range.set(min_id, max_id);