Fix defaulting to filament preview when multiple tools are available but only 1 is used (#11734)
Some checks are pending
Build all / Build Linux (push) Waiting to run
Build all / Build Non-Linux (push) Waiting to run
Build all / Unit Tests (push) Blocked by required conditions
Build all / Flatpak (push) Waiting to run

This commit is contained in:
Ioannis Giannakas 2025-12-24 14:50:48 +02:00 committed by GitHub
parent 2a0cfdb356
commit 2026a0cf0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -868,24 +868,13 @@ void GCodeViewer::init(ConfigOptionMode mode, PresetBundle* preset_bundle)
m_gl_data_initialized = true;
if (preset_bundle)
m_nozzle_nums = preset_bundle->get_printer_extruder_count();
bool multimaterial = preset_bundle->filament_presets.empty() ? 0 : preset_bundle->filament_presets.size() > 1;
// set to color print by default if use multi extruders
if (m_nozzle_nums > 1) {
m_view_type_sel = std::distance(view_type_items.begin(),
std::find(view_type_items.begin(), view_type_items.end(), EViewType::Summary));
set_view_type(EViewType::Summary);
} else if (multimaterial) {
m_view_type_sel = std::distance(view_type_items.begin(),
std::find(view_type_items.begin(), view_type_items.end(), EViewType::ColorPrint));
set_view_type(EViewType::ColorPrint);
} else {
m_view_type_sel = std::distance(view_type_items.begin(),
std::find(view_type_items.begin(), view_type_items.end(), EViewType::FeatureType));
set_view_type(EViewType::FeatureType);
}
// Orca:
// Default view type at first slice.
// May be overridden in load() once we know how many tools are actually used in the G-code.
m_nozzle_nums = preset_bundle ? preset_bundle->get_printer_extruder_count() : 1;
auto it = std::find(view_type_items.begin(), view_type_items.end(), EViewType::FeatureType);
m_view_type_sel = (it != view_type_items.end()) ? std::distance(view_type_items.begin(), it) : 0;
set_view_type(EViewType::FeatureType);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": finished");
}
@ -995,6 +984,20 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
m_max_print_height = gcode_result.printable_height;
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_extruder_ids.size() > 1) {
auto it = std::find(view_type_items.begin(), view_type_items.end(), EViewType::ColorPrint);
if (it != view_type_items.end())
m_view_type_sel = std::distance(view_type_items.begin(), it);
set_view_type(EViewType::ColorPrint);
} else if (m_view_type == EViewType::ColorPrint) {
auto it = std::find(view_type_items.begin(), view_type_items.end(), EViewType::FeatureType);
if (it != view_type_items.end())
m_view_type_sel = std::distance(view_type_items.begin(), it);
set_view_type(EViewType::FeatureType);
}
// BBS: data for rendering color arrangement recommendation
m_nozzle_nums = print.config().option<ConfigOptionFloats>("nozzle_diameter")->values.size();