From 8c2f658c939b09c6c2e37d167e170e3847aa41e4 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Tue, 26 Nov 2024 19:47:25 +0800 Subject: [PATCH] FIX:add "check_objects_empty_and_gcode3mf" api jira: none Change-Id: I8ffa72f5898292dbb8c539b743acd18d12e8dbb7 (cherry picked from commit 3a233b06db4ab913143d552c2c554a8c664eba9b) --- src/slic3r/GUI/PartPlate.cpp | 45 ++++++++++++++++++------------------ src/slic3r/GUI/PartPlate.hpp | 1 + 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 664cc28db4..9b05eba4af 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -1392,14 +1392,9 @@ int PartPlate::picking_id_component(int idx) const std::vector PartPlate::get_extruders(bool conside_custom_gcode) const { std::vector plate_extruders; - // if gcode.3mf file - if (m_model->objects.empty()) { - for (int i = 0; i < slice_filaments_info.size(); i++) { - plate_extruders.push_back(slice_filaments_info[i].id + 1); - } - return plate_extruders; - } - + if (check_objects_empty_and_gcode3mf(plate_extruders)) { + return plate_extruders; + } // if 3mf file const DynamicPrintConfig& glb_config = wxGetApp().preset_bundle->prints.get_edited_preset().config; int glb_support_intf_extr = glb_config.opt_int("support_interface_filament"); @@ -1631,17 +1626,25 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D return plate_extruders; } +bool PartPlate::check_objects_empty_and_gcode3mf(std::vector &result) const +{ + if (m_model->objects.empty()) {//objects is empty + if (wxGetApp().plater()->is_gcode_3mf()) { // if gcode.3mf file + for (int i = 0; i < slice_filaments_info.size(); i++) { + result.push_back(slice_filaments_info[i].id + 1); + } + } + return true; + } + return false; +} + std::vector PartPlate::get_extruders_without_support(bool conside_custom_gcode) const { std::vector plate_extruders; - // if gcode.3mf file - if (m_model->objects.empty()) { - for (int i = 0; i < slice_filaments_info.size(); i++) { - plate_extruders.push_back(slice_filaments_info[i].id + 1); - } - return plate_extruders; - } - + if (check_objects_empty_and_gcode3mf(plate_extruders)) { + return plate_extruders; + } // if 3mf file const DynamicPrintConfig& glb_config = wxGetApp().preset_bundle->prints.get_edited_preset().config; @@ -1679,13 +1682,9 @@ std::vector PartPlate::get_extruders_without_support(bool conside_custom_gc std::vector PartPlate::get_used_extruders() { std::vector used_extruders; - // if gcode.3mf file - if (m_model->objects.empty()) { - for (int i = 0; i < slice_filaments_info.size(); i++) { - used_extruders.push_back(slice_filaments_info[i].id + 1); - } - return used_extruders; - } + if (check_objects_empty_and_gcode3mf(used_extruders)) { + return used_extruders; + } GCodeProcessorResult* result = get_slice_result(); if (!result) diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index 51f642f9dd..e33e0b5b25 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -320,6 +320,7 @@ public: Vec3d get_origin() { return m_origin; } Vec3d estimate_wipe_tower_size(const DynamicPrintConfig & config, const double w, const double d, int plate_extruder_size = 0, bool use_global_objects = false) const; arrangement::ArrangePolygon estimate_wipe_tower_polygon(const DynamicPrintConfig & config, int plate_index, int plate_extruder_size = 0, bool use_global_objects = false) const; + bool check_objects_empty_and_gcode3mf(std::vector &result) const; std::vector get_extruders(bool conside_custom_gcode = false) const; std::vector get_extruders_under_cli(bool conside_custom_gcode, DynamicPrintConfig& full_config) const; std::vector get_extruders_without_support(bool conside_custom_gcode = false) const;