From 6b09cfee71ae25d83523bb157545bb7bb0213a7c Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Thu, 6 Jun 2024 15:16:00 +0800 Subject: [PATCH] FIX: modify parameter type of process preset jira: none Change-Id: I5c973a29e5b983e3f480d55aeeb2b14d13e950ee --- src/libslic3r/Calib.cpp | 2 +- src/libslic3r/Calib.hpp | 4 +- src/libslic3r/Config.cpp | 59 ++++++++ src/libslic3r/Config.hpp | 18 ++- src/libslic3r/Fill/Fill.cpp | 6 +- src/libslic3r/GCode.cpp | 120 +++++++-------- src/libslic3r/GCode.hpp | 1 + src/libslic3r/GCode/CoolingBuffer.cpp | 2 +- src/libslic3r/GCode/WipeTower.cpp | 4 +- src/libslic3r/GCodeWriter.cpp | 20 +-- src/libslic3r/Layer.cpp | 6 +- src/libslic3r/Model.cpp | 27 ++-- src/libslic3r/MultiMaterialSegmentation.cpp | 2 +- src/libslic3r/PerimeterGenerator.cpp | 11 +- src/libslic3r/PlaceholderParser.cpp | 154 +++++++++++++------- src/libslic3r/PrintConfig.cpp | 117 +++++++-------- src/libslic3r/PrintConfig.hpp | 60 ++++---- src/slic3r/GUI/ConfigManipulation.cpp | 6 +- src/slic3r/GUI/GUI_Factories.cpp | 1 + src/slic3r/GUI/GUI_ObjectTable.cpp | 1 + src/slic3r/GUI/Plater.cpp | 5 +- src/slic3r/Utils/CalibUtils.cpp | 4 +- 22 files changed, 387 insertions(+), 243 deletions(-) diff --git a/src/libslic3r/Calib.cpp b/src/libslic3r/Calib.cpp index 933f646a9..1290c09f8 100644 --- a/src/libslic3r/Calib.cpp +++ b/src/libslic3r/Calib.cpp @@ -11,7 +11,7 @@ float CalibPressureAdvance::find_optimal_PA_speed(const DynamicPrintConfig &conf const double general_suggested_min_speed = 100.0; double filament_max_volumetric_speed = config.option("filament_max_volumetric_speed")->get_at(0); Flow pattern_line = Flow(line_width, layer_height, config.option("nozzle_diameter")->get_at(0)); - auto pa_speed = std::min(std::max(general_suggested_min_speed, config.option("outer_wall_speed")->value), + auto pa_speed = std::min(std::max(general_suggested_min_speed, config.option("outer_wall_speed")->get_at(get_extruder_index(filament_idx))), filament_max_volumetric_speed / pattern_line.mm3_per_mm()); return std::floor(pa_speed); diff --git a/src/libslic3r/Calib.hpp b/src/libslic3r/Calib.hpp index 6419c73c3..b6ecee4d2 100644 --- a/src/libslic3r/Calib.hpp +++ b/src/libslic3r/Calib.hpp @@ -251,8 +251,8 @@ public: Vec3d get_start_offset(); protected: - double speed_first_layer() const { return m_config.option("initial_layer_speed")->value; }; - double speed_perimeter() const { return m_config.option("outer_wall_speed")->value; }; + double speed_first_layer() const { return m_config.option("initial_layer_speed")->get_at(get_extruder_index(m_writer.extruder()->id())); }; + double speed_perimeter() const { return m_config.option("outer_wall_speed")->get_at(get_extruder_index(m_writer.extruder()->id())); }; double line_width_first_layer() const { return m_config.get_abs_value("initial_layer_line_width"); }; double line_width() const { return m_config.get_abs_value("line_width"); }; int wall_count() const { return m_config.option("wall_loops")->value; }; diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 8ee78e874..d5cab16d7 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -650,6 +650,32 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con return success; } +double ConfigBase::get_abs_value_at(const t_config_option_key &opt_key, size_t index) const +{ + const ConfigOption *raw_opt = this->option(opt_key); + assert(raw_opt != nullptr); + if (raw_opt->type() == coFloats) { + return static_cast(raw_opt)->get_at(index); + } + if (raw_opt->type() == coFloatsOrPercents) { + const ConfigDef *def = this->def(); + if (def == nullptr) throw NoDefinitionException(opt_key); + const ConfigOptionDef *opt_def = def->get(opt_key); + assert(opt_def != nullptr); + + if (opt_def->ratio_over.empty()) { + return 0; + } else { + const ConfigOption *ratio_opt = this->option(opt_def->ratio_over); + assert(ratio_opt->type() == coFloats); + const ConfigOptionFloats *ratio_values = static_cast(raw_opt); + return static_cast(raw_opt)->get_at(index).get_abs_value(ratio_values->get_at(index)); + } + } + + throw ConfigurationError("ConfigBase::get_abs_value_at(): Not a valid option type for get_abs_value_at()"); +} + // Return an absolute value of a possibly relative config variable. // For example, return absolute infill extrusion width, either from an absolute value, or relative to the layer height. double ConfigBase::get_abs_value(const t_config_option_key &opt_key) const @@ -1704,6 +1730,39 @@ t_config_option_keys DynamicConfig::equal(const DynamicConfig &other) const return equal; } +double& DynamicConfig::opt_float(const t_config_option_key &opt_key, unsigned int idx) +{ + if (ConfigOptionFloats *opt_floats = dynamic_cast(this->option(opt_key))) { + return opt_floats->get_at(idx); + } else { + ConfigOptionFloatsNullable *opt_floats_nullable = dynamic_cast(this->option(opt_key)); + assert(opt_floats_nullable != nullptr); + return opt_floats_nullable->get_at(idx); + } +} +const double& DynamicConfig::opt_float(const t_config_option_key &opt_key, unsigned int idx) const +{ + if (const ConfigOptionFloats *opt_floats = dynamic_cast(this->option(opt_key))) { + return opt_floats->get_at(idx); + } else if (const ConfigOptionFloatsNullable *opt_floats_nullable = dynamic_cast(this->option(opt_key))) { + return opt_floats_nullable->get_at(idx); + } else { + assert(false); + return 0; + } +} + +bool DynamicConfig::opt_bool(const t_config_option_key &opt_key, unsigned int idx) const { + if (const ConfigOptionBools *opts = dynamic_cast(this->option(opt_key))) { + return opts->get_at(idx) != 0; + } + else { + const ConfigOptionBoolsNullable *opt_s = dynamic_cast(this->option(opt_key)); + assert(opt_s != nullptr); + return opt_s->get_at(idx) != 0; + } +} + } #include diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index ed45a4861..be5c9f327 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -28,8 +28,13 @@ namespace Slic3r { struct FloatOrPercent { - double value; - bool percent; + double value = 0; + bool percent = false; + + FloatOrPercent() {} + FloatOrPercent(double value_, bool percent_) : value(value_), percent(percent_) { } + + double get_abs_value(double ratio_over) const { return this->percent ? (ratio_over * this->value / 100) : this->value; } FloatOrPercent() {} FloatOrPercent(double value_, bool percent_) : value(value_), percent(percent_) {} @@ -2151,6 +2156,7 @@ public: void set_deserialize_strict(std::initializer_list items) { ConfigSubstitutionContext ctxt{ ForwardCompatibilitySubstitutionRule::Disable }; this->set_deserialize(items, ctxt); } + double get_abs_value_at(const t_config_option_key &opt_key, size_t index) const; double get_abs_value(const t_config_option_key &opt_key) const; double get_abs_value(const t_config_option_key &opt_key, double ratio_over) const; void setenv_() const; @@ -2325,8 +2331,10 @@ public: double& opt_float(const t_config_option_key &opt_key) { return this->option(opt_key)->value; } const double& opt_float(const t_config_option_key &opt_key) const { return dynamic_cast(this->option(opt_key))->value; } - double& opt_float(const t_config_option_key &opt_key, unsigned int idx) { return this->option(opt_key)->get_at(idx); } - const double& opt_float(const t_config_option_key &opt_key, unsigned int idx) const { return dynamic_cast(this->option(opt_key))->get_at(idx); } + double & opt_float(const t_config_option_key &opt_key, unsigned int idx); + const double & opt_float(const t_config_option_key &opt_key, unsigned int idx) const; + double & opt_float_nullable(const t_config_option_key &opt_key, unsigned int idx) { return this->option(opt_key)->get_at(idx); } + const double & opt_float_nullable(const t_config_option_key &opt_key, unsigned int idx) const { return dynamic_cast(this->option(opt_key))->get_at(idx); } int& opt_int(const t_config_option_key &opt_key) { return this->option(opt_key)->value; } int opt_int(const t_config_option_key &opt_key) const { return dynamic_cast(this->option(opt_key))->value; } @@ -2341,7 +2349,7 @@ public: int opt_enum(const t_config_option_key &opt_key, unsigned int idx) const { return dynamic_cast(this->option(opt_key))->get_at(idx); } bool opt_bool(const t_config_option_key &opt_key) const { return this->option(opt_key)->value != 0; } - bool opt_bool(const t_config_option_key &opt_key, unsigned int idx) const { return this->option(opt_key)->get_at(idx) != 0; } + bool opt_bool(const t_config_option_key &opt_key, unsigned int idx) const; // Command line processing bool read_cli(int argc, const char* const argv[], t_config_option_keys* extra, t_config_option_keys* keys = nullptr); diff --git a/src/libslic3r/Fill/Fill.cpp b/src/libslic3r/Fill/Fill.cpp index fc6c31f70..4f2776096 100644 --- a/src/libslic3r/Fill/Fill.cpp +++ b/src/libslic3r/Fill/Fill.cpp @@ -189,11 +189,11 @@ std::vector group_fills(const Layer &layer) //BBS: record speed params if (!params.bridge) { if (params.extrusion_role == erInternalInfill) - params.sparse_infill_speed = region_config.sparse_infill_speed; + params.sparse_infill_speed = region_config.sparse_infill_speed.get_at(get_extruder_index(params.extruder)); else if (params.extrusion_role == erTopSolidInfill) - params.top_surface_speed = region_config.top_surface_speed; + params.top_surface_speed = region_config.top_surface_speed.get_at(get_extruder_index(params.extruder)); else if (params.extrusion_role == erSolidInfill) - params.solid_infill_speed = region_config.internal_solid_infill_speed; + params.solid_infill_speed = region_config.internal_solid_infill_speed.get_at(get_extruder_index(params.extruder)); } // Calculate flow spacing for infill pattern generation. if (surface.is_solid() || is_bridge) { diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index f2a413c45..a7669f6aa 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -297,7 +297,7 @@ static std::vector get_path_of_change_filament(const Print& print) //OrcaSlicer double cur_speed = gcodegen.writer().get_current_speed(); double wipe_speed = gcodegen.config().role_base_wipe_speed && cur_speed > EPSILON ? cur_speed / 60 : - gcodegen.writer().config.travel_speed.value * gcodegen.config().wipe_speed.value / 100; + gcodegen.writer().config.travel_speed.get_at(get_extruder_index(gcodegen.writer().config, gcodegen.writer().filament()->id())) * gcodegen.config().wipe_speed.value / 100; // get the retraction length @@ -1291,7 +1291,7 @@ namespace DoExport { // BBS: remove small small_perimeter_speed config, and will absolutely // remove related code if no other issue in the coming release. //region.config().get_abs_value("small_perimeter_speed") == 0 || - region.config().outer_wall_speed.value == 0 || + region.config().outer_wall_speed.get_at(cur_extruder_index()) == 0 || region.config().get_abs_value("bridge_speed") == 0) mm3_per_mm.push_back(layerm->perimeters.min_mm3_per_mm()); if (region.config().get_abs_value("sparse_infill_speed") == 0 || @@ -1999,7 +1999,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato outer_wall_line_width = default_line_width == 0.0 ? m_config.nozzle_diameter.get_at(initial_non_support_extruder_id) : default_line_width; } Flow outer_wall_flow = Flow(outer_wall_line_width, m_config.layer_height, m_config.nozzle_diameter.get_at(initial_non_support_extruder_id)); - float outer_wall_speed = print.default_region_config().outer_wall_speed.value; + float outer_wall_speed = print.default_region_config().outer_wall_speed.get_at(get_extruder_index(initial_extruder_id)); float outer_wall_volumetric_speed = outer_wall_speed * outer_wall_flow.mm3_per_mm(); if (outer_wall_volumetric_speed > filament_max_volumetric_speed) outer_wall_volumetric_speed = filament_max_volumetric_speed; @@ -2092,8 +2092,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato // OrcaSlicer: calib if (print.calib_params().mode == CalibMode::Calib_PA_Line) { std::string gcode; - if ((m_config.default_acceleration.value > 0 && m_config.outer_wall_acceleration.value > 0)) { - gcode += m_writer.set_acceleration((unsigned int) floor(m_config.outer_wall_acceleration.value + 0.5)); + if ((m_config.default_acceleration.get_at(cur_extruder_index()) > 0 && m_config.outer_wall_acceleration.get_at(cur_extruder_index()) > 0)) { + gcode += m_writer.set_acceleration((unsigned int) floor(m_config.outer_wall_acceleration.get_at(cur_extruder_index()) + 0.5)); } if (m_config.default_jerk.value > 0 && !this->is_BBL_Printer()) { @@ -2104,7 +2104,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato CalibPressureAdvanceLine pa_test(this); double filament_max_volumetric_speed = m_config.option("filament_max_volumetric_speed")->get_at(initial_extruder_id); Flow pattern_line = Flow(pa_test.line_width(), 0.2, m_config.nozzle_diameter.get_at(0)); - auto fast_speed = std::min(print.default_region_config().outer_wall_speed.value, filament_max_volumetric_speed / pattern_line.mm3_per_mm()); + auto fast_speed = std::min(print.default_region_config().outer_wall_speed.get_at(cur_extruder_index()), filament_max_volumetric_speed / pattern_line.mm3_per_mm()); auto slow_speed = fast_speed / 4; /*std::max(20.0, fast_speed / 10.0);*/ pa_test.set_speed(fast_speed, slow_speed); pa_test.draw_numbers() = print.calib_params().print_numbers; @@ -2375,6 +2375,11 @@ void GCode::check_placeholder_parser_failed() } } +size_t GCode::cur_extruder_index() const +{ + return get_extruder_index(m_writer.extruder()->id()); +} + // Process all layers of all objects (non-sequential mode) with a parallel pipeline: // Generate G-code, run the filters (vase mode, cooling buffer), run the G-code analyser // and export G-code into file. @@ -3116,8 +3121,8 @@ GCode::LayerResult GCode::process_layer( //BBS if (first_layer) { //BBS: set first layer global acceleration - if (m_config.default_acceleration.value > 0 && m_config.initial_layer_acceleration.value > 0) { - double acceleration = m_config.initial_layer_acceleration.value; + if (m_config.default_acceleration.get_at(cur_extruder_index()) > 0 && m_config.initial_layer_acceleration.get_at(cur_extruder_index()) > 0) { + double acceleration = m_config.initial_layer_acceleration.get_at(cur_extruder_index()); gcode += m_writer.set_acceleration((unsigned int)floor(acceleration + 0.5)); } @@ -3143,8 +3148,8 @@ GCode::LayerResult GCode::process_layer( } //BBS: reset acceleration at sencond layer - if (m_config.default_acceleration.value > 0 && m_config.initial_layer_acceleration.value > 0) { - double acceleration = m_config.default_acceleration.value; + if (m_config.default_acceleration.get_at(cur_extruder_index()) > 0 && m_config.initial_layer_acceleration.get_at(cur_extruder_index()) > 0) { + double acceleration = m_config.default_acceleration.get_at(cur_extruder_index()); gcode += m_writer.set_acceleration((unsigned int)floor(acceleration + 0.5)); } @@ -3455,7 +3460,7 @@ GCode::LayerResult GCode::process_layer( path.mm3_per_mm = mm3_per_mm; } //FIXME using the support_speed of the 1st object printed. - gcode += this->extrude_loop(loop, "skirt", m_config.support_speed.value); + gcode += this->extrude_loop(loop, "skirt", m_config.support_speed.get_at(cur_extruder_index())); } m_avoid_crossing_perimeters.use_external_mp(false); // Allow a straight travel move to the first object point if this is the first layer (but don't in next layers). @@ -3510,7 +3515,7 @@ GCode::LayerResult GCode::process_layer( set_origin(unscaled(offset)); for (ExtrusionEntity* ee : layer.object()->object_skirt().entities) //FIXME using the support_speed of the 1st object printed. - gcode += this->extrude_entity(*ee, "skirt", m_config.support_speed.value); + gcode += this->extrude_entity(*ee, "skirt", m_config.support_speed.get_at(cur_extruder_index())); } } @@ -3570,7 +3575,7 @@ GCode::LayerResult GCode::process_layer( this->set_origin(0., 0.); m_avoid_crossing_perimeters.use_external_mp(); for (const ExtrusionEntity* ee : print.m_supportBrimMap.at(instance_to_print.print_object.id()).entities) { - gcode += this->extrude_entity(*ee, "brim", m_config.support_speed.value); + gcode += this->extrude_entity(*ee, "brim", m_config.support_speed.get_at(cur_extruder_index())); } m_avoid_crossing_perimeters.use_external_mp(false); // Allow a straight travel move to the first object point. @@ -3611,7 +3616,7 @@ GCode::LayerResult GCode::process_layer( this->set_origin(0., 0.); m_avoid_crossing_perimeters.use_external_mp(); for (const ExtrusionEntity* ee : print.m_brimMap.at(instance_to_print.print_object.id()).entities) { - gcode += this->extrude_entity(*ee, "brim", m_config.support_speed.value); + gcode += this->extrude_entity(*ee, "brim", m_config.support_speed.get_at(cur_extruder_index())); } m_avoid_crossing_perimeters.use_external_mp(false); // Allow a straight travel move to the first object point. @@ -3943,23 +3948,24 @@ double GCode::get_path_speed(const ExtrusionPath &path) // set speed double speed = 0; if (path.role() == erPerimeter) { - speed = m_config.get_abs_value("inner_wall_speed"); - if (m_config.enable_overhang_speed.value) { + speed = m_config.inner_wall_speed.get_at(cur_extruder_index()); + if (m_config.enable_overhang_speed.get_at(cur_extruder_index())) { double new_speed = 0; new_speed = get_overhang_degree_corr_speed(speed, path.overhang_degree); speed = new_speed == 0.0 ? speed : new_speed; } } else if (path.role() == erExternalPerimeter) { - speed = m_config.get_abs_value("outer_wall_speed"); - if (m_config.enable_overhang_speed.value) { + speed = m_config.outer_wall_speed.get_at(cur_extruder_index()); + if (m_config.enable_overhang_speed.get_at(cur_extruder_index())) { double new_speed = 0; new_speed = get_overhang_degree_corr_speed(speed, path.overhang_degree); speed = new_speed == 0.0 ? speed : new_speed; } - } else if (path.role() == erOverhangPerimeter && path.overhang_degree == 5) - speed = m_config.get_abs_value("overhang_totally_speed"); + } + else if (path.role() == erOverhangPerimeter && path.overhang_degree == 5) + speed = m_config.overhang_totally_speed.get_at(cur_extruder_index()); else if (path.role() == erOverhangPerimeter || path.role() == erBridgeInfill || path.role() == erSupportTransition) { - speed = m_config.get_abs_value("bridge_speed"); + speed = m_config.bridge_speed.get_at(cur_extruder_index()); } auto _mm3_per_mm = path.mm3_per_mm * double(m_curr_print->calib_mode() == CalibMode::Calib_Flow_Rate ? this->config().print_flow_ratio.value : 1); @@ -3973,7 +3979,7 @@ double GCode::get_path_speed(const ExtrusionPath &path) if (this->on_first_layer()) { // BBS: for solid infill of initial layer, speed can be higher as long as // wall lines have be attached - if (path.role() != erBottomSurface) speed = m_config.get_abs_value("initial_layer_speed"); + if (path.role() != erBottomSurface) speed = m_config.initial_layer_speed.get_at(cur_extruder_index()); } if (EXTRUDER_CONFIG(filament_max_volumetric_speed) > 0) { @@ -4032,8 +4038,8 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou double small_peri_speed=-1; // apply the small perimeter speed - if (speed==-1 && loop.length() <= SMALL_PERIMETER_LENGTH(m_config.small_perimeter_threshold.value)) - small_peri_speed = m_config.small_perimeter_speed.get_abs_value(m_config.outer_wall_speed); + if (speed==-1 && loop.length() <= SMALL_PERIMETER_LENGTH(m_config.small_perimeter_threshold.get_at(cur_extruder_index()))) + small_peri_speed = m_config.small_perimeter_speed.get_at(cur_extruder_index()).get_abs_value(m_config.outer_wall_speed.get_at(cur_extruder_index())); // extrude along the path std::string gcode; @@ -4121,7 +4127,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou //BBS: don't reset acceleration when printing first layer. During first layer, acceleration is always same value. if (!this->on_first_layer()) { // reset acceleration - gcode += m_writer.set_acceleration((unsigned int) (m_config.default_acceleration.value + 0.5)); + gcode += m_writer.set_acceleration((unsigned int) (m_config.default_acceleration.get_at(cur_extruder_index()) + 0.5)); if (!this->is_BBL_Printer()) gcode += m_writer.set_jerk_xy(m_config.default_jerk.value); } @@ -4206,7 +4212,7 @@ std::string GCode::extrude_multi_path(ExtrusionMultiPath multipath, std::string //BBS: don't reset acceleration when printing first layer. During first layer, acceleration is always same value. if (!this->on_first_layer()) { // reset acceleration - gcode += m_writer.set_acceleration((unsigned int) floor(m_config.default_acceleration.value + 0.5)); + gcode += m_writer.set_acceleration((unsigned int) floor(m_config.default_acceleration.get_at(cur_extruder_index()) + 0.5)); if (!this->is_BBL_Printer()) gcode += m_writer.set_jerk_xy(m_config.default_jerk.value); } @@ -4237,7 +4243,7 @@ std::string GCode::extrude_path(ExtrusionPath path, std::string description, dou //BBS: don't reset acceleration when printing first layer. During first layer, acceleration is always same value. if (!this->on_first_layer()) { // reset acceleration - gcode += m_writer.set_acceleration((unsigned int) floor(m_config.default_acceleration.value + 0.5)); + gcode += m_writer.set_acceleration((unsigned int) floor(m_config.default_acceleration.get_at(cur_extruder_index()) + 0.5)); if (!this->is_BBL_Printer()) gcode += m_writer.set_jerk_xy(m_config.default_jerk.value); } @@ -4295,8 +4301,8 @@ std::string GCode::extrude_support(const ExtrusionEntityCollection &support_fill std::string gcode; if (! support_fills.entities.empty()) { - const double support_speed = m_config.support_speed.value; - const double support_interface_speed = m_config.get_abs_value("support_interface_speed"); + const double support_speed = m_config.support_speed.get_at(cur_extruder_index()); + const double support_interface_speed = m_config.support_interface_speed.get_at(cur_extruder_index()); for (const ExtrusionEntity *ee : support_fills.entities) { ExtrusionRole role = ee->role(); assert(role == erSupportMaterial || role == erSupportMaterialInterface || role == erSupportTransition); @@ -4418,12 +4424,12 @@ double GCode::get_overhang_degree_corr_speed(float normal_speed, double path_deg int lower_degree_bound = int(path_degree); // BBS: use lower speed of 75%-100% for better cooling if (path_degree >= 4 || path_degree == lower_degree_bound) - return m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str()); + return m_config.get_abs_value_at(overhang_speed_key_map[lower_degree_bound].c_str(), cur_extruder_index()); int upper_degree_bound = lower_degree_bound + 1; - double lower_speed_bound = lower_degree_bound == 0 ? normal_speed : m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str()); - double upper_speed_bound = upper_degree_bound == 0 ? normal_speed : m_config.get_abs_value(overhang_speed_key_map[upper_degree_bound].c_str()); + double lower_speed_bound = lower_degree_bound == 0 ? normal_speed : m_config.get_abs_value_at(overhang_speed_key_map[lower_degree_bound].c_str(), cur_extruder_index()); + double upper_speed_bound = upper_degree_bound == 0 ? normal_speed : m_config.get_abs_value_at(overhang_speed_key_map[upper_degree_bound].c_str(), cur_extruder_index()); lower_speed_bound = lower_speed_bound == 0 ? normal_speed : lower_speed_bound; upper_speed_bound = upper_speed_bound == 0 ? normal_speed : upper_speed_bound; @@ -4670,29 +4676,29 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, m_config.apply(m_calib_config); // adjust acceleration - if (m_config.default_acceleration.value > 0) { + if (m_config.default_acceleration.get_at(cur_extruder_index()) > 0) { double acceleration; - if (this->on_first_layer() && m_config.initial_layer_acceleration.value > 0) { - acceleration = m_config.initial_layer_acceleration.value; + if (this->on_first_layer() && m_config.initial_layer_acceleration.get_at(cur_extruder_index()) > 0) { + acceleration = m_config.initial_layer_acceleration.get_at(cur_extruder_index()); #if 0 } else if (this->object_layer_over_raft() && m_config.first_layer_acceleration_over_raft.value > 0) { acceleration = m_config.first_layer_acceleration_over_raft.value; } else if (m_config.bridge_acceleration.value > 0 && is_bridge(path.role())) { acceleration = m_config.bridge_acceleration.value; #endif - } else if (m_config.outer_wall_acceleration.value > 0 + } else if (m_config.outer_wall_acceleration.get_at(cur_extruder_index()) > 0 //BBS: FIXME, in fact,we only need to set acceleration for outer wall. But we don't know //whether the overhang perimeter is outer or not. So using specific acceleration together. && (path.role() == erExternalPerimeter || path.role() == erOverhangPerimeter)) { - acceleration = m_config.outer_wall_acceleration.value; - } else if (m_config.top_surface_acceleration.value > 0 && is_top_surface(path.role())) { - acceleration = m_config.top_surface_acceleration.value; - } else if (m_config.inner_wall_acceleration.value > 0 && path.role() == erPerimeter) { - acceleration = m_config.inner_wall_acceleration.value; - } else if (m_config.get_abs_value("sparse_infill_acceleration") > 0 && (path.role() == erInternalInfill)) { - acceleration = m_config.get_abs_value("sparse_infill_acceleration"); + acceleration = m_config.outer_wall_acceleration.get_at(cur_extruder_index()); + } else if (m_config.top_surface_acceleration.get_at(cur_extruder_index()) > 0 && is_top_surface(path.role())) { + acceleration = m_config.top_surface_acceleration.get_at(cur_extruder_index()); + } else if (m_config.inner_wall_acceleration.get_at(cur_extruder_index()) > 0 && path.role() == erPerimeter) { + acceleration = m_config.inner_wall_acceleration.get_at(cur_extruder_index()); + } else if (m_config.get_abs_value_at("sparse_infill_acceleration", cur_extruder_index()) > 0 && (path.role() == erInternalInfill)) { + acceleration = m_config.get_abs_value_at("sparse_infill_acceleration", cur_extruder_index()); } else { - acceleration = m_config.default_acceleration.value; + acceleration = m_config.default_acceleration.get_at(cur_extruder_index()); } gcode += m_writer.set_acceleration((unsigned int)floor(acceleration + 0.5)); } @@ -4727,19 +4733,19 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, // set speed if (speed == -1) { if (path.role() == erPerimeter) { - speed = m_config.get_abs_value("inner_wall_speed"); + speed = m_config.inner_wall_speed.get_at(cur_extruder_index()); if (m_config.detect_overhang_wall && m_config.smooth_speed_discontinuity_area && path.smooth_speed != 0) speed = path.smooth_speed; - else if (m_config.enable_overhang_speed.value) { + else if (m_config.enable_overhang_speed.get_at(cur_extruder_index())) { double new_speed = 0; new_speed = get_overhang_degree_corr_speed(speed, path.overhang_degree); speed = new_speed == 0.0 ? speed : new_speed; } } else if (path.role() == erExternalPerimeter) { - speed = m_config.get_abs_value("outer_wall_speed"); + speed = m_config.outer_wall_speed.get_at(cur_extruder_index()); if (m_config.detect_overhang_wall && m_config.smooth_speed_discontinuity_area && path.smooth_speed != 0) speed = path.smooth_speed; - else if (m_config.enable_overhang_speed.value) { + else if (m_config.enable_overhang_speed.get_at(cur_extruder_index())) { double new_speed = 0; new_speed = get_overhang_degree_corr_speed(speed, path.overhang_degree); @@ -4748,24 +4754,24 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, } else if (path.role() == erOverhangPerimeter && path.overhang_degree == 5) { speed = m_config.get_abs_value("overhang_totally_speed"); } else if (path.role() == erOverhangPerimeter || path.role() == erBridgeInfill || path.role() == erSupportTransition) { - speed = m_config.get_abs_value("bridge_speed"); + speed = m_config.bridge_speed.get_at(cur_extruder_index()); } else if (path.role() == erInternalInfill) { - speed = m_config.get_abs_value("sparse_infill_speed"); + speed = m_config.sparse_infill_speed.get_at(cur_extruder_index()); } else if (path.role() == erSolidInfill) { - speed = m_config.get_abs_value("internal_solid_infill_speed"); + speed = m_config.internal_solid_infill_speed.get_at(cur_extruder_index()); } else if (path.role() == erTopSolidInfill) { - speed = m_config.get_abs_value("top_surface_speed"); + speed = m_config.top_surface_speed.get_at(cur_extruder_index()); } else if (path.role() == erIroning) { speed = m_config.get_abs_value("ironing_speed"); } else if (path.role() == erBottomSurface) { - speed = m_config.get_abs_value("initial_layer_infill_speed"); + speed = m_config.initial_layer_infill_speed.get_at(cur_extruder_index()); } else if (path.role() == erGapFill) { - speed = m_config.get_abs_value("gap_infill_speed"); + speed = m_config.gap_infill_speed.get_at(cur_extruder_index()); } else if (path.role() == erSupportMaterial || path.role() == erSupportMaterialInterface) { - const double support_speed = m_config.support_speed.value; - const double support_interface_speed = m_config.get_abs_value("support_interface_speed"); + const double support_speed = m_config.support_speed.get_at(cur_extruder_index()); + const double support_interface_speed = m_config.support_interface_speed.get_at(cur_extruder_index()); speed = (path.role() == erSupportMaterial) ? support_speed : support_interface_speed; } else { throw Slic3r::InvalidArgument("Invalid speed"); @@ -4783,7 +4789,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, //BBS: for solid infill of initial layer, speed can be higher as long as //wall lines have be attached if (path.role() != erBottomSurface) - speed = m_config.get_abs_value("initial_layer_speed"); + speed = m_config.initial_layer_speed.get_at(cur_extruder_index()); } //BBS: remove this config //else if (this->object_layer_over_raft()) diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index f3096a74b..0391a989f 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -332,6 +332,7 @@ private: //BBS void check_placeholder_parser_failed(); + size_t cur_extruder_index() const; void set_last_pos(const Point &pos) { m_last_pos = pos; m_last_pos_defined = true; } void set_last_scarf_seam_flag(bool flag) { m_last_scarf_seam_flag = flag; } diff --git a/src/libslic3r/GCode/CoolingBuffer.cpp b/src/libslic3r/GCode/CoolingBuffer.cpp index 1d35b2ec5..b466b932d 100644 --- a/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/src/libslic3r/GCode/CoolingBuffer.cpp @@ -35,7 +35,7 @@ void CoolingBuffer::reset(const Vec3d &position) m_current_pos[0] = float(position.x()); m_current_pos[1] = float(position.y()); m_current_pos[2] = float(position.z()); - m_current_pos[4] = float(m_config.travel_speed.value); + m_current_pos[4] = float(m_config.travel_speed.get_at(get_extruder_index(m_current_extruder))); m_fan_speed = -1; m_additional_fan_speed = -1; m_current_fan_speed = -1; diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index b2f4a2c91..c3a637574 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -610,7 +610,7 @@ WipeTower::WipeTower(const PrintConfig& config, int plate_idx, Vec3d plate_origi m_bridging(10.f), m_no_sparse_layers(config.wipe_tower_no_sparse_layers), m_gcode_flavor(config.gcode_flavor), - m_travel_speed(config.travel_speed), + m_travel_speed(config.travel_speed.get_at(get_extruder_index(initial_tool))), m_current_tool(initial_tool), //wipe_volumes(flush_matrix) m_wipe_volume(prime_volume), @@ -620,7 +620,7 @@ WipeTower::WipeTower(const PrintConfig& config, int plate_idx, Vec3d plate_origi // it is taken over following default. Speeds from config are not // easily accessible here. const float default_speed = 60.f; - m_first_layer_speed = config.get_abs_value("initial_layer_speed"); + m_first_layer_speed = config.initial_layer_speed.get_at(get_extruder_index(initial_tool)); if (m_first_layer_speed == 0.f) // just to make sure autospeed doesn't break it. m_first_layer_speed = default_speed / 2.f; diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index 927d13339..13453a04a 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -343,7 +343,7 @@ std::string GCodeWriter::travel_to_xy(const Vec2d &point, const std::string &com GCodeG1Formatter w; w.emit_xy(point_on_plate); - w.emit_f(this->config.travel_speed.value * 60.0); + w.emit_f(this->config.travel_speed.get_at(get_extruder_index(extruder()->id())) * 60.0); //BBS w.emit_comment(GCodeWriter::full_gcode_comment, comment); return w.string(); @@ -403,7 +403,7 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co Vec3d slope_top_point = Vec3d(temp(0), temp(1), delta(2)) + source; GCodeG1Formatter w0; w0.emit_xyz(slope_top_point); - w0.emit_f(this->config.travel_speed.value * 60.0); + w0.emit_f(this->config.travel_speed.get_at(get_extruder_index(extruder()->id())) * 60.0); //BBS w0.emit_comment(GCodeWriter::full_gcode_comment, "slope lift Z"); slop_move = w0.string(); @@ -418,13 +418,13 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co GCodeG1Formatter w0; if (this->is_current_position_clear()) { w0.emit_xyz(target); - w0.emit_f(this->config.travel_speed.value * 60.0); + w0.emit_f(this->config.travel_speed.get_at(get_extruder_index(extruder()->id())) * 60.0); w0.emit_comment(GCodeWriter::full_gcode_comment, comment); xy_z_move = w0.string(); } else { w0.emit_xy(Vec2d(target.x(), target.y())); - w0.emit_f(this->config.travel_speed.value * 60.0); + w0.emit_f(this->config.travel_speed.get_at(get_extruder_index(extruder()->id())) * 60.0); w0.emit_comment(GCodeWriter::full_gcode_comment, comment); xy_z_move = w0.string() + _travel_to_z(target.z(), comment); } @@ -458,13 +458,13 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co { //force to move xy first then z after filament change w.emit_xy(Vec2d(point_on_plate.x(), point_on_plate.y())); - w.emit_f(this->config.travel_speed.value * 60.0); + w.emit_f(this->config.travel_speed.get_at(get_extruder_index(extruder()->id())) * 60.0); w.emit_comment(GCodeWriter::full_gcode_comment, comment); out_string = w.string() + _travel_to_z(point_on_plate.z(), comment); } else { GCodeG1Formatter w; w.emit_xyz(point_on_plate); - w.emit_f(this->config.travel_speed.value * 60.0); + w.emit_f(this->config.travel_speed.get_at(get_extruder_index(extruder()->id())) * 60.0); w.emit_comment(GCodeWriter::full_gcode_comment, comment); out_string = w.string(); } @@ -497,9 +497,9 @@ std::string GCodeWriter::_travel_to_z(double z, const std::string &comment) { m_pos(2) = z; - double speed = this->config.travel_speed_z.value; + double speed = this->config.travel_speed_z.get_at(get_extruder_index(extruder()->id())); if (speed == 0.) - speed = this->config.travel_speed.value; + speed = this->config.travel_speed.get_at(get_extruder_index(extruder()->id())); GCodeG1Formatter w; w.emit_z(z); @@ -513,9 +513,9 @@ std::string GCodeWriter::_spiral_travel_to_z(double z, const Vec2d &ij_offset, c { m_pos(2) = z; - double speed = this->config.travel_speed_z.value; + double speed = this->config.travel_speed_z.get_at(get_extruder_index(extruder()->id())); if (speed == 0.) - speed = this->config.travel_speed.value; + speed = this->config.travel_speed.get_at(get_extruder_index(extruder()->id())); std::string output = "G17\n"; GCodeG2G3Formatter w(true); diff --git a/src/libslic3r/Layer.cpp b/src/libslic3r/Layer.cpp index cc4d26480..74d3bbaf7 100644 --- a/src/libslic3r/Layer.cpp +++ b/src/libslic3r/Layer.cpp @@ -168,9 +168,9 @@ void Layer::make_perimeters() const PrintRegionConfig &other_config = other_layerm->region().config(); if (config.wall_filament == other_config.wall_filament && config.wall_loops == other_config.wall_loops - && config.inner_wall_speed == other_config.inner_wall_speed - && config.outer_wall_speed == other_config.outer_wall_speed - && config.gap_infill_speed.value == other_config.gap_infill_speed.value + && config.inner_wall_speed.get_at(get_extruder_index(config.wall_filament)) == other_config.inner_wall_speed.get_at(get_extruder_index(config.wall_filament)) + && config.outer_wall_speed.get_at(get_extruder_index(config.wall_filament)) == other_config.outer_wall_speed.get_at(get_extruder_index(config.wall_filament)) + && config.gap_infill_speed.get_at(get_extruder_index(config.wall_filament)) == other_config.gap_infill_speed.get_at(get_extruder_index(config.wall_filament)) && config.detect_overhang_wall == other_config.detect_overhang_wall && config.filter_out_gap_fill.value == other_config.filter_out_gap_fill.value && config.opt_serialize("inner_wall_line_width") == other_config.opt_serialize("inner_wall_line_width") diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 2c71793c2..8e37be13f 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -3511,32 +3511,34 @@ const Transform3d &ModelInstance::get_matrix(bool dont_translate, bool dont_rota void Model::setPrintSpeedTable(const DynamicPrintConfig& config, const PrintConfig& print_config) { //Slic3r::DynamicPrintConfig config = wxGetApp().preset_bundle->full_config(); printSpeedMap.maxSpeed = 0; + + // todo multi_extruders: the following parameters need get exact filament id if (config.has("inner_wall_speed")) { - printSpeedMap.perimeterSpeed = config.opt_float("inner_wall_speed"); + printSpeedMap.perimeterSpeed = config.opt_float_nullable("inner_wall_speed", 0); if (printSpeedMap.perimeterSpeed > printSpeedMap.maxSpeed) printSpeedMap.maxSpeed = printSpeedMap.perimeterSpeed; } if (config.has("outer_wall_speed")) { - printSpeedMap.externalPerimeterSpeed = config.opt_float("outer_wall_speed"); + printSpeedMap.externalPerimeterSpeed = config.opt_float_nullable("outer_wall_speed", 0); printSpeedMap.maxSpeed = std::max(printSpeedMap.maxSpeed, printSpeedMap.externalPerimeterSpeed); } if (config.has("sparse_infill_speed")) { - printSpeedMap.infillSpeed = config.opt_float("sparse_infill_speed"); + printSpeedMap.infillSpeed = config.opt_float_nullable("sparse_infill_speed", 0); if (printSpeedMap.infillSpeed > printSpeedMap.maxSpeed) printSpeedMap.maxSpeed = printSpeedMap.infillSpeed; } if (config.has("internal_solid_infill_speed")) { - printSpeedMap.solidInfillSpeed = config.opt_float("internal_solid_infill_speed"); + printSpeedMap.solidInfillSpeed = config.opt_float_nullable("internal_solid_infill_speed", 0); if (printSpeedMap.solidInfillSpeed > printSpeedMap.maxSpeed) printSpeedMap.maxSpeed = printSpeedMap.solidInfillSpeed; } if (config.has("top_surface_speed")) { - printSpeedMap.topSolidInfillSpeed = config.opt_float("top_surface_speed"); + printSpeedMap.topSolidInfillSpeed = config.opt_float_nullable("top_surface_speed", 0); if (printSpeedMap.topSolidInfillSpeed > printSpeedMap.maxSpeed) printSpeedMap.maxSpeed = printSpeedMap.topSolidInfillSpeed; } if (config.has("support_speed")) { - printSpeedMap.supportSpeed = config.opt_float("support_speed"); + printSpeedMap.supportSpeed = config.opt_float_nullable("support_speed", 0); if (printSpeedMap.supportSpeed > printSpeedMap.maxSpeed) printSpeedMap.maxSpeed = printSpeedMap.supportSpeed; @@ -3763,20 +3765,21 @@ double Model::findMaxSpeed(const ModelObject* object) { double supportSpeedObj = Model::printSpeedMap.supportSpeed; double smallPerimeterSpeedObj = Model::printSpeedMap.smallPerimeterSpeed; for (std::string objectKey : objectKeys) { + // todo multi_extruders: if (objectKey == "inner_wall_speed"){ - perimeterSpeedObj = object->config.opt_float(objectKey); + perimeterSpeedObj = object->config.get().opt_float_nullable(objectKey, 0); externalPerimeterSpeedObj = Model::printSpeedMap.externalPerimeterSpeed / Model::printSpeedMap.perimeterSpeed * perimeterSpeedObj; } if (objectKey == "sparse_infill_speed") - infillSpeedObj = object->config.opt_float(objectKey); + infillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0); if (objectKey == "internal_solid_infill_speed") - solidInfillSpeedObj = object->config.opt_float(objectKey); + solidInfillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0); if (objectKey == "top_surface_speed") - topSolidInfillSpeedObj = object->config.opt_float(objectKey); + topSolidInfillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0); if (objectKey == "support_speed") - supportSpeedObj = object->config.opt_float(objectKey); + supportSpeedObj = object->config.get().opt_float_nullable(objectKey, 0); if (objectKey == "outer_wall_speed") - externalPerimeterSpeedObj = object->config.opt_float(objectKey); + externalPerimeterSpeedObj = object->config.get().opt_float_nullable(objectKey, 0); if (objectKey == "small_perimeter_speed") smallPerimeterSpeedObj = object->config.opt_float(objectKey); } diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index ffc5d8f05..4af7045d1 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -1495,7 +1495,7 @@ static inline std::vector> mmu_segmentation_top_and_bott out.extrusion_width = std::max(out.extrusion_width, outer_wall_line_width); out.top_shell_layers = std::max(out.top_shell_layers, config.top_shell_layers); out.bottom_shell_layers = std::max(out.bottom_shell_layers, config.bottom_shell_layers); - out.small_region_threshold = config.gap_infill_speed.value > 0 ? + out.small_region_threshold = config.gap_infill_speed.get_at(get_extruder_index(config.wall_filament - 1)) > 0 ? // Gap fill enabled. Enable a single line of 1/2 extrusion width. 0.5f * outer_wall_line_width : // Gap fill disabled. Enable two lines slightly overlapping. diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 903507f90..e962c014c 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -523,7 +523,8 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime remain_polines = diff_pl_2({to_polyline(polygon)}, lower_polygons_series_clipped); - bool detect_overhang_degree = perimeter_generator.config->enable_overhang_speed && perimeter_generator.config->fuzzy_skin == FuzzySkinType::None; + bool detect_overhang_degree = perimeter_generator.config->enable_overhang_speed.get_at(get_extruder_index(perimeter_generator.config->wall_filament - 1)) + && perimeter_generator.config->fuzzy_skin == FuzzySkinType::None; //BBS: fuzziy skin may generate a line that approximates a point, which can cause the clipper to get empty results if (loop.fuzzify && remain_polines.empty() && inside_polines.empty()) { @@ -931,7 +932,8 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p extrusion_paths_append(temp_paths, clip_extrusion(extrusion_path, lower_slices_paths, ClipperLib_Z::ctIntersection), role, is_external ? perimeter_generator.ext_perimeter_flow : perimeter_generator.perimeter_flow); - if (perimeter_generator.config->enable_overhang_speed && perimeter_generator.config->fuzzy_skin == FuzzySkinType::None) { + if (perimeter_generator.config->enable_overhang_speed.get_at(get_extruder_index(perimeter_generator.config->wall_filament - 1)) + && perimeter_generator.config->fuzzy_skin == FuzzySkinType::None) { Flow flow = is_external ? perimeter_generator.ext_perimeter_flow : perimeter_generator.perimeter_flow; std::map> clipper_serise; @@ -1030,7 +1032,8 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p chain_and_reorder_extrusion_paths(paths, &start_point); - if (perimeter_generator.config->enable_overhang_speed && perimeter_generator.config->fuzzy_skin == FuzzySkinType::None) { + if (perimeter_generator.config->enable_overhang_speed.get_at(get_extruder_index(perimeter_generator.config->wall_filament - 1)) + && perimeter_generator.config->fuzzy_skin == FuzzySkinType::None) { // BBS: filter the speed smooth_overhang_level(paths); } @@ -1119,7 +1122,7 @@ void PerimeterGenerator::process_classic() // internal flow which is unrelated. coord_t min_spacing = coord_t(perimeter_spacing * (1 - INSET_OVERLAP_TOLERANCE)); coord_t ext_min_spacing = coord_t(ext_perimeter_spacing * (1 - INSET_OVERLAP_TOLERANCE)); - bool has_gap_fill = this->config->gap_infill_speed.value > 0; + bool has_gap_fill = this->config->gap_infill_speed.get_at(get_extruder_index(this->config->wall_filament - 1)) > 0; // BBS: this flow is for smaller external perimeter for small area coord_t ext_min_spacing_smaller = coord_t(ext_perimeter_spacing * (1 - SMALLER_EXT_INSET_OVERLAP_TOLERANCE)); diff --git a/src/libslic3r/PlaceholderParser.cpp b/src/libslic3r/PlaceholderParser.cpp index c2373caa5..ff88122db 100644 --- a/src/libslic3r/PlaceholderParser.cpp +++ b/src/libslic3r/PlaceholderParser.cpp @@ -808,58 +808,110 @@ namespace client OptWithPos &opt, expr &output) { - if (opt.opt->is_vector()) - ctx->throw_exception("Referencing a vector variable when scalar is expected", opt.it_range); - switch (opt.opt->type()) { - case coFloat: output.set_d(opt.opt->getFloat()); break; - case coInt: output.set_i(opt.opt->getInt()); break; - case coString: output.set_s(static_cast(opt.opt)->value); break; - case coPercent: output.set_d(opt.opt->getFloat()); break; - case coPoint: output.set_s(opt.opt->serialize()); break; - case coBool: output.set_b(opt.opt->getBool()); break; - case coFloatOrPercent: - { - std::string opt_key(opt.it_range.begin(), opt.it_range.end()); - if (boost::ends_with(opt_key, "line_width")) { - // Extrusion width supports defaults and a complex graph of dependencies. - output.set_d(Flow::extrusion_width(opt_key, *ctx, static_cast(ctx->current_extruder_id))); - } else if (! static_cast(opt.opt)->percent) { - // Not a percent, just return the value. - output.set_d(opt.opt->getFloat()); - } else { - // Resolve dependencies using the "ratio_over" link to a parent value. - const ConfigOptionDef *opt_def = print_config_def.get(opt_key); - assert(opt_def != nullptr); - double v = opt.opt->getFloat() * 0.01; // percent to ratio - for (;;) { - const ConfigOption *opt_parent = opt_def->ratio_over.empty() ? nullptr : ctx->resolve_symbol(opt_def->ratio_over); - if (opt_parent == nullptr) - ctx->throw_exception("FloatOrPercent variable failed to resolve the \"ratio_over\" dependencies", opt.it_range); - if (boost::ends_with(opt_def->ratio_over, "line_width")) { - // Extrusion width supports defaults and a complex graph of dependencies. - assert(opt_parent->type() == coFloatOrPercent); - v *= Flow::extrusion_width(opt_def->ratio_over, static_cast(opt_parent), *ctx, static_cast(ctx->current_extruder_id)); - break; - } - if (opt_parent->type() == coFloat || opt_parent->type() == coFloatOrPercent) { - v *= opt_parent->getFloat(); - if (opt_parent->type() == coFloat || ! static_cast(opt_parent)->percent) - break; - v *= 0.01; // percent to ratio - } - // Continue one level up in the "ratio_over" hierarchy. - opt_def = print_config_def.get(opt_def->ratio_over); - assert(opt_def != nullptr); - } - output.set_d(v); - } - break; - } - //BBS: Add enum. Otherwise enum can not be judged in placeholder - case coEnum: output.set_s(opt.opt->serialize()); break; - default: - ctx->throw_exception("Unknown scalar variable type", opt.it_range); + if (opt.opt->is_vector()) { + switch (opt.opt->type()) { + case coFloats: { + const ConfigOptionFloatsNullable* opt_floats = static_cast(opt.opt); + if (opt_floats->size() == 1) { // old version + output.set_d(static_cast(opt.opt)->get_at(0)); + } + else { + output.set_d(static_cast(opt.opt)->get_at(get_extruder_index(ctx->current_extruder_id))); + } + break; + } + case coFloatsOrPercents: { + const ConfigOptionFloatsOrPercentsNullable * opt_floats = static_cast(opt.opt); + size_t index = 0; // old version only one value + if (opt_floats->size() > 1) { + index = get_extruder_index(ctx->current_extruder_id); + } + std::string opt_key(opt.it_range.begin(), opt.it_range.end()); + if (!opt_floats->get_at(index).percent) { + // Not a percent, just return the value. + output.set_d(opt_floats->get_at(index).value); + } else { + // Resolve dependencies using the "ratio_over" link to a parent value. + const ConfigOptionDef *opt_def = print_config_def.get(opt_key); + assert(opt_def != nullptr); + assert(opt_def->type() == coFloatsOrPercents); + + FloatOrPercent opt_value = opt_floats->get_at(index); + double v = opt_value.value; + if (opt_value.percent) { + v *= 0.01; + while (true) { + const ConfigOption *opt_parent = opt_def->ratio_over.empty() ? nullptr : ctx->resolve_symbol(opt_def->ratio_over); + if (opt_parent == nullptr) { + ctx->throw_exception("FloatOrPercentNullable variable failed to resolve the \"ratio_over\" dependencies", opt.it_range); + } + if (opt_parent->type() == coFloat || opt_parent->type() == coFloatOrPercent) { + v *= opt_parent->getFloat(); + if (opt_parent->type() == coFloat || !static_cast(opt_parent)->percent) break; + v *= 0.01; // percent to ratio + } + } + } + output.set_d(v); + } + break; + } + default: ctx->throw_exception("Unknown scalar variable type", opt.it_range); + } } + else { + switch (opt.opt->type()) { + case coFloat: output.set_d(opt.opt->getFloat()); break; + case coInt: output.set_i(opt.opt->getInt()); break; + case coString: output.set_s(static_cast(opt.opt)->value); break; + case coPercent: output.set_d(opt.opt->getFloat()); break; + case coPoint: output.set_s(opt.opt->serialize()); break; + case coBool: output.set_b(opt.opt->getBool()); break; + case coFloatOrPercent: + { + std::string opt_key(opt.it_range.begin(), opt.it_range.end()); + if (boost::ends_with(opt_key, "line_width")) { + // Extrusion width supports defaults and a complex graph of dependencies. + output.set_d(Flow::extrusion_width(opt_key, *ctx, static_cast(ctx->current_extruder_id))); + } else if (! static_cast(opt.opt)->percent) { + // Not a percent, just return the value. + output.set_d(opt.opt->getFloat()); + } else { + // Resolve dependencies using the "ratio_over" link to a parent value. + const ConfigOptionDef *opt_def = print_config_def.get(opt_key); + assert(opt_def != nullptr); + double v = opt.opt->getFloat() * 0.01; // percent to ratio + for (;;) { + const ConfigOption *opt_parent = opt_def->ratio_over.empty() ? nullptr : ctx->resolve_symbol(opt_def->ratio_over); + if (opt_parent == nullptr) + ctx->throw_exception("FloatOrPercent variable failed to resolve the \"ratio_over\" dependencies", opt.it_range); + if (boost::ends_with(opt_def->ratio_over, "line_width")) { + // Extrusion width supports defaults and a complex graph of dependencies. + assert(opt_parent->type() == coFloatOrPercent); + v *= Flow::extrusion_width(opt_def->ratio_over, static_cast(opt_parent), *ctx, static_cast(ctx->current_extruder_id)); + break; + } + if (opt_parent->type() == coFloat || opt_parent->type() == coFloatOrPercent) { + v *= opt_parent->getFloat(); + if (opt_parent->type() == coFloat || ! static_cast(opt_parent)->percent) + break; + v *= 0.01; // percent to ratio + } + // Continue one level up in the "ratio_over" hierarchy. + opt_def = print_config_def.get(opt_def->ratio_over); + assert(opt_def != nullptr); + } + output.set_d(v); + } + break; + } + //BBS: Add enum. Otherwise enum can not be judged in placeholder + case coEnum: output.set_s(opt.opt->serialize()); break; + default: + ctx->throw_exception("Unknown scalar variable type", opt.it_range); + } + } + output.it_range = opt.it_range; } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 69be58c8d..2982dd0a6 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -898,14 +898,14 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Use only one wall on the first layer of model"); def->set_default_value(new ConfigOptionBool(false)); - def = this->add("enable_overhang_speed", coBool); + def = this->add("enable_overhang_speed", coBools); def->label = L("Slow down for overhang"); def->category = L("Speed"); def->tooltip = L("Enable this option to slow printing down for different overhang degree"); def->mode = comAdvanced; - def->set_default_value(new ConfigOptionBool{ true }); + def->set_default_value(new ConfigOptionBoolsNullable{ true }); - def = this->add("overhang_1_4_speed", coFloat); + def = this->add("overhang_1_4_speed", coFloats); def->label = "(10%, 25%)"; def->category = L("Speed"); def->full_label = "(10%, 25%)"; @@ -914,9 +914,9 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(0)); + def->set_default_value(new ConfigOptionFloatsNullable{0}); - def = this->add("overhang_2_4_speed", coFloat); + def = this->add("overhang_2_4_speed", coFloats); def->label = "[25%, 50%)"; def->category = L("Speed"); def->full_label = "[25%, 50%)"; @@ -925,9 +925,9 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(0)); + def->set_default_value(new ConfigOptionFloatsNullable{0}); - def = this->add("overhang_3_4_speed", coFloat); + def = this->add("overhang_3_4_speed", coFloats); def->label = "[50%, 75%)"; def->category = L("Speed"); def->full_label = "[50%, 75%)"; @@ -935,9 +935,9 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(0)); + def->set_default_value(new ConfigOptionFloatsNullable{0}); - def = this->add("overhang_4_4_speed", coFloat); + def = this->add("overhang_4_4_speed", coFloats); def->label = "[75%, 100%)"; def->category = L("Speed"); def->full_label = "[75%, 100%)"; @@ -945,25 +945,26 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(0)); + def->set_default_value(new ConfigOptionFloatsNullable{0}); - def = this->add("overhang_totally_speed", coFloat); - def->label = L("over 100% wall (not bridge)"); - def->category = L("Speed"); + def = this->add("overhang_totally_speed", coFloats); + def->label = L("over 100% wall (not bridge)"); + def->category = L("Speed"); def->tooltip = L("Speed for line of wall which has degree of overhang over 100% line width, but the wall is not a bridge wall."); def->sidetext = L("mm/s"); - def->min = 0; - def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat{24}); + def->min = 0; + def->mode = comAdvanced; + def->nullable = true; + def->set_default_value(new ConfigOptionFloatsNullable{ 24 }); - def = this->add("bridge_speed", coFloat); + def = this->add("bridge_speed", coFloats); def->label = L("Bridge"); def->category = L("Speed"); def->tooltip = L("Speed of bridge and completely overhang wall"); def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(25)); + def->set_default_value(new ConfigOptionFloatsNullable{25}); def = this->add("brim_width", coFloat); def->label = L("Brim width"); @@ -1088,13 +1089,13 @@ void PrintConfigDef::init_fff_params() "This can improve the cooling quality for needle and small details"); def->set_default_value(new ConfigOptionBools { true }); - def = this->add("default_acceleration", coFloat); + def = this->add("default_acceleration", coFloats); def->label = L("Normal printing"); def->tooltip = L("The default acceleration of both normal printing and travel except initial layer"); def->sidetext = "mm/s²"; def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(500.0)); + def->set_default_value(new ConfigOptionFloatsNullable{500.0}); def = this->add("default_filament_profile", coStrings); def->label = L("Default filament profile"); @@ -1265,7 +1266,7 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("outer_wall_speed", coFloat); + def = this->add("outer_wall_speed", coFloats); def->label = L("Outer wall"); def->category = L("Speed"); def->tooltip = L("Speed of outer wall which is outermost and visible. " @@ -1273,10 +1274,10 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(60)); + def->set_default_value(new ConfigOptionFloatsNullable{60}); - def = this->add("small_perimeter_speed", coFloatOrPercent); + def = this->add("small_perimeter_speed", coFloatsOrPercents); def->label = L("Small perimeters"); def->category = L("Speed"); def->tooltip = L("This setting will affect the speed of perimeters having radius <= small perimeter threshold" @@ -1286,16 +1287,16 @@ void PrintConfigDef::init_fff_params() def->ratio_over = "outer_wall_speed"; def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloatOrPercent(50, true)); + def->set_default_value(new ConfigOptionFloatsOrPercentsNullable{FloatOrPercent(50, true)}); - def = this->add("small_perimeter_threshold", coFloat); + def = this->add("small_perimeter_threshold", coFloats); def->label = L("Small perimter threshold"); def->category = L("Speed"); def->tooltip = L("This sets the threshold for small perimeter length. Default threshold is 0mm"); def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(0)); + def->set_default_value(new ConfigOptionFloatsNullable{0}); def = this->add("wall_sequence", coEnum); def->label = L("Order of walls"); @@ -1755,46 +1756,46 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Cross Hatch")); def->set_default_value(new ConfigOptionEnum(ipCubic)); - def = this->add("top_surface_acceleration", coFloat); + def = this->add("top_surface_acceleration", coFloats); def->label = L("Top surface"); def->tooltip = L("Acceleration of top surface infill. Using a lower value may improve top surface quality"); def->sidetext = "mm/s²"; def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(500)); + def->set_default_value(new ConfigOptionFloats{500}); - def = this->add("outer_wall_acceleration", coFloat); + def = this->add("outer_wall_acceleration", coFloats); def->label = L("Outer wall"); def->tooltip = L("Acceleration of outer wall. Using a lower value can improve quality"); def->sidetext = "mm/s²"; def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(500)); + def->set_default_value(new ConfigOptionFloatsNullable{500}); - def = this->add("inner_wall_acceleration", coFloat); + def = this->add("inner_wall_acceleration", coFloats); def->label = L("Inner wall"); def->tooltip = L("Acceleration of inner walls. 0 means using normal printing acceleration"); def->sidetext = "mm/s²"; def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(0)); + def->set_default_value(new ConfigOptionFloats{0}); - def = this->add("sparse_infill_acceleration", coFloatOrPercent); + def = this->add("sparse_infill_acceleration", coFloatsOrPercents); def->label = L("Sparse infill"); def->tooltip = L("Acceleration of sparse infill. If the value is expressed as a percentage (e.g. 100%), it will be calculated based on the default acceleration."); def->sidetext = L("mm/s² or %"); def->min = 0; def->mode = comAdvanced; def->ratio_over = "default_acceleration"; - def->set_default_value(new ConfigOptionFloatOrPercent(100, true)); + def->set_default_value(new ConfigOptionFloatsOrPercents{FloatOrPercent(100, true)}); - def = this->add("initial_layer_acceleration", coFloat); + def = this->add("initial_layer_acceleration", coFloats); def->label = L("Initial layer"); def->tooltip = L("Acceleration of initial layer. Using a lower value can improve build plate adhensive"); def->sidetext = "mm/s²"; def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(300)); + def->set_default_value(new ConfigOptionFloatsNullable{300}); def = this->add("accel_to_decel_enable", coBool); def->label = L("Enable accel_to_decel"); @@ -1892,21 +1893,21 @@ void PrintConfigDef::init_fff_params() // "Note that this option only takes effect if no prime tower is generated in current plate."); //def->set_default_value(new ConfigOptionBool(0)); - def = this->add("initial_layer_speed", coFloat); + def = this->add("initial_layer_speed", coFloats); def->label = L("Initial layer"); def->tooltip = L("Speed of initial layer except the solid infill part"); def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(30)); + def->set_default_value(new ConfigOptionFloatsNullable{30}); - def = this->add("initial_layer_infill_speed", coFloat); + def = this->add("initial_layer_infill_speed", coFloats); def->label = L("Initial layer infill"); def->tooltip = L("Speed of solid infill part of initial layer"); def->sidetext = L("mm/s"); def->min = 1; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(60.0)); + def->set_default_value(new ConfigOptionFloatsNullable{60.0}); def = this->add("nozzle_temperature_initial_layer", coInts); def->label = L("Initial layer"); @@ -1971,14 +1972,14 @@ void PrintConfigDef::init_fff_params() def->mode = comDevelop; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("gap_infill_speed", coFloat); + def = this->add("gap_infill_speed", coFloats); def->label = L("Gap infill"); def->category = L("Speed"); def->tooltip = L("Speed of gap infill. Gap usually has irregular line width and should be printed more slowly"); def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(30)); + def->set_default_value(new ConfigOptionFloatsNullable{30}); // BBS def = this->add("precise_z_height", coBool); @@ -2215,14 +2216,14 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionPercent(15)); - def = this->add("sparse_infill_speed", coFloat); + def = this->add("sparse_infill_speed", coFloats); def->label = L("Sparse infill"); def->category = L("Speed"); def->tooltip = L("Speed of internal sparse infill"); def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(100)); + def->set_default_value(new ConfigOptionFloatsNullable{100}); def = this->add("inherits", coString); //def->label = L("Inherits profile"); @@ -2716,7 +2717,7 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(0.4)); - def = this->add("inner_wall_speed", coFloat); + def = this->add("inner_wall_speed", coFloats); def->label = L("Inner wall"); def->category = L("Speed"); def->tooltip = L("Speed of inner wall"); @@ -2724,7 +2725,7 @@ void PrintConfigDef::init_fff_params() def->aliases = { "perimeter_feed_rate" }; def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(60)); + def->set_default_value(new ConfigOptionFloatsNullable{60}); def = this->add("wall_loops", coInt); def->label = L("Wall loops"); @@ -3132,14 +3133,14 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(0.4)); - def = this->add("internal_solid_infill_speed", coFloat); + def = this->add("internal_solid_infill_speed", coFloats); def->label = L("Internal solid infill"); def->category = L("Speed"); def->tooltip = L("Speed of internal solid infill, not the top and bottom surface"); def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(100)); + def->set_default_value(new ConfigOptionFloatsNullable{100}); def = this->add("spiral_mode", coBool); def->label = L("Spiral vase"); @@ -3466,14 +3467,14 @@ void PrintConfigDef::init_fff_params() def->mode = comDevelop; def->set_default_value(new ConfigOptionFloat(0.5)); - def = this->add("support_interface_speed", coFloat); + def = this->add("support_interface_speed", coFloats); def->label = L("Support interface"); def->category = L("Speed"); def->tooltip = L("Speed of support interface"); def->sidetext = L("mm/s"); def->min = 1; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(80)); + def->set_default_value(new ConfigOptionFloatsNullable{80}); def = this->add("support_base_pattern", coEnum); def->label = L("Base pattern"); @@ -3532,14 +3533,14 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("support_speed", coFloat); + def = this->add("support_speed", coFloats); def->label = L("Support"); def->category = L("Speed"); def->tooltip = L("Speed of support"); def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(80)); + def->set_default_value(new ConfigOptionFloatsNullable{ 80 }); def = this->add("support_style", coEnum); def->label = L("Style"); @@ -3707,14 +3708,14 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(0.4)); - def = this->add("top_surface_speed", coFloat); + def = this->add("top_surface_speed", coFloats); def->label = L("Top surface"); def->category = L("Speed"); def->tooltip = L("Speed of top surface infill which is solid"); def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(100)); + def->set_default_value(new ConfigOptionFloatsNullable{100}); def = this->add("top_shell_layers", coInt); def->label = L("Top shell layers"); @@ -3737,15 +3738,15 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->set_default_value(new ConfigOptionFloat(0.6)); - def = this->add("travel_speed", coFloat); + def = this->add("travel_speed", coFloats); def->label = L("Travel"); def->tooltip = L("Speed of travel which is faster and without extrusion"); def->sidetext = L("mm/s"); def->min = 1; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(120)); + def->set_default_value(new ConfigOptionFloatsNullable{120}); - def = this->add("travel_speed_z", coFloat); + def = this->add("travel_speed_z", coFloats); //def->label = L("Z travel"); //def->tooltip = L("Speed of vertical travel along z axis. " // "This is typically lower because build plate or gantry is hard to be moved. " @@ -3753,7 +3754,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comDevelop; - def->set_default_value(new ConfigOptionFloat(0.)); + def->set_default_value(new ConfigOptionFloatsNullable{0.}); def = this->add("use_relative_e_distances", coBool); def->label = L("Use relative E distances"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index cec3eed19..952de3d91 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -355,6 +355,12 @@ 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; +} + #define CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(NAME) \ template<> const t_config_enum_names& ConfigOptionEnum::get_enum_names(); \ template<> const t_config_enum_values& ConfigOptionEnum::get_enum_values(); @@ -749,13 +755,13 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionInt, support_interface_bottom_layers)) // Spacing between interface lines (the hatching distance). Set zero to get a solid interface. ((ConfigOptionFloat, support_interface_spacing)) - ((ConfigOptionFloat, support_interface_speed)) + ((ConfigOptionFloatsNullable, support_interface_speed)) ((ConfigOptionEnum, support_base_pattern)) ((ConfigOptionEnum, support_interface_pattern)) // Spacing between support material lines (the hatching distance). ((ConfigOptionFloat, support_base_pattern_spacing)) ((ConfigOptionFloat, support_expansion)) - ((ConfigOptionFloat, support_speed)) + ((ConfigOptionFloatsNullable, support_speed)) ((ConfigOptionEnum, support_style)) // BBS //((ConfigOptionBool, independent_support_layer_height)) @@ -806,25 +812,25 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloat, bottom_shell_thickness)) ((ConfigOptionFloat, bridge_angle)) ((ConfigOptionFloat, bridge_flow)) - ((ConfigOptionFloat, overhang_totally_speed)) - ((ConfigOptionFloat, bridge_speed)) + ((ConfigOptionFloatsNullable, overhang_totally_speed)) + ((ConfigOptionFloatsNullable, bridge_speed)) ((ConfigOptionBool, ensure_vertical_shell_thickness)) ((ConfigOptionEnum, top_surface_pattern)) ((ConfigOptionEnum, bottom_surface_pattern)) ((ConfigOptionEnum, internal_solid_infill_pattern)) ((ConfigOptionFloat, outer_wall_line_width)) - ((ConfigOptionFloat, outer_wall_speed)) + ((ConfigOptionFloatsNullable, outer_wall_speed)) ((ConfigOptionFloat, infill_direction)) ((ConfigOptionPercent, sparse_infill_density)) ((ConfigOptionEnum, sparse_infill_pattern)) ((ConfigOptionEnum, fuzzy_skin)) ((ConfigOptionFloat, fuzzy_skin_thickness)) ((ConfigOptionFloat, fuzzy_skin_point_distance)) - ((ConfigOptionFloat, gap_infill_speed)) + ((ConfigOptionFloatsNullable, gap_infill_speed)) ((ConfigOptionInt, sparse_infill_filament)) ((ConfigOptionFloat, sparse_infill_line_width)) ((ConfigOptionPercent, infill_wall_overlap)) - ((ConfigOptionFloat, sparse_infill_speed)) + ((ConfigOptionFloatsNullable, sparse_infill_speed)) //BBS ((ConfigOptionBool, infill_combination)) // Ironing options @@ -841,27 +847,27 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloat, smooth_coefficient)) ((ConfigOptionInt, wall_filament)) ((ConfigOptionFloat, inner_wall_line_width)) - ((ConfigOptionFloat, inner_wall_speed)) + ((ConfigOptionFloatsNullable, inner_wall_speed)) // Total number of perimeters. ((ConfigOptionInt, wall_loops)) ((ConfigOptionFloat, minimum_sparse_infill_area)) ((ConfigOptionInt, solid_infill_filament)) ((ConfigOptionFloat, internal_solid_infill_line_width)) - ((ConfigOptionFloat, internal_solid_infill_speed)) + ((ConfigOptionFloatsNullable, internal_solid_infill_speed)) // Detect thin walls. ((ConfigOptionBool, detect_thin_wall)) ((ConfigOptionFloat, top_surface_line_width)) ((ConfigOptionInt, top_shell_layers)) ((ConfigOptionFloat, top_shell_thickness)) - ((ConfigOptionFloat, top_surface_speed)) - ((ConfigOptionFloatOrPercent, small_perimeter_speed)) - ((ConfigOptionFloat, small_perimeter_threshold)) + ((ConfigOptionFloatsNullable, top_surface_speed)) + ((ConfigOptionFloatsOrPercentsNullable, small_perimeter_speed)) + ((ConfigOptionFloatsNullable, small_perimeter_threshold)) //BBS - ((ConfigOptionBool, enable_overhang_speed)) - ((ConfigOptionFloat, overhang_1_4_speed)) - ((ConfigOptionFloat, overhang_2_4_speed)) - ((ConfigOptionFloat, overhang_3_4_speed)) - ((ConfigOptionFloat, overhang_4_4_speed)) + ((ConfigOptionBoolsNullable, enable_overhang_speed)) + ((ConfigOptionFloatsNullable, overhang_1_4_speed)) + ((ConfigOptionFloatsNullable, overhang_2_4_speed)) + ((ConfigOptionFloatsNullable, overhang_3_4_speed)) + ((ConfigOptionFloatsNullable, overhang_4_4_speed)) ((ConfigOptionFloatOrPercent, sparse_infill_anchor)) ((ConfigOptionFloatOrPercent, sparse_infill_anchor_max)) //OrcaSlicer @@ -976,8 +982,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionBool, single_extruder_multi_material)) ((ConfigOptionBool, wipe_tower_no_sparse_layers)) ((ConfigOptionString, change_filament_gcode)) - ((ConfigOptionFloat, travel_speed)) - ((ConfigOptionFloat, travel_speed_z)) + ((ConfigOptionFloatsNullable, travel_speed)) + ((ConfigOptionFloatsNullable, travel_speed_z)) ((ConfigOptionBool, use_relative_e_distances)) ((ConfigOptionBool, use_firmware_retraction)) ((ConfigOptionBool, silent_mode)) @@ -1032,9 +1038,9 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionInts, other_layers_print_sequence)) ((ConfigOptionInt, other_layers_print_sequence_nums)) ((ConfigOptionBools, slow_down_for_layer_cooling)) - ((ConfigOptionFloat, default_acceleration)) - ((ConfigOptionFloat, inner_wall_acceleration)) - ((ConfigOptionFloatOrPercent, sparse_infill_acceleration)) + ((ConfigOptionFloatsNullable, default_acceleration)) + ((ConfigOptionFloats, inner_wall_acceleration)) + ((ConfigOptionFloatsOrPercents, sparse_infill_acceleration)) ((ConfigOptionBools, activate_air_filtration)) ((ConfigOptionInts, during_print_exhaust_fan_speed)) ((ConfigOptionInts, complete_print_exhaust_fan_speed)) @@ -1050,14 +1056,14 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionBools, reduce_fan_stop_start_freq)) ((ConfigOptionInts, fan_cooling_layer_time)) ((ConfigOptionStrings, filament_colour)) - ((ConfigOptionFloat, top_surface_acceleration)) - ((ConfigOptionFloat, outer_wall_acceleration)) - ((ConfigOptionFloat, initial_layer_acceleration)) + ((ConfigOptionFloats, top_surface_acceleration)) + ((ConfigOptionFloatsNullable, outer_wall_acceleration)) + ((ConfigOptionFloatsNullable, initial_layer_acceleration)) ((ConfigOptionFloat, initial_layer_line_width)) ((ConfigOptionFloat, initial_layer_print_height)) - ((ConfigOptionFloat, initial_layer_speed)) + ((ConfigOptionFloatsNullable, initial_layer_speed)) //BBS - ((ConfigOptionFloat, initial_layer_infill_speed)) + ((ConfigOptionFloatsNullable, initial_layer_infill_speed)) ((ConfigOptionInts, nozzle_temperature_initial_layer)) ((ConfigOptionInts, full_fan_speed_layer)) ((ConfigOptionInts, fan_max_speed)) diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 1895fd75b..ffeee02d8 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -575,7 +575,8 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co for (auto el : { "top_surface_line_width", "top_surface_speed" }) toggle_field(el, has_top_solid_infill || (has_spiral_vase && has_bottom_solid_infill)); - bool have_default_acceleration = config->opt_float("default_acceleration") > 0; + // todo multi_extruders: the exact filament id + bool have_default_acceleration = config->opt_float("default_acceleration", 0) > 0; //BBS for (auto el : { "initial_layer_acceleration", "outer_wall_acceleration", "top_surface_acceleration", "inner_wall_acceleration", "sparse_infill_acceleration" }) toggle_field(el, have_default_acceleration); @@ -674,7 +675,8 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co bool have_avoid_crossing_perimeters = config->opt_bool("reduce_crossing_wall"); toggle_line("max_travel_detour_distance", have_avoid_crossing_perimeters); - bool has_overhang_speed = config->opt_bool("enable_overhang_speed"); + // todo multi_extruders: + bool has_overhang_speed = config->opt_bool("enable_overhang_speed", 0); for (auto el : { "overhang_1_4_speed", "overhang_2_4_speed", "overhang_3_4_speed", "overhang_4_4_speed"}) toggle_line(el, has_overhang_speed); diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 8ba12bf72..b9e614ad8 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -96,6 +96,7 @@ std::map> SettingsFactory::OBJECT_C }} }; +// todo multi_extruders: Does the following need to be modified? std::map> SettingsFactory::PART_CATEGORY_SETTINGS= {{L("Quality"), {{"ironing_type", "", 8}, {"ironing_flow", "", 9}, {"ironing_spacing", "", 10}, {"ironing_inset", "", 11}, {"ironing_speed", "", 12}, {"ironing_direction", "",13} }}, diff --git a/src/slic3r/GUI/GUI_ObjectTable.cpp b/src/slic3r/GUI/GUI_ObjectTable.cpp index ade7f77da..a20c85416 100644 --- a/src/slic3r/GUI/GUI_ObjectTable.cpp +++ b/src/slic3r/GUI/GUI_ObjectTable.cpp @@ -1901,6 +1901,7 @@ void ObjectGridTable::init_cols(ObjectGrid *object_grid) col = new ObjectGridCol(coEnum, "brim_type_reset", L("Support"), true, true, false, false, wxALIGN_LEFT); m_col_data.push_back(col); + // todo mutli_extruders: //object/volume speed col = new ObjectGridCol(coFloat, "outer_wall_speed", L("Speed"), false, false, true, true, wxALIGN_LEFT); col->size = object_grid->GetTextExtent(L("Outer wall speed")).x; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4f1d2dbb6..815d7ca56 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -9789,8 +9789,9 @@ void Plater::calib_flowrate(int pass) Flow infill_flow = Flow(nozzle_diameter * 1.2f, layer_height, nozzle_diameter); double filament_max_volumetric_speed = filament_config->option("filament_max_volumetric_speed")->get_at(0); double max_infill_speed = filament_max_volumetric_speed / (infill_flow.mm3_per_mm() * (pass == 1 ? 1.2 : 1)); - double internal_solid_speed = std::floor(std::min(print_config->opt_float("internal_solid_infill_speed"), max_infill_speed)); - double top_surface_speed = std::floor(std::min(print_config->opt_float("top_surface_speed"), max_infill_speed)); + // todo multi_extruder: + double internal_solid_speed = std::floor(std::min(print_config->opt_float("internal_solid_infill_speed", 0), max_infill_speed)); + double top_surface_speed = std::floor(std::min(print_config->opt_float("top_surface_speed", 0), max_infill_speed)); // adjust parameters for (auto _obj : model().objects) { diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index c002c2e99..79fb1c974 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -557,8 +557,8 @@ bool CalibUtils::calib_flowrate(int pass, const CalibInfo &calib_info, wxString Flow infill_flow = Flow(nozzle_diameter * 1.2f, layer_height, nozzle_diameter); double filament_max_volumetric_speed = filament_config.option("filament_max_volumetric_speed")->get_at(0); double max_infill_speed = filament_max_volumetric_speed / (infill_flow.mm3_per_mm() * (pass == 1 ? 1.2 : 1)); - double internal_solid_speed = std::floor(std::min(print_config.opt_float("internal_solid_infill_speed"), max_infill_speed)); - double top_surface_speed = std::floor(std::min(print_config.opt_float("top_surface_speed"), max_infill_speed)); + double internal_solid_speed = std::floor(std::min(print_config.opt_float("internal_solid_infill_speed", get_extruder_index(stoi(calib_info.filament_prest->filament_id))), max_infill_speed)); + double top_surface_speed = std::floor(std::min(print_config.opt_float("top_surface_speed", get_extruder_index(stoi(calib_info.filament_prest->filament_id))), max_infill_speed)); // adjust parameters filament_config.set_key_value("curr_bed_type", new ConfigOptionEnum(calib_info.bed_type));