From a61e8335365d711be4f1cbe08e02832426cef294 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 3 May 2019 18:01:39 +0200 Subject: [PATCH] Implemented the "Support for support enforcers only" quick selection. Reduced some memory leaks due to the ConfigDef::default_value pointer. --- src/libslic3r/Config.cpp | 8 +- src/libslic3r/Config.hpp | 10 +- src/libslic3r/PrintConfig.cpp | 590 +++++++++++----------- src/libslic3r/PrintConfig.hpp | 4 +- src/libslic3r/clonable_ptr.hpp | 168 ++++++ src/slic3r/GUI/BedShapeDialog.cpp | 6 +- src/slic3r/GUI/ConfigWizard.cpp | 10 +- src/slic3r/GUI/Field.cpp | 26 +- src/slic3r/GUI/GUI_ObjectManipulation.cpp | 6 +- src/slic3r/GUI/LambdaObjectDialog.cpp | 8 +- src/slic3r/GUI/Plater.cpp | 41 +- src/slic3r/GUI/Preferences.cpp | 18 +- src/slic3r/GUI/Tab.cpp | 48 +- xs/xsp/Config.xsp | 4 +- 14 files changed, 559 insertions(+), 388 deletions(-) create mode 100644 src/libslic3r/clonable_ptr.hpp diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index a7db29b8e..7273fda01 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -280,7 +280,7 @@ std::ostream& ConfigDef::print_cli_help(std::ostream& out, bool show_defaults, s // right: option description std::string descr = def.tooltip; - if (show_defaults && def.default_value != nullptr && def.type != coBool + if (show_defaults && def.default_value && def.type != coBool && (def.type != coString || !def.default_value->serialize().empty())) { descr += " ("; if (!def.sidetext.empty()) { @@ -627,7 +627,7 @@ ConfigOption* DynamicConfig::optptr(const t_config_option_key &opt_key, bool cre // Let the parent decide what to do if the opt_key is not defined by this->def(). return nullptr; ConfigOption *opt = nullptr; - if (optdef->default_value != nullptr) { + if (optdef->default_value) { opt = (optdef->default_value->type() == coEnum) ? // Special case: For a DynamicConfig, convert a templated enum to a generic enum. new ConfigOptionEnumGeneric(optdef->enum_keys_map, optdef->default_value->getInt()) : @@ -783,8 +783,8 @@ void StaticConfig::set_defaults() for (const std::string &key : this->keys()) { const ConfigOptionDef *def = defs->get(key); ConfigOption *opt = this->option(key); - if (def != nullptr && opt != nullptr && def->default_value != nullptr) - opt->set(def->default_value); + if (def != nullptr && opt != nullptr && def->default_value) + opt->set(def->default_value.get()); } } } diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 1e5972701..625335de6 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -12,6 +12,7 @@ #include #include #include "libslic3r.h" +#include "clonable_ptr.hpp" #include "Point.hpp" #include @@ -1010,7 +1011,8 @@ public: // What type? bool, int, string etc. ConfigOptionType type = coNone; // Default value of this option. The default value object is owned by ConfigDef, it is released in its destructor. - const ConfigOption *default_value = nullptr; + Slic3r::clonable_ptr default_value = nullptr; + void set_default_value(const ConfigOption* ptr) { this->default_value = Slic3r::clonable_ptr(ptr); } // Usually empty. // Special values - "i_enum_open", "f_enum_open" to provide combo box for int or float selection, @@ -1099,12 +1101,6 @@ typedef std::map t_optiondef_map; class ConfigDef { public: - ~ConfigDef() { - for (std::pair &def : this->options) - delete def.second.default_value; - this->options.clear(); - } - t_optiondef_map options; bool has(const t_config_option_key &opt_key) const { return this->options.count(opt_key) > 0; } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 3e1fc5c3d..f9936530e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -44,12 +44,12 @@ void PrintConfigDef::init_common_params() def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); def->enum_values.push_back("FFF"); def->enum_values.push_back("SLA"); - def->default_value = new ConfigOptionEnum(ptFFF); + def->set_default_value(new ConfigOptionEnum(ptFFF)); def = this->add("bed_shape", coPoints); def->label = L("Bed shape"); def->mode = comAdvanced; - def->default_value = new ConfigOptionPoints{ Vec2d(0, 0), Vec2d(200, 0), Vec2d(200, 200), Vec2d(0, 200) }; + def->set_default_value(new ConfigOptionPoints{ Vec2d(0, 0), Vec2d(200, 0), Vec2d(200, 200), Vec2d(0, 200) }); def = this->add("layer_height", coFloat); def->label = L("Layer height"); @@ -58,14 +58,14 @@ void PrintConfigDef::init_common_params() "Thinner layers give better accuracy but take more time to print."); def->sidetext = L("mm"); def->min = 0; - def->default_value = new ConfigOptionFloat(0.3); + def->set_default_value(new ConfigOptionFloat(0.3)); def = this->add("max_print_height", coFloat); def->label = L("Max print height"); def->tooltip = L("Set this to the maximum height that can be reached by your extruder while printing."); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(200.0); + def->set_default_value(new ConfigOptionFloat(200.0)); def = this->add("slice_closing_radius", coFloat); def->label = L("Slice gap closing radius"); @@ -75,28 +75,28 @@ void PrintConfigDef::init_common_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(0.049); + def->set_default_value(new ConfigOptionFloat(0.049)); def = this->add("print_host", coString); def->label = L("Hostname, IP or URL"); def->tooltip = L("Slic3r can upload G-code files to a printer host. This field should contain " "the hostname, IP address or URL of the printer host instance."); def->mode = comAdvanced; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("printhost_apikey", coString); def->label = L("API Key / Password"); def->tooltip = L("Slic3r can upload G-code files to a printer host. This field should contain " "the API Key or the password required for authentication."); def->mode = comAdvanced; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("printhost_cafile", coString); def->label = "HTTPS CA File"; def->tooltip = "Custom CA certificate file can be specified for HTTPS OctoPrint connections, in crt/pem format. " "If left blank, the default OS CA certificate repository is used."; def->mode = comAdvanced; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); } void PrintConfigDef::init_fff_params() @@ -113,7 +113,7 @@ void PrintConfigDef::init_fff_params() "This is mostly useful with Bowden extruders which suffer from oozing. " "This feature slows down both the print and the G-code generation."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("bed_temperature", coInts); def->label = L("Other layers"); @@ -122,7 +122,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("Bed temperature"); def->min = 0; def->max = 300; - def->default_value = new ConfigOptionInts { 0 }; + def->set_default_value(new ConfigOptionInts { 0 }); def = this->add("before_layer_gcode", coString); def->label = L("Before layer change G-code"); @@ -133,7 +133,7 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 5; def->mode = comExpert; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("between_objects_gcode", coString); def->label = L("Between objects G-code"); @@ -142,7 +142,7 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 12; def->mode = comExpert; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("bottom_solid_layers", coInt); def->label = L("Bottom"); @@ -150,7 +150,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Number of solid layers to generate on bottom surfaces."); def->full_label = L("Bottom solid layers"); def->min = 0; - def->default_value = new ConfigOptionInt(3); + def->set_default_value(new ConfigOptionInt(3)); def = this->add("bridge_acceleration", coFloat); def->label = L("Bridge"); @@ -159,7 +159,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("bridge_angle", coFloat); def->label = L("Bridging angle"); @@ -170,7 +170,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("°"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(0.); + def->set_default_value(new ConfigOptionFloat(0.)); def = this->add("bridge_fan_speed", coInts); def->label = L("Bridges fan speed"); @@ -179,7 +179,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 100; def->mode = comExpert; - def->default_value = new ConfigOptionInts { 100 }; + def->set_default_value(new ConfigOptionInts { 100 }); def = this->add("bridge_flow_ratio", coFloat); def->label = L("Bridge flow ratio"); @@ -191,7 +191,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 2; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(1); + def->set_default_value(new ConfigOptionFloat(1)); def = this->add("bridge_speed", coFloat); def->label = L("Bridges"); @@ -201,7 +201,7 @@ void PrintConfigDef::init_fff_params() def->aliases = { "bridge_feed_rate" }; def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(60); + def->set_default_value(new ConfigOptionFloat(60)); def = this->add("brim_width", coFloat); def->label = L("Brim width"); @@ -209,7 +209,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comSimple; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("clip_multipart_objects", coBool); def->label = L("Clip multi-part objects"); @@ -217,17 +217,17 @@ void PrintConfigDef::init_fff_params() "to clip the overlapping object parts one by the other " "(2nd part will be clipped by the 1st, 3rd part will be clipped by the 1st and 2nd etc)."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("colorprint_heights", coFloats); def->label = L("Colorprint height"); def->tooltip = L("Heights at which a filament change is to occur. "); - def->default_value = new ConfigOptionFloats { }; + def->set_default_value(new ConfigOptionFloats { }); def = this->add("compatible_printers", coStrings); def->label = L("Compatible printers"); def->mode = comAdvanced; - def->default_value = new ConfigOptionStrings(); + def->set_default_value(new ConfigOptionStrings()); def->cli = ConfigOptionDef::nocli; def = this->add("compatible_printers_condition", coString); @@ -236,13 +236,13 @@ void PrintConfigDef::init_fff_params() "If this expression evaluates to true, this profile is considered compatible " "with the active printer profile."); def->mode = comExpert; - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; def = this->add("compatible_prints", coStrings); def->label = L("Compatible print profiles"); def->mode = comAdvanced; - def->default_value = new ConfigOptionStrings(); + def->set_default_value(new ConfigOptionStrings()); def->cli = ConfigOptionDef::nocli; def = this->add("compatible_prints_condition", coString); @@ -251,16 +251,16 @@ void PrintConfigDef::init_fff_params() "If this expression evaluates to true, this profile is considered compatible " "with the active print profile."); def->mode = comExpert; - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; // The following value is to be stored into the project file (AMF, 3MF, Config ...) // and it contains a sum of "compatible_printers_condition" values over the print and filament profiles. def = this->add("compatible_printers_condition_cummulative", coStrings); - def->default_value = new ConfigOptionStrings(); + def->set_default_value(new ConfigOptionStrings()); def->cli = ConfigOptionDef::nocli; def = this->add("compatible_prints_condition_cummulative", coStrings); - def->default_value = new ConfigOptionStrings(); + def->set_default_value(new ConfigOptionStrings()); def->cli = ConfigOptionDef::nocli; def = this->add("complete_objects", coBool); @@ -270,13 +270,13 @@ void PrintConfigDef::init_fff_params() "This feature is useful to avoid the risk of ruined prints. " "Slic3r should warn and prevent you from extruder collisions, but beware."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("cooling", coBools); def->label = L("Enable auto cooling"); def->tooltip = L("This flag enables the automatic cooling logic that adjusts print speed " "and fan speed according to layer printing time."); - def->default_value = new ConfigOptionBools { true }; + def->set_default_value(new ConfigOptionBools { true }); def = this->add("cooling_tube_retraction", coFloat); def->label = L("Cooling tube position"); @@ -284,7 +284,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(91.5f); + def->set_default_value(new ConfigOptionFloat(91.5f)); def = this->add("cooling_tube_length", coFloat); def->label = L("Cooling tube length"); @@ -292,7 +292,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(5.f); + def->set_default_value(new ConfigOptionFloat(5.f)); def = this->add("default_acceleration", coFloat); def->label = L("Default"); @@ -302,20 +302,20 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("default_filament_profile", coStrings); def->label = L("Default filament profile"); def->tooltip = L("Default filament profile associated with the current printer profile. " "On selection of the current printer profile, this filament profile will be activated."); - def->default_value = new ConfigOptionStrings(); + def->set_default_value(new ConfigOptionStrings()); def->cli = ConfigOptionDef::nocli; def = this->add("default_print_profile", coString); def->label = L("Default print profile"); def->tooltip = L("Default print profile associated with the current printer profile. " "On selection of the current printer profile, this print profile will be activated."); - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; def = this->add("disable_fan_first_layers", coInts); @@ -326,7 +326,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 1000; def->mode = comExpert; - def->default_value = new ConfigOptionInts { 3 }; + def->set_default_value(new ConfigOptionInts { 3 }); def = this->add("dont_support_bridges", coBool); def->label = L("Don't support bridges"); @@ -334,7 +334,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Experimental option for preventing support material from being generated " "under bridged areas."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("duplicate_distance", coFloat); def->label = L("Distance between copies"); @@ -342,7 +342,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->aliases = { "multiply_distance" }; def->min = 0; - def->default_value = new ConfigOptionFloat(6); + def->set_default_value(new ConfigOptionFloat(6)); def = this->add("elefant_foot_compensation", coFloat); def->label = L("Elephant foot compensation"); @@ -352,7 +352,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("end_gcode", coString); def->label = L("End G-code"); @@ -362,7 +362,7 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 12; def->mode = comExpert; - def->default_value = new ConfigOptionString("M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n"); + def->set_default_value(new ConfigOptionString("M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n")); def = this->add("end_filament_gcode", coStrings); def->label = L("End G-code"); @@ -373,7 +373,7 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 120; def->mode = comExpert; - def->default_value = new ConfigOptionStrings { "; Filament-specific end gcode \n;END gcode for filament\n" }; + def->set_default_value(new ConfigOptionStrings { "; Filament-specific end gcode \n;END gcode for filament\n" }); def = this->add("ensure_vertical_shell_thickness", coBool); def->label = L("Ensure vertical shell thickness"); @@ -381,7 +381,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Add solid infill near sloping surfaces to guarantee the vertical shell thickness " "(top+bottom solid layers)."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); auto def_top_fill_pattern = def = this->add("top_fill_pattern", coEnum); def->label = L("Top fill pattern"); @@ -401,14 +401,14 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Octagram Spiral")); // solid_fill_pattern is an obsolete equivalent to top_fill_pattern/bottom_fill_pattern. def->aliases = { "solid_fill_pattern", "external_fill_pattern" }; - def->default_value = new ConfigOptionEnum(ipRectilinear); + def->set_default_value(new ConfigOptionEnum(ipRectilinear)); def = this->add("bottom_fill_pattern", coEnum); *def = *def_top_fill_pattern; def->label = L("Bottom fill pattern"); def->tooltip = L("Fill pattern for bottom infill. This only affects the bottom external visible layer, and not its adjacent solid shells."); def->cli = "bottom-fill-pattern|external-fill-pattern|solid-fill-pattern"; - def->default_value = new ConfigOptionEnum(ipRectilinear); + def->set_default_value(new ConfigOptionEnum(ipRectilinear)); def = this->add("external_perimeter_extrusion_width", coFloatOrPercent); def->label = L("External perimeters"); @@ -418,7 +418,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 200%), it will be computed over layer height."); def->sidetext = L("mm or % (leave 0 for default)"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(0, false); + def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); def = this->add("external_perimeter_speed", coFloatOrPercent); def->label = L("External perimeters"); @@ -430,7 +430,7 @@ void PrintConfigDef::init_fff_params() def->ratio_over = "perimeter_speed"; def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(50, true); + def->set_default_value(new ConfigOptionFloatOrPercent(50, true)); def = this->add("external_perimeters_first", coBool); def->label = L("External perimeters first"); @@ -438,7 +438,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Print contour perimeters from the outermost one to the innermost one " "instead of the default inverse order."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("extra_perimeters", coBool); def->label = L("Extra perimeters if needed"); @@ -447,7 +447,7 @@ void PrintConfigDef::init_fff_params() "Slic3r keeps adding perimeters, until more than 70% of the loop immediately above " "is supported."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("extruder", coInt); def->gui_type = "i_enum_open"; @@ -472,7 +472,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(20); + def->set_default_value(new ConfigOptionFloat(20)); def = this->add("extruder_clearance_radius", coFloat); def->label = L("Radius"); @@ -483,14 +483,14 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(20); + def->set_default_value(new ConfigOptionFloat(20)); def = this->add("extruder_colour", coStrings); def->label = L("Extruder Color"); def->tooltip = L("This is only used in the Slic3r interface as a visual help."); def->gui_type = "color"; // Empty string means no color assigned yet. - def->default_value = new ConfigOptionStrings { "" }; + def->set_default_value(new ConfigOptionStrings { "" }); def = this->add("extruder_offset", coPoints); def->label = L("Extruder offset"); @@ -500,13 +500,13 @@ void PrintConfigDef::init_fff_params() "from the XY coordinate)."); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionPoints { Vec2d(0,0) }; + def->set_default_value(new ConfigOptionPoints { Vec2d(0,0) }); def = this->add("extrusion_axis", coString); def->label = L("Extrusion axis"); def->tooltip = L("Use this option to set the axis letter associated to your printer's extruder " "(usually E but some printers use A)."); - def->default_value = new ConfigOptionString("E"); + def->set_default_value(new ConfigOptionString("E")); def = this->add("extrusion_multiplier", coFloats); def->label = L("Extrusion multiplier"); @@ -515,7 +515,7 @@ void PrintConfigDef::init_fff_params() "Usual values are between 0.9 and 1.1. If you think you need to change this more, " "check filament diameter and your firmware E steps."); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 1. }; + def->set_default_value(new ConfigOptionFloats { 1. }); def = this->add("extrusion_width", coFloatOrPercent); def->label = L("Default extrusion width"); @@ -526,13 +526,13 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example: 230%), it will be computed over layer height."); def->sidetext = L("mm or % (leave 0 for auto)"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(0, false); + def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); def = this->add("fan_always_on", coBools); def->label = L("Keep fan always on"); def->tooltip = L("If this is enabled, fan will never be disabled and will be kept running at least " "at its minimum speed. Useful for PLA, harmful for ABS."); - def->default_value = new ConfigOptionBools { false }; + def->set_default_value(new ConfigOptionBools { false }); def = this->add("fan_below_layer_time", coInts); def->label = L("Enable fan if layer print time is below"); @@ -543,13 +543,13 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 1000; def->mode = comExpert; - def->default_value = new ConfigOptionInts { 60 }; + def->set_default_value(new ConfigOptionInts { 60 }); def = this->add("filament_colour", coStrings); def->label = L("Color"); def->tooltip = L("This is only used in the Slic3r interface as a visual help."); def->gui_type = "color"; - def->default_value = new ConfigOptionStrings { "#29B2B2" }; + def->set_default_value(new ConfigOptionStrings { "#29B2B2" }); def = this->add("filament_notes", coStrings); def->label = L("Filament notes"); @@ -558,7 +558,7 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 13; def->mode = comAdvanced; - def->default_value = new ConfigOptionStrings { "" }; + def->set_default_value(new ConfigOptionStrings { "" }); def = this->add("filament_max_volumetric_speed", coFloats); def->label = L("Max volumetric speed"); @@ -568,7 +568,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm³/s"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("filament_loading_speed", coFloats); def->label = L("Loading speed"); @@ -576,7 +576,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 28. }; + def->set_default_value(new ConfigOptionFloats { 28. }); def = this->add("filament_loading_speed_start", coFloats); def->label = L("Loading speed at the start"); @@ -584,7 +584,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 3. }; + def->set_default_value(new ConfigOptionFloats { 3. }); def = this->add("filament_unloading_speed", coFloats); def->label = L("Unloading speed"); @@ -593,7 +593,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 90. }; + def->set_default_value(new ConfigOptionFloats { 90. }); def = this->add("filament_unloading_speed_start", coFloats); def->label = L("Unloading speed at the start"); @@ -601,7 +601,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 100. }; + def->set_default_value(new ConfigOptionFloats { 100. }); def = this->add("filament_toolchange_delay", coFloats); def->label = L("Delay after unloading"); @@ -611,7 +611,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("filament_cooling_moves", coInts); def->label = L("Number of cooling moves"); @@ -620,7 +620,7 @@ void PrintConfigDef::init_fff_params() def->max = 0; def->max = 20; def->mode = comExpert; - def->default_value = new ConfigOptionInts { 4 }; + def->set_default_value(new ConfigOptionInts { 4 }); def = this->add("filament_cooling_initial_speed", coFloats); def->label = L("Speed of the first cooling move"); @@ -628,7 +628,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 2.2f }; + def->set_default_value(new ConfigOptionFloats { 2.2f }); def = this->add("filament_minimal_purge_on_wipe_tower", coFloats); def->label = L("Minimal purge on wipe tower"); @@ -639,7 +639,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm³"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 15.f }; + def->set_default_value(new ConfigOptionFloats { 15.f }); def = this->add("filament_cooling_final_speed", coFloats); def->label = L("Speed of the last cooling move"); @@ -647,7 +647,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 3.4f }; + def->set_default_value(new ConfigOptionFloats { 3.4f }); def = this->add("filament_load_time", coFloats); def->label = L("Filament load time"); @@ -655,14 +655,14 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 0.0f }; + def->set_default_value(new ConfigOptionFloats { 0.0f }); def = this->add("filament_ramming_parameters", coStrings); def->label = L("Ramming parameters"); def->tooltip = L("This string is edited by RammingDialog and contains ramming specific parameters "); def->mode = comExpert; - 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" }; + def->set_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" }); def = this->add("filament_unload_time", coFloats); def->label = L("Filament unload time"); @@ -670,7 +670,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 0.0f }; + def->set_default_value(new ConfigOptionFloats { 0.0f }); def = this->add("filament_diameter", coFloats); def->label = L("Diameter"); @@ -678,7 +678,7 @@ void PrintConfigDef::init_fff_params() "and do multiple measurements along the filament, then compute the average."); def->sidetext = L("mm"); def->min = 0; - def->default_value = new ConfigOptionFloats { 3. }; + def->set_default_value(new ConfigOptionFloats { 3. }); def = this->add("filament_density", coFloats); def->label = L("Density"); @@ -687,7 +687,7 @@ void PrintConfigDef::init_fff_params() "of the length to volume. Better is to calculate the volume directly through displacement."); def->sidetext = L("g/cm³"); def->min = 0; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("filament_type", coStrings); def->label = L("Filament type"); @@ -704,23 +704,23 @@ void PrintConfigDef::init_fff_params() def->enum_values.push_back("NGEN"); def->enum_values.push_back("PVA"); def->mode = comAdvanced; - def->default_value = new ConfigOptionStrings { "PLA" }; + def->set_default_value(new ConfigOptionStrings { "PLA" }); def = this->add("filament_soluble", coBools); def->label = L("Soluble material"); def->tooltip = L("Soluble material is most likely used for a soluble support."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBools { false }; + def->set_default_value(new ConfigOptionBools { false }); def = this->add("filament_cost", coFloats); def->label = L("Cost"); def->tooltip = L("Enter your filament cost per kg here. This is only for statistical information."); def->sidetext = L("money/kg"); def->min = 0; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("filament_settings_id", coStrings); - def->default_value = new ConfigOptionStrings { "" }; + def->set_default_value(new ConfigOptionStrings { "" }); def->cli = ConfigOptionDef::nocli; def = this->add("fill_angle", coFloat); @@ -733,7 +733,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 360; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(45); + def->set_default_value(new ConfigOptionFloat(45)); def = this->add("fill_density", coPercent); def->gui_type = "f_enum_open"; @@ -772,7 +772,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back("80%"); def->enum_labels.push_back("90%"); def->enum_labels.push_back("100%"); - def->default_value = new ConfigOptionPercent(20); + def->set_default_value(new ConfigOptionPercent(20)); def = this->add("fill_pattern", coEnum); def->label = L("Fill pattern"); @@ -805,7 +805,7 @@ void PrintConfigDef::init_fff_params() 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->default_value = new ConfigOptionEnum(ipStars); + def->set_default_value(new ConfigOptionEnum(ipStars)); def = this->add("first_layer_acceleration", coFloat); def->label = L("First layer"); @@ -814,7 +814,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("first_layer_bed_temperature", coInts); def->label = L("First layer"); @@ -822,7 +822,7 @@ void PrintConfigDef::init_fff_params() "bed temperature control commands in the output."); def->max = 0; def->max = 300; - def->default_value = new ConfigOptionInts { 0 }; + def->set_default_value(new ConfigOptionInts { 0 }); def = this->add("first_layer_extrusion_width", coFloatOrPercent); def->label = L("First layer"); @@ -834,7 +834,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm or % (leave 0 for default)"); def->ratio_over = "first_layer_height"; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(200, true); + def->set_default_value(new ConfigOptionFloatOrPercent(200, true)); def = this->add("first_layer_height", coFloatOrPercent); def->label = L("First layer height"); @@ -845,7 +845,7 @@ void PrintConfigDef::init_fff_params() "over the default layer height."); def->sidetext = L("mm or %"); def->ratio_over = "layer_height"; - def->default_value = new ConfigOptionFloatOrPercent(0.35, false); + def->set_default_value(new ConfigOptionFloatOrPercent(0.35, false)); def = this->add("first_layer_speed", coFloatOrPercent); def->label = L("First layer speed"); @@ -855,7 +855,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s or %"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(30, false); + def->set_default_value(new ConfigOptionFloatOrPercent(30, false)); def = this->add("first_layer_temperature", coInts); def->label = L("First layer"); @@ -863,7 +863,7 @@ void PrintConfigDef::init_fff_params() "during print, set this to zero to disable temperature control commands in the output file."); def->min = 0; def->max = max_temp; - def->default_value = new ConfigOptionInts { 200 }; + def->set_default_value(new ConfigOptionInts { 200 }); def = this->add("gap_fill_speed", coFloat); def->label = L("Gap fill"); @@ -873,7 +873,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(20); + def->set_default_value(new ConfigOptionFloat(20)); def = this->add("gcode_comments", coBool); def->label = L("Verbose G-code"); @@ -881,7 +881,7 @@ void PrintConfigDef::init_fff_params() "If you print from SD card, the additional weight of the file could make your firmware " "slow down."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(0); + def->set_default_value(new ConfigOptionBool(0)); def = this->add("gcode_flavor", coEnum); def->label = L("G-code flavor"); @@ -910,7 +910,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back("Smoothie"); def->enum_labels.push_back(L("No extrusion")); def->mode = comExpert; - def->default_value = new ConfigOptionEnum(gcfRepRap); + def->set_default_value(new ConfigOptionEnum(gcfRepRap)); def = this->add("gcode_label_objects", coBool); def->label = "Label objects"; @@ -918,7 +918,7 @@ void PrintConfigDef::init_fff_params() " which is useful for the Octoprint CancelObject plugin. This settings is NOT compatible with " "Single Extruder Multi Material setup and Wipe into Object / Wipe into Infill."; def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(0); + def->set_default_value(new ConfigOptionBool(0)); def = this->add("high_current_on_filament_swap", coBool); def->label = L("High extruder current on filament swap"); @@ -926,7 +926,7 @@ void PrintConfigDef::init_fff_params() " sequence to allow for rapid ramming feed rates and to overcome resistance when loading" " a filament with an ugly shaped tip."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(0); + def->set_default_value(new ConfigOptionBool(0)); def = this->add("infill_acceleration", coFloat); def->label = L("Infill"); @@ -935,7 +935,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("infill_every_layers", coInt); def->label = L("Combine infill every"); @@ -946,7 +946,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("Combine infill every n layers"); def->min = 1; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(1); + def->set_default_value(new ConfigOptionInt(1)); def = this->add("infill_extruder", coInt); def->label = L("Infill extruder"); @@ -954,7 +954,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("The extruder to use when printing infill."); def->min = 1; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(1); + def->set_default_value(new ConfigOptionInt(1)); def = this->add("infill_extrusion_width", coFloatOrPercent); def->label = L("Infill"); @@ -965,13 +965,13 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 90%) it will be computed over layer height."); def->sidetext = L("mm or % (leave 0 for default)"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(0, false); + def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); def = this->add("infill_first", coBool); def->label = L("Infill before perimeters"); def->tooltip = L("This option will switch the print order of perimeters and infill, making the latter first."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("infill_only_where_needed", coBool); def->label = L("Only infill where needed"); @@ -980,7 +980,7 @@ void PrintConfigDef::init_fff_params() "(it will act as internal support material). If enabled, slows down the G-code generation " "due to the multiple checks involved."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("infill_overlap", coFloatOrPercent); def->label = L("Infill/perimeters overlap"); @@ -991,7 +991,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm or %"); def->ratio_over = "perimeter_extrusion_width"; def->mode = comExpert; - def->default_value = new ConfigOptionFloatOrPercent(25, true); + def->set_default_value(new ConfigOptionFloatOrPercent(25, true)); def = this->add("infill_speed", coFloat); def->label = L("Infill"); @@ -1001,20 +1001,20 @@ void PrintConfigDef::init_fff_params() def->aliases = { "print_feed_rate", "infill_feed_rate" }; def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(80); + def->set_default_value(new ConfigOptionFloat(80)); def = this->add("inherits", coString); def->label = L("Inherits profile"); def->tooltip = L("Name of the profile, from which this profile inherits."); def->full_width = true; def->height = 5; - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; // The following value is to be stored into the project file (AMF, 3MF, Config ...) // and it contains a sum of "inherits" values over the print and filament profiles. def = this->add("inherits_cummulative", coStrings); - def->default_value = new ConfigOptionStrings(); + def->set_default_value(new ConfigOptionStrings()); def->cli = ConfigOptionDef::nocli; def = this->add("interface_shells", coBool); @@ -1024,7 +1024,7 @@ void PrintConfigDef::init_fff_params() "support material."); def->category = L("Layers and Perimeters"); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("layer_gcode", coString); def->label = L("After layer change G-code"); @@ -1036,7 +1036,7 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 5; def->mode = comExpert; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("remaining_times", coBool); def->label = L("Supports remaining times"); @@ -1045,13 +1045,13 @@ void PrintConfigDef::init_fff_params() " As of now only the Prusa i3 MK3 firmware recognizes M73." " Also the i3 MK3 firmware supports M73 Qxx Sxx for the silent mode."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("silent_mode", coBool); def->label = L("Supports silent mode"); def->tooltip = L("Set silent mode for the G-code flavor"); def->mode = comExpert; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); const int machine_limits_opt_width = 7; { @@ -1079,7 +1079,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->width = machine_limits_opt_width; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats(axis.max_feedrate); + def->set_default_value(new ConfigOptionFloats(axis.max_feedrate)); // Add the machine acceleration limits for XYZE axes (M201) def = this->add("machine_max_acceleration_" + axis.name, coFloats); def->full_label = (boost::format(L("Maximum acceleration %1%")) % axis_upper).str(); @@ -1089,7 +1089,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->width = machine_limits_opt_width; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats(axis.max_acceleration); + def->set_default_value(new ConfigOptionFloats(axis.max_acceleration)); // Add the machine jerk limits for XYZE axes (M205) def = this->add("machine_max_jerk_" + axis.name, coFloats); def->full_label = (boost::format(L("Maximum jerk %1%")) % axis_upper).str(); @@ -1099,7 +1099,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->width = machine_limits_opt_width; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats(axis.max_jerk); + def->set_default_value(new ConfigOptionFloats(axis.max_jerk)); } } @@ -1112,7 +1112,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->width = machine_limits_opt_width; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats{ 0., 0. }; + def->set_default_value(new ConfigOptionFloats{ 0., 0. }); // M205 T... [mm/sec] def = this->add("machine_min_travel_rate", coFloats); @@ -1123,7 +1123,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->width = machine_limits_opt_width; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats{ 0., 0. }; + def->set_default_value(new ConfigOptionFloats{ 0., 0. }); // M204 S... [mm/sec^2] def = this->add("machine_max_acceleration_extruding", coFloats); @@ -1134,7 +1134,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->width = machine_limits_opt_width; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats{ 1500., 1250. }; + def->set_default_value(new ConfigOptionFloats{ 1500., 1250. }); // M204 T... [mm/sec^2] def = this->add("machine_max_acceleration_retracting", coFloats); @@ -1145,7 +1145,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->width = machine_limits_opt_width; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats{ 1500., 1250. }; + def->set_default_value(new ConfigOptionFloats{ 1500., 1250. }); def = this->add("max_fan_speed", coInts); def->label = L("Max"); @@ -1154,7 +1154,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 100; def->mode = comExpert; - def->default_value = new ConfigOptionInts { 100 }; + def->set_default_value(new ConfigOptionInts { 100 }); def = this->add("max_layer_height", coFloats); def->label = L("Max"); @@ -1165,7 +1165,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("max_print_speed", coFloat); def->label = L("Max print speed"); @@ -1175,7 +1175,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 1; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(80); + def->set_default_value(new ConfigOptionFloat(80)); def = this->add("max_volumetric_speed", coFloat); def->label = L("Max volumetric speed"); @@ -1184,7 +1184,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm³/s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); #ifdef HAS_PRESSURE_EQUALIZER def = this->add("max_volumetric_extrusion_rate_slope_positive", coFloat); @@ -1196,7 +1196,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm³/s²"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("max_volumetric_extrusion_rate_slope_negative", coFloat); def->label = L("Max volumetric slope negative"); @@ -1207,7 +1207,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm³/s²"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); #endif /* HAS_PRESSURE_EQUALIZER */ def = this->add("min_fan_speed", coInts); @@ -1217,7 +1217,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 100; def->mode = comExpert; - def->default_value = new ConfigOptionInts { 35 }; + def->set_default_value(new ConfigOptionInts { 35 }); def = this->add("min_layer_height", coFloats); def->label = L("Min"); @@ -1226,7 +1226,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 0.07 }; + def->set_default_value(new ConfigOptionFloats { 0.07 }); def = this->add("min_print_speed", coFloats); def->label = L("Min print speed"); @@ -1234,7 +1234,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 10. }; + def->set_default_value(new ConfigOptionFloats { 10. }); def = this->add("min_skirt_length", coFloat); def->label = L("Minimal filament extrusion length"); @@ -1244,7 +1244,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("notes", coString); def->label = L("Configuration notes"); @@ -1254,13 +1254,13 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 13; def->mode = comAdvanced; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("nozzle_diameter", coFloats); def->label = L("Nozzle diameter"); def->tooltip = L("This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)"); def->sidetext = L("mm"); - def->default_value = new ConfigOptionFloats { 0.5 }; + def->set_default_value(new ConfigOptionFloats { 0.5 }); def = this->add("host_type", coEnum); def->label = L("Host Type"); @@ -1272,14 +1272,14 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back("OctoPrint"); def->enum_labels.push_back("Duet"); def->mode = comAdvanced; - def->default_value = new ConfigOptionEnum(htOctoPrint); + def->set_default_value(new ConfigOptionEnum(htOctoPrint)); def = this->add("only_retract_when_crossing_perimeters", coBool); def->label = L("Only retract when crossing perimeters"); def->tooltip = L("Disables retraction when the travel path does not exceed the upper layer's perimeters " "(and thus any ooze will be probably invisible)."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("ooze_prevention", coBool); def->label = L("Enable"); @@ -1287,7 +1287,7 @@ void PrintConfigDef::init_fff_params() "It will enable a tall skirt automatically and move extruders outside such " "skirt when changing temperatures."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("output_filename_format", coString); def->label = L("Output filename format"); @@ -1297,7 +1297,7 @@ void PrintConfigDef::init_fff_params() "[input_filename_base]."); def->full_width = true; def->mode = comExpert; - def->default_value = new ConfigOptionString("[input_filename_base]"); + def->set_default_value(new ConfigOptionString("[input_filename_base]")); def = this->add("overhangs", coBool); def->label = L("Detect bridging perimeters"); @@ -1305,7 +1305,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Experimental option to adjust flow for overhangs (bridge flow will be used), " "to apply bridge speed to them and enable fan."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("parking_pos_retraction", coFloat); def->label = L("Filament parking position"); @@ -1314,7 +1314,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(92.f); + def->set_default_value(new ConfigOptionFloat(92.f)); def = this->add("extra_loading_move", coFloat); def->label = L("Extra loading distance"); @@ -1323,7 +1323,7 @@ void PrintConfigDef::init_fff_params() " if negative, the loading move is shorter than unloading. "); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(-2.f); + def->set_default_value(new ConfigOptionFloat(-2.f)); def = this->add("perimeter_acceleration", coFloat); def->label = L("Perimeters"); @@ -1332,7 +1332,7 @@ void PrintConfigDef::init_fff_params() "Set zero to disable acceleration control for perimeters."); def->sidetext = L("mm/s²"); def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("perimeter_extruder", coInt); def->label = L("Perimeter extruder"); @@ -1341,7 +1341,7 @@ void PrintConfigDef::init_fff_params() def->aliases = { "perimeters_extruder" }; def->min = 1; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(1); + def->set_default_value(new ConfigOptionInt(1)); def = this->add("perimeter_extrusion_width", coFloatOrPercent); def->label = L("Perimeters"); @@ -1353,7 +1353,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm or % (leave 0 for default)"); def->aliases = { "perimeters_extrusion_width" }; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(0, false); + def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); def = this->add("perimeter_speed", coFloat); def->label = L("Perimeters"); @@ -1363,7 +1363,7 @@ void PrintConfigDef::init_fff_params() def->aliases = { "perimeter_feed_rate" }; def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(60); + def->set_default_value(new ConfigOptionFloat(60)); def = this->add("perimeters", coInt); def->label = L("Perimeters"); @@ -1376,7 +1376,7 @@ void PrintConfigDef::init_fff_params() def->aliases = { "perimeter_offsets" }; def->min = 0; def->max = 10000; - def->default_value = new ConfigOptionInt(3); + def->set_default_value(new ConfigOptionInt(3)); def = this->add("post_process", coStrings); def->label = L("Post-processing scripts"); @@ -1389,12 +1389,12 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 6; def->mode = comExpert; - def->default_value = new ConfigOptionStrings(); + def->set_default_value(new ConfigOptionStrings()); def = this->add("printer_model", coString); def->label = L("Printer type"); def->tooltip = L("Type of the printer."); - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; def = this->add("printer_notes", coString); @@ -1404,26 +1404,26 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 13; def->mode = comAdvanced; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("printer_vendor", coString); def->label = L("Printer vendor"); def->tooltip = L("Name of the printer vendor."); - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; def = this->add("printer_variant", coString); def->label = L("Printer variant"); def->tooltip = L("Name of the printer variant. For example, the printer variants may be differentiated by a nozzle diameter."); - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; def = this->add("print_settings_id", coString); - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def->cli = ConfigOptionDef::nocli; def = this->add("printer_settings_id", coString); - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def->cli = ConfigOptionDef::nocli; def = this->add("raft_layers", coInt); @@ -1434,7 +1434,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("layers"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(0); + def->set_default_value(new ConfigOptionInt(0)); def = this->add("resolution", coFloat); def->label = L("Resolution"); @@ -1445,14 +1445,14 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("retract_before_travel", coFloats); def->label = L("Minimum travel after retraction"); def->tooltip = L("Retraction is not triggered when travel moves are shorter than this length."); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 2. }; + def->set_default_value(new ConfigOptionFloats { 2. }); def = this->add("retract_before_wipe", coPercents); def->label = L("Retract amount before wipe"); @@ -1460,13 +1460,13 @@ void PrintConfigDef::init_fff_params() "before doing the wipe movement."); def->sidetext = L("%"); def->mode = comAdvanced; - def->default_value = new ConfigOptionPercents { 0. }; + def->set_default_value(new ConfigOptionPercents { 0. }); def = this->add("retract_layer_change", coBools); def->label = L("Retract on layer change"); def->tooltip = L("This flag enforces a retraction whenever a Z move is done."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBools { false }; + def->set_default_value(new ConfigOptionBools { false }); def = this->add("retract_length", coFloats); def->label = L("Length"); @@ -1474,7 +1474,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("When retraction is triggered, filament is pulled back by the specified amount " "(the length is measured on raw filament, before it enters the extruder)."); def->sidetext = L("mm (zero to disable)"); - def->default_value = new ConfigOptionFloats { 2. }; + def->set_default_value(new ConfigOptionFloats { 2. }); def = this->add("retract_length_toolchange", coFloats); def->label = L("Length"); @@ -1484,7 +1484,7 @@ void PrintConfigDef::init_fff_params() "the extruder)."); def->sidetext = L("mm (zero to disable)"); def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 10. }; + def->set_default_value(new ConfigOptionFloats { 10. }); def = this->add("retract_lift", coFloats); def->label = L("Lift Z"); @@ -1492,7 +1492,7 @@ void PrintConfigDef::init_fff_params() "is triggered. When using multiple extruders, only the setting for the first extruder " "will be considered."); def->sidetext = L("mm"); - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("retract_lift_above", coFloats); def->label = L("Above Z"); @@ -1501,7 +1501,7 @@ void PrintConfigDef::init_fff_params() "absolute Z. You can tune this setting for skipping lift on the first layers."); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("retract_lift_below", coFloats); def->label = L("Below Z"); @@ -1511,7 +1511,7 @@ void PrintConfigDef::init_fff_params() "to the first layers."); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("retract_restart_extra", coFloats); def->label = L("Extra length on restart"); @@ -1519,7 +1519,7 @@ void PrintConfigDef::init_fff_params() "this additional amount of filament. This setting is rarely needed."); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("retract_restart_extra_toolchange", coFloats); def->label = L("Extra length on restart"); @@ -1527,7 +1527,7 @@ void PrintConfigDef::init_fff_params() "this additional amount of filament."); def->sidetext = L("mm"); def->mode = comExpert; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("retract_speed", coFloats); def->label = L("Retraction Speed"); @@ -1535,7 +1535,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("The speed for retractions (it only applies to the extruder motor)."); def->sidetext = L("mm/s"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 40. }; + def->set_default_value(new ConfigOptionFloats { 40. }); def = this->add("deretract_speed", coFloats); def->label = L("Deretraction Speed"); @@ -1544,7 +1544,7 @@ void PrintConfigDef::init_fff_params() "(it only applies to the extruder motor). If left to zero, the retraction speed is used."); def->sidetext = L("mm/s"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloats { 0. }; + def->set_default_value(new ConfigOptionFloats { 0. }); def = this->add("seam_position", coEnum); def->label = L("Seam position"); @@ -1560,7 +1560,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Aligned")); def->enum_labels.push_back(L("Rear")); def->mode = comSimple; - def->default_value = new ConfigOptionEnum(spAligned); + def->set_default_value(new ConfigOptionEnum(spAligned)); #if 0 def = this->add("seam_preferred_direction", coFloat); @@ -1571,7 +1571,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Seam preferred direction"); def->min = 0; def->max = 360; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("seam_preferred_direction_jitter", coFloat); // def->gui_type = "slider"; @@ -1581,7 +1581,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Preferred direction of the seam - jitter"); def->min = 0; def->max = 360; - def->default_value = new ConfigOptionFloat(30); + def->set_default_value(new ConfigOptionFloat(30)); #endif def = this->add("serial_port", coString); @@ -1590,7 +1590,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("Serial port"); def->tooltip = L("USB/serial port for printer connection."); def->width = 20; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("serial_speed", coInt); def->gui_type = "i_enum_open"; @@ -1602,7 +1602,7 @@ void PrintConfigDef::init_fff_params() def->enum_values.push_back("115200"); def->enum_values.push_back("250000"); def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(250000); + def->set_default_value(new ConfigOptionInt(250000)); def = this->add("skirt_distance", coFloat); def->label = L("Distance from object"); @@ -1610,7 +1610,7 @@ void PrintConfigDef::init_fff_params() "to the object(s) and get a brim for better adhesion."); def->sidetext = L("mm"); def->min = 0; - def->default_value = new ConfigOptionFloat(6); + def->set_default_value(new ConfigOptionFloat(6)); def = this->add("skirt_height", coInt); def->label = L("Skirt height"); @@ -1618,7 +1618,7 @@ void PrintConfigDef::init_fff_params() "as a shield against drafts."); def->sidetext = L("layers"); def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(1); + def->set_default_value(new ConfigOptionInt(1)); def = this->add("skirts", coInt); def->label = L("Loops (minimum)"); @@ -1628,7 +1628,7 @@ void PrintConfigDef::init_fff_params() "to disable skirt completely."); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(1); + def->set_default_value(new ConfigOptionInt(1)); def = this->add("slowdown_below_layer_time", coInts); def->label = L("Slow down if layer print time is below"); @@ -1639,7 +1639,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 1000; def->mode = comExpert; - def->default_value = new ConfigOptionInts { 5 }; + def->set_default_value(new ConfigOptionInts { 5 }); def = this->add("small_perimeter_speed", coFloatOrPercent); def->label = L("Small perimeters"); @@ -1651,7 +1651,7 @@ void PrintConfigDef::init_fff_params() def->ratio_over = "perimeter_speed"; def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(15, false); + def->set_default_value(new ConfigOptionFloatOrPercent(15, false)); def = this->add("solid_infill_below_area", coFloat); def->label = L("Solid infill threshold area"); @@ -1660,7 +1660,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm²"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(70); + def->set_default_value(new ConfigOptionFloat(70)); def = this->add("solid_infill_extruder", coInt); def->label = L("Solid infill extruder"); @@ -1668,7 +1668,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("The extruder to use when printing solid infill."); def->min = 1; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(1); + def->set_default_value(new ConfigOptionInt(1)); def = this->add("solid_infill_every_layers", coInt); def->label = L("Solid infill every"); @@ -1680,7 +1680,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("layers"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionInt(0); + def->set_default_value(new ConfigOptionInt(0)); def = this->add("solid_infill_extrusion_width", coFloatOrPercent); def->label = L("Solid infill"); @@ -1690,7 +1690,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 90%) it will be computed over layer height."); def->sidetext = L("mm or % (leave 0 for default)"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(0, false); + def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); def = this->add("solid_infill_speed", coFloatOrPercent); def->label = L("Solid infill"); @@ -1703,7 +1703,7 @@ void PrintConfigDef::init_fff_params() def->aliases = { "solid_infill_feed_rate" }; def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(20, false); + def->set_default_value(new ConfigOptionFloatOrPercent(20, false)); def = this->add("solid_layers", coInt); def->label = L("Solid layers"); @@ -1719,7 +1719,7 @@ void PrintConfigDef::init_fff_params() "no infill, no top solid layers and no support material. You can still set " "any number of bottom solid layers as well as skirt/brim loops. " "It won't work when printing more than an object."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("standby_temperature_delta", coInt); def->label = L("Temperature variation"); @@ -1729,7 +1729,7 @@ void PrintConfigDef::init_fff_params() def->min = -max_temp; def->max = max_temp; def->mode = comExpert; - def->default_value = new ConfigOptionInt(-5); + def->set_default_value(new ConfigOptionInt(-5)); def = this->add("start_gcode", coString); def->label = L("Start G-code"); @@ -1744,7 +1744,7 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 12; def->mode = comExpert; - def->default_value = new ConfigOptionString("G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n"); + def->set_default_value(new ConfigOptionString("G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n")); def = this->add("start_filament_gcode", coStrings); def->label = L("Start G-code"); @@ -1760,25 +1760,25 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 12; def->mode = comExpert; - def->default_value = new ConfigOptionStrings { "; Filament gcode\n" }; + def->set_default_value(new ConfigOptionStrings { "; Filament gcode\n" }); def = this->add("single_extruder_multi_material", coBool); def->label = L("Single Extruder Multi Material"); def->tooltip = L("The printer multiplexes filaments into a single hot end."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("single_extruder_multi_material_priming", coBool); def->label = L("Prime all printing extruders"); def->tooltip = L("If enabled, all printing extruders will be primed at the front edge of the print bed at the start of the print."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("support_material", coBool); def->label = L("Generate support material"); def->category = L("Support material"); def->tooltip = L("Enable support material generation."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("support_material_auto", coBool); def->label = L("Auto generated supports"); @@ -1786,7 +1786,7 @@ void PrintConfigDef::init_fff_params() 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->mode = comSimple; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("support_material_xy_spacing", coFloatOrPercent); def->label = L("XY separation between an object and its support"); @@ -1798,7 +1798,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->mode = comAdvanced; // Default is half the external perimeter width. - def->default_value = new ConfigOptionFloatOrPercent(50, true); + def->set_default_value(new ConfigOptionFloatOrPercent(50, true)); def = this->add("support_material_angle", coFloat); def->label = L("Pattern angle"); @@ -1808,14 +1808,14 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 359; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("support_material_buildplate_only", coBool); def->label = L("Support on build plate only"); def->category = L("Support material"); def->tooltip = L("Only create support if it lies on a build plate. Don't create support on a print."); def->mode = comSimple; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("support_material_contact_distance", coFloat); def->gui_type = "f_enum_open"; @@ -1831,7 +1831,7 @@ void PrintConfigDef::init_fff_params() 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->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(0.2); + def->set_default_value(new ConfigOptionFloat(0.2)); def = this->add("support_material_enforce_layers", coInt); def->label = L("Enforce support for the first"); @@ -1844,7 +1844,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("Enforce support for the first n layers"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionInt(0); + def->set_default_value(new ConfigOptionInt(0)); def = this->add("support_material_extruder", coInt); def->label = L("Support material/raft/skirt extruder"); @@ -1853,7 +1853,7 @@ void PrintConfigDef::init_fff_params() "(1+, 0 to use the current extruder to minimize tool changes)."); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(1); + def->set_default_value(new ConfigOptionInt(1)); def = this->add("support_material_extrusion_width", coFloatOrPercent); def->label = L("Support material"); @@ -1863,14 +1863,14 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 90%) it will be computed over layer height."); def->sidetext = L("mm or % (leave 0 for default)"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(0, false); + def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); def = this->add("support_material_interface_contact_loops", coBool); def->label = L("Interface loops"); def->category = L("Support material"); def->tooltip = L("Cover the top contact layer of the supports with loops. Disabled by default."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("support_material_interface_extruder", coInt); def->label = L("Support material/raft interface extruder"); @@ -1879,7 +1879,7 @@ void PrintConfigDef::init_fff_params() "(1+, 0 to use the current extruder to minimize tool changes). This affects raft too."); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(1); + def->set_default_value(new ConfigOptionInt(1)); def = this->add("support_material_interface_layers", coInt); def->label = L("Interface layers"); @@ -1888,7 +1888,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("layers"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(3); + def->set_default_value(new ConfigOptionInt(3)); def = this->add("support_material_interface_spacing", coFloat); def->label = L("Interface pattern spacing"); @@ -1897,7 +1897,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("support_material_interface_speed", coFloatOrPercent); def->label = L("Support material interface"); @@ -1908,7 +1908,7 @@ void PrintConfigDef::init_fff_params() def->ratio_over = "support_material_speed"; def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(100, true); + def->set_default_value(new ConfigOptionFloatOrPercent(100, true)); def = this->add("support_material_pattern", coEnum); def->label = L("Pattern"); @@ -1922,7 +1922,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Rectilinear grid")); def->enum_labels.push_back(L("Honeycomb")); def->mode = comAdvanced; - def->default_value = new ConfigOptionEnum(smpRectilinear); + def->set_default_value(new ConfigOptionEnum(smpRectilinear)); def = this->add("support_material_spacing", coFloat); def->label = L("Pattern spacing"); @@ -1931,7 +1931,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(2.5); + def->set_default_value(new ConfigOptionFloat(2.5)); def = this->add("support_material_speed", coFloat); def->label = L("Support material"); @@ -1940,7 +1940,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm/s"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(60); + def->set_default_value(new ConfigOptionFloat(60)); def = this->add("support_material_synchronize_layers", coBool); def->label = L("Synchronize with object layers"); @@ -1948,7 +1948,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Synchronize support layers with the object print layers. This is useful " "with multi-material printers, where the extruder switch is expensive."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("support_material_threshold", coInt); def->label = L("Overhang threshold"); @@ -1962,7 +1962,7 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->max = 90; def->mode = comAdvanced; - def->default_value = new ConfigOptionInt(0); + def->set_default_value(new ConfigOptionInt(0)); def = this->add("support_material_with_sheath", coBool); def->label = L("With sheath around the support"); @@ -1970,7 +1970,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Add a sheath (a single perimeter line) around the base support. This makes " "the support more reliable, but also more difficult to remove."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("temperature", coInts); def->label = L("Other layers"); @@ -1979,7 +1979,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("Temperature"); def->min = 0; def->max = max_temp; - def->default_value = new ConfigOptionInts { 200 }; + def->set_default_value(new ConfigOptionInts { 200 }); def = this->add("thin_walls", coBool); def->label = L("Detect thin walls"); @@ -1987,7 +1987,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Detect single-width walls (parts where two extrusions don't fit and we need " "to collapse them into a single trace)."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("threads", coInt); def->label = L("Threads"); @@ -1997,7 +1997,7 @@ void PrintConfigDef::init_fff_params() def->min = 1; { int threads = (unsigned int)boost::thread::hardware_concurrency(); - def->default_value = new ConfigOptionInt(threads > 0 ? threads : 2); + def->set_default_value(new ConfigOptionInt(threads > 0 ? threads : 2)); def->cli == ConfigOptionDef::nocli; } @@ -2010,7 +2010,7 @@ void PrintConfigDef::init_fff_params() def->full_width = true; def->height = 5; def->mode = comExpert; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("top_infill_extrusion_width", coFloatOrPercent); def->label = L("Top solid infill"); @@ -2021,7 +2021,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 90%) it will be computed over layer height."); def->sidetext = L("mm or % (leave 0 for default)"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(0, false); + def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); def = this->add("top_solid_infill_speed", coFloatOrPercent); def->label = L("Top solid infill"); @@ -2035,7 +2035,7 @@ void PrintConfigDef::init_fff_params() def->ratio_over = "solid_infill_speed"; def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloatOrPercent(15, false); + def->set_default_value(new ConfigOptionFloatOrPercent(15, false)); def = this->add("top_solid_layers", coInt); def->label = L("Top"); @@ -2043,7 +2043,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Number of solid layers to generate on top surfaces."); def->full_label = L("Top solid layers"); def->min = 0; - def->default_value = new ConfigOptionInt(3); + def->set_default_value(new ConfigOptionInt(3)); def = this->add("travel_speed", coFloat); def->label = L("Travel"); @@ -2052,21 +2052,21 @@ void PrintConfigDef::init_fff_params() def->aliases = { "travel_feed_rate" }; def->min = 1; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(130); + def->set_default_value(new ConfigOptionFloat(130)); def = this->add("use_firmware_retraction", coBool); def->label = L("Use firmware retraction"); def->tooltip = L("This experimental setting uses G10 and G11 commands to have the firmware " "handle the retraction. This is only supported in recent Marlin."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("use_relative_e_distances", coBool); def->label = L("Use relative E distances"); def->tooltip = L("If your firmware requires relative E values, check this, " "otherwise leave it unchecked. Most firmwares use absolute values."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("use_volumetric_e", coBool); def->label = L("Use volumetric E"); @@ -2077,73 +2077,73 @@ void PrintConfigDef::init_fff_params() "diameter associated to the filament selected in Slic3r. This is only supported " "in recent Marlin."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("variable_layer_height", coBool); def->label = L("Enable variable layer height feature"); def->tooltip = L("Some printers or printer setups may have difficulties printing " "with a variable layer height. Enabled by default."); def->mode = comExpert; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("wipe", coBools); def->label = L("Wipe while retracting"); def->tooltip = L("This flag will move the nozzle while retracting to minimize the possible blob " "on leaky extruders."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBools { false }; + def->set_default_value(new ConfigOptionBools { false }); def = this->add("wipe_tower", coBool); def->label = L("Enable"); def->tooltip = L("Multi material printers may need to prime or purge extruders on tool changes. " "Extrude the excess material into the wipe tower."); def->mode = comAdvanced; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("wiping_volumes_extruders", coFloats); def->label = L("Purging volumes - load/unload volumes"); def->tooltip = L("This vector saves required volumes to change from/to each tool used on the " "wipe tower. These values are used to simplify creation of the full purging " "volumes below. "); - def->default_value = new ConfigOptionFloats { 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f }; + def->set_default_value(new ConfigOptionFloats { 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f }); def = this->add("wiping_volumes_matrix", coFloats); def->label = L("Purging volumes - matrix"); def->tooltip = L("This matrix describes volumes (in cubic milimetres) required to purge the" " new filament on the wipe tower for any given pair of tools. "); - def->default_value = new ConfigOptionFloats { 0.f, 140.f, 140.f, 140.f, 140.f, - 140.f, 0.f, 140.f, 140.f, 140.f, - 140.f, 140.f, 0.f, 140.f, 140.f, - 140.f, 140.f, 140.f, 0.f, 140.f, - 140.f, 140.f, 140.f, 140.f, 0.f }; + def->set_default_value(new ConfigOptionFloats { 0.f, 140.f, 140.f, 140.f, 140.f, + 140.f, 0.f, 140.f, 140.f, 140.f, + 140.f, 140.f, 0.f, 140.f, 140.f, + 140.f, 140.f, 140.f, 0.f, 140.f, + 140.f, 140.f, 140.f, 140.f, 0.f }); def = this->add("wipe_tower_x", coFloat); def->label = L("Position X"); def->tooltip = L("X coordinate of the left front corner of a wipe tower"); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(180.); + def->set_default_value(new ConfigOptionFloat(180.)); def = this->add("wipe_tower_y", coFloat); def->label = L("Position Y"); def->tooltip = L("Y coordinate of the left front corner of a wipe tower"); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(140.); + def->set_default_value(new ConfigOptionFloat(140.)); def = this->add("wipe_tower_width", coFloat); def->label = L("Width"); def->tooltip = L("Width of a wipe tower"); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(60.); + def->set_default_value(new ConfigOptionFloat(60.)); def = this->add("wipe_tower_rotation_angle", coFloat); def->label = L("Wipe tower rotation angle"); def->tooltip = L("Wipe tower rotation angle with respect to x-axis "); def->sidetext = L("degrees"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(0.); + def->set_default_value(new ConfigOptionFloat(0.)); def = this->add("wipe_into_infill", coBool); def->category = L("Extruders"); @@ -2151,7 +2151,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Purging after toolchange will done inside this object's infills. " "This lowers the amount of waste but may result in longer print time " " due to additional travel moves."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("wipe_into_objects", coBool); def->category = L("Extruders"); @@ -2159,14 +2159,14 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Object will be used to purge the nozzle after a toolchange to save material " "that would otherwise end up in the wipe tower and decrease print time. " "Colours of the objects will be mixed as a result."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("wipe_tower_bridging", coFloat); def->label = L("Maximal bridging distance"); def->tooltip = L("Maximal distance between supports on sparse infill sections. "); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(10.); + def->set_default_value(new ConfigOptionFloat(10.)); def = this->add("xy_size_compensation", coFloat); def->label = L("XY Size Compensation"); @@ -2176,7 +2176,7 @@ void PrintConfigDef::init_fff_params() "for fine-tuning hole sizes."); def->sidetext = L("mm"); def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("z_offset", coFloat); def->label = L("Z offset"); @@ -2186,7 +2186,7 @@ void PrintConfigDef::init_fff_params() "from the print bed, set this to -0.3 (or fix your endstop)."); def->sidetext = L("mm"); def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); } void PrintConfigDef::init_sla_params() @@ -2200,26 +2200,26 @@ void PrintConfigDef::init_sla_params() def->label = L("Display width"); def->tooltip = L("Width of the display"); def->min = 1; - def->default_value = new ConfigOptionFloat(120.); + def->set_default_value(new ConfigOptionFloat(120.)); def = this->add("display_height", coFloat); def->label = L("Display height"); def->tooltip = L("Height of the display"); def->min = 1; - def->default_value = new ConfigOptionFloat(68.); + def->set_default_value(new ConfigOptionFloat(68.)); def = this->add("display_pixels_x", coInt); def->full_label = L("Number of pixels in"); def->label = ("X"); def->tooltip = L("Number of pixels in X"); def->min = 100; - def->default_value = new ConfigOptionInt(2560); + def->set_default_value(new ConfigOptionInt(2560)); def = this->add("display_pixels_y", coInt); def->label = ("Y"); def->tooltip = L("Number of pixels in Y"); def->min = 100; - def->default_value = new ConfigOptionInt(1440); + def->set_default_value(new ConfigOptionInt(1440)); def = this->add("display_orientation", coEnum); def->label = L("Display orientation"); @@ -2232,7 +2232,7 @@ void PrintConfigDef::init_sla_params() def->enum_labels.push_back(L("Landscape")); def->enum_labels.push_back(L("Portrait")); def->mode = comExpert; - def->default_value = new ConfigOptionEnum(sladoPortrait); + def->set_default_value(new ConfigOptionEnum(sladoPortrait)); def = this->add("fast_tilt_time", coFloat); def->label = L("Fast"); @@ -2241,7 +2241,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(5.); + def->set_default_value(new ConfigOptionFloat(5.)); def = this->add("slow_tilt_time", coFloat); def->label = L("Slow"); @@ -2250,7 +2250,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("s"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(8.); + def->set_default_value(new ConfigOptionFloat(8.)); def = this->add("area_fill", coFloat); def->label = L("Area fill"); @@ -2258,7 +2258,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("%"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(50.); + def->set_default_value(new ConfigOptionFloat(50.)); def = this->add("relative_correction", coFloats); def->label = L("Printer scaling correction"); @@ -2266,7 +2266,7 @@ void PrintConfigDef::init_sla_params() def->tooltip = L("Printer scaling correction"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats( { 1., 1. } ); + def->set_default_value(new ConfigOptionFloats( { 1., 1. } )); def = this->add("absolute_correction", coFloat); def->label = L("Printer absolute correction"); @@ -2274,7 +2274,7 @@ void PrintConfigDef::init_sla_params() def->tooltip = L("Will inflate or deflate the sliced 2D polygons according " "to the sign of the correction."); def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0.0); + def->set_default_value(new ConfigOptionFloat(0.0)); def = this->add("gamma_correction", coFloat); def->label = L("Printer gamma correction"); @@ -2285,7 +2285,7 @@ void PrintConfigDef::init_sla_params() "antialiasing without losing holes in polygons."); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(1.0); + def->set_default_value(new ConfigOptionFloat(1.0)); // SLA Material settings. @@ -2294,7 +2294,7 @@ void PrintConfigDef::init_sla_params() def->tooltip = L("Initial layer height"); def->sidetext = L("mm"); def->min = 0; - def->default_value = new ConfigOptionFloat(0.3); + def->set_default_value(new ConfigOptionFloat(0.3)); def = this->add("faded_layers", coInt); def->label = L("Faded layers"); @@ -2302,28 +2302,28 @@ void PrintConfigDef::init_sla_params() def->min = 3; def->max = 20; def->mode = comExpert; - def->default_value = new ConfigOptionInt(10); + def->set_default_value(new ConfigOptionInt(10)); def = this->add("exposure_time", coFloat); def->label = L("Exposure time"); def->tooltip = L("Exposure time"); def->sidetext = L("s"); def->min = 0; - def->default_value = new ConfigOptionFloat(10); + def->set_default_value(new ConfigOptionFloat(10)); def = this->add("initial_exposure_time", coFloat); def->label = L("Initial exposure time"); def->tooltip = L("Initial exposure time"); def->sidetext = L("s"); def->min = 0; - def->default_value = new ConfigOptionFloat(15); + def->set_default_value(new ConfigOptionFloat(15)); def = this->add("material_correction", coFloats); def->full_label = L("Correction for expansion"); def->tooltip = L("Correction for expansion"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloats( { 1. , 1. } ); + def->set_default_value(new ConfigOptionFloats( { 1. , 1. } )); def = this->add("material_notes", coString); def->label = L("SLA print material notes"); @@ -2332,28 +2332,28 @@ void PrintConfigDef::init_sla_params() def->full_width = true; def->height = 13; def->mode = comAdvanced; - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def = this->add("default_sla_material_profile", coString); def->label = L("Default SLA material profile"); def->tooltip = L("Default print profile associated with the current printer profile. " "On selection of the current printer profile, this print profile will be activated."); - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; def = this->add("sla_material_settings_id", coString); - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def->cli = ConfigOptionDef::nocli; def = this->add("default_sla_print_profile", coString); def->label = L("Default SLA material profile"); def->tooltip = L("Default print profile associated with the current printer profile. " "On selection of the current printer profile, this print profile will be activated."); - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); def->cli = ConfigOptionDef::nocli; def = this->add("sla_print_settings_id", coString); - def->default_value = new ConfigOptionString(""); + def->set_default_value(new ConfigOptionString("")); def->cli = ConfigOptionDef::nocli; def = this->add("supports_enable", coBool); @@ -2361,7 +2361,7 @@ void PrintConfigDef::init_sla_params() def->category = L("Supports"); def->tooltip = L("Generate supports for the models"); def->mode = comSimple; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("support_head_front_diameter", coFloat); def->label = L("Support head front diameter"); @@ -2370,7 +2370,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(0.4); + def->set_default_value(new ConfigOptionFloat(0.4)); def = this->add("support_head_penetration", coFloat); def->label = L("Support head penetration"); @@ -2379,7 +2379,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("mm"); def->mode = comAdvanced; def->min = 0; - def->default_value = new ConfigOptionFloat(0.2); + def->set_default_value(new ConfigOptionFloat(0.2)); def = this->add("support_head_width", coFloat); def->label = L("Support head width"); @@ -2389,7 +2389,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 20; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(1.0); + def->set_default_value(new ConfigOptionFloat(1.0)); def = this->add("support_pillar_diameter", coFloat); def->label = L("Support pillar diameter"); @@ -2399,7 +2399,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 15; def->mode = comSimple; - def->default_value = new ConfigOptionFloat(1.0); + def->set_default_value(new ConfigOptionFloat(1.0)); def = this->add("support_pillar_connection_mode", coEnum); def->label = L("Support pillar connection mode"); @@ -2415,14 +2415,14 @@ void PrintConfigDef::init_sla_params() def->enum_labels.push_back(L("Cross")); def->enum_labels.push_back(L("Dynamic")); def->mode = comAdvanced; - def->default_value = new ConfigOptionEnum(slapcmDynamic); + def->set_default_value(new ConfigOptionEnum(slapcmDynamic)); def = this->add("support_buildplate_only", coBool); def->label = L("Support on build plate only"); def->category = L("Supports"); def->tooltip = L("Only create support if it lies on a build plate. Don't create support on a print."); def->mode = comSimple; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("support_pillar_widening_factor", coFloat); def->label = L("Pillar widening factor"); @@ -2433,7 +2433,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 1; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0.0); + def->set_default_value(new ConfigOptionFloat(0.0)); def = this->add("support_base_diameter", coFloat); def->label = L("Support base diameter"); @@ -2443,7 +2443,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 30; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(4.0); + def->set_default_value(new ConfigOptionFloat(4.0)); def = this->add("support_base_height", coFloat); def->label = L("Support base height"); @@ -2452,7 +2452,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(1.0); + def->set_default_value(new ConfigOptionFloat(1.0)); def = this->add("support_critical_angle", coFloat); def->label = L("Critical angle"); @@ -2462,7 +2462,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 90; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(45); + def->set_default_value(new ConfigOptionFloat(45)); def = this->add("support_max_bridge_length", coFloat); def->label = L("Max bridge length"); @@ -2471,7 +2471,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(15.0); + def->set_default_value(new ConfigOptionFloat(15.0)); def = this->add("support_max_pillar_link_distance", coFloat); def->label = L("Max pillar linking distance"); @@ -2481,7 +2481,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("mm"); def->min = 0; // 0 means no linking def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(10.0); + def->set_default_value(new ConfigOptionFloat(10.0)); def = this->add("support_object_elevation", coFloat); def->label = L("Object elevation"); @@ -2491,7 +2491,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 150; // This is the max height of print on SL1 def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(5.0); + def->set_default_value(new ConfigOptionFloat(5.0)); def = this->add("support_points_density_relative", coInt); def->label = L("Support points density"); @@ -2499,7 +2499,7 @@ void PrintConfigDef::init_sla_params() def->tooltip = L("This is a relative measure of support points density."); def->sidetext = L("%"); def->min = 0; - def->default_value = new ConfigOptionInt(100); + def->set_default_value(new ConfigOptionInt(100)); def = this->add("support_points_minimal_distance", coFloat); def->label = L("Minimal distance of the support points"); @@ -2507,14 +2507,14 @@ void PrintConfigDef::init_sla_params() def->tooltip = L("No support points will be placed closer than this threshold."); def->sidetext = L("mm"); def->min = 0; - def->default_value = new ConfigOptionFloat(1.f); + def->set_default_value(new ConfigOptionFloat(1.f)); def = this->add("pad_enable", coBool); def->label = L("Use pad"); def->category = L("Pad"); def->tooltip = L("Add a pad underneath the supported model"); def->mode = comSimple; - def->default_value = new ConfigOptionBool(true); + def->set_default_value(new ConfigOptionBool(true)); def = this->add("pad_wall_thickness", coFloat); def->label = L("Pad wall thickness"); @@ -2524,7 +2524,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 30; def->mode = comSimple; - def->default_value = new ConfigOptionFloat(2.0); + def->set_default_value(new ConfigOptionFloat(2.0)); def = this->add("pad_wall_height", coFloat); def->label = L("Pad wall height"); @@ -2538,7 +2538,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 30; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(0.); + def->set_default_value(new ConfigOptionFloat(0.)); def = this->add("pad_max_merge_distance", coFloat); def->label = L("Max merge distance"); @@ -2550,7 +2550,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("mm"); def->min = 0; def->mode = comExpert; - def->default_value = new ConfigOptionFloat(50.0); + def->set_default_value(new ConfigOptionFloat(50.0)); // This is disabled on the UI. I hope it will never be enabled. def = this->add("pad_edge_radius", coFloat); @@ -2560,7 +2560,7 @@ void PrintConfigDef::init_sla_params() def->sidetext = L("mm"); def->min = 0; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(1.0); + def->set_default_value(new ConfigOptionFloat(1.0)); def = this->add("pad_wall_slope", coFloat); def->label = L("Pad wall slope"); @@ -2571,7 +2571,7 @@ void PrintConfigDef::init_sla_params() def->min = 45; def->max = 90; def->mode = comAdvanced; - def->default_value = new ConfigOptionFloat(45.0); + def->set_default_value(new ConfigOptionFloat(45.0)); } void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &value) @@ -2928,73 +2928,73 @@ CLIActionsConfigDef::CLIActionsConfigDef() def = this->add("export_obj", coBool); def->label = L("Export OBJ"); def->tooltip = L("Export the model(s) as OBJ."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); /* def = this->add("export_svg", coBool); def->label = L("Export SVG"); def->tooltip = L("Slice the model and export solid slices as SVG."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); */ def = this->add("export_sla", coBool); def->label = L("Export SLA"); def->tooltip = L("Slice the model and export SLA printing layers as PNG."); def->cli = "export-sla|sla"; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("export_3mf", coBool); def->label = L("Export 3MF"); def->tooltip = L("Export the model(s) as 3MF."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("export_amf", coBool); def->label = L("Export AMF"); def->tooltip = L("Export the model(s) as AMF."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("export_stl", coBool); def->label = L("Export STL"); def->tooltip = L("Export the model(s) as STL."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("export_gcode", coBool); def->label = L("Export G-code"); def->tooltip = L("Slice the model and export toolpaths as G-code."); def->cli = "export-gcode|gcode|g"; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("slice", coBool); def->label = L("Slice"); def->tooltip = L("Slice the model as FFF or SLA based on the printer_technology configuration value."); def->cli = "slice|s"; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("help", coBool); def->label = L("Help"); def->tooltip = L("Show this help."); def->cli = "help|h"; - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("help_fff", coBool); def->label = L("Help (FFF options)"); def->tooltip = L("Show the full list of print/G-code configuration options."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("help_sla", coBool); def->label = L("Help (SLA options)"); def->tooltip = L("Show the full list of SLA print configuration options."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("info", coBool); def->label = L("Output Model Info"); def->tooltip = L("Write information about the model to the console."); - def->default_value = new ConfigOptionBool(false); + def->set_default_value(new ConfigOptionBool(false)); def = this->add("save", coString); def->label = L("Save config file"); def->tooltip = L("Save configuration to the specified file."); - def->default_value = new ConfigOptionString(); + def->set_default_value(new ConfigOptionString()); } CLITransformConfigDef::CLITransformConfigDef() @@ -3005,34 +3005,34 @@ CLITransformConfigDef::CLITransformConfigDef() def = this->add("align_xy", coPoint); def->label = L("Align XY"); def->tooltip = L("Align the model to the given point."); - def->default_value = new ConfigOptionPoint(Vec2d(100,100)); + def->set_default_value(new ConfigOptionPoint(Vec2d(100,100))); def = this->add("cut", coFloat); def->label = L("Cut"); def->tooltip = L("Cut model at the given Z."); - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); /* def = this->add("cut_grid", coFloat); def->label = L("Cut"); def->tooltip = L("Cut model in the XY plane into tiles of the specified max size."); - def->default_value = new ConfigOptionPoint(); + def->set_default_value(new ConfigOptionPoint()); def = this->add("cut_x", coFloat); def->label = L("Cut"); def->tooltip = L("Cut model at the given X."); - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("cut_y", coFloat); def->label = L("Cut"); def->tooltip = L("Cut model at the given Y."); - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); */ def = this->add("center", coPoint); def->label = L("Center"); def->tooltip = L("Center the print around the given center."); - def->default_value = new ConfigOptionPoint(Vec2d(100,100)); + def->set_default_value(new ConfigOptionPoint(Vec2d(100,100))); def = this->add("dont_arrange", coBool); def->label = L("Don't arrange"); @@ -3059,22 +3059,22 @@ CLITransformConfigDef::CLITransformConfigDef() def = this->add("rotate", coFloat); def->label = L("Rotate"); def->tooltip = L("Rotation angle around the Z axis in degrees."); - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("rotate_x", coFloat); def->label = L("Rotate around X"); def->tooltip = L("Rotation angle around the X axis in degrees."); - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("rotate_y", coFloat); def->label = L("Rotate around Y"); def->tooltip = L("Rotation angle around the Y axis in degrees."); - def->default_value = new ConfigOptionFloat(0); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("scale", coFloatOrPercent); def->label = L("Scale"); def->tooltip = L("Scaling factor or percentage."); - def->default_value = new ConfigOptionFloatOrPercent(1, false); + def->set_default_value(new ConfigOptionFloatOrPercent(1, false)); def = this->add("split", coBool); def->label = L("Split"); @@ -3083,7 +3083,7 @@ CLITransformConfigDef::CLITransformConfigDef() def = this->add("scale_to_fit", coPoint3); def->label = L("Scale to Fit"); def->tooltip = L("Scale to fit the given volume."); - def->default_value = new ConfigOptionPoint3(Vec3d(0,0,0)); + def->set_default_value(new ConfigOptionPoint3(Vec3d(0,0,0))); } CLIMiscConfigDef::CLIMiscConfigDef() diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index db3e63fe7..d4ad1db8c 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -307,8 +307,8 @@ protected: m_keys.emplace_back(kvp.first); const ConfigOptionDef *def = defs->get(kvp.first); assert(def != nullptr); - if (def->default_value != nullptr) - opt->set(def->default_value); + if (def->default_value) + opt->set(def->default_value.get()); } } diff --git a/src/libslic3r/clonable_ptr.hpp b/src/libslic3r/clonable_ptr.hpp new file mode 100644 index 000000000..a3b7ee244 --- /dev/null +++ b/src/libslic3r/clonable_ptr.hpp @@ -0,0 +1,168 @@ +// clonable_ptr: a smart pointer with a usage similar to unique_ptr, with the exception, that +// the copy constructor / copy assignment operator work by calling the ->clone() method. + +// derived from https://github.com/SRombauts/shared_ptr/blob/master/include/unique_ptr.hpp +/** + * @file clonable_ptr.hpp + * @brief clonable_ptr is a fake implementation to use in place of a C++11 std::clonable_ptr when compiling on an older compiler. + * + * @see http://www.cplusplus.com/reference/memory/clonable_ptr/ + * + * Copyright (c) 2014-2019 Sebastien Rombauts (sebastien.rombauts@gmail.com) + * + * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt + * or copy at http://opensource.org/licenses/MIT) + */ + +#include "assert.h" + +namespace Slic3r { + +// Detect whether the compiler supports C++11 noexcept exception specifications. +#if defined(_MSC_VER) && _MSC_VER < 1900 && ! defined(noexcept) + #define noexcept throw() +#endif + +template +class clonable_ptr +{ +public: + /// The type of the managed object, aliased as member type + typedef T element_type; + + /// @brief Default constructor + clonable_ptr() noexcept : + px(nullptr) + { + } + /// @brief Constructor with the provided pointer to manage + explicit clonable_ptr(T* p) noexcept : + px(p) + { + } + /// @brief Copy constructor, clones by calling the rhs.clone() method + clonable_ptr(const clonable_ptr& rhs) : + px(rhs ? rhs.px->clone() : nullptr) + { + } + /// @brief Move constructor, never throws + clonable_ptr(clonable_ptr&& rhs) noexcept : + px(rhs.px) + { + rhs.px = nullptr; + } + /// @brief Assignment operator + clonable_ptr& operator=(const clonable_ptr& rhs) + { + delete px; + px = rhs ? rhs.px->clone() : nullptr; + return *this; + } + /// @brief Move operator, never throws + clonable_ptr& operator=(clonable_ptr&& rhs) + { + delete px; + px = rhs.px; + rhs.px = nullptr; + return *this; + } + /// @brief the destructor releases its ownership and destroy the object + inline ~clonable_ptr() noexcept + { + destroy(); + } + /// @brief this reset releases its ownership and destroy the object + inline void reset() noexcept + { + destroy(); + } + /// @brief this reset release its ownership and re-acquire another one + void reset(T* p) noexcept + { + assert((nullptr == p) || (px != p)); // auto-reset not allowed + destroy(); + px = p; + } + + /// @brief Swap method for the copy-and-swap idiom (copy constructor and swap method) + void swap(clonable_ptr& rhs) noexcept + { + T *tmp = px; + px = rhs.px; + rhs.px = tmp; + } + + /// @brief release the ownership of the px pointer without destroying the object! + inline void release() noexcept + { + px = nullptr; + } + + // reference counter operations : + inline operator bool() const noexcept + { + return (nullptr != px); // TODO nullptrptr + } + + // underlying pointer operations : + inline T& operator*() const noexcept + { + assert(nullptr != px); + return *px; + } + inline T* operator->() const noexcept + { + assert(nullptr != px); + return px; + } + inline T* get() const noexcept + { + // no assert, can return nullptr + return px; + } + +private: + /// @brief release the ownership of the px pointer and destroy the object + inline void destroy() noexcept + { + delete px; + px = nullptr; + } + + /// @brief hack: const-cast release the ownership of the px pointer without destroying the object! + inline void release() const noexcept + { + px = nullptr; + } + +private: + T* px; //!< Native pointer +}; + +// comparison operators +template inline bool operator==(const clonable_ptr& l, const clonable_ptr& r) noexcept +{ + return (l.get() == r.get()); +} +template inline bool operator!=(const clonable_ptr& l, const clonable_ptr& r) noexcept +{ + return (l.get() != r.get()); +} +template inline bool operator<=(const clonable_ptr& l, const clonable_ptr& r) noexcept +{ + return (l.get() <= r.get()); +} +template inline bool operator<(const clonable_ptr& l, const clonable_ptr& r) noexcept +{ + return (l.get() < r.get()); +} +template inline bool operator>=(const clonable_ptr& l, const clonable_ptr& r) noexcept +{ + return (l.get() >= r.get()); +} +template inline bool operator>(const clonable_ptr& l, const clonable_ptr& r) noexcept +{ + return (l.get() > r.get()); +} + +} // namespace Slic3r diff --git a/src/slic3r/GUI/BedShapeDialog.cpp b/src/slic3r/GUI/BedShapeDialog.cpp index 00ebf117c..fbbca7c70 100644 --- a/src/slic3r/GUI/BedShapeDialog.cpp +++ b/src/slic3r/GUI/BedShapeDialog.cpp @@ -68,14 +68,14 @@ void BedShapePanel::build_panel(ConfigOptionPoints* default_pt) auto optgroup = init_shape_options_page(_(L("Rectangular"))); ConfigOptionDef def; def.type = coPoints; - def.default_value = new ConfigOptionPoints{ Vec2d(200, 200) }; + def.set_default_value(new ConfigOptionPoints{ Vec2d(200, 200) }); def.label = L("Size"); def.tooltip = L("Size in X and Y of the rectangular plate."); Option option(def, "rect_size"); optgroup->append_single_option_line(option); def.type = coPoints; - def.default_value = new ConfigOptionPoints{ Vec2d(0, 0) }; + def.set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) }); def.label = L("Origin"); def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle."); option = Option(def, "rect_origin"); @@ -83,7 +83,7 @@ void BedShapePanel::build_panel(ConfigOptionPoints* default_pt) optgroup = init_shape_options_page(_(L("Circular"))); def.type = coFloat; - def.default_value = new ConfigOptionFloat(200); + def.set_default_value(new ConfigOptionFloat(200)); def.sidetext = L("mm"); def.label = L("Diameter"); def.tooltip = L("Diameter of the print bed. It is assumed that origin (0,0) is located in the center."); diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 93c780909..bd45104c4 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -499,7 +499,7 @@ PageFirmware::PageFirmware(ConfigWizard *parent) gcode_picker = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices); const auto &enum_values = gcode_opt.enum_values; auto needle = enum_values.cend(); - if (gcode_opt.default_value != nullptr) { + if (gcode_opt.default_value) { needle = std::find(enum_values.cbegin(), enum_values.cend(), gcode_opt.default_value->serialize()); } if (needle != enum_values.cend()) { @@ -545,13 +545,13 @@ PageDiameters::PageDiameters(ConfigWizard *parent) spin_nozzle->SetDigits(2); spin_nozzle->SetIncrement(0.1); const auto &def_nozzle = *print_config_def.get("nozzle_diameter"); - auto *default_nozzle = dynamic_cast(def_nozzle.default_value); + auto *default_nozzle = dynamic_cast(def_nozzle.default_value.get()); spin_nozzle->SetValue(default_nozzle != nullptr && default_nozzle->size() > 0 ? default_nozzle->get_at(0) : 0.5); spin_filam->SetDigits(2); spin_filam->SetIncrement(0.25); const auto &def_filam = *print_config_def.get("filament_diameter"); - auto *default_filam = dynamic_cast(def_filam.default_value); + auto *default_filam = dynamic_cast(def_filam.default_value.get()); spin_filam->SetValue(default_filam != nullptr && default_filam->size() > 0 ? default_filam->get_at(0) : 3.0); append_text(_(L("Enter the diameter of your printer's hot end nozzle."))); @@ -596,13 +596,13 @@ PageTemperatures::PageTemperatures(ConfigWizard *parent) spin_extr->SetIncrement(5.0); const auto &def_extr = *print_config_def.get("temperature"); spin_extr->SetRange(def_extr.min, def_extr.max); - auto *default_extr = dynamic_cast(def_extr.default_value); + auto *default_extr = dynamic_cast(def_extr.default_value.get()); spin_extr->SetValue(default_extr != nullptr && default_extr->size() > 0 ? default_extr->get_at(0) : 200); spin_bed->SetIncrement(5.0); const auto &def_bed = *print_config_def.get("bed_temperature"); spin_bed->SetRange(def_bed.min, def_bed.max); - auto *default_bed = dynamic_cast(def_bed.default_value); + auto *default_bed = dynamic_cast(def_bed.default_value.get()); spin_bed->SetValue(default_bed != nullptr && default_bed->size() > 0 ? default_bed->get_at(0) : 0); append_text(_(L("Enter the temperature needed for extruding your filament."))); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index cb414fa79..02f58667c 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -203,7 +203,7 @@ void TextCtrl::BUILD() { case coFloatOrPercent: { text_value = double_to_string(m_opt.default_value->getFloat()); - if (static_cast(m_opt.default_value)->percent) + if (static_cast(m_opt.default_value.get())->percent) text_value += "%"; break; } @@ -218,19 +218,19 @@ void TextCtrl::BUILD() { case coFloat: { double val = m_opt.type == coFloats ? - static_cast(m_opt.default_value)->get_at(m_opt_idx) : + static_cast(m_opt.default_value.get())->get_at(m_opt_idx) : m_opt.type == coFloat ? m_opt.default_value->getFloat() : - static_cast(m_opt.default_value)->get_at(m_opt_idx); + static_cast(m_opt.default_value.get())->get_at(m_opt_idx); text_value = double_to_string(val); break; } case coString: - text_value = static_cast(m_opt.default_value)->value; + text_value = static_cast(m_opt.default_value.get())->value; break; case coStrings: { - const ConfigOptionStrings *vec = static_cast(m_opt.default_value); + const ConfigOptionStrings *vec = static_cast(m_opt.default_value.get()); if (vec == nullptr || vec->empty()) break; //for the case of empty default value text_value = vec->get_at(m_opt_idx); break; @@ -373,7 +373,7 @@ void CheckBox::BUILD() { bool check_value = m_opt.type == coBool ? m_opt.default_value->getBool() : m_opt.type == coBools ? - static_cast(m_opt.default_value)->get_at(m_opt_idx) : + static_cast(m_opt.default_value.get())->get_at(m_opt_idx) : false; // Set Label as a string of at least one space simbol to correct system scaling of a CheckBox @@ -427,7 +427,7 @@ void SpinCtrl::BUILD() { break; case coInts: { - const ConfigOptionInts *vec = static_cast(m_opt.default_value); + const ConfigOptionInts *vec = static_cast(m_opt.default_value.get()); if (vec == nullptr || vec->empty()) break; for (size_t id = 0; id < vec->size(); ++id) { @@ -629,7 +629,7 @@ void Choice::set_selection() break; } case coEnum:{ - int id_value = static_cast*>(m_opt.default_value)->value; //!! + int id_value = static_cast*>(m_opt.default_value.get())->value; //!! field->SetSelection(id_value); break; } @@ -649,7 +649,7 @@ void Choice::set_selection() break; } case coStrings:{ - text_value = static_cast(m_opt.default_value)->get_at(m_opt_idx); + text_value = static_cast(m_opt.default_value.get())->get_at(m_opt_idx); size_t idx = 0; for (auto el : m_opt.enum_values) @@ -886,7 +886,7 @@ void ColourPicker::BUILD() if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); // Validate the color - wxString clr_str(static_cast(m_opt.default_value)->get_at(m_opt_idx)); + wxString clr_str(static_cast(m_opt.default_value.get())->get_at(m_opt_idx)); wxColour clr(clr_str); if (! clr.IsOk()) { clr = wxTransparentColour; @@ -920,7 +920,7 @@ void PointCtrl::BUILD() const wxSize field_size(4 * m_em_unit, -1); - auto default_pt = static_cast(m_opt.default_value)->values.at(0); + auto default_pt = static_cast(m_opt.default_value.get())->values.at(0); double val = default_pt(0); wxString X = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None); val = default_pt(1); @@ -1019,7 +1019,7 @@ void StaticText::BUILD() if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); - const wxString legend(static_cast(m_opt.default_value)->value); + const wxString legend(static_cast(m_opt.default_value.get())->value); auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE); temp->SetFont(Slic3r::GUI::wxGetApp().normal_font()); temp->SetBackgroundStyle(wxBG_STYLE_PAINT); @@ -1054,7 +1054,7 @@ void SliderCtrl::BUILD() auto temp = new wxBoxSizer(wxHORIZONTAL); - auto def_val = static_cast(m_opt.default_value)->value; + auto def_val = static_cast(m_opt.default_value.get())->value; auto min = m_opt.min == INT_MIN ? 0 : m_opt.min; auto max = m_opt.max == INT_MAX ? 100 : m_opt.max; diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index 1da17f676..36b356c5d 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -90,7 +90,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : def.gui_type = "legend"; def.tooltip = L("Object name"); def.width = 21; - def.default_value = new ConfigOptionString{ " " }; + def.set_default_value(new ConfigOptionString{ " " }); m_og->append_single_option_line(Option(def, "object_name")); const int field_width = 5; @@ -103,7 +103,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : for (const std::string axis : { "x", "y", "z" }) { const std::string label = boost::algorithm::to_upper_copy(axis); - def.default_value = new ConfigOptionString{ " " + label }; + def.set_default_value(new ConfigOptionString{ " " + label }); Option option = Option(def, axis + "_axis_legend"); line.append_option(option); } @@ -120,7 +120,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : Line line = { _(option_name), "" }; ConfigOptionDef def; def.type = coFloat; - def.default_value = new ConfigOptionFloat(0.0); + def.set_default_value(new ConfigOptionFloat(0.0)); def.width = field_width/*50*/; // Add "uniform scaling" button in front of "Scale" option diff --git a/src/slic3r/GUI/LambdaObjectDialog.cpp b/src/slic3r/GUI/LambdaObjectDialog.cpp index 0146db5f6..4d1cb0658 100644 --- a/src/slic3r/GUI/LambdaObjectDialog.cpp +++ b/src/slic3r/GUI/LambdaObjectDialog.cpp @@ -49,7 +49,7 @@ LambdaObjectDialog::LambdaObjectDialog(wxWindow* parent, }; def.type = coFloat; - def.default_value = new ConfigOptionFloat{ 1.0 }; + def.set_default_value(new ConfigOptionFloat{ 1.0 }); def.label = L("Length"); Option option(def, "l"); optgroup->append_single_option_line(option); @@ -75,7 +75,7 @@ LambdaObjectDialog::LambdaObjectDialog(wxWindow* parent, }; def.type = coInt; - def.default_value = new ConfigOptionInt{ 1 }; + def.set_default_value(new ConfigOptionInt{ 1 }); def.label = L("Radius"); auto option = Option(def, "cyl_r"); optgroup->append_single_option_line(option); @@ -94,7 +94,7 @@ LambdaObjectDialog::LambdaObjectDialog(wxWindow* parent, }; def.type = coFloat; - def.default_value = new ConfigOptionFloat{ 1.0 }; + def.set_default_value(new ConfigOptionFloat{ 1.0 }); def.label = L("Rho"); auto option = Option(def, "sph_rho"); optgroup->append_single_option_line(option); @@ -112,7 +112,7 @@ LambdaObjectDialog::LambdaObjectDialog(wxWindow* parent, }; def.type = coFloat; - def.default_value = new ConfigOptionFloat{ 1.0 }; + def.set_default_value(new ConfigOptionFloat{ 1.0 }); def.label = L("Height"); auto option = Option(def, "slab_h"); optgroup->append_single_option_line(option); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index b3757dc8b..292d47d91 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -394,16 +394,27 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) : } new_conf.set_key_value("brim_width", new ConfigOptionFloat(new_val)); } - else { //(opt_key == "support") + else { + assert(opt_key == "support"); const wxString& selection = boost::any_cast(value); + PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology(); auto support_material = selection == _("None") ? false : true; new_conf.set_key_value("support_material", new ConfigOptionBool(support_material)); - if (selection == _("Everywhere")) + if (selection == _("Everywhere")) { new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(false)); - else if (selection == _("Support on build plate only")) + if (printer_technology == ptFFF) + new_conf.set_key_value("support_material_auto", new ConfigOptionBool(true)); + } else if (selection == _("Support on build plate only")) { new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(true)); + if (printer_technology == ptFFF) + new_conf.set_key_value("support_material_auto", new ConfigOptionBool(true)); + } else if (selection == _("For support enforcers only")) { + assert(printer_technology == ptFFF); + new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(false)); + new_conf.set_key_value("support_material_auto", new ConfigOptionBool(false)); + } } tab_print->load_config(new_conf); } @@ -421,12 +432,9 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) : support_def.tooltip = L("Select what kind of support do you need"); support_def.enum_labels.push_back(L("None")); support_def.enum_labels.push_back(L("Support on build plate only")); + support_def.enum_labels.push_back(L("For support enforcers only")); support_def.enum_labels.push_back(L("Everywhere")); - std::string selection = !config->opt_bool("support_material") ? - "None" : config->opt_bool("support_material_buildplate_only") ? - "Support on build plate only" : - "Everywhere"; - support_def.default_value = new ConfigOptionStrings{ selection }; + support_def.set_default_value(new ConfigOptionStrings{ "None" }); Option option = Option(support_def, "support"); option.opt.full_width = true; line.append_option(option); @@ -447,7 +455,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) : def.type = coBool; def.tooltip = L("This flag enables the brim that will be printed around each object on the first layer."); def.gui_type = ""; - def.default_value = new ConfigOptionBool{ m_brim_width > 0.0 ? true : false }; + def.set_default_value(new ConfigOptionBool{ m_brim_width > 0.0 ? true : false }); option = Option(def, "brim"); option.opt.sidetext = " "; line.append_option(option); @@ -493,8 +501,9 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) : tab->set_value(opt_key, value); tab->update(); } - else //(opt_key == "support") + else { + assert(opt_key == "support"); DynamicPrintConfig new_conf = *config_sla; const wxString& selection = boost::any_cast(value); @@ -514,17 +523,15 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) : line = Line{ "", "" }; - selection = !config_sla->opt_bool("supports_enable") ? - "None" : config_sla->opt_bool("support_buildplate_only") ? - "Support on build plate only" : - "Everywhere"; - support_def.default_value = new ConfigOptionStrings{ selection }; - option = Option(support_def, "support"); + ConfigOptionDef support_def_sla = support_def; + support_def_sla.set_default_value(new ConfigOptionStrings{ "None" }); + assert(support_def_sla.enum_labels[2] == L("For support enforcers only")); + support_def_sla.enum_labels.erase(support_def_sla.enum_labels.begin() + 2); + option = Option(support_def_sla, "support"); option.opt.full_width = true; line.append_option(option); m_og_sla->append_line(line); - line = Line{ "", "" }; option = m_og_sla->get_option("pad_enable"); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index b6a340d08..2bf9b6332 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -37,7 +37,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory " "instead of the one containing the input files."); - def.default_value = new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true }; + def.set_default_value(new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true }); Option option(def, "remember_output_path"); m_optgroup->append_single_option_line(option); @@ -45,7 +45,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("If this is enabled, Slic3r will auto-center objects " "around the print bed center."); - def.default_value = new ConfigOptionBool{ app_config->get("autocenter") == "1" }; + def.set_default_value(new ConfigOptionBool{ app_config->get("autocenter") == "1" }); option = Option (def,"autocenter"); m_optgroup->append_single_option_line(option); @@ -53,7 +53,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("If this is enabled, Slic3r will pre-process objects as soon " "as they\'re loaded in order to save time when exporting G-code."); - def.default_value = new ConfigOptionBool{ app_config->get("background_processing") == "1" }; + def.set_default_value(new ConfigOptionBool{ app_config->get("background_processing") == "1" }); option = Option (def,"background_processing"); m_optgroup->append_single_option_line(option); @@ -61,7 +61,7 @@ void PreferencesDialog::build() def.label = L("Check for application updates"); def.type = coBool; def.tooltip = L("If enabled, Slic3r checks for new versions of " SLIC3R_APP_NAME " online. When a new version becomes available a notification is displayed at the next application startup (never during program usage). This is only a notification mechanisms, no automatic installation is done."); - def.default_value = new ConfigOptionBool(app_config->get("version_check") == "1"); + def.set_default_value(new ConfigOptionBool(app_config->get("version_check") == "1")); option = Option (def, "version_check"); m_optgroup->append_single_option_line(option); @@ -69,7 +69,7 @@ void PreferencesDialog::build() def.label = L("Update built-in Presets automatically"); def.type = coBool; def.tooltip = L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded into a separate temporary location. When a new preset version becomes available it is offered at application startup."); - def.default_value = new ConfigOptionBool(app_config->get("preset_update") == "1"); + def.set_default_value(new ConfigOptionBool(app_config->get("preset_update") == "1")); option = Option (def, "preset_update"); m_optgroup->append_single_option_line(option); @@ -77,7 +77,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("Suppress \" - default - \" presets in the Print / Filament / Printer " "selections once there are any other valid presets available."); - def.default_value = new ConfigOptionBool{ app_config->get("no_defaults") == "1" }; + def.set_default_value(new ConfigOptionBool{ app_config->get("no_defaults") == "1" }); option = Option (def,"no_defaults"); m_optgroup->append_single_option_line(option); @@ -85,7 +85,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("When checked, the print and filament presets are shown in the preset editor " "even if they are marked as incompatible with the active printer"); - def.default_value = new ConfigOptionBool{ app_config->get("show_incompatible_presets") == "1" }; + def.set_default_value(new ConfigOptionBool{ app_config->get("show_incompatible_presets") == "1" }); option = Option (def,"show_incompatible_presets"); m_optgroup->append_single_option_line(option); @@ -95,7 +95,7 @@ void PreferencesDialog::build() def.tooltip = L("If you have rendering issues caused by a buggy OpenGL 2.0 driver, " "you may try to check this checkbox. This will disable the layer height " "editing and anti aliasing, so it is likely better to upgrade your graphics driver."); - def.default_value = new ConfigOptionBool{ app_config->get("use_legacy_opengl") == "1" }; + def.set_default_value(new ConfigOptionBool{ app_config->get("use_legacy_opengl") == "1" }); option = Option (def,"use_legacy_opengl"); m_optgroup->append_single_option_line(option); @@ -104,7 +104,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("If enabled, the 3D scene will be rendered in Retina resolution. " "If you are experiencing 3D performance problems, disabling this option may help."); - def.default_value = new ConfigOptionBool{ app_config->get("use_retina_opengl") == "1" }; + def.set_default_value(new ConfigOptionBool{ app_config->get("use_retina_opengl") == "1" }); option = Option (def, "use_retina_opengl"); m_optgroup->append_single_option_line(option); #endif diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index fb8147ad2..129643d18 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -815,6 +815,19 @@ void Tab::load_key_value(const std::string& opt_key, const boost::any& value, bo update(); } +static wxString support_combo_value_for_config(const DynamicPrintConfig &config, bool is_fff) +{ + const std::string support = is_fff ? "support_material" : "supports_enable"; + const std::string buildplate_only = is_fff ? "support_material_buildplate_only" : "support_buildplate_only"; + return + ! config.opt_bool(support) ? + _("None") : + (is_fff && !config.opt_bool("support_material_auto")) ? + _("For support enforcers only") : + (config.opt_bool(buildplate_only) ? _("Support on build plate only") : + _("Everywhere")); +} + void Tab::on_value_change(const std::string& opt_key, const boost::any& value) { if (wxGetApp().plater() == nullptr) { @@ -822,23 +835,17 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) } const bool is_fff = supports_printer_technology(ptFFF); - ConfigOptionsGroup* og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params(is_fff); + ConfigOptionsGroup* og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params(is_fff); if (opt_key == "fill_density" || opt_key == "pad_enable") { boost::any val = og_freq_chng_params->get_config_value(*m_config, opt_key); og_freq_chng_params->set_value(opt_key, val); } - if ( is_fff && (opt_key == "support_material" || opt_key == "support_material_buildplate_only") || - !is_fff && (opt_key == "supports_enable" || opt_key == "support_buildplate_only")) - { - const std::string support = is_fff ? "support_material" : "supports_enable"; - const std::string buildplate_only = is_fff ? "support_material_buildplate_only" : "support_buildplate_only"; - wxString new_selection = !m_config->opt_bool(support) ? _("None") : - m_config->opt_bool(buildplate_only) ? _("Support on build plate only") : - _("Everywhere"); - og_freq_chng_params->set_value("support", new_selection); - } + if (is_fff ? + (opt_key == "support_material" || opt_key == "support_material_auto" || opt_key == "support_material_buildplate_only") : + (opt_key == "supports_enable" || opt_key == "support_buildplate_only")) + og_freq_chng_params->set_value("support", support_combo_value_for_config(*m_config, is_fff)); if (opt_key == "brim_width") { @@ -964,18 +971,11 @@ void Tab::update_preset_description_line() void Tab::update_frequently_changed_parameters() { - auto og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params(supports_printer_technology(ptFFF)); + const bool is_fff = supports_printer_technology(ptFFF); + auto og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params(is_fff); if (!og_freq_chng_params) return; - const bool is_fff = supports_printer_technology(ptFFF); - - const std::string support = is_fff ? "support_material" : "supports_enable"; - const std::string buildplate_only = is_fff ? "support_material_buildplate_only" : "support_buildplate_only"; - - wxString new_selection = !m_config->opt_bool(support) ? _("None") : - m_config->opt_bool(buildplate_only) ? _("Support on build plate only") : - _("Everywhere"); - og_freq_chng_params->set_value("support", new_selection); + og_freq_chng_params->set_value("support", support_combo_value_for_config(*m_config, is_fff)); const std::string updated_value_key = is_fff ? "fill_density" : "pad_enable"; @@ -1840,7 +1840,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(_(L("Capabilities"))); ConfigOptionDef def; def.type = coInt, - def.default_value = new ConfigOptionInt(1); + def.set_default_value(new ConfigOptionInt(1)); def.label = L("Extruders"); def.tooltip = L("Number of extruders of the printer."); def.min = 1; @@ -2148,13 +2148,13 @@ PageShp TabPrinter::build_kinematics_page() def.gui_type = "legend"; def.mode = comAdvanced; def.tooltip = L("Values in this column are for Full Power mode"); - def.default_value = new ConfigOptionString{ L("Full Power") }; + def.set_default_value(new ConfigOptionString{ L("Full Power") }); auto option = Option(def, "full_power_legend"); line.append_option(option); def.tooltip = L("Values in this column are for Silent mode"); - def.default_value = new ConfigOptionString{ L("Silent") }; + def.set_default_value(new ConfigOptionString{ L("Silent") }); option = Option(def, "silent_legend"); line.append_option(option); diff --git a/xs/xsp/Config.xsp b/xs/xsp/Config.xsp index f9482bd3b..4d48a2c6f 100644 --- a/xs/xsp/Config.xsp +++ b/xs/xsp/Config.xsp @@ -223,8 +223,8 @@ print_config_def() (void)hv_stores( hv, "labels", newRV_noinc((SV*)av) ); } - if (optdef->default_value != NULL) - (void)hv_stores( hv, "default", ConfigOption_to_SV(*optdef->default_value, *optdef) ); + if (optdef->default_value) + (void)hv_stores( hv, "default", ConfigOption_to_SV(*optdef->default_value.get(), *optdef) ); (void)hv_store( options_hv, opt_key.c_str(), opt_key.length(), newRV_noinc((SV*)hv), 0 ); }