diff options
Diffstat (limited to 'xs/src/libslic3r/PrintConfig.cpp')
-rw-r--r-- | xs/src/libslic3r/PrintConfig.cpp | 104 |
1 files changed, 64 insertions, 40 deletions
diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 463dc7eeb..5fd932cc7 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1,6 +1,7 @@ #include "PrintConfig.hpp" #include "I18N.hpp" +#include <algorithm> #include <set> #include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/case_conv.hpp> @@ -25,16 +26,16 @@ PrintConfigDef::PrintConfigDef() // Maximum extruder temperature, bumped to 1500 to support printing of glass. const int max_temp = 1500; - def = this->add("avoid_crossing_perimeters", coBool); + def = this->add("avoid_crossing_perimeters", coBool); def->label = L("Avoid crossing perimeters"); - def->tooltip = L("Optimize travel moves in order to minimize the crossing of perimeters. " + def->tooltip = L("Optimize travel moves in order to minimize the crossing of perimeters. " "This is mostly useful with Bowden extruders which suffer from oozing. " "This feature slows down both the print and the G-code generation."); def->cli = "avoid-crossing-perimeters!"; def->default_value = new ConfigOptionBool(false); def = this->add("bed_shape", coPoints); - def->label = L("Bed shape"); + def->label = L("Bed shape"); def->default_value = new ConfigOptionPoints { Pointf(0,0), Pointf(200,0), Pointf(200,200), Pointf(0,200) }; def = this->add("bed_temperature", coInts); @@ -91,7 +92,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Bridging angle override. If left to zero, the bridging angle will be calculated " "automatically. Otherwise the provided angle will be used for all bridges. " "Use 180° for zero angle."); - def->sidetext = L("°"); + def->sidetext = L("°"); def->cli = "bridge-angle=f"; def->min = 0; def->default_value = new ConfigOptionFloat(0.); @@ -123,8 +124,8 @@ PrintConfigDef::PrintConfigDef() "with cooling (use a fan) before tweaking this."); def->cli = "bridge-flow-ratio=f"; def->min = 0; - def->max = 2; - def->default_value = new ConfigOptionFloat(1); + def->max = 2; + def->default_value = new ConfigOptionFloat(1); def = this->add("over_bridge_flow_ratio", coFloat); def->label = L("Above the bridges"); @@ -132,7 +133,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("This factor affects the amount of plastic to overextrude " "when we are filling on top of a bridge surface." "With a number >1, we can retrieve a correct z-height " - "even if the bridged layer has fallen a bit. " + "even if the bridged layer has fallen a bit. " "It's useful if you want to have a nice flat top layer."); def->cli = "over-bridge-flow-ratio=f"; def->min = 0; @@ -144,7 +145,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Speed for printing bridges."); def->sidetext = L("mm/s"); def->cli = "bridge-speed=f"; - def->aliases.push_back("bridge_feed_rate"); + def->aliases = { "bridge_feed_rate" }; def->min = 0; def->default_value = new ConfigOptionFloat(60); @@ -257,7 +258,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Distance used for the auto-arrange feature of the plater."); def->sidetext = L("mm"); def->cli = "duplicate-distance=f"; - def->aliases.push_back("multiply_distance"); + def->aliases = { "multiply_distance" }; def->min = 0; def->default_value = new ConfigOptionFloat(6); @@ -309,7 +310,7 @@ PrintConfigDef::PrintConfigDef() def->enum_values.push_back("concentric"); def->enum_values.push_back("hilbertcurve"); def->enum_values.push_back("archimedeanchords"); - def->enum_values.push_back("octagramspiral"); + def->enum_values.push_back("octagramspiral"); def->enum_values.push_back("smooth"); def->enum_values.push_back("smoothtriple"); def->enum_values.push_back("smoothhilbert"); @@ -318,11 +319,9 @@ PrintConfigDef::PrintConfigDef() def->enum_labels.push_back(L("Hilbert Curve")); def->enum_labels.push_back(L("Archimedean Chords")); def->enum_labels.push_back(L("Octagram Spiral")); - def->enum_labels.push_back("Ironing"); - //def->enum_labels.push_back("Ironing (triple)"); - //def->enum_labels.push_back("Ironing (hilbert)"); + def->enum_labels.push_back("Ironing"); // solid_fill_pattern is an obsolete equivalent to top_fill_pattern/bottom_fill_pattern. - def->aliases.push_back("solid_fill_pattern"); + def->aliases = { "solid_fill_pattern" }; def->default_value = new ConfigOptionEnum<InfillPattern>(ipRectilinear); def = this->add("bottom_fill_pattern", coEnum); @@ -642,7 +641,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("This string is edited by RammingDialog and contains ramming specific parameters "); def->cli = "filament-ramming-parameters=s@"; def->default_value = new ConfigOptionStrings { "120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0|" - " 0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" }; + " 0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" }; def = this->add("filament_unload_time", coFloats); def->label = L("Filament unload time"); @@ -727,7 +726,7 @@ PrintConfigDef::PrintConfigDef() def->cli = "fill-density=s"; def->min = 0; def->max = 100; - /* + /* def->enum_values.push_back("0"); def->enum_values.push_back("5"); def->enum_values.push_back("10"); @@ -756,7 +755,7 @@ PrintConfigDef::PrintConfigDef() def->enum_labels.push_back("80%"); def->enum_labels.push_back("90%"); def->enum_labels.push_back("100%"); - */ + */ def->enum_values.push_back("0"); def->enum_values.push_back("4"); def->enum_values.push_back("5.5"); @@ -1028,8 +1027,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Speed for printing the internal fill. Set to zero for auto."); def->sidetext = L("mm/s"); def->cli = "infill-speed=f"; - def->aliases.push_back("print_feed_rate"); - def->aliases.push_back("infill_feed_rate"); + def->aliases = { "print_feed_rate", "infill_feed_rate" }; def->min = 0; def->default_value = new ConfigOptionFloat(80); @@ -1149,8 +1147,8 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Minimum feedrate when extruding") + " (M205 S)"; def->sidetext = L("mm/s"); def->min = 0; - def->width = machine_limits_opt_width; - def->default_value = new ConfigOptionFloats{ 0., 0. }; + def->width = machine_limits_opt_width; + def->default_value = new ConfigOptionFloats{ 0., 0. }; // M205 T... [mm/sec] def = this->add("machine_min_travel_rate", coFloats); @@ -1159,8 +1157,8 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Minimum travel feedrate") + " (M205 T)"; def->sidetext = L("mm/s"); def->min = 0; - def->width = machine_limits_opt_width; - def->default_value = new ConfigOptionFloats{ 0., 0. }; + def->width = machine_limits_opt_width; + def->default_value = new ConfigOptionFloats{ 0., 0. }; // M204 S... [mm/sec^2] def = this->add("machine_max_acceleration_extruding", coFloats); @@ -1169,7 +1167,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Maximum acceleration when extruding") + " (M204 S)"; def->sidetext = L("mm/s²"); def->min = 0; - def->width = machine_limits_opt_width; + def->width = machine_limits_opt_width; def->default_value = new ConfigOptionFloats{ 1500., 1250. }; // M204 T... [mm/sec^2] @@ -1179,7 +1177,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Maximum acceleration when retracting") + " (M204 T)"; def->sidetext = L("mm/s²"); def->min = 0; - def->width = machine_limits_opt_width; + def->width = machine_limits_opt_width; def->default_value = new ConfigOptionFloats{ 1500., 1250. }; def = this->add("max_fan_speed", coInts); @@ -1423,7 +1421,7 @@ PrintConfigDef::PrintConfigDef() def->category = L("Extruders"); def->tooltip = L("The extruder to use when printing perimeters and brim. First extruder is 1."); def->cli = "perimeter-extruder=i"; - def->aliases.push_back("perimeters_extruder"); + def->aliases = { "perimeters_extruder" }; def->min = 1; def->default_value = new ConfigOptionInt(1); @@ -1436,7 +1434,7 @@ PrintConfigDef::PrintConfigDef() "If expressed as percentage (for example 200%) it will be computed over layer height."); def->sidetext = L("mm or % (leave 0 for default)"); def->cli = "perimeter-extrusion-width=s"; - def->aliases.push_back("perimeters_extrusion_width"); + def->aliases = { "perimeters_extrusion_width" }; def->default_value = new ConfigOptionFloatOrPercent(0, false); def = this->add("perimeter_speed", coFloat); @@ -1445,7 +1443,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Speed for perimeters (contours, aka vertical shells). Set to zero for auto."); def->sidetext = L("mm/s"); def->cli = "perimeter-speed=f"; - def->aliases.push_back("perimeter_feed_rate"); + def->aliases = { "perimeter_feed_rate" }; def->min = 0; def->default_value = new ConfigOptionFloat(60); @@ -1458,7 +1456,7 @@ PrintConfigDef::PrintConfigDef() "if the Extra Perimeters option is enabled."); def->sidetext = L("(minimum)"); def->cli = "perimeters=i"; - def->aliases.push_back("perimeter_offsets"); + def->aliases = { "perimeter_offsets" }; def->min = 0; def->default_value = new ConfigOptionInt(3); @@ -1472,8 +1470,8 @@ PrintConfigDef::PrintConfigDef() def->gui_flags = "serialized"; def->multiline = true; def->full_width = true; - def->height = 60; - def->default_value = new ConfigOptionStrings(); + def->height = 60; + def->default_value = new ConfigOptionStrings(); def = this->add("printer_model", coString); def->label = L("Printer type"); @@ -1793,7 +1791,7 @@ PrintConfigDef::PrintConfigDef() def->sidetext = L("mm/s or %"); def->cli = "solid-infill-speed=s"; def->ratio_over = "infill_speed"; - def->aliases.push_back("solid_infill_feed_rate"); + def->aliases = { "solid_infill_feed_rate" }; def->min = 0; def->default_value = new ConfigOptionFloatOrPercent(20, false); @@ -1819,7 +1817,7 @@ PrintConfigDef::PrintConfigDef() def->label = L("Temperature variation"); def->tooltip = L("Temperature difference to be applied when an extruder is not active. " "Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped."); - def->sidetext = "∆°C"; + def->sidetext = "∆°C"; def->cli = "standby-temperature-delta=i"; def->min = -max_temp; def->max = max_temp; @@ -1875,6 +1873,14 @@ PrintConfigDef::PrintConfigDef() def->cli = "support-material!"; def->default_value = new ConfigOptionBool(false); + def = this->add("support_material_auto", coBool); + def->label = L("Auto generated supports"); + def->category = L("Support material"); + def->tooltip = L("If checked, supports will be generated automatically based on the overhang threshold value."\ + " If unchecked, supports will be generated inside the \"Support Enforcer\" volumes only."); + def->cli = "support-material-auto!"; + def->default_value = new ConfigOptionBool(true); + def = this->add("support_material_xy_spacing", coFloatOrPercent); def->label = L("XY separation between an object and its support"); def->category = L("Support material"); @@ -1913,11 +1919,11 @@ PrintConfigDef::PrintConfigDef() "for the first object layer."); def->sidetext = L("mm"); def->cli = "support-material-contact-distance=f"; - def->min = 0; +// def->min = 0; def->enum_values.push_back("0"); def->enum_values.push_back("0.2"); - def->enum_labels.push_back((boost::format("0 (%1%)") % L("soluble")).str()); - def->enum_labels.push_back((boost::format("0.2 (%1%)") % L("detachable")).str()); + def->enum_labels.push_back((boost::format("0 (%1%)") % L("soluble")).str()); + def->enum_labels.push_back((boost::format("0.2 (%1%)") % L("detachable")).str()); def->default_value = new ConfigOptionFloat(0.2); def = this->add("support_material_enforce_layers", coInt); @@ -2006,7 +2012,7 @@ PrintConfigDef::PrintConfigDef() def->enum_values.push_back("rectilinear"); def->enum_values.push_back("rectilinear-grid"); def->enum_values.push_back("honeycomb"); - def->enum_labels.push_back(L("Rectilinear")); + def->enum_labels.push_back(L("Rectilinear")); def->enum_labels.push_back(L("Rectilinear grid")); def->enum_labels.push_back(L("Honeycomb")); def->default_value = new ConfigOptionEnum<SupportMaterialPattern>(smpRectilinear); @@ -2139,7 +2145,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("Speed for travel moves (jumps between distant extrusion points)."); def->sidetext = L("mm/s"); def->cli = "travel-speed=f"; - def->aliases.push_back("travel_feed_rate"); + def->aliases = { "travel_feed_rate" }; def->min = 1; def->default_value = new ConfigOptionFloat(130); @@ -2427,6 +2433,24 @@ std::string DynamicPrintConfig::validate() return fpc.validate(); } +size_t DynamicPrintConfig::remove_keys_not_in(const DynamicPrintConfig &default_config, std::string &removed_keys_message) +{ + size_t n_removed_keys = 0; + for (const std::string &key : this->keys()) { + if (! default_config.has(key)) { + if (removed_keys_message.empty()) + removed_keys_message = key; + else { + removed_keys_message += ", "; + removed_keys_message += key; + } + this->erase(key); + ++ n_removed_keys; + } + } + return n_removed_keys; +} + double PrintConfig::min_object_distance() const { return PrintConfig::min_object_distance(static_cast<const ConfigBase*>(this)); @@ -2507,8 +2531,8 @@ std::string FullPrintConfig::validate() // --fill-density if (fabs(this->fill_density.value - 100.) < EPSILON && (! print_config_def.get("top_fill_pattern")->has_enum_value(this->fill_pattern.serialize()) - || ! print_config_def.get("bottom_fill_pattern")->has_enum_value(this->fill_pattern.serialize()) - )) + || ! print_config_def.get("bottom_fill_pattern")->has_enum_value(this->fill_pattern.serialize()) + )) return "The selected fill pattern is not supposed to work at 100% density"; // --infill-every-layers |