From 559173c2a11c93ee3b2307e5cf5fcc9395978e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Althaus?= Date: Sun, 10 Jul 2022 13:19:38 +0200 Subject: [PATCH] Don't change to color print view when no color change gcodes are set When changing custom gcodes the view type is always changed to color view when any custom gcode is set. This fix only changes to color view when the custom gcodes contain at least one color change. Fixes #8413 and #5837 --- src/slic3r/GUI/GUI_Preview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 7ee4e7955..9e2fe46f6 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -1011,8 +1011,10 @@ void Preview::load_print_as_fff(bool keep_z_range) std::vector gcodes = wxGetApp().is_editor() ? wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes : m_canvas->get_custom_gcode_per_print_z(); + const bool contains_color_gcodes = std::any_of(std::begin(gcodes), std::end(gcodes), + [] (auto const& item) { return item.type == CustomGCode::Type::ColorChange; }); #if ENABLE_PREVIEW_LAYOUT - const GCodeViewer::EViewType choice = !gcodes.empty() ? + const GCodeViewer::EViewType choice = contains_color_gcodes ? GCodeViewer::EViewType::ColorPrint : (number_extruders > 1) ? GCodeViewer::EViewType::Tool : GCodeViewer::EViewType::FeatureType; if (choice != gcode_view_type) { @@ -1022,7 +1024,7 @@ void Preview::load_print_as_fff(bool keep_z_range) refresh_print(); } #else - const wxString choice = !gcodes.empty() ? + const wxString choice = contains_color_gcodes ? _L("Color Print") : (number_extruders > 1) ? _L("Tool") : _L("Feature type"); int type = m_choice_view_type->FindString(choice);