From b0c1887f40180bd6b5bc572ac94968b0987363c2 Mon Sep 17 00:00:00 2001 From: Allyn Malventano Date: Tue, 16 Jun 2026 07:15:00 -0700 Subject: [PATCH] fix: persist user-selected preview view mode after first load (#13625) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: apply smart preview defaults per extruder count session - Track last extruder count (1=single, 2+=multi) instead of boolean flag - Apply appropriate default (ColorPrint/FeatureType) when count changes - User selections persist within same extruder count - Symmetric behavior: both single and multi actively apply defaults - Delete duplicate dead code block (uncommented TODO scaffolding) Behavior: - First slice (any type) → appropriate default - User changes view → persists on re-slice - Switch single→single or multi→multi → persists - Switch single↔multi → appropriate default applies --- src/slic3r/GUI/GCodeViewer.cpp | 44 ++++++++++++++++------------------ src/slic3r/GUI/GCodeViewer.hpp | 1 + 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 79afc1daaf..81151a5a5d 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1344,18 +1344,26 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const // load_toolpaths(gcode_result, build_volume, exclude_bounding_box); - // ORCA: Only show filament/color print preview if more than one tool/extruder is actually used in the toolpaths. - // Only reset back to Toolpaths (FeatureType) if we are currently in ColorPrint and this load is single-tool. - if (m_viewer.get_used_extruders_count() > 1) { - auto it = std::find(view_type_items.begin(), view_type_items.end(), libvgcode::EViewType::ColorPrint); - if (it != view_type_items.end()) - m_view_type_sel = std::distance(view_type_items.begin(), it); - set_view_type(libvgcode::EViewType::ColorPrint); - } else if (get_view_type() == libvgcode::EViewType::ColorPrint) { - auto it = std::find(view_type_items.begin(), view_type_items.end(), libvgcode::EViewType::FeatureType); - if (it != view_type_items.end()) - m_view_type_sel = std::distance(view_type_items.begin(), it); - set_view_type(libvgcode::EViewType::FeatureType); + // ORCA: Apply smart default view type when extruder count changes. + // Multi-color: ColorPrint (Filament), Single-color: FeatureType (Line Type). + // User selections persist within same extruder count, defaults reapply on count change. + int current_count = m_viewer.get_used_extruders_count(); + if (current_count > 1) { + if (m_last_extruder_count_default_applied != 2) { + auto it = std::find(view_type_items.begin(), view_type_items.end(), libvgcode::EViewType::ColorPrint); + if (it != view_type_items.end()) + m_view_type_sel = std::distance(view_type_items.begin(), it); + set_view_type(libvgcode::EViewType::ColorPrint); + m_last_extruder_count_default_applied = 2; + } + } else { + if (m_last_extruder_count_default_applied != 1) { + auto it = std::find(view_type_items.begin(), view_type_items.end(), libvgcode::EViewType::FeatureType); + if (it != view_type_items.end()) + m_view_type_sel = std::distance(view_type_items.begin(), it); + set_view_type(libvgcode::EViewType::FeatureType); + m_last_extruder_count_default_applied = 1; + } } // BBS: data for rendering color arrangement recommendation @@ -1455,18 +1463,6 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const m_viewer.set_time_mode(libvgcode::convert(PrintEstimatedStatistics::ETimeMode::Normal)); } - // set to color print by default if use multi extruders - if (m_viewer.get_used_extruders_count() > 1) { - for (int i = 0; i < view_type_items.size(); i++) { - if (view_type_items[i] == libvgcode::EViewType::ColorPrint) { - m_view_type_sel = i; - break; - } - } - - set_view_type(libvgcode::EViewType::ColorPrint); - } - bool only_gcode_3mf = false; PartPlate* current_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate(); bool current_has_print_instances = current_plate->has_printable_instances(); diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 600c59d829..4958fc25a8 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -226,6 +226,7 @@ private: std::vector view_type_items; std::vector view_type_items_str; int m_view_type_sel = 0; + int m_last_extruder_count_default_applied{0}; // 0=unset, 1=single, 2+=multi std::vector options_items; bool m_legend_visible{ true };