fix: persist user-selected preview view mode after first load (#13625)

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
This commit is contained in:
Allyn Malventano
2026-06-16 07:15:00 -07:00
committed by GitHub
parent e6f917d7c5
commit b0c1887f40
2 changed files with 21 additions and 24 deletions

View File

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

View File

@@ -226,6 +226,7 @@ private:
std::vector<libvgcode::EViewType> view_type_items;
std::vector<std::string> 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<EMoveType> options_items;
bool m_legend_visible{ true };