diff --git a/src/libslic3r/Extruder.cpp b/src/libslic3r/Extruder.cpp index 2abe138b3..f8cba0d0b 100644 --- a/src/libslic3r/Extruder.cpp +++ b/src/libslic3r/Extruder.cpp @@ -18,6 +18,11 @@ Extruder::Extruder(unsigned int id, GCodeConfig *config, bool share_extruder) : m_e_per_mm3 /= this->filament_crossection(); } +unsigned int Extruder::extruder_id() const +{ + return get_extruder_index(m_id); +} + double Extruder::extrude(double dE) { // BBS diff --git a/src/libslic3r/Extruder.hpp b/src/libslic3r/Extruder.hpp index 4bf74389f..123bfc87f 100644 --- a/src/libslic3r/Extruder.hpp +++ b/src/libslic3r/Extruder.hpp @@ -30,13 +30,7 @@ public: unsigned int id() const { return m_id; } - unsigned int extruder_id() const - { - //TODO: get extruder id - unsigned int extruder_id = -1; - // get matched id - return extruder_id; - } + unsigned int extruder_id() const; double extrude(double dE); double retract(double length, double restart_extra); double unretract(); diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 751248ceb..c0daca1b1 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -375,7 +375,7 @@ static std::vector get_path_of_change_filament(const Print& print) if (new_filament_id != -1 && new_filament_id != tcr.new_tool) throw Slic3r::InvalidArgument("Error: WipeTowerIntegration::append_tcr was asked to do a toolchange it didn't expect."); - int new_extruder_id = gcodegen.get_extruder_id(new_filament_id); + int new_extruder_id = get_extruder_index(new_filament_id); std::string gcode; // Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines) @@ -1865,10 +1865,10 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato m_cooling_buffer = make_unique(*this); m_cooling_buffer->set_current_extruder(initial_extruder_id); - int extruder_id = get_extruder_id(initial_extruder_id); + int extruder_id = get_extruder_index(initial_extruder_id); // Emit machine envelope limits for the Marlin firmware. - this->print_machine_envelope(file, print); + this->print_machine_envelope(file, print, initial_extruder_id); // Disable fan. if (print.config().close_fan_the_first_x_layers.get_at(initial_extruder_id)) { @@ -5296,7 +5296,7 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li std::string GCode::set_extruder(unsigned int filament_id, double print_z, bool by_object) { - int extruder_id = get_extruder_id(filament_id); + int extruder_id = get_extruder_index(filament_id); if (!m_writer.need_toolchange(filament_id)) return ""; diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index f99a63a98..47e63c9db 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -171,11 +171,6 @@ public: // throws std::runtime_exception on error, // throws CanceledException through print->throw_if_canceled(). void do_export(Print* print, const char* path, GCodeProcessorResult* result = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr); - int get_extruder_id(unsigned int) { - //TODO: get matched extruder - int extruder_id = -1; - return extruder_id; - }; //BBS: set offset for gcode writer void set_gcode_offset(double x, double y) { m_writer.set_xy_offset(x, y); m_processor.set_xy_offset(x, y);} diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index d914efef4..2d32c5c51 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -1990,6 +1990,12 @@ DynamicPrintConfig PresetBundle::full_fff_config() const // BBS size_t num_filaments = this->filament_presets.size(); + + // todo multi_extruders: to delete + for (size_t i = 0; i < num_filaments; ++i) { + this->filament_maps.push_back(1); + } + auto* extruder_diameter = dynamic_cast(out.option("nozzle_diameter")); // Collect the "compatible_printers_condition" and "inherits" values over all presets (print, filaments, printers) into a single vector. std::vector compatible_printers_condition; diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 5e7f64ecb..0942e45ea 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -125,7 +125,8 @@ public: std::map filament_ams_list; std::vector> ams_multi_color_filment; - std::vector filament_maps; + // todo multi_extruders: delete mutable + mutable std::vector filament_maps; // Calibrate Preset const * calibrate_printer = nullptr; std::set calibrate_filaments; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 704222325..d25d2121e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -54,6 +54,12 @@ namespace Slic3r { #define L(s) (s) #define _(s) Slic3r::I18N::translate(s) +size_t get_extruder_index(unsigned int filament_id) +{ + // todo multi_extruders: + return 0; +} + static t_config_enum_names enum_names_from_keys_map(const t_config_enum_values &enum_keys_map) { t_config_enum_names names; @@ -5378,13 +5384,14 @@ bool DynamicPrintConfig::support_different_extruders(int& extruder_count) int size = nozzle_diameters_opt->size(); extruder_count = size; auto extruder_variant_opt = dynamic_cast(this->option("extruder_variant_list")); - for (int index = 0; index < size; index++) - { - std::string variant = extruder_variant_opt->get_at(index); - std::vector variants_list; - boost::split(variants_list, variant, boost::is_any_of(","), boost::token_compress_on); - if (!variants_list.empty()) - variant_set.insert(variants_list.begin(), variants_list.end()); + if (extruder_variant_opt != nullptr) { + for (int index = 0; index < size; index++) { + std::string variant = extruder_variant_opt->get_at(index); + std::vector variants_list; + boost::split(variants_list, variant, boost::is_any_of(","), boost::token_compress_on); + if (!variants_list.empty()) + variant_set.insert(variants_list.begin(), variants_list.end()); + } } } diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index cec514242..846112cb2 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -364,11 +364,7 @@ static std::string get_bed_temp_1st_layer_key(const BedType type) return ""; } -static size_t get_extruder_index(unsigned int filament_id) -{ - // todo: - return 0; -} +size_t get_extruder_index(unsigned int filament_id); #define CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(NAME) \ template<> const t_config_enum_names& ConfigOptionEnum::get_enum_names(); \ diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 86bbc4373..29321795a 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -714,6 +714,7 @@ bool PrintObject::invalidate_state_by_config_options( steps.emplace_back(posPerimeters); } else if (opt_key == "gap_infill_speed" || opt_key == "filter_out_gap_fill") { // Return true if gap-fill speed has changed from zero value to non-zero or from non-zero value to zero. + // todo multi_extruders: Parameter migration between single and double extruder printers auto is_gap_fill_changed_state_due_to_speed = [&opt_key, &old_config, &new_config]() -> bool { if (opt_key == "gap_infill_speed") { const auto *old_gap_fill_speed = old_config.option(opt_key);