diff --git a/src/slic3r/GUI/LibVGCode/ViewRange.cpp b/src/slic3r/GUI/LibVGCode/ViewRange.cpp index ec19d6cbf5..058e4bf243 100644 --- a/src/slic3r/GUI/LibVGCode/ViewRange.cpp +++ b/src/slic3r/GUI/LibVGCode/ViewRange.cpp @@ -14,8 +14,6 @@ #if ENABLE_NEW_GCODE_VIEWER //################################################################################################################################ -#include - namespace libvgcode { const std::array& ViewRange::get_current_range() const @@ -36,6 +34,7 @@ void ViewRange::set_current_range(const std::array& range) void ViewRange::set_current_range(uint32_t min, uint32_t max) { m_current.set(min, max); + // force the current range to stay inside the modified global range m_global.clamp(m_current); } @@ -56,14 +55,20 @@ void ViewRange::set_global_range(const std::array& range) void ViewRange::set_global_range(uint32_t min, uint32_t max) { + // is the global range being extended ? + const bool new_max = max > m_global.get()[1]; m_global.set(min, max); + // force the current range to stay inside the modified global range m_global.clamp(m_current); + if (new_max) + // force the current range to fill the extended global range + m_current.set(m_current.get()[0], max); } void ViewRange::reset() { m_global.reset(); - m_global.reset(); + m_current.reset(); } } // namespace libvgcode diff --git a/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp b/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp index 2c11f3c192..b8dc881abe 100644 --- a/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp +++ b/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp @@ -745,8 +745,11 @@ void ViewerImpl::update_enabled_entities() std::vector enabled_segments; std::vector enabled_options; - const std::array& current_range = m_view_range.get_current_range(); - for (uint32_t i = current_range[0]; i < current_range[1]; ++i) { + std::array range = m_view_range.get_current_range(); + if (m_settings.top_layer_only_view) + range[0] = m_view_range.get_global_range()[0]; + + for (uint32_t i = range[0]; i < range[1]; ++i) { const PathVertex& v = m_vertices[i]; if (!m_valid_lines_bitset[i] && !v.is_option()) @@ -820,8 +823,8 @@ void ViewerImpl::update_colors() const uint32_t top_layer_id = m_settings.top_layer_only_view ? m_layers_range.get()[1] : 0; std::vector colors(m_vertices.size()); for (size_t i = 0; i < m_vertices.size(); i++) { - colors[i] = (m_vertices[i].layer_id < top_layer_id) ? - encode_color(Dummy_Color) : encode_color(select_color(m_vertices[i])); + colors[i] = (m_vertices[i].layer_id < top_layer_id) ? + encode_color(Dummy_Color) : encode_color(select_color(m_vertices[i])); } // update gpu buffer for colors @@ -929,6 +932,7 @@ void ViewerImpl::set_layers_range(uint32_t min, uint32_t max) m_layers_range.set(min, max); m_settings.update_view_global_range = true; m_settings.update_enabled_entities = true; + m_settings.update_colors = true; } void ViewerImpl::set_top_layer_only_view(bool top_layer_only_view) @@ -1584,6 +1588,7 @@ void ViewerImpl::render_debug_window() imgui.end(); +/* auto to_string = [](EMoveType type) { switch (type) { @@ -1623,6 +1628,7 @@ void ViewerImpl::render_debug_window() ImGui::EndTable(); } imgui.end(); +*/ } #endif // ENABLE_NEW_GCODE_VIEWER_DEBUG