Added additional checkbox to enable zero elevation

This commit is contained in:
tamasmeszaros 2019-08-06 16:51:32 +02:00
parent b43f7c3880
commit 3c09473f2a
5 changed files with 2626 additions and 2568 deletions

View File

@ -12,7 +12,7 @@
namespace Slic3r { namespace Slic3r {
//! macro used to mark string used at localization, //! macro used to mark string used at localization,
//! return same string //! return same string
#define L(s) (s) #define L(s) (s)
#define _(s) Slic3r::I18N::translate(s) #define _(s) Slic3r::I18N::translate(s)
@ -51,7 +51,7 @@ void PrintConfigDef::init_common_params()
def->label = L("Bed shape"); def->label = L("Bed shape");
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_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("bed_custom_texture", coString); def = this->add("bed_custom_texture", coString);
def->label = L("Bed custom texture"); def->label = L("Bed custom texture");
def->mode = comAdvanced; def->mode = comAdvanced;
@ -85,8 +85,8 @@ void PrintConfigDef::init_common_params()
"The gap closing operation may reduce the final print resolution, therefore it is advisable to keep the value reasonably low."); "The gap closing operation may reduce the final print resolution, therefore it is advisable to keep the value reasonably low.");
def->sidetext = L("mm"); def->sidetext = L("mm");
def->min = 0; def->min = 0;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.049)); def->set_default_value(new ConfigOptionFloat(0.049));
def = this->add("print_host", coString); def = this->add("print_host", coString);
def->label = L("Hostname, IP or URL"); def->label = L("Hostname, IP or URL");
@ -101,7 +101,7 @@ void PrintConfigDef::init_common_params()
"the API Key or the password required for authentication."); "the API Key or the password required for authentication.");
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionString("")); def->set_default_value(new ConfigOptionString(""));
def = this->add("printhost_cafile", coString); def = this->add("printhost_cafile", coString);
def->label = L("HTTPS CA File"); def->label = L("HTTPS CA File");
def->tooltip = L("Custom CA certificate file can be specified for HTTPS OctoPrint connections, in crt/pem format. " def->tooltip = L("Custom CA certificate file can be specified for HTTPS OctoPrint connections, in crt/pem format. "
@ -117,9 +117,9 @@ void PrintConfigDef::init_fff_params()
// Maximum extruder temperature, bumped to 1500 to support printing of glass. // Maximum extruder temperature, bumped to 1500 to support printing of glass.
const int max_temp = 1500; const int max_temp = 1500;
def = this->add("avoid_crossing_perimeters", coBool); def = this->add("avoid_crossing_perimeters", coBool);
def->label = L("Avoid crossing perimeters"); def->label = L("Avoid crossing perimeters");
def->tooltip = L("Optimize travel moves in order to minimize the crossing of perimeters. " def->tooltip = L("Optimize travel moves in order to minimize the crossing of perimeters. "
"This is mostly useful with Bowden extruders which suffer from oozing. " "This is mostly useful with Bowden extruders which suffer from oozing. "
"This feature slows down both the print and the G-code generation."); "This feature slows down both the print and the G-code generation.");
def->mode = comExpert; def->mode = comExpert;
@ -178,7 +178,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Bridging angle override. If left to zero, the bridging angle will be calculated " def->tooltip = L("Bridging angle override. If left to zero, the bridging angle will be calculated "
"automatically. Otherwise the provided angle will be used for all bridges. " "automatically. Otherwise the provided angle will be used for all bridges. "
"Use 180° for zero angle."); "Use 180° for zero angle.");
def->sidetext = L("°"); def->sidetext = L("°");
def->min = 0; def->min = 0;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.)); def->set_default_value(new ConfigOptionFloat(0.));
@ -200,9 +200,9 @@ void PrintConfigDef::init_fff_params()
"although default settings are usually good and you should experiment " "although default settings are usually good and you should experiment "
"with cooling (use a fan) before tweaking this."); "with cooling (use a fan) before tweaking this.");
def->min = 0; def->min = 0;
def->max = 2; def->max = 2;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(1)); def->set_default_value(new ConfigOptionFloat(1));
def = this->add("bridge_speed", coFloat); def = this->add("bridge_speed", coFloat);
def->label = L("Bridges"); def->label = L("Bridges");
@ -532,7 +532,7 @@ void PrintConfigDef::init_fff_params()
"check filament diameter and your firmware E steps."); "check filament diameter and your firmware E steps.");
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats { 1. }); def->set_default_value(new ConfigOptionFloats { 1. });
def = this->add("extrusion_width", coFloatOrPercent); def = this->add("extrusion_width", coFloatOrPercent);
def->label = L("Default extrusion width"); def->label = L("Default extrusion width");
def->category = L("Extrusion Width"); def->category = L("Extrusion Width");
@ -678,7 +678,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("This string is edited by RammingDialog and contains ramming specific parameters."); def->tooltip = L("This string is edited by RammingDialog and contains ramming specific parameters.");
def->mode = comExpert; def->mode = comExpert;
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|" 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" }); " 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 = this->add("filament_unload_time", coFloats);
def->label = L("Filament unload time"); def->label = L("Filament unload time");
@ -744,7 +744,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("money/kg"); def->sidetext = L("money/kg");
def->min = 0; def->min = 0;
def->set_default_value(new ConfigOptionFloats { 0. }); def->set_default_value(new ConfigOptionFloats { 0. });
def = this->add("filament_settings_id", coStrings); def = this->add("filament_settings_id", coStrings);
def->set_default_value(new ConfigOptionStrings { "" }); def->set_default_value(new ConfigOptionStrings { "" });
def->cli = ConfigOptionDef::nocli; def->cli = ConfigOptionDef::nocli;
@ -890,7 +890,7 @@ void PrintConfigDef::init_fff_params()
def->min = 0; def->min = 0;
def->max = max_temp; def->max = max_temp;
def->set_default_value(new ConfigOptionInts { 200 }); def->set_default_value(new ConfigOptionInts { 200 });
def = this->add("gap_fill_speed", coFloat); def = this->add("gap_fill_speed", coFloat);
def->label = L("Gap fill"); def->label = L("Gap fill");
def->category = L("Speed"); def->category = L("Speed");
@ -1073,85 +1073,85 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
def = this->add("silent_mode", coBool); def = this->add("silent_mode", coBool);
def->label = L("Supports stealth mode"); def->label = L("Supports stealth mode");
def->tooltip = L("The firmware supports stealth mode"); def->tooltip = L("The firmware supports stealth mode");
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(true)); def->set_default_value(new ConfigOptionBool(true));
const int machine_limits_opt_width = 7; const int machine_limits_opt_width = 7;
{ {
struct AxisDefault { struct AxisDefault {
std::string name; std::string name;
std::vector<double> max_feedrate; std::vector<double> max_feedrate;
std::vector<double> max_acceleration; std::vector<double> max_acceleration;
std::vector<double> max_jerk; std::vector<double> max_jerk;
}; };
std::vector<AxisDefault> axes { std::vector<AxisDefault> axes {
// name, max_feedrate, max_acceleration, max_jerk // name, max_feedrate, max_acceleration, max_jerk
{ "x", { 500., 200. }, { 9000., 1000. }, { 10. , 10. } }, { "x", { 500., 200. }, { 9000., 1000. }, { 10. , 10. } },
{ "y", { 500., 200. }, { 9000., 1000. }, { 10. , 10. } }, { "y", { 500., 200. }, { 9000., 1000. }, { 10. , 10. } },
{ "z", { 12., 12. }, { 500., 200. }, { 0.2, 0.4 } }, { "z", { 12., 12. }, { 500., 200. }, { 0.2, 0.4 } },
{ "e", { 120., 120. }, { 10000., 5000. }, { 2.5, 2.5 } } { "e", { 120., 120. }, { 10000., 5000. }, { 2.5, 2.5 } }
}; };
for (const AxisDefault &axis : axes) { for (const AxisDefault &axis : axes) {
std::string axis_upper = boost::to_upper_copy<std::string>(axis.name); std::string axis_upper = boost::to_upper_copy<std::string>(axis.name);
// Add the machine feedrate limits for XYZE axes. (M203) // Add the machine feedrate limits for XYZE axes. (M203)
def = this->add("machine_max_feedrate_" + axis.name, coFloats); def = this->add("machine_max_feedrate_" + axis.name, coFloats);
def->full_label = (boost::format("Maximum feedrate %1%") % axis_upper).str(); def->full_label = (boost::format("Maximum feedrate %1%") % axis_upper).str();
(void)L("Maximum feedrate X"); (void)L("Maximum feedrate X");
(void)L("Maximum feedrate Y"); (void)L("Maximum feedrate Y");
(void)L("Maximum feedrate Z"); (void)L("Maximum feedrate Z");
(void)L("Maximum feedrate E"); (void)L("Maximum feedrate E");
def->category = L("Machine limits"); def->category = L("Machine limits");
def->tooltip = (boost::format("Maximum feedrate of the %1% axis") % axis_upper).str(); def->tooltip = (boost::format("Maximum feedrate of the %1% axis") % axis_upper).str();
(void)L("Maximum feedrate of the X axis"); (void)L("Maximum feedrate of the X axis");
(void)L("Maximum feedrate of the Y axis"); (void)L("Maximum feedrate of the Y axis");
(void)L("Maximum feedrate of the Z axis"); (void)L("Maximum feedrate of the Z axis");
(void)L("Maximum feedrate of the E axis"); (void)L("Maximum feedrate of the E axis");
def->sidetext = L("mm/s"); def->sidetext = L("mm/s");
def->min = 0; def->min = 0;
def->width = machine_limits_opt_width; def->width = machine_limits_opt_width;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_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) // Add the machine acceleration limits for XYZE axes (M201)
def = this->add("machine_max_acceleration_" + axis.name, coFloats); def = this->add("machine_max_acceleration_" + axis.name, coFloats);
def->full_label = (boost::format("Maximum acceleration %1%") % axis_upper).str(); def->full_label = (boost::format("Maximum acceleration %1%") % axis_upper).str();
(void)L("Maximum acceleration X"); (void)L("Maximum acceleration X");
(void)L("Maximum acceleration Y"); (void)L("Maximum acceleration Y");
(void)L("Maximum acceleration Z"); (void)L("Maximum acceleration Z");
(void)L("Maximum acceleration E"); (void)L("Maximum acceleration E");
def->category = L("Machine limits"); def->category = L("Machine limits");
def->tooltip = (boost::format("Maximum acceleration of the %1% axis") % axis_upper).str(); def->tooltip = (boost::format("Maximum acceleration of the %1% axis") % axis_upper).str();
(void)L("Maximum acceleration of the X axis"); (void)L("Maximum acceleration of the X axis");
(void)L("Maximum acceleration of the Y axis"); (void)L("Maximum acceleration of the Y axis");
(void)L("Maximum acceleration of the Z axis"); (void)L("Maximum acceleration of the Z axis");
(void)L("Maximum acceleration of the E axis"); (void)L("Maximum acceleration of the E axis");
def->sidetext = L("mm/s²"); def->sidetext = L("mm/s²");
def->min = 0; def->min = 0;
def->width = machine_limits_opt_width; def->width = machine_limits_opt_width;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_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) // Add the machine jerk limits for XYZE axes (M205)
def = this->add("machine_max_jerk_" + axis.name, coFloats); def = this->add("machine_max_jerk_" + axis.name, coFloats);
def->full_label = (boost::format("Maximum jerk %1%") % axis_upper).str(); def->full_label = (boost::format("Maximum jerk %1%") % axis_upper).str();
(void)L("Maximum jerk X"); (void)L("Maximum jerk X");
(void)L("Maximum jerk Y"); (void)L("Maximum jerk Y");
(void)L("Maximum jerk Z"); (void)L("Maximum jerk Z");
(void)L("Maximum jerk E"); (void)L("Maximum jerk E");
def->category = L("Machine limits"); def->category = L("Machine limits");
def->tooltip = (boost::format("Maximum jerk of the %1% axis") % axis_upper).str(); def->tooltip = (boost::format("Maximum jerk of the %1% axis") % axis_upper).str();
(void)L("Maximum jerk of the X axis"); (void)L("Maximum jerk of the X axis");
(void)L("Maximum jerk of the Y axis"); (void)L("Maximum jerk of the Y axis");
(void)L("Maximum jerk of the Z axis"); (void)L("Maximum jerk of the Z axis");
(void)L("Maximum jerk of the E axis"); (void)L("Maximum jerk of the E axis");
def->sidetext = L("mm/s"); def->sidetext = L("mm/s");
def->min = 0; def->min = 0;
def->width = machine_limits_opt_width; def->width = machine_limits_opt_width;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats(axis.max_jerk)); def->set_default_value(new ConfigOptionFloats(axis.max_jerk));
} }
} }
// M205 S... [mm/sec] // M205 S... [mm/sec]
def = this->add("machine_min_extruding_rate", coFloats); def = this->add("machine_min_extruding_rate", coFloats);
@ -1160,9 +1160,9 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Minimum feedrate when extruding (M205 S)"); def->tooltip = L("Minimum feedrate when extruding (M205 S)");
def->sidetext = L("mm/s"); def->sidetext = L("mm/s");
def->min = 0; def->min = 0;
def->width = machine_limits_opt_width; def->width = machine_limits_opt_width;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 0., 0. }); def->set_default_value(new ConfigOptionFloats{ 0., 0. });
// M205 T... [mm/sec] // M205 T... [mm/sec]
def = this->add("machine_min_travel_rate", coFloats); def = this->add("machine_min_travel_rate", coFloats);
@ -1171,9 +1171,9 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Minimum travel feedrate (M205 T)"); def->tooltip = L("Minimum travel feedrate (M205 T)");
def->sidetext = L("mm/s"); def->sidetext = L("mm/s");
def->min = 0; def->min = 0;
def->width = machine_limits_opt_width; def->width = machine_limits_opt_width;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 0., 0. }); def->set_default_value(new ConfigOptionFloats{ 0., 0. });
// M204 S... [mm/sec^2] // M204 S... [mm/sec^2]
def = this->add("machine_max_acceleration_extruding", coFloats); def = this->add("machine_max_acceleration_extruding", coFloats);
@ -1182,7 +1182,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Maximum acceleration when extruding (M204 S)"); def->tooltip = L("Maximum acceleration when extruding (M204 S)");
def->sidetext = L("mm/s²"); def->sidetext = L("mm/s²");
def->min = 0; def->min = 0;
def->width = machine_limits_opt_width; def->width = machine_limits_opt_width;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 1500., 1250. }); def->set_default_value(new ConfigOptionFloats{ 1500., 1250. });
@ -1193,7 +1193,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Maximum acceleration when retracting (M204 T)"); def->tooltip = L("Maximum acceleration when retracting (M204 T)");
def->sidetext = L("mm/s²"); def->sidetext = L("mm/s²");
def->min = 0; def->min = 0;
def->width = machine_limits_opt_width; def->width = machine_limits_opt_width;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 1500., 1250. }); def->set_default_value(new ConfigOptionFloats{ 1500., 1250. });
@ -1437,9 +1437,9 @@ void PrintConfigDef::init_fff_params()
def->gui_flags = "serialized"; def->gui_flags = "serialized";
def->multiline = true; def->multiline = true;
def->full_width = true; def->full_width = true;
def->height = 6; def->height = 6;
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionStrings()); def->set_default_value(new ConfigOptionStrings());
def = this->add("printer_model", coString); def = this->add("printer_model", coString);
def->label = L("Printer type"); def->label = L("Printer type");
@ -1471,7 +1471,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("print_settings_id", coString); def = this->add("print_settings_id", coString);
def->set_default_value(new ConfigOptionString("")); def->set_default_value(new ConfigOptionString(""));
def->cli = ConfigOptionDef::nocli; def->cli = ConfigOptionDef::nocli;
def = this->add("printer_settings_id", coString); def = this->add("printer_settings_id", coString);
def->set_default_value(new ConfigOptionString("")); def->set_default_value(new ConfigOptionString(""));
def->cli = ConfigOptionDef::nocli; def->cli = ConfigOptionDef::nocli;
@ -1511,7 +1511,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("%"); def->sidetext = L("%");
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPercents { 0. }); def->set_default_value(new ConfigOptionPercents { 0. });
def = this->add("retract_layer_change", coBools); def = this->add("retract_layer_change", coBools);
def->label = L("Retract on layer change"); def->label = L("Retract on layer change");
def->tooltip = L("This flag enforces a retraction whenever a Z move is done."); def->tooltip = L("This flag enforces a retraction whenever a Z move is done.");
@ -1608,7 +1608,7 @@ void PrintConfigDef::init_fff_params()
def->enum_labels.push_back(L("Random")); def->enum_labels.push_back(L("Random"));
def->enum_labels.push_back(L("Nearest")); def->enum_labels.push_back(L("Nearest"));
def->enum_labels.push_back(L("Aligned")); def->enum_labels.push_back(L("Aligned"));
def->enum_labels.push_back(L("Rear")); def->enum_labels.push_back(L("Rear"));
def->mode = comSimple; def->mode = comSimple;
def->set_default_value(new ConfigOptionEnum<SeamPosition>(spAligned)); def->set_default_value(new ConfigOptionEnum<SeamPosition>(spAligned));
@ -1679,7 +1679,7 @@ void PrintConfigDef::init_fff_params()
def->min = 0; def->min = 0;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionInt(1)); def->set_default_value(new ConfigOptionInt(1));
def = this->add("slowdown_below_layer_time", coInts); def = this->add("slowdown_below_layer_time", coInts);
def->label = L("Slow down if layer print time is below"); def->label = L("Slow down if layer print time is below");
def->tooltip = L("If layer print time is estimated below this number of seconds, print moves " def->tooltip = L("If layer print time is estimated below this number of seconds, print moves "
@ -1775,7 +1775,7 @@ void PrintConfigDef::init_fff_params()
def->label = L("Temperature variation"); def->label = L("Temperature variation");
def->tooltip = L("Temperature difference to be applied when an extruder is not active. " def->tooltip = L("Temperature difference to be applied when an extruder is not active. "
"Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped."); "Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped.");
def->sidetext = "∆°C"; def->sidetext = "∆°C";
def->min = -max_temp; def->min = -max_temp;
def->max = max_temp; def->max = max_temp;
def->mode = comExpert; def->mode = comExpert;
@ -1817,7 +1817,7 @@ void PrintConfigDef::init_fff_params()
def->label = L("Single Extruder Multi Material"); def->label = L("Single Extruder Multi Material");
def->tooltip = L("The printer multiplexes filaments into a single hot end."); def->tooltip = L("The printer multiplexes filaments into a single hot end.");
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
def = this->add("single_extruder_multi_material_priming", coBool); def = this->add("single_extruder_multi_material_priming", coBool);
def->label = L("Prime all printing extruders"); def->label = L("Prime all printing extruders");
@ -1879,8 +1879,8 @@ void PrintConfigDef::init_fff_params()
// def->min = 0; // def->min = 0;
def->enum_values.push_back("0"); def->enum_values.push_back("0");
def->enum_values.push_back("0.2"); def->enum_values.push_back("0.2");
def->enum_labels.push_back(L("0 (soluble)")); def->enum_labels.push_back(L("0 (soluble)"));
def->enum_labels.push_back(L("0.2 (detachable)")); def->enum_labels.push_back(L("0.2 (detachable)"));
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.2)); def->set_default_value(new ConfigOptionFloat(0.2));
@ -1969,7 +1969,7 @@ void PrintConfigDef::init_fff_params()
def->enum_values.push_back("rectilinear"); def->enum_values.push_back("rectilinear");
def->enum_values.push_back("rectilinear-grid"); def->enum_values.push_back("rectilinear-grid");
def->enum_values.push_back("honeycomb"); def->enum_values.push_back("honeycomb");
def->enum_labels.push_back(L("Rectilinear")); def->enum_labels.push_back(L("Rectilinear"));
def->enum_labels.push_back(L("Rectilinear grid")); def->enum_labels.push_back(L("Rectilinear grid"));
def->enum_labels.push_back(L("Honeycomb")); def->enum_labels.push_back(L("Honeycomb"));
def->mode = comAdvanced; def->mode = comAdvanced;
@ -2031,7 +2031,7 @@ void PrintConfigDef::init_fff_params()
def->min = 0; def->min = 0;
def->max = max_temp; def->max = max_temp;
def->set_default_value(new ConfigOptionInts { 200 }); def->set_default_value(new ConfigOptionInts { 200 });
def = this->add("thin_walls", coBool); def = this->add("thin_walls", coBool);
def->label = L("Detect thin walls"); def->label = L("Detect thin walls");
def->category = L("Layers and Perimeters"); def->category = L("Layers and Perimeters");
@ -2051,7 +2051,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionInt(threads > 0 ? threads : 2)); def->set_default_value(new ConfigOptionInt(threads > 0 ? threads : 2));
def->cli == ConfigOptionDef::nocli; def->cli == ConfigOptionDef::nocli;
} }
def = this->add("toolchange_gcode", coString); def = this->add("toolchange_gcode", coString);
def->label = L("Tool change G-code"); def->label = L("Tool change G-code");
def->tooltip = L("This custom code is inserted at every extruder change. If you don't leave this empty, you are " def->tooltip = L("This custom code is inserted at every extruder change. If you don't leave this empty, you are "
@ -2243,45 +2243,45 @@ void PrintConfigDef::init_fff_params()
// Declare retract values for filament profile, overriding the printer's extruder profile. // Declare retract values for filament profile, overriding the printer's extruder profile.
for (const char *opt_key : { for (const char *opt_key : {
// floats // floats
"retract_length", "retract_lift", "retract_lift_above", "retract_lift_below", "retract_speed", "deretract_speed", "retract_restart_extra", "retract_before_travel", "retract_length", "retract_lift", "retract_lift_above", "retract_lift_below", "retract_speed", "deretract_speed", "retract_restart_extra", "retract_before_travel",
// bools // bools
"retract_layer_change", "wipe", "retract_layer_change", "wipe",
// percents // percents
"retract_before_wipe"}) { "retract_before_wipe"}) {
auto it_opt = options.find(opt_key); auto it_opt = options.find(opt_key);
assert(it_opt != options.end()); assert(it_opt != options.end());
def = this->add_nullable(std::string("filament_") + opt_key, it_opt->second.type); def = this->add_nullable(std::string("filament_") + opt_key, it_opt->second.type);
def->label = it_opt->second.label; def->label = it_opt->second.label;
def->full_label = it_opt->second.full_label; def->full_label = it_opt->second.full_label;
def->tooltip = it_opt->second.tooltip; def->tooltip = it_opt->second.tooltip;
def->sidetext = it_opt->second.sidetext; def->sidetext = it_opt->second.sidetext;
def->mode = it_opt->second.mode; def->mode = it_opt->second.mode;
switch (def->type) { switch (def->type) {
case coFloats : def->set_default_value(new ConfigOptionFloatsNullable (static_cast<const ConfigOptionFloats* >(it_opt->second.default_value.get())->values)); break; case coFloats : def->set_default_value(new ConfigOptionFloatsNullable (static_cast<const ConfigOptionFloats* >(it_opt->second.default_value.get())->values)); break;
case coPercents : def->set_default_value(new ConfigOptionPercentsNullable(static_cast<const ConfigOptionPercents*>(it_opt->second.default_value.get())->values)); break; case coPercents : def->set_default_value(new ConfigOptionPercentsNullable(static_cast<const ConfigOptionPercents*>(it_opt->second.default_value.get())->values)); break;
case coBools : def->set_default_value(new ConfigOptionBoolsNullable (static_cast<const ConfigOptionBools* >(it_opt->second.default_value.get())->values)); break; case coBools : def->set_default_value(new ConfigOptionBoolsNullable (static_cast<const ConfigOptionBools* >(it_opt->second.default_value.get())->values)); break;
default: assert(false); default: assert(false);
} }
} }
} }
void PrintConfigDef::init_extruder_retract_keys() void PrintConfigDef::init_extruder_retract_keys()
{ {
m_extruder_retract_keys = { m_extruder_retract_keys = {
"deretract_speed", "deretract_speed",
"retract_before_travel", "retract_before_travel",
"retract_before_wipe", "retract_before_wipe",
"retract_layer_change", "retract_layer_change",
"retract_length", "retract_length",
"retract_lift", "retract_lift",
"retract_lift_above", "retract_lift_above",
"retract_lift_below", "retract_lift_below",
"retract_restart_extra", "retract_restart_extra",
"retract_speed", "retract_speed",
"wipe" "wipe"
}; };
assert(std::is_sorted(m_extruder_retract_keys.begin(), m_extruder_retract_keys.end())); assert(std::is_sorted(m_extruder_retract_keys.begin(), m_extruder_retract_keys.end()));
} }
void PrintConfigDef::init_sla_params() void PrintConfigDef::init_sla_params()
@ -2375,7 +2375,7 @@ void PrintConfigDef::init_sla_params()
def->min = 0; def->min = 0;
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloats( { 1., 1. } )); def->set_default_value(new ConfigOptionFloats( { 1., 1. } ));
def = this->add("absolute_correction", coFloat); def = this->add("absolute_correction", coFloat);
def->label = L("Printer absolute correction"); def->label = L("Printer absolute correction");
def->full_label = L("Printer absolute correction"); def->full_label = L("Printer absolute correction");
@ -2383,7 +2383,7 @@ void PrintConfigDef::init_sla_params()
"to the sign of the correction."); "to the sign of the correction.");
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0.0)); def->set_default_value(new ConfigOptionFloat(0.0));
def = this->add("gamma_correction", coFloat); def = this->add("gamma_correction", coFloat);
def->label = L("Printer gamma correction"); def->label = L("Printer gamma correction");
def->full_label = L("Printer gamma correction"); def->full_label = L("Printer gamma correction");
@ -2394,7 +2394,7 @@ void PrintConfigDef::init_sla_params()
def->min = 0; def->min = 0;
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(1.0)); def->set_default_value(new ConfigOptionFloat(1.0));
// SLA Material settings. // SLA Material settings.
def = this->add("initial_layer_height", coFloat); def = this->add("initial_layer_height", coFloat);
@ -2561,7 +2561,7 @@ void PrintConfigDef::init_sla_params()
def->min = 0; def->min = 0;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(1.0)); def->set_default_value(new ConfigOptionFloat(1.0));
def = this->add("support_base_safety_distance", coFloat); def = this->add("support_base_safety_distance", coFloat);
def->label = L("Support base safety distance"); def->label = L("Support base safety distance");
def->category = L("Supports"); def->category = L("Supports");
@ -2676,14 +2676,14 @@ void PrintConfigDef::init_sla_params()
def->set_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. // This is disabled on the UI. I hope it will never be enabled.
def = this->add("pad_edge_radius", coFloat); // def = this->add("pad_edge_radius", coFloat);
def->label = L("Pad edge radius"); // def->label = L("Pad edge radius");
def->category = L("Pad"); // def->category = L("Pad");
// def->tooltip = L(""); //// def->tooltip = L("");
def->sidetext = L("mm"); // def->sidetext = L("mm");
def->min = 0; // def->min = 0;
def->mode = comAdvanced; // def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(1.0)); // def->set_default_value(new ConfigOptionFloat(1.0));
def = this->add("pad_wall_slope", coFloat); def = this->add("pad_wall_slope", coFloat);
def->label = L("Pad wall slope"); def->label = L("Pad wall slope");
@ -2695,7 +2695,14 @@ void PrintConfigDef::init_sla_params()
def->max = 90; def->max = 90;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(45.0)); def->set_default_value(new ConfigOptionFloat(45.0));
def = this->add("pad_zero_elevation", coBool);
def->label = L("Pad around object");
def->category = L("Pad");
def->tooltip = L("Create pad around object and ignore the support elevation");
def->mode = comSimple;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("pad_object_gap", coFloat); def = this->add("pad_object_gap", coFloat);
def->label = L("Pad object gap"); def->label = L("Pad object gap");
def->category = L("Pad"); def->category = L("Pad");
@ -2706,7 +2713,7 @@ void PrintConfigDef::init_sla_params()
def->max = 10; def->max = 10;
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(1)); def->set_default_value(new ConfigOptionFloat(1));
def = this->add("pad_object_connector_stride", coFloat); def = this->add("pad_object_connector_stride", coFloat);
def->label = L("Pad object connector stride"); def->label = L("Pad object connector stride");
def->category = L("Pad"); def->category = L("Pad");
@ -2716,7 +2723,7 @@ void PrintConfigDef::init_sla_params()
def->min = 0; def->min = 0;
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(10)); def->set_default_value(new ConfigOptionFloat(10));
def = this->add("pad_object_connector_width", coFloat); def = this->add("pad_object_connector_width", coFloat);
def->label = L("Pad object connector width"); def->label = L("Pad object connector width");
def->category = L("Pad"); def->category = L("Pad");
@ -2726,7 +2733,7 @@ void PrintConfigDef::init_sla_params()
def->min = 0; def->min = 0;
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0.5)); def->set_default_value(new ConfigOptionFloat(0.5));
def = this->add("pad_object_connector_penetration", coFloat); def = this->add("pad_object_connector_penetration", coFloat);
def->label = L("Pad object connector penetration"); def->label = L("Pad object connector penetration");
def->category = L("Pad"); def->category = L("Pad");
@ -2747,7 +2754,7 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
if (opt_key == "bottom_layer_speed") opt_key = "first_layer_speed"; if (opt_key == "bottom_layer_speed") opt_key = "first_layer_speed";
try { try {
float v = boost::lexical_cast<float>(value); float v = boost::lexical_cast<float>(value);
if (v != 0) if (v != 0)
value = boost::lexical_cast<std::string>(v*100) + "%"; value = boost::lexical_cast<std::string>(v*100) + "%";
} catch (boost::bad_lexical_cast &) { } catch (boost::bad_lexical_cast &) {
value = "0"; value = "0";
@ -2787,14 +2794,14 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
} else if (opt_key == "octoprint_apikey") { } else if (opt_key == "octoprint_apikey") {
opt_key = "printhost_apikey"; opt_key = "printhost_apikey";
} }
// Ignore the following obsolete configuration keys: // Ignore the following obsolete configuration keys:
static std::set<std::string> ignore = { static std::set<std::string> ignore = {
"duplicate_x", "duplicate_y", "gcode_arcs", "multiply_x", "multiply_y", "duplicate_x", "duplicate_y", "gcode_arcs", "multiply_x", "multiply_y",
"support_material_tool", "acceleration", "adjust_overhang_flow", "support_material_tool", "acceleration", "adjust_overhang_flow",
"standby_temperature", "scale", "rotate", "duplicate", "duplicate_grid", "standby_temperature", "scale", "rotate", "duplicate", "duplicate_grid",
"start_perimeters_at_concave_points", "start_perimeters_at_non_overhang", "randomize_start", "start_perimeters_at_concave_points", "start_perimeters_at_non_overhang", "randomize_start",
"seal_position", "vibration_limit", "bed_size", "seal_position", "vibration_limit", "bed_size",
"print_center", "g0", "threads", "pressure_advance", "wipe_tower_per_color_wipe" "print_center", "g0", "threads", "pressure_advance", "wipe_tower_per_color_wipe"
#ifndef HAS_PRESSURE_EQUALIZER #ifndef HAS_PRESSURE_EQUALIZER
, "max_volumetric_extrusion_rate_slope_positive", "max_volumetric_extrusion_rate_slope_negative" , "max_volumetric_extrusion_rate_slope_positive", "max_volumetric_extrusion_rate_slope_negative"
@ -2805,7 +2812,7 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
opt_key = ""; opt_key = "";
return; return;
} }
if (! print_config_def.has(opt_key)) { if (! print_config_def.has(opt_key)) {
opt_key = ""; opt_key = "";
return; return;
@ -2845,10 +2852,10 @@ void DynamicPrintConfig::normalize()
// this->option("support_material_interface_extruder", true)->setInt(extruder); // this->option("support_material_interface_extruder", true)->setInt(extruder);
} }
} }
if (!this->has("solid_infill_extruder") && this->has("infill_extruder")) if (!this->has("solid_infill_extruder") && this->has("infill_extruder"))
this->option("solid_infill_extruder", true)->setInt(this->option("infill_extruder")->getInt()); this->option("solid_infill_extruder", true)->setInt(this->option("infill_extruder")->getInt());
if (this->has("spiral_vase") && this->opt<ConfigOptionBool>("spiral_vase", true)->value) { if (this->has("spiral_vase") && this->opt<ConfigOptionBool>("spiral_vase", true)->value) {
{ {
// this should be actually done only on the spiral layers instead of all // this should be actually done only on the spiral layers instead of all
@ -2866,8 +2873,8 @@ void DynamicPrintConfig::normalize()
std::string DynamicPrintConfig::validate() std::string DynamicPrintConfig::validate()
{ {
// Full print config is initialized from the defaults. // Full print config is initialized from the defaults.
const ConfigOption *opt = this->option("printer_technology", false); const ConfigOption *opt = this->option("printer_technology", false);
auto printer_technology = (opt == nullptr) ? ptFFF : static_cast<PrinterTechnology>(dynamic_cast<const ConfigOptionEnumGeneric*>(opt)->value); auto printer_technology = (opt == nullptr) ? ptFFF : static_cast<PrinterTechnology>(dynamic_cast<const ConfigOptionEnumGeneric*>(opt)->value);
switch (printer_technology) { switch (printer_technology) {
case ptFFF: case ptFFF:
{ {
@ -2891,7 +2898,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config)
{ {
double extruder_clearance_radius = config->option("extruder_clearance_radius")->getFloat(); double extruder_clearance_radius = config->option("extruder_clearance_radius")->getFloat();
double duplicate_distance = config->option("duplicate_distance")->getFloat(); double duplicate_distance = config->option("duplicate_distance")->getFloat();
// min object distance is max(duplicate_distance, clearance_radius) // min object distance is max(duplicate_distance, clearance_radius)
return (config->option("complete_objects")->getBool() && extruder_clearance_radius > duplicate_distance) return (config->option("complete_objects")->getBool() && extruder_clearance_radius > duplicate_distance)
? extruder_clearance_radius ? extruder_clearance_radius
@ -2920,7 +2927,7 @@ std::string FullPrintConfig::validate()
for (double nd : this->nozzle_diameter.values) for (double nd : this->nozzle_diameter.values)
if (nd < 0.005) if (nd < 0.005)
return "Invalid value for --nozzle-diameter"; return "Invalid value for --nozzle-diameter";
// --perimeters // --perimeters
if (this->perimeters.value < 0) if (this->perimeters.value < 0)
return "Invalid value for --perimeters"; return "Invalid value for --perimeters";
@ -2930,8 +2937,8 @@ std::string FullPrintConfig::validate()
return "Invalid value for --top-solid-layers"; return "Invalid value for --top-solid-layers";
if (this->bottom_solid_layers < 0) if (this->bottom_solid_layers < 0)
return "Invalid value for --bottom-solid-layers"; return "Invalid value for --bottom-solid-layers";
if (this->use_firmware_retraction.value && if (this->use_firmware_retraction.value &&
this->gcode_flavor.value != gcfSmoothie && this->gcode_flavor.value != gcfSmoothie &&
this->gcode_flavor.value != gcfRepRap && this->gcode_flavor.value != gcfRepRap &&
this->gcode_flavor.value != gcfMarlin && this->gcode_flavor.value != gcfMarlin &&
@ -2943,15 +2950,15 @@ std::string FullPrintConfig::validate()
for (unsigned char wipe : this->wipe.values) for (unsigned char wipe : this->wipe.values)
if (wipe) if (wipe)
return "--use-firmware-retraction is not compatible with --wipe"; return "--use-firmware-retraction is not compatible with --wipe";
// --gcode-flavor // --gcode-flavor
if (! print_config_def.get("gcode_flavor")->has_enum_value(this->gcode_flavor.serialize())) if (! print_config_def.get("gcode_flavor")->has_enum_value(this->gcode_flavor.serialize()))
return "Invalid value for --gcode-flavor"; return "Invalid value for --gcode-flavor";
// --fill-pattern // --fill-pattern
if (! print_config_def.get("fill_pattern")->has_enum_value(this->fill_pattern.serialize())) if (! print_config_def.get("fill_pattern")->has_enum_value(this->fill_pattern.serialize()))
return "Invalid value for --fill-pattern"; return "Invalid value for --fill-pattern";
// --top-fill-pattern // --top-fill-pattern
if (! print_config_def.get("top_fill_pattern")->has_enum_value(this->top_fill_pattern.serialize())) if (! print_config_def.get("top_fill_pattern")->has_enum_value(this->top_fill_pattern.serialize()))
return "Invalid value for --top-fill-pattern"; return "Invalid value for --top-fill-pattern";
@ -2964,7 +2971,7 @@ std::string FullPrintConfig::validate()
if (fabs(this->fill_density.value - 100.) < EPSILON && if (fabs(this->fill_density.value - 100.) < EPSILON &&
! print_config_def.get("top_fill_pattern")->has_enum_value(this->fill_pattern.serialize())) ! print_config_def.get("top_fill_pattern")->has_enum_value(this->fill_pattern.serialize()))
return "The selected fill pattern is not supposed to work at 100% density"; return "The selected fill pattern is not supposed to work at 100% density";
// --infill-every-layers // --infill-every-layers
if (this->infill_every_layers < 1) if (this->infill_every_layers < 1)
return "Invalid value for --infill-every-layers"; return "Invalid value for --infill-every-layers";
@ -2972,11 +2979,11 @@ std::string FullPrintConfig::validate()
// --skirt-height // --skirt-height
if (this->skirt_height < -1) // -1 means as tall as the object if (this->skirt_height < -1) // -1 means as tall as the object
return "Invalid value for --skirt-height"; return "Invalid value for --skirt-height";
// --bridge-flow-ratio // --bridge-flow-ratio
if (this->bridge_flow_ratio <= 0) if (this->bridge_flow_ratio <= 0)
return "Invalid value for --bridge-flow-ratio"; return "Invalid value for --bridge-flow-ratio";
// extruder clearance // extruder clearance
if (this->extruder_clearance_radius <= 0) if (this->extruder_clearance_radius <= 0)
return "Invalid value for --extruder-clearance-radius"; return "Invalid value for --extruder-clearance-radius";
@ -3008,7 +3015,7 @@ std::string FullPrintConfig::validate()
if (this->support_material || this->support_material_enforce_layers > 0) if (this->support_material || this->support_material_enforce_layers > 0)
return "Spiral vase mode is not compatible with support material"; return "Spiral vase mode is not compatible with support material";
} }
// extrusion widths // extrusion widths
{ {
double max_nozzle_diameter = 0.; double max_nozzle_diameter = 0.;
@ -3065,7 +3072,7 @@ std::string FullPrintConfig::validate()
if (out_of_range) if (out_of_range)
return std::string("Value out of range: " + opt_key); return std::string("Value out of range: " + opt_key);
} }
// The configuration is valid. // The configuration is valid.
return ""; return "";
} }
@ -3088,20 +3095,20 @@ StaticPrintConfig::StaticCache<class Slic3r::SLAFullPrintConfig> SLAFullPrint
CLIActionsConfigDef::CLIActionsConfigDef() CLIActionsConfigDef::CLIActionsConfigDef()
{ {
ConfigOptionDef* def; ConfigOptionDef* def;
// Actions: // Actions:
def = this->add("export_obj", coBool); def = this->add("export_obj", coBool);
def->label = L("Export OBJ"); def->label = L("Export OBJ");
def->tooltip = L("Export the model(s) as OBJ."); def->tooltip = L("Export the model(s) as OBJ.");
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
/* /*
def = this->add("export_svg", coBool); def = this->add("export_svg", coBool);
def->label = L("Export SVG"); def->label = L("Export SVG");
def->tooltip = L("Slice the model and export solid slices as SVG."); def->tooltip = L("Slice the model and export solid slices as SVG.");
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
*/ */
def = this->add("export_sla", coBool); def = this->add("export_sla", coBool);
def->label = L("Export SLA"); def->label = L("Export SLA");
def->tooltip = L("Slice the model and export SLA printing layers as PNG."); def->tooltip = L("Slice the model and export SLA printing layers as PNG.");
@ -3150,12 +3157,12 @@ CLIActionsConfigDef::CLIActionsConfigDef()
def->label = L("Help (SLA options)"); def->label = L("Help (SLA options)");
def->tooltip = L("Show the full list of SLA print configuration options."); def->tooltip = L("Show the full list of SLA print configuration options.");
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
def = this->add("info", coBool); def = this->add("info", coBool);
def->label = L("Output Model Info"); def->label = L("Output Model Info");
def->tooltip = L("Write information about the model to the console."); def->tooltip = L("Write information about the model to the console.");
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
def = this->add("save", coString); def = this->add("save", coString);
def->label = L("Save config file"); def->label = L("Save config file");
def->tooltip = L("Save configuration to the specified file."); def->tooltip = L("Save configuration to the specified file.");
@ -3165,35 +3172,35 @@ CLIActionsConfigDef::CLIActionsConfigDef()
CLITransformConfigDef::CLITransformConfigDef() CLITransformConfigDef::CLITransformConfigDef()
{ {
ConfigOptionDef* def; ConfigOptionDef* def;
// Transform options: // Transform options:
def = this->add("align_xy", coPoint); def = this->add("align_xy", coPoint);
def->label = L("Align XY"); def->label = L("Align XY");
def->tooltip = L("Align the model to the given point."); def->tooltip = L("Align the model to the given point.");
def->set_default_value(new ConfigOptionPoint(Vec2d(100,100))); def->set_default_value(new ConfigOptionPoint(Vec2d(100,100)));
def = this->add("cut", coFloat); def = this->add("cut", coFloat);
def->label = L("Cut"); def->label = L("Cut");
def->tooltip = L("Cut model at the given Z."); def->tooltip = L("Cut model at the given Z.");
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
/* /*
def = this->add("cut_grid", coFloat); def = this->add("cut_grid", coFloat);
def->label = L("Cut"); def->label = L("Cut");
def->tooltip = L("Cut model in the XY plane into tiles of the specified max size."); def->tooltip = L("Cut model in the XY plane into tiles of the specified max size.");
def->set_default_value(new ConfigOptionPoint()); def->set_default_value(new ConfigOptionPoint());
def = this->add("cut_x", coFloat); def = this->add("cut_x", coFloat);
def->label = L("Cut"); def->label = L("Cut");
def->tooltip = L("Cut model at the given X."); def->tooltip = L("Cut model at the given X.");
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
def = this->add("cut_y", coFloat); def = this->add("cut_y", coFloat);
def->label = L("Cut"); def->label = L("Cut");
def->tooltip = L("Cut model at the given Y."); def->tooltip = L("Cut model at the given Y.");
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
*/ */
def = this->add("center", coPoint); def = this->add("center", coPoint);
def->label = L("Center"); def->label = L("Center");
def->tooltip = L("Center the print around the given center."); def->tooltip = L("Center the print around the given center.");
@ -3202,12 +3209,12 @@ CLITransformConfigDef::CLITransformConfigDef()
def = this->add("dont_arrange", coBool); def = this->add("dont_arrange", coBool);
def->label = L("Don't arrange"); def->label = L("Don't arrange");
def->tooltip = L("Do not rearrange the given models before merging and keep their original XY coordinates."); def->tooltip = L("Do not rearrange the given models before merging and keep their original XY coordinates.");
def = this->add("duplicate", coInt); def = this->add("duplicate", coInt);
def->label = L("Duplicate"); def->label = L("Duplicate");
def->tooltip =L("Multiply copies by this factor."); def->tooltip =L("Multiply copies by this factor.");
def->min = 1; def->min = 1;
def = this->add("duplicate_grid", coPoint); def = this->add("duplicate_grid", coPoint);
def->label = L("Duplicate by grid"); def->label = L("Duplicate by grid");
def->tooltip = L("Multiply copies by creating a grid."); def->tooltip = L("Multiply copies by creating a grid.");
@ -3220,22 +3227,22 @@ CLITransformConfigDef::CLITransformConfigDef()
def = this->add("repair", coBool); def = this->add("repair", coBool);
def->label = L("Repair"); def->label = L("Repair");
def->tooltip = L("Try to repair any non-manifold meshes (this option is implicitly added whenever we need to slice the model to perform the requested action)."); def->tooltip = L("Try to repair any non-manifold meshes (this option is implicitly added whenever we need to slice the model to perform the requested action).");
def = this->add("rotate", coFloat); def = this->add("rotate", coFloat);
def->label = L("Rotate"); def->label = L("Rotate");
def->tooltip = L("Rotation angle around the Z axis in degrees."); def->tooltip = L("Rotation angle around the Z axis in degrees.");
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
def = this->add("rotate_x", coFloat); def = this->add("rotate_x", coFloat);
def->label = L("Rotate around X"); def->label = L("Rotate around X");
def->tooltip = L("Rotation angle around the X axis in degrees."); def->tooltip = L("Rotation angle around the X axis in degrees.");
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
def = this->add("rotate_y", coFloat); def = this->add("rotate_y", coFloat);
def->label = L("Rotate around Y"); def->label = L("Rotate around Y");
def->tooltip = L("Rotation angle around the Y axis in degrees."); def->tooltip = L("Rotation angle around the Y axis in degrees.");
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
def = this->add("scale", coFloatOrPercent); def = this->add("scale", coFloatOrPercent);
def->label = L("Scale"); def->label = L("Scale");
def->tooltip = L("Scaling factor or percentage."); def->tooltip = L("Scaling factor or percentage.");
@ -3244,7 +3251,7 @@ CLITransformConfigDef::CLITransformConfigDef()
def = this->add("split", coBool); def = this->add("split", coBool);
def->label = L("Split"); def->label = L("Split");
def->tooltip = L("Detect unconnected parts in the given model(s) and split them into separate objects."); def->tooltip = L("Detect unconnected parts in the given model(s) and split them into separate objects.");
def = this->add("scale_to_fit", coPoint3); def = this->add("scale_to_fit", coPoint3);
def->label = L("Scale to Fit"); def->label = L("Scale to Fit");
def->tooltip = L("Scale to fit the given volume."); def->tooltip = L("Scale to fit the given volume.");
@ -3254,26 +3261,26 @@ CLITransformConfigDef::CLITransformConfigDef()
CLIMiscConfigDef::CLIMiscConfigDef() CLIMiscConfigDef::CLIMiscConfigDef()
{ {
ConfigOptionDef* def; ConfigOptionDef* def;
def = this->add("ignore_nonexistent_config", coBool); def = this->add("ignore_nonexistent_config", coBool);
def->label = L("Ignore non-existent config files"); def->label = L("Ignore non-existent config files");
def->tooltip = L("Do not fail if a file supplied to --load does not exist."); def->tooltip = L("Do not fail if a file supplied to --load does not exist.");
def = this->add("load", coStrings); def = this->add("load", coStrings);
def->label = L("Load config file"); def->label = L("Load config file");
def->tooltip = L("Load configuration from the specified file. It can be used more than once to load options from multiple files."); def->tooltip = L("Load configuration from the specified file. It can be used more than once to load options from multiple files.");
def = this->add("output", coString); def = this->add("output", coString);
def->label = L("Output File"); def->label = L("Output File");
def->tooltip = L("The file where the output will be written (if not specified, it will be based on the input file)."); def->tooltip = L("The file where the output will be written (if not specified, it will be based on the input file).");
def->cli = "output|o"; def->cli = "output|o";
/* /*
def = this->add("autosave", coString); def = this->add("autosave", coString);
def->label = L("Autosave"); def->label = L("Autosave");
def->tooltip = L("Automatically export current configuration to the specified file."); def->tooltip = L("Automatically export current configuration to the specified file.");
*/ */
def = this->add("datadir", coString); def = this->add("datadir", coString);
def->label = L("Data directory"); def->label = L("Data directory");
def->tooltip = L("Load and store settings at the given directory. This is useful for maintaining different profiles or including configurations from a network storage."); def->tooltip = L("Load and store settings at the given directory. This is useful for maintaining different profiles or including configurations from a network storage.");
@ -3299,15 +3306,15 @@ DynamicPrintAndCLIConfig::PrintAndCLIConfigDef DynamicPrintAndCLIConfig::s_def;
void DynamicPrintAndCLIConfig::handle_legacy(t_config_option_key &opt_key, std::string &value) const void DynamicPrintAndCLIConfig::handle_legacy(t_config_option_key &opt_key, std::string &value) const
{ {
if (cli_actions_config_def .options.find(opt_key) == cli_actions_config_def .options.end() && if (cli_actions_config_def .options.find(opt_key) == cli_actions_config_def .options.end() &&
cli_transform_config_def.options.find(opt_key) == cli_transform_config_def.options.end() && cli_transform_config_def.options.find(opt_key) == cli_transform_config_def.options.end() &&
cli_misc_config_def .options.find(opt_key) == cli_misc_config_def .options.end()) { cli_misc_config_def .options.find(opt_key) == cli_misc_config_def .options.end()) {
PrintConfigDef::handle_legacy(opt_key, value); PrintConfigDef::handle_legacy(opt_key, value);
} }
} }
} }
#include <cereal/types/polymorphic.hpp> #include <cereal/types/polymorphic.hpp>
CEREAL_REGISTER_TYPE(Slic3r::DynamicPrintConfig) CEREAL_REGISTER_TYPE(Slic3r::DynamicPrintConfig)
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::DynamicConfig, Slic3r::DynamicPrintConfig) CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::DynamicConfig, Slic3r::DynamicPrintConfig)

View File

@ -740,7 +740,7 @@ protected:
class PrintConfig : public MachineEnvelopeConfig, public GCodeConfig class PrintConfig : public MachineEnvelopeConfig, public GCodeConfig
{ {
STATIC_PRINT_CONFIG_CACHE_DERIVED(PrintConfig) STATIC_PRINT_CONFIG_CACHE_DERIVED(PrintConfig)
PrintConfig() : MachineEnvelopeConfig(0), GCodeConfig(0) { initialize_cache(); *this = s_cache_PrintConfig.defaults(); } PrintConfig() : MachineEnvelopeConfig(0), GCodeConfig(0) { initialize_cache(); *this = s_cache_PrintConfig.defaults(); }
public: public:
double min_object_distance() const; double min_object_distance() const;
static double min_object_distance(const ConfigBase *config); static double min_object_distance(const ConfigBase *config);
@ -812,7 +812,7 @@ public:
ConfigOptionFloat z_offset; ConfigOptionFloat z_offset;
protected: protected:
PrintConfig(int) : MachineEnvelopeConfig(1), GCodeConfig(1) {} PrintConfig(int) : MachineEnvelopeConfig(1), GCodeConfig(1) {}
void initialize(StaticCacheBase &cache, const char *base_ptr) void initialize(StaticCacheBase &cache, const char *base_ptr)
{ {
this->MachineEnvelopeConfig::initialize(cache, base_ptr); this->MachineEnvelopeConfig::initialize(cache, base_ptr);
@ -991,7 +991,7 @@ public:
// The height of the pillar base cone in mm. // The height of the pillar base cone in mm.
ConfigOptionFloat support_base_height /*= 1.0*/; ConfigOptionFloat support_base_height /*= 1.0*/;
// The minimum distance of the pillar base from the model in mm. // The minimum distance of the pillar base from the model in mm.
ConfigOptionFloat support_base_safety_distance; /*= 1.0*/; ConfigOptionFloat support_base_safety_distance; /*= 1.0*/;
@ -1007,7 +1007,7 @@ public:
// The elevation in Z direction upwards. This is the space between the pad // The elevation in Z direction upwards. This is the space between the pad
// and the model object's bounding box bottom. Units in mm. // and the model object's bounding box bottom. Units in mm.
ConfigOptionFloat support_object_elevation /*= 5.0*/; ConfigOptionFloat support_object_elevation /*= 5.0*/;
/////// Following options influence automatic support points placement: /////// Following options influence automatic support points placement:
ConfigOptionInt support_points_density_relative; ConfigOptionInt support_points_density_relative;
ConfigOptionFloat support_points_minimal_distance; ConfigOptionFloat support_points_minimal_distance;
@ -1028,11 +1028,11 @@ public:
ConfigOptionFloat pad_max_merge_distance /*= 50*/; ConfigOptionFloat pad_max_merge_distance /*= 50*/;
// The smoothing radius of the pad edges // The smoothing radius of the pad edges
ConfigOptionFloat pad_edge_radius /*= 1*/; // ConfigOptionFloat pad_edge_radius /*= 1*/;
// The slope of the pad wall... // The slope of the pad wall...
ConfigOptionFloat pad_wall_slope; ConfigOptionFloat pad_wall_slope;
// ///////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////
// Zero elevation mode parameters: // Zero elevation mode parameters:
// - The object pad will be derived from the the model geometry. // - The object pad will be derived from the the model geometry.
@ -1040,16 +1040,19 @@ public:
// according to the support_base_safety_distance parameter. // according to the support_base_safety_distance parameter.
// - The two pads will be connected with tiny connector sticks // - The two pads will be connected with tiny connector sticks
// ///////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////
// Disable the elevation (ignore its value) and use the zero elevation mode
ConfigOptionBool pad_zero_elevation;
// This is the gap between the object bottom and the generated pad // This is the gap between the object bottom and the generated pad
ConfigOptionFloat pad_object_gap; ConfigOptionFloat pad_object_gap;
// How far to place the connector sticks on the object pad perimeter // How far to place the connector sticks on the object pad perimeter
ConfigOptionFloat pad_object_connector_stride; ConfigOptionFloat pad_object_connector_stride;
// The width of the connectors sticks // The width of the connectors sticks
ConfigOptionFloat pad_object_connector_width; ConfigOptionFloat pad_object_connector_width;
// How much should the tiny connectors penetrate into the model body // How much should the tiny connectors penetrate into the model body
ConfigOptionFloat pad_object_connector_penetration; ConfigOptionFloat pad_object_connector_penetration;
@ -1080,8 +1083,9 @@ protected:
OPT_PTR(pad_wall_thickness); OPT_PTR(pad_wall_thickness);
OPT_PTR(pad_wall_height); OPT_PTR(pad_wall_height);
OPT_PTR(pad_max_merge_distance); OPT_PTR(pad_max_merge_distance);
OPT_PTR(pad_edge_radius); // OPT_PTR(pad_edge_radius);
OPT_PTR(pad_wall_slope); OPT_PTR(pad_wall_slope);
OPT_PTR(pad_zero_elevation);
OPT_PTR(pad_object_gap); OPT_PTR(pad_object_gap);
OPT_PTR(pad_object_connector_stride); OPT_PTR(pad_object_connector_stride);
OPT_PTR(pad_object_connector_width); OPT_PTR(pad_object_connector_width);
@ -1205,8 +1209,8 @@ extern const CLIMiscConfigDef cli_misc_config_def;
class DynamicPrintAndCLIConfig : public DynamicPrintConfig class DynamicPrintAndCLIConfig : public DynamicPrintConfig
{ {
public: public:
DynamicPrintAndCLIConfig() {} DynamicPrintAndCLIConfig() {}
DynamicPrintAndCLIConfig(const DynamicPrintAndCLIConfig &other) : DynamicPrintConfig(other) {} DynamicPrintAndCLIConfig(const DynamicPrintAndCLIConfig &other) : DynamicPrintConfig(other) {}
// Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here. // Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here.
const ConfigDef* def() const override { return &s_def; } const ConfigDef* def() const override { return &s_def; }
@ -1227,7 +1231,7 @@ private:
this->options.insert(cli_transform_config_def.options.begin(), cli_transform_config_def.options.end()); this->options.insert(cli_transform_config_def.options.begin(), cli_transform_config_def.options.end());
this->options.insert(cli_misc_config_def.options.begin(), cli_misc_config_def.options.end()); this->options.insert(cli_misc_config_def.options.begin(), cli_misc_config_def.options.end());
for (const auto &kvp : this->options) for (const auto &kvp : this->options)
this->by_serialization_key_ordinal[kvp.second.serialization_key_ordinal] = &kvp.second; this->by_serialization_key_ordinal[kvp.second.serialization_key_ordinal] = &kvp.second;
} }
// Do not release the default values, they are handled by print_config_def & cli_actions_config_def / cli_transform_config_def / cli_misc_config_def. // Do not release the default values, they are handled by print_config_def & cli_actions_config_def / cli_transform_config_def / cli_misc_config_def.
~PrintAndCLIConfigDef() { this->options.clear(); } ~PrintAndCLIConfigDef() { this->options.clear(); }
@ -1239,36 +1243,36 @@ private:
// Serialization through the Cereal library // Serialization through the Cereal library
namespace cereal { namespace cereal {
// Let cereal know that there are load / save non-member functions declared for DynamicPrintConfig, ignore serialize / load / save from parent class DynamicConfig. // Let cereal know that there are load / save non-member functions declared for DynamicPrintConfig, ignore serialize / load / save from parent class DynamicConfig.
template <class Archive> struct specialize<Archive, Slic3r::DynamicPrintConfig, cereal::specialization::non_member_load_save> {}; template <class Archive> struct specialize<Archive, Slic3r::DynamicPrintConfig, cereal::specialization::non_member_load_save> {};
template<class Archive> void load(Archive& archive, Slic3r::DynamicPrintConfig &config) template<class Archive> void load(Archive& archive, Slic3r::DynamicPrintConfig &config)
{ {
size_t cnt; size_t cnt;
archive(cnt); archive(cnt);
config.clear(); config.clear();
for (size_t i = 0; i < cnt; ++ i) { for (size_t i = 0; i < cnt; ++ i) {
size_t serialization_key_ordinal; size_t serialization_key_ordinal;
archive(serialization_key_ordinal); archive(serialization_key_ordinal);
assert(serialization_key_ordinal > 0); assert(serialization_key_ordinal > 0);
auto it = Slic3r::print_config_def.by_serialization_key_ordinal.find(serialization_key_ordinal); auto it = Slic3r::print_config_def.by_serialization_key_ordinal.find(serialization_key_ordinal);
assert(it != Slic3r::print_config_def.by_serialization_key_ordinal.end()); assert(it != Slic3r::print_config_def.by_serialization_key_ordinal.end());
config.set_key_value(it->second->opt_key, it->second->load_option_from_archive(archive)); config.set_key_value(it->second->opt_key, it->second->load_option_from_archive(archive));
} }
} }
template<class Archive> void save(Archive& archive, const Slic3r::DynamicPrintConfig &config) template<class Archive> void save(Archive& archive, const Slic3r::DynamicPrintConfig &config)
{ {
size_t cnt = config.size(); size_t cnt = config.size();
archive(cnt); archive(cnt);
for (auto it = config.cbegin(); it != config.cend(); ++it) { for (auto it = config.cbegin(); it != config.cend(); ++it) {
const Slic3r::ConfigOptionDef* optdef = Slic3r::print_config_def.get(it->first); const Slic3r::ConfigOptionDef* optdef = Slic3r::print_config_def.get(it->first);
assert(optdef != nullptr); assert(optdef != nullptr);
assert(optdef->serialization_key_ordinal > 0); assert(optdef->serialization_key_ordinal > 0);
archive(optdef->serialization_key_ordinal); archive(optdef->serialization_key_ordinal);
optdef->save_option_to_archive(archive, it->second.get()); optdef->save_option_to_archive(archive, it->second.get());
} }
} }
} }
#endif #endif

View File

@ -52,7 +52,7 @@ const std::array<unsigned, slaposCount> OBJ_STEP_LEVELS =
}; };
// Object step to status label. The labels are localized at the time of calling, thus supporting language switching. // Object step to status label. The labels are localized at the time of calling, thus supporting language switching.
std::string OBJ_STEP_LABELS(size_t idx) std::string OBJ_STEP_LABELS(size_t idx)
{ {
switch (idx) { switch (idx) {
case slaposObjectSlice: return L("Slicing model"); case slaposObjectSlice: return L("Slicing model");
@ -365,7 +365,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, DynamicPrintConfig con
// Synchronize Object's config. // Synchronize Object's config.
bool object_config_changed = model_object.config != model_object_new.config; bool object_config_changed = model_object.config != model_object_new.config;
if (object_config_changed) if (object_config_changed)
static_cast<DynamicPrintConfig&>(model_object.config) = static_cast<const DynamicPrintConfig&>(model_object_new.config); static_cast<DynamicPrintConfig&>(model_object.config) = static_cast<const DynamicPrintConfig&>(model_object_new.config);
if (! object_diff.empty() || object_config_changed) { if (! object_diff.empty() || object_config_changed) {
SLAPrintObjectConfig new_config = m_default_object_config; SLAPrintObjectConfig new_config = m_default_object_config;
normalize_and_apply_config(new_config, model_object.config); normalize_and_apply_config(new_config, model_object.config);
@ -424,10 +424,10 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, DynamicPrintConfig con
print_object->set_trafo(sla_trafo(*this, model_object), model_object.instances.front()->is_left_handed()); print_object->set_trafo(sla_trafo(*this, model_object), model_object.instances.front()->is_left_handed());
print_object->set_instances(std::move(new_instances)); print_object->set_instances(std::move(new_instances));
SLAPrintObjectConfig new_config = m_default_object_config; SLAPrintObjectConfig new_config = m_default_object_config;
normalize_and_apply_config(new_config, model_object.config); normalize_and_apply_config(new_config, model_object.config);
print_object->config_apply(new_config, true); print_object->config_apply(new_config, true);
print_objects_new.emplace_back(print_object); print_objects_new.emplace_back(print_object);
new_objects = true; new_objects = true;
} }
@ -446,7 +446,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, DynamicPrintConfig con
if (new_objects) if (new_objects)
update_apply_status(false); update_apply_status(false);
} }
if(m_objects.empty()) { if(m_objects.empty()) {
m_printer.release(); m_printer.release();
m_printer_input.clear(); m_printer_input.clear();
@ -569,6 +569,16 @@ std::string SLAPrint::output_filename(const std::string &filename_base) const
} }
namespace { namespace {
bool is_zero_elevation(const SLAPrintObjectConfig &c) {
bool en_implicit = c.support_object_elevation.getFloat() <= EPSILON &&
c.pad_enable.getBool() && c.supports_enable.getBool();
bool en_explicit = c.pad_zero_elevation.getBool() &&
c.supports_enable.getBool();
return en_implicit || en_explicit;
}
// Compile the argument for support creation from the static print config. // Compile the argument for support creation from the static print config.
sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) { sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) {
sla::SupportConfig scfg; sla::SupportConfig scfg;
@ -577,7 +587,8 @@ sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) {
scfg.head_back_radius_mm = 0.5*c.support_pillar_diameter.getFloat(); scfg.head_back_radius_mm = 0.5*c.support_pillar_diameter.getFloat();
scfg.head_penetration_mm = c.support_head_penetration.getFloat(); scfg.head_penetration_mm = c.support_head_penetration.getFloat();
scfg.head_width_mm = c.support_head_width.getFloat(); scfg.head_width_mm = c.support_head_width.getFloat();
scfg.object_elevation_mm = c.support_object_elevation.getFloat(); scfg.object_elevation_mm = is_zero_elevation(c) ?
0. : c.support_object_elevation.getFloat();
scfg.bridge_slope = c.support_critical_angle.getFloat() * PI / 180.0 ; scfg.bridge_slope = c.support_critical_angle.getFloat() * PI / 180.0 ;
scfg.max_bridge_length_mm = c.support_max_bridge_length.getFloat(); scfg.max_bridge_length_mm = c.support_max_bridge_length.getFloat();
scfg.max_pillar_link_distance_mm = c.support_max_pillar_link_distance.getFloat(); scfg.max_pillar_link_distance_mm = c.support_max_pillar_link_distance.getFloat();
@ -596,16 +607,15 @@ sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) {
scfg.pillar_base_safety_distance_mm = scfg.pillar_base_safety_distance_mm =
c.support_base_safety_distance.getFloat() < EPSILON ? c.support_base_safety_distance.getFloat() < EPSILON ?
scfg.safety_distance_mm : c.support_base_safety_distance.getFloat(); scfg.safety_distance_mm : c.support_base_safety_distance.getFloat();
return scfg; return scfg;
} }
sla::PoolConfig::EmbedObject builtin_pad_cfg(const SLAPrintObjectConfig& c) { sla::PoolConfig::EmbedObject builtin_pad_cfg(const SLAPrintObjectConfig& c) {
sla::PoolConfig::EmbedObject ret; sla::PoolConfig::EmbedObject ret;
ret.enabled = c.support_object_elevation.getFloat() <= EPSILON && ret.enabled = is_zero_elevation(c);
c.pad_enable.getBool() && c.supports_enable.getBool();
if(ret.enabled) { if(ret.enabled) {
ret.object_gap_mm = c.pad_object_gap.getFloat(); ret.object_gap_mm = c.pad_object_gap.getFloat();
ret.stick_width_mm = c.pad_object_connector_width.getFloat(); ret.stick_width_mm = c.pad_object_connector_width.getFloat();
@ -613,7 +623,7 @@ sla::PoolConfig::EmbedObject builtin_pad_cfg(const SLAPrintObjectConfig& c) {
ret.stick_penetration_mm = c.pad_object_connector_penetration ret.stick_penetration_mm = c.pad_object_connector_penetration
.getFloat(); .getFloat();
} }
return ret; return ret;
} }
@ -622,16 +632,16 @@ sla::PoolConfig make_pool_config(const SLAPrintObjectConfig& c) {
pcfg.min_wall_thickness_mm = c.pad_wall_thickness.getFloat(); pcfg.min_wall_thickness_mm = c.pad_wall_thickness.getFloat();
pcfg.wall_slope = c.pad_wall_slope.getFloat() * PI / 180.0; pcfg.wall_slope = c.pad_wall_slope.getFloat() * PI / 180.0;
// We do not support radius for now // We do not support radius for now
pcfg.edge_radius_mm = 0.0; //c.pad_edge_radius.getFloat(); pcfg.edge_radius_mm = 0.0; //c.pad_edge_radius.getFloat();
pcfg.max_merge_distance_mm = c.pad_max_merge_distance.getFloat(); pcfg.max_merge_distance_mm = c.pad_max_merge_distance.getFloat();
pcfg.min_wall_height_mm = c.pad_wall_height.getFloat(); pcfg.min_wall_height_mm = c.pad_wall_height.getFloat();
// set builtin pad implicitly ON // set builtin pad implicitly ON
pcfg.embed_object = builtin_pad_cfg(c); pcfg.embed_object = builtin_pad_cfg(c);
return pcfg; return pcfg;
} }
@ -657,12 +667,14 @@ std::string SLAPrint::validate() const
cfg.head_width_mm + cfg.head_width_mm +
2 * cfg.head_back_radius_mm - 2 * cfg.head_back_radius_mm -
cfg.head_penetration_mm; cfg.head_penetration_mm;
double elv = cfg.object_elevation_mm; double elv = cfg.object_elevation_mm;
if(supports_en && elv > EPSILON && elv < pinhead_width ) if(supports_en && elv > EPSILON && elv < pinhead_width )
return L("Elevation is too low for object."); return L(
"Elevation is too low for object. Use the \"Pad around "
"obect\" feature to print the object without elevation.");
sla::PoolConfig::EmbedObject builtinpad = builtin_pad_cfg(po->config()); sla::PoolConfig::EmbedObject builtinpad = builtin_pad_cfg(po->config());
if(supports_en && builtinpad.enabled && if(supports_en && builtinpad.enabled &&
cfg.pillar_base_safety_distance_mm < builtinpad.object_gap_mm) { cfg.pillar_base_safety_distance_mm < builtinpad.object_gap_mm) {
@ -740,15 +752,15 @@ void SLAPrint::process()
coord_t maxZs = scaled(maxZ); coord_t maxZs = scaled(maxZ);
po.m_slice_index.clear(); po.m_slice_index.clear();
size_t cap = size_t(1 + (maxZs - minZs - ilhs) / lhs); size_t cap = size_t(1 + (maxZs - minZs - ilhs) / lhs);
po.m_slice_index.reserve(cap); po.m_slice_index.reserve(cap);
po.m_slice_index.emplace_back(minZs + ilhs, minZf + ilh / 2.f, ilh); po.m_slice_index.emplace_back(minZs + ilhs, minZf + ilh / 2.f, ilh);
for(coord_t h = minZs + ilhs + lhs; h <= maxZs; h += lhs) for(coord_t h = minZs + ilhs + lhs; h <= maxZs; h += lhs)
po.m_slice_index.emplace_back(h, unscaled<float>(h) - lh / 2.f, lh); po.m_slice_index.emplace_back(h, unscaled<float>(h) - lh / 2.f, lh);
// Just get the first record that is form the model: // Just get the first record that is form the model:
auto slindex_it = auto slindex_it =
po.closest_slice_record(po.m_slice_index, float(bb3d.min(Z))); po.closest_slice_record(po.m_slice_index, float(bb3d.min(Z)));
@ -781,9 +793,9 @@ void SLAPrint::process()
{ {
// We apply the printer correction offset here. // We apply the printer correction offset here.
if(clpr_offs != 0) if(clpr_offs != 0)
po.m_model_slices[id] = po.m_model_slices[id] =
offset_ex(po.m_model_slices[id], float(clpr_offs)); offset_ex(po.m_model_slices[id], float(clpr_offs));
mit->set_model_slice_idx(po, id); ++mit; mit->set_model_slice_idx(po, id); ++mit;
} }
@ -876,10 +888,10 @@ void SLAPrint::process()
// removed them on purpose. No calculation will be done. // removed them on purpose. No calculation will be done.
po.m_supportdata->support_points = po.transformed_support_points(); po.m_supportdata->support_points = po.transformed_support_points();
} }
// If the zero elevation mode is engaged, we have to filter out all the // If the zero elevation mode is engaged, we have to filter out all the
// points that are on the bottom of the object // points that are on the bottom of the object
if (po.config().support_object_elevation.getFloat() <= EPSILON) { if (is_zero_elevation(po.config())) {
double gnd = po.m_supportdata->emesh.ground_level(); double gnd = po.m_supportdata->emesh.ground_level();
auto & pts = po.m_supportdata->support_points; auto & pts = po.m_supportdata->support_points;
double tolerance = po.config().pad_enable.getBool() double tolerance = po.config().pad_enable.getBool()
@ -894,7 +906,7 @@ void SLAPrint::process()
double diff = std::abs(gnd - double(sp.pos(Z))); double diff = std::abs(gnd - double(sp.pos(Z)));
return diff <= tolerance; return diff <= tolerance;
}); });
// erase all elements after the new end // erase all elements after the new end
pts.erase(endit, pts.end()); pts.erase(endit, pts.end());
} }
@ -904,7 +916,7 @@ void SLAPrint::process()
auto support_tree = [this, ostepd](SLAPrintObject& po) auto support_tree = [this, ostepd](SLAPrintObject& po)
{ {
if(!po.m_supportdata) return; if(!po.m_supportdata) return;
sla::PoolConfig pcfg = make_pool_config(po.m_config); sla::PoolConfig pcfg = make_pool_config(po.m_config);
if (pcfg.embed_object) if (pcfg.embed_object)
@ -912,11 +924,11 @@ void SLAPrint::process()
pcfg.min_wall_thickness_mm); pcfg.min_wall_thickness_mm);
if(!po.m_config.supports_enable.getBool()) { if(!po.m_config.supports_enable.getBool()) {
// Generate empty support tree. It can still host a pad // Generate empty support tree. It can still host a pad
po.m_supportdata->support_tree_ptr.reset( po.m_supportdata->support_tree_ptr.reset(
new SLASupportTree(po.m_supportdata->emesh.ground_level())); new SLASupportTree(po.m_supportdata->emesh.ground_level()));
return; return;
} }
@ -940,7 +952,7 @@ void SLAPrint::process()
ctl.stopcondition = [this](){ return canceled(); }; ctl.stopcondition = [this](){ return canceled(); };
ctl.cancelfn = [this]() { throw_if_canceled(); }; ctl.cancelfn = [this]() { throw_if_canceled(); };
po.m_supportdata->support_tree_ptr.reset( po.m_supportdata->support_tree_ptr.reset(
new SLASupportTree(po.m_supportdata->support_points, new SLASupportTree(po.m_supportdata->support_points,
po.m_supportdata->emesh, scfg, ctl)); po.m_supportdata->emesh, scfg, ctl));
@ -1040,7 +1052,7 @@ void SLAPrint::process()
if(clpr_offs != 0) if(clpr_offs != 0)
sd->support_slices[i] = sd->support_slices[i] =
offset_ex(sd->support_slices[i], float(clpr_offs)); offset_ex(sd->support_slices[i], float(clpr_offs));
po.m_slice_index[i].set_support_slice_idx(po, i); po.m_slice_index[i].set_support_slice_idx(po, i);
} }
@ -1268,7 +1280,7 @@ void SLAPrint::process()
const SLAPrintObject *po = record.print_obj(); const SLAPrintObject *po = record.print_obj();
const ExPolygons &modelslices = record.get_slice(soModel); const ExPolygons &modelslices = record.get_slice(soModel);
bool is_lefth = record.print_obj()->is_left_handed(); bool is_lefth = record.print_obj()->is_left_handed();
if (!modelslices.empty()) { if (!modelslices.empty()) {
ClipperPolygons v = get_all_polygons(modelslices, po->instances(), is_lefth); ClipperPolygons v = get_all_polygons(modelslices, po->instances(), is_lefth);
@ -1276,7 +1288,7 @@ void SLAPrint::process()
} }
const ExPolygons &supportslices = record.get_slice(soSupport); const ExPolygons &supportslices = record.get_slice(soSupport);
if (!supportslices.empty()) { if (!supportslices.empty()) {
ClipperPolygons v = get_all_polygons(supportslices, po->instances(), is_lefth); ClipperPolygons v = get_all_polygons(supportslices, po->instances(), is_lefth);
for(ClipperPolygon& p_tmp : v) supports_polygons.emplace_back(std::move(p_tmp)); for(ClipperPolygon& p_tmp : v) supports_polygons.emplace_back(std::move(p_tmp));
@ -1369,8 +1381,8 @@ void SLAPrint::process()
{ // create a raster printer for the current print parameters { // create a raster printer for the current print parameters
double layerh = m_default_object_config.layer_height.getFloat(); double layerh = m_default_object_config.layer_height.getFloat();
m_printer.reset(new SLAPrinter(m_printer_config, m_printer.reset(new SLAPrinter(m_printer_config,
m_material_config, m_material_config,
layerh)); layerh));
} }
@ -1647,6 +1659,7 @@ bool SLAPrintObject::invalidate_state_by_config_options(const std::vector<t_conf
|| opt_key == "pad_wall_thickness" || opt_key == "pad_wall_thickness"
|| opt_key == "supports_enable" || opt_key == "supports_enable"
|| opt_key == "support_object_elevation" || opt_key == "support_object_elevation"
|| opt_key == "pad_zero_elevation"
|| opt_key == "slice_closing_radius") { || opt_key == "slice_closing_radius") {
steps.emplace_back(slaposObjectSlice); steps.emplace_back(slaposObjectSlice);
} else if ( } else if (
@ -1719,7 +1732,10 @@ bool SLAPrintObject::invalidate_all_steps()
} }
double SLAPrintObject::get_elevation() const { double SLAPrintObject::get_elevation() const {
bool en = m_config.supports_enable.getBool(); if (is_zero_elevation(m_config)) return 0.;
bool en = m_config.supports_enable.getBool();
double ret = en ? m_config.support_object_elevation.getFloat() : 0.; double ret = en ? m_config.support_object_elevation.getFloat() : 0.;
if(m_config.pad_enable.getBool()) { if(m_config.pad_enable.getBool()) {
@ -1736,8 +1752,10 @@ double SLAPrintObject::get_elevation() const {
double SLAPrintObject::get_current_elevation() const double SLAPrintObject::get_current_elevation() const
{ {
if (is_zero_elevation(m_config)) return 0.;
bool has_supports = is_step_done(slaposSupportTree); bool has_supports = is_step_done(slaposSupportTree);
bool has_pad = is_step_done(slaposBasePool); bool has_pad = is_step_done(slaposBasePool);
if(!has_supports && !has_pad) if(!has_supports && !has_pad)
return 0; return 0;
@ -1756,7 +1774,7 @@ Vec3d SLAPrint::relative_correction() const
corr(X) = printer_config().relative_correction.values[0]; corr(X) = printer_config().relative_correction.values[0];
corr(Y) = printer_config().relative_correction.values[0]; corr(Y) = printer_config().relative_correction.values[0];
corr(Z) = printer_config().relative_correction.values.back(); corr(Z) = printer_config().relative_correction.values.back();
} }
if(material_config().material_correction.values.size() >= 2) { if(material_config().material_correction.values.size() >= 2) {
corr(X) *= material_config().material_correction.values[0]; corr(X) *= material_config().material_correction.values[0];
@ -1925,7 +1943,7 @@ void SLAPrint::StatusReporter::operator()(SLAPrint & p,
BOOST_LOG_TRIVIAL(info) BOOST_LOG_TRIVIAL(info)
<< st << "% " << msg << (logmsg.empty() ? "" : ": ") << logmsg << st << "% " << msg << (logmsg.empty() ? "" : ": ") << logmsg
<< log_memory_info(); << log_memory_info();
p.set_status(int(std::round(st)), msg, flags); p.set_status(int(std::round(st)), msg, flags);
} }

View File

@ -162,11 +162,11 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
if (from_pre_map != pre_family_model_map.end()) { model.family = from_pre_map->second; } if (from_pre_map != pre_family_model_map.end()) { model.family = from_pre_map->second; }
} }
#if 0 #if 0
// Remove SLA printers from the initial alpha. // Remove SLA printers from the initial alpha.
if (model.technology == ptSLA) if (model.technology == ptSLA)
continue; continue;
#endif #endif
section.second.get<std::string>("variants", ""); section.second.get<std::string>("variants", "");
const auto variants_field = section.second.get<std::string>("variants", ""); const auto variants_field = section.second.get<std::string>("variants", "");
std::vector<std::string> variants; std::vector<std::string> variants;
if (Slic3r::unescape_strings_cstyle(variants_field, variants)) { if (Slic3r::unescape_strings_cstyle(variants_field, variants)) {
@ -209,7 +209,7 @@ const std::string& Preset::suffix_modified()
void Preset::update_suffix_modified() void Preset::update_suffix_modified()
{ {
g_suffix_modified = (" (" + _(L("modified")) + ")").ToUTF8().data(); g_suffix_modified = (" (" + _(L("modified")) + ")").ToUTF8().data();
} }
// Remove an optional "(modified)" suffix from a name. // Remove an optional "(modified)" suffix from a name.
// This converts a UI name to a unique preset identifier. // This converts a UI name to a unique preset identifier.
@ -224,8 +224,8 @@ void Preset::set_num_extruders(DynamicPrintConfig &config, unsigned int num_extr
{ {
const auto &defaults = FullPrintConfig::defaults(); const auto &defaults = FullPrintConfig::defaults();
for (const std::string &key : Preset::nozzle_options()) { for (const std::string &key : Preset::nozzle_options()) {
if (key == "default_filament_profile") if (key == "default_filament_profile")
continue; continue;
auto *opt = config.option(key, false); auto *opt = config.option(key, false);
assert(opt != nullptr); assert(opt != nullptr);
assert(opt->is_vector()); assert(opt->is_vector());
@ -247,8 +247,8 @@ void Preset::normalize(DynamicPrintConfig &config)
size_t n = (nozzle_diameter == nullptr) ? 1 : nozzle_diameter->values.size(); size_t n = (nozzle_diameter == nullptr) ? 1 : nozzle_diameter->values.size();
const auto &defaults = FullPrintConfig::defaults(); const auto &defaults = FullPrintConfig::defaults();
for (const std::string &key : Preset::filament_options()) { for (const std::string &key : Preset::filament_options()) {
if (key == "compatible_prints" || key == "compatible_printers") if (key == "compatible_prints" || key == "compatible_printers")
continue; continue;
auto *opt = config.option(key, false); auto *opt = config.option(key, false);
/*assert(opt != nullptr); /*assert(opt != nullptr);
assert(opt->is_vector());*/ assert(opt->is_vector());*/
@ -307,7 +307,7 @@ bool Preset::is_compatible_with_print(const Preset &active_print) const
} }
} }
return this->is_default || active_print.name.empty() || ! has_compatible_prints || return this->is_default || active_print.name.empty() || ! has_compatible_prints ||
std::find(compatible_prints->values.begin(), compatible_prints->values.end(), active_print.name) != std::find(compatible_prints->values.begin(), compatible_prints->values.end(), active_print.name) !=
compatible_prints->values.end(); compatible_prints->values.end();
} }
@ -326,7 +326,7 @@ bool Preset::is_compatible_with_printer(const Preset &active_printer, const Dyna
} }
} }
return this->is_default || active_printer.name.empty() || ! has_compatible_printers || return this->is_default || active_printer.name.empty() || ! has_compatible_printers ||
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.name) != std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.name) !=
compatible_printers->values.end(); compatible_printers->values.end();
} }
@ -334,9 +334,9 @@ bool Preset::is_compatible_with_printer(const Preset &active_printer) const
{ {
DynamicPrintConfig config; DynamicPrintConfig config;
config.set_key_value("printer_preset", new ConfigOptionString(active_printer.name)); config.set_key_value("printer_preset", new ConfigOptionString(active_printer.name));
const ConfigOption *opt = active_printer.config.option("nozzle_diameter"); const ConfigOption *opt = active_printer.config.option("nozzle_diameter");
if (opt) if (opt)
config.set_key_value("num_extruders", new ConfigOptionInt((int)static_cast<const ConfigOptionFloats*>(opt)->values.size())); config.set_key_value("num_extruders", new ConfigOptionInt((int)static_cast<const ConfigOptionFloats*>(opt)->values.size()));
return this->is_compatible_with_printer(active_printer, &config); return this->is_compatible_with_printer(active_printer, &config);
} }
@ -358,40 +358,40 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config)
} }
const std::vector<std::string>& Preset::print_options() const std::vector<std::string>& Preset::print_options()
{ {
static std::vector<std::string> s_opts { static std::vector<std::string> s_opts {
"layer_height", "first_layer_height", "perimeters", "spiral_vase", "slice_closing_radius", "top_solid_layers", "bottom_solid_layers", "layer_height", "first_layer_height", "perimeters", "spiral_vase", "slice_closing_radius", "top_solid_layers", "bottom_solid_layers",
"extra_perimeters", "ensure_vertical_shell_thickness", "avoid_crossing_perimeters", "thin_walls", "overhangs", "extra_perimeters", "ensure_vertical_shell_thickness", "avoid_crossing_perimeters", "thin_walls", "overhangs",
"seam_position", "external_perimeters_first", "fill_density", "fill_pattern", "top_fill_pattern", "bottom_fill_pattern", "seam_position", "external_perimeters_first", "fill_density", "fill_pattern", "top_fill_pattern", "bottom_fill_pattern",
"infill_every_layers", "infill_only_where_needed", "solid_infill_every_layers", "fill_angle", "bridge_angle", "infill_every_layers", "infill_only_where_needed", "solid_infill_every_layers", "fill_angle", "bridge_angle",
"solid_infill_below_area", "only_retract_when_crossing_perimeters", "infill_first", "max_print_speed", "solid_infill_below_area", "only_retract_when_crossing_perimeters", "infill_first", "max_print_speed",
"max_volumetric_speed", "max_volumetric_speed",
#ifdef HAS_PRESSURE_EQUALIZER #ifdef HAS_PRESSURE_EQUALIZER
"max_volumetric_extrusion_rate_slope_positive", "max_volumetric_extrusion_rate_slope_negative", "max_volumetric_extrusion_rate_slope_positive", "max_volumetric_extrusion_rate_slope_negative",
#endif /* HAS_PRESSURE_EQUALIZER */ #endif /* HAS_PRESSURE_EQUALIZER */
"perimeter_speed", "small_perimeter_speed", "external_perimeter_speed", "infill_speed", "solid_infill_speed", "perimeter_speed", "small_perimeter_speed", "external_perimeter_speed", "infill_speed", "solid_infill_speed",
"top_solid_infill_speed", "support_material_speed", "support_material_xy_spacing", "support_material_interface_speed", "top_solid_infill_speed", "support_material_speed", "support_material_xy_spacing", "support_material_interface_speed",
"bridge_speed", "gap_fill_speed", "travel_speed", "first_layer_speed", "perimeter_acceleration", "infill_acceleration", "bridge_speed", "gap_fill_speed", "travel_speed", "first_layer_speed", "perimeter_acceleration", "infill_acceleration",
"bridge_acceleration", "first_layer_acceleration", "default_acceleration", "skirts", "skirt_distance", "skirt_height", "bridge_acceleration", "first_layer_acceleration", "default_acceleration", "skirts", "skirt_distance", "skirt_height",
"min_skirt_length", "brim_width", "support_material", "support_material_auto", "support_material_threshold", "support_material_enforce_layers", "min_skirt_length", "brim_width", "support_material", "support_material_auto", "support_material_threshold", "support_material_enforce_layers",
"raft_layers", "support_material_pattern", "support_material_with_sheath", "support_material_spacing", "raft_layers", "support_material_pattern", "support_material_with_sheath", "support_material_spacing",
"support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers", "support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers",
"support_material_interface_spacing", "support_material_interface_contact_loops", "support_material_contact_distance", "support_material_interface_spacing", "support_material_interface_contact_loops", "support_material_contact_distance",
"support_material_buildplate_only", "dont_support_bridges", "notes", "complete_objects", "extruder_clearance_radius", "support_material_buildplate_only", "dont_support_bridges", "notes", "complete_objects", "extruder_clearance_radius",
"extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "perimeter_extruder", "extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "perimeter_extruder",
"infill_extruder", "solid_infill_extruder", "support_material_extruder", "support_material_interface_extruder", "infill_extruder", "solid_infill_extruder", "support_material_extruder", "support_material_interface_extruder",
"ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width", "ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width",
"perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width",
"top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects",
"elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y",
"wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging", "single_extruder_multi_material_priming", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging", "single_extruder_multi_material_priming",
"compatible_printers", "compatible_printers_condition", "inherits" "compatible_printers", "compatible_printers_condition", "inherits"
}; };
return s_opts; return s_opts;
} }
const std::vector<std::string>& Preset::filament_options() const std::vector<std::string>& Preset::filament_options()
{ {
static std::vector<std::string> s_opts { static std::vector<std::string> s_opts {
"filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed",
"extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_loading_speed_start", "filament_load_time", "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_loading_speed_start", "filament_load_time",
@ -401,16 +401,16 @@ const std::vector<std::string>& Preset::filament_options()
"max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed",
"start_filament_gcode", "end_filament_gcode", "start_filament_gcode", "end_filament_gcode",
// Retract overrides // Retract overrides
"filament_retract_length", "filament_retract_lift", "filament_retract_lift_above", "filament_retract_lift_below", "filament_retract_speed", "filament_deretract_speed", "filament_retract_restart_extra", "filament_retract_before_travel", "filament_retract_length", "filament_retract_lift", "filament_retract_lift_above", "filament_retract_lift_below", "filament_retract_speed", "filament_deretract_speed", "filament_retract_restart_extra", "filament_retract_before_travel",
"filament_retract_layer_change", "filament_wipe", "filament_retract_before_wipe", "filament_retract_layer_change", "filament_wipe", "filament_retract_before_wipe",
// Profile compatibility // Profile compatibility
"compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits" "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits"
}; };
return s_opts; return s_opts;
} }
const std::vector<std::string>& Preset::printer_options() const std::vector<std::string>& Preset::printer_options()
{ {
static std::vector<std::string> s_opts; static std::vector<std::string> s_opts;
if (s_opts.empty()) { if (s_opts.empty()) {
s_opts = { s_opts = {
@ -420,20 +420,20 @@ const std::vector<std::string>& Preset::printer_options()
"host_type", "print_host", "printhost_apikey", "printhost_cafile", "host_type", "print_host", "printhost_apikey", "printhost_cafile",
"single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode", "single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode",
"between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction", "between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "max_print_height", "cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "max_print_height",
"default_print_profile", "inherits", "default_print_profile", "inherits",
"remaining_times", "silent_mode", "machine_max_acceleration_extruding", "machine_max_acceleration_retracting", "remaining_times", "silent_mode", "machine_max_acceleration_extruding", "machine_max_acceleration_retracting",
"machine_max_acceleration_x", "machine_max_acceleration_y", "machine_max_acceleration_z", "machine_max_acceleration_e", "machine_max_acceleration_x", "machine_max_acceleration_y", "machine_max_acceleration_z", "machine_max_acceleration_e",
"machine_max_feedrate_x", "machine_max_feedrate_y", "machine_max_feedrate_z", "machine_max_feedrate_e", "machine_max_feedrate_x", "machine_max_feedrate_y", "machine_max_feedrate_z", "machine_max_feedrate_e",
"machine_min_extruding_rate", "machine_min_travel_rate", "machine_min_extruding_rate", "machine_min_travel_rate",
"machine_max_jerk_x", "machine_max_jerk_y", "machine_max_jerk_z", "machine_max_jerk_e" "machine_max_jerk_x", "machine_max_jerk_y", "machine_max_jerk_z", "machine_max_jerk_e"
}; };
s_opts.insert(s_opts.end(), Preset::nozzle_options().begin(), Preset::nozzle_options().end()); s_opts.insert(s_opts.end(), Preset::nozzle_options().begin(), Preset::nozzle_options().end());
} }
return s_opts; return s_opts;
} }
// The following nozzle options of a printer profile will be adjusted to match the size // The following nozzle options of a printer profile will be adjusted to match the size
// of the nozzle_diameter vector. // of the nozzle_diameter vector.
const std::vector<std::string>& Preset::nozzle_options() const std::vector<std::string>& Preset::nozzle_options()
{ {
@ -442,14 +442,14 @@ const std::vector<std::string>& Preset::nozzle_options()
"nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset", "nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset",
"retract_length", "retract_lift", "retract_lift_above", "retract_lift_below", "retract_speed", "deretract_speed", "retract_length", "retract_lift", "retract_lift_above", "retract_lift_below", "retract_speed", "deretract_speed",
"retract_before_wipe", "retract_restart_extra", "retract_before_travel", "wipe", "retract_before_wipe", "retract_restart_extra", "retract_before_travel", "wipe",
"retract_layer_change", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", "retract_layer_change", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour",
"default_filament_profile" "default_filament_profile"
}; };
return s_opts; return s_opts;
} }
const std::vector<std::string>& Preset::sla_print_options() const std::vector<std::string>& Preset::sla_print_options()
{ {
static std::vector<std::string> s_opts; static std::vector<std::string> s_opts;
if (s_opts.empty()) { if (s_opts.empty()) {
s_opts = { s_opts = {
@ -477,16 +477,17 @@ const std::vector<std::string>& Preset::sla_print_options()
"pad_wall_thickness", "pad_wall_thickness",
"pad_wall_height", "pad_wall_height",
"pad_max_merge_distance", "pad_max_merge_distance",
"pad_edge_radius", // "pad_edge_radius",
"pad_wall_slope", "pad_wall_slope",
"pad_object_gap", "pad_object_gap",
"pad_zero_elevation",
"pad_object_connector_stride", "pad_object_connector_stride",
"pad_object_connector_width", "pad_object_connector_width",
"pad_object_connector_penetration", "pad_object_connector_penetration",
"output_filename_format", "output_filename_format",
"default_sla_print_profile", "default_sla_print_profile",
"compatible_printers", "compatible_printers",
"compatible_printers_condition", "compatible_printers_condition",
"inherits" "inherits"
}; };
} }
@ -494,7 +495,7 @@ const std::vector<std::string>& Preset::sla_print_options()
} }
const std::vector<std::string>& Preset::sla_material_options() const std::vector<std::string>& Preset::sla_material_options()
{ {
static std::vector<std::string> s_opts; static std::vector<std::string> s_opts;
if (s_opts.empty()) { if (s_opts.empty()) {
s_opts = { s_opts = {
@ -503,7 +504,7 @@ const std::vector<std::string>& Preset::sla_material_options()
"material_correction", "material_correction",
"material_notes", "material_notes",
"default_sla_material_profile", "default_sla_material_profile",
"compatible_prints", "compatible_prints_condition", "compatible_prints", "compatible_prints_condition",
"compatible_printers", "compatible_printers_condition", "inherits" "compatible_printers", "compatible_printers_condition", "inherits"
}; };
} }
@ -511,7 +512,7 @@ const std::vector<std::string>& Preset::sla_material_options()
} }
const std::vector<std::string>& Preset::sla_printer_options() const std::vector<std::string>& Preset::sla_printer_options()
{ {
static std::vector<std::string> s_opts; static std::vector<std::string> s_opts;
if (s_opts.empty()) { if (s_opts.empty()) {
s_opts = { s_opts = {
@ -539,7 +540,7 @@ PresetCollection::PresetCollection(Preset::Type type, const std::vector<std::str
m_idx_selected(0), m_idx_selected(0),
m_bitmap_main_frame(new wxBitmap), m_bitmap_main_frame(new wxBitmap),
m_bitmap_add(new wxBitmap), m_bitmap_add(new wxBitmap),
m_bitmap_cache(new GUI::BitmapCache) m_bitmap_cache(new GUI::BitmapCache)
{ {
// Insert just the default preset. // Insert just the default preset.
this->add_default_preset(keys, defaults, default_name); this->add_default_preset(keys, defaults, default_name);
@ -552,8 +553,8 @@ PresetCollection::~PresetCollection()
m_bitmap_main_frame = nullptr; m_bitmap_main_frame = nullptr;
delete m_bitmap_add; delete m_bitmap_add;
m_bitmap_add = nullptr; m_bitmap_add = nullptr;
delete m_bitmap_cache; delete m_bitmap_cache;
m_bitmap_cache = nullptr; m_bitmap_cache = nullptr;
} }
void PresetCollection::reset(bool delete_files) void PresetCollection::reset(bool delete_files)
@ -575,8 +576,8 @@ void PresetCollection::add_default_preset(const std::vector<std::string> &keys,
{ {
// Insert just the default preset. // Insert just the default preset.
m_presets.emplace_back(Preset(this->type(), preset_name, true)); m_presets.emplace_back(Preset(this->type(), preset_name, true));
m_presets.back().config.apply_only(defaults, keys.empty() ? defaults.keys() : keys); m_presets.back().config.apply_only(defaults, keys.empty() ? defaults.keys() : keys);
m_presets.back().loaded = true; m_presets.back().loaded = true;
++ m_num_default_presets; ++ m_num_default_presets;
} }
@ -584,13 +585,13 @@ void PresetCollection::add_default_preset(const std::vector<std::string> &keys,
// Throws an exception on error. // Throws an exception on error.
void PresetCollection::load_presets(const std::string &dir_path, const std::string &subdir) void PresetCollection::load_presets(const std::string &dir_path, const std::string &subdir)
{ {
boost::filesystem::path dir = boost::filesystem::canonical(boost::filesystem::path(dir_path) / subdir).make_preferred(); boost::filesystem::path dir = boost::filesystem::canonical(boost::filesystem::path(dir_path) / subdir).make_preferred();
m_dir_path = dir.string(); m_dir_path = dir.string();
std::string errors_cummulative; std::string errors_cummulative;
// Store the loaded presets into a new vector, otherwise the binary search for already existing presets would be broken. // Store the loaded presets into a new vector, otherwise the binary search for already existing presets would be broken.
// (see the "Preset already present, not loading" message). // (see the "Preset already present, not loading" message).
std::deque<Preset> presets_loaded; std::deque<Preset> presets_loaded;
for (auto &dir_entry : boost::filesystem::directory_iterator(dir)) for (auto &dir_entry : boost::filesystem::directory_iterator(dir))
if (Slic3r::is_ini_file(dir_entry)) { if (Slic3r::is_ini_file(dir_entry)) {
std::string name = dir_entry.path().filename().string(); std::string name = dir_entry.path().filename().string();
// Remove the .ini suffix. // Remove the .ini suffix.
@ -609,28 +610,28 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri
DynamicPrintConfig config; DynamicPrintConfig config;
config.load_from_ini(preset.file); config.load_from_ini(preset.file);
// Find a default preset for the config. The PrintPresetCollection provides different default preset based on the "printer_technology" field. // Find a default preset for the config. The PrintPresetCollection provides different default preset based on the "printer_technology" field.
const Preset &default_preset = this->default_preset_for(config); const Preset &default_preset = this->default_preset_for(config);
preset.config = default_preset.config; preset.config = default_preset.config;
preset.config.apply(std::move(config)); preset.config.apply(std::move(config));
Preset::normalize(preset.config); Preset::normalize(preset.config);
// Report configuration fields, which are misplaced into a wrong group. // Report configuration fields, which are misplaced into a wrong group.
std::string incorrect_keys = Preset::remove_invalid_keys(config, default_preset.config); std::string incorrect_keys = Preset::remove_invalid_keys(config, default_preset.config);
if (! incorrect_keys.empty()) if (! incorrect_keys.empty())
BOOST_LOG_TRIVIAL(error) << "Error in a preset file: The preset \"" << BOOST_LOG_TRIVIAL(error) << "Error in a preset file: The preset \"" <<
preset.file << "\" contains the following incorrect keys: " << incorrect_keys << ", which were removed"; preset.file << "\" contains the following incorrect keys: " << incorrect_keys << ", which were removed";
preset.loaded = true; preset.loaded = true;
} catch (const std::ifstream::failure &err) { } catch (const std::ifstream::failure &err) {
throw std::runtime_error(std::string("The selected preset cannot be loaded: ") + preset.file + "\n\tReason: " + err.what()); throw std::runtime_error(std::string("The selected preset cannot be loaded: ") + preset.file + "\n\tReason: " + err.what());
} catch (const std::runtime_error &err) { } catch (const std::runtime_error &err) {
throw std::runtime_error(std::string("Failed loading the preset file: ") + preset.file + "\n\tReason: " + err.what()); throw std::runtime_error(std::string("Failed loading the preset file: ") + preset.file + "\n\tReason: " + err.what());
} }
presets_loaded.emplace_back(preset); presets_loaded.emplace_back(preset);
} catch (const std::runtime_error &err) { } catch (const std::runtime_error &err) {
errors_cummulative += err.what(); errors_cummulative += err.what();
errors_cummulative += "\n"; errors_cummulative += "\n";
} }
} }
m_presets.insert(m_presets.end(), std::make_move_iterator(presets_loaded.begin()), std::make_move_iterator(presets_loaded.end())); m_presets.insert(m_presets.end(), std::make_move_iterator(presets_loaded.begin()), std::make_move_iterator(presets_loaded.end()));
std::sort(m_presets.begin() + m_num_default_presets, m_presets.end()); std::sort(m_presets.begin() + m_num_default_presets, m_presets.end());
this->select_preset(first_visible_idx()); this->select_preset(first_visible_idx());
if (! errors_cummulative.empty()) if (! errors_cummulative.empty())
@ -651,8 +652,8 @@ static bool profile_print_params_same(const DynamicPrintConfig &cfg1, const Dyna
t_config_option_keys diff = cfg1.diff(cfg2); t_config_option_keys diff = cfg1.diff(cfg2);
// Following keys are used by the UI, not by the slicing core, therefore they are not important // Following keys are used by the UI, not by the slicing core, therefore they are not important
// when comparing profiles for equality. Ignore them. // when comparing profiles for equality. Ignore them.
for (const char *key : { "compatible_prints", "compatible_prints_condition", for (const char *key : { "compatible_prints", "compatible_prints_condition",
"compatible_printers", "compatible_printers_condition", "inherits", "compatible_printers", "compatible_printers_condition", "inherits",
"print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id", "print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id",
"printer_model", "printer_variant", "default_print_profile", "default_filament_profile", "default_sla_print_profile", "default_sla_material_profile", "printer_model", "printer_variant", "default_print_profile", "default_filament_profile", "default_sla_print_profile", "default_sla_material_profile",
"printhost_apikey", "printhost_cafile" }) "printhost_apikey", "printhost_cafile" })
@ -663,7 +664,7 @@ static bool profile_print_params_same(const DynamicPrintConfig &cfg1, const Dyna
// Load a preset from an already parsed config file, insert it into the sorted sequence of presets // Load a preset from an already parsed config file, insert it into the sorted sequence of presets
// and select it, losing previous modifications. // and select it, losing previous modifications.
// In case // In case
Preset& PresetCollection::load_external_preset( Preset& PresetCollection::load_external_preset(
// Path to the profile source file (a G-code, an AMF or 3MF file, a config file) // Path to the profile source file (a G-code, an AMF or 3MF file, a config file)
const std::string &path, const std::string &path,
@ -681,7 +682,7 @@ Preset& PresetCollection::load_external_preset(
cfg.apply_only(config, cfg.keys(), true); cfg.apply_only(config, cfg.keys(), true);
// Is there a preset already loaded with the name stored inside the config? // Is there a preset already loaded with the name stored inside the config?
std::deque<Preset>::iterator it = this->find_preset_internal(original_name); std::deque<Preset>::iterator it = this->find_preset_internal(original_name);
bool found = it != m_presets.end() && it->name == original_name; bool found = it != m_presets.end() && it->name == original_name;
if (found && profile_print_params_same(it->config, cfg)) { if (found && profile_print_params_same(it->config, cfg)) {
// The preset exists and it matches the values stored inside config. // The preset exists and it matches the values stored inside config.
if (select) if (select)
@ -706,7 +707,7 @@ Preset& PresetCollection::load_external_preset(
suffix = " (" + std::to_string(idx) + ")"; suffix = " (" + std::to_string(idx) + ")";
} else { } else {
if (idx == 0) if (idx == 0)
suffix = " (" + original_name + ")"; suffix = " (" + original_name + ")";
else else
suffix = " (" + original_name + "-" + std::to_string(idx) + ")"; suffix = " (" + original_name + "-" + std::to_string(idx) + ")";
} }
@ -751,8 +752,8 @@ Preset& PresetCollection::load_preset(const std::string &path, const std::string
void PresetCollection::save_current_preset(const std::string &new_name) void PresetCollection::save_current_preset(const std::string &new_name)
{ {
// 1) Find the preset with a new_name or create a new one, // 1) Find the preset with a new_name or create a new one,
// initialize it with the edited config. // initialize it with the edited config.
auto it = this->find_preset_internal(new_name); auto it = this->find_preset_internal(new_name);
if (it != m_presets.end() && it->name == new_name) { if (it != m_presets.end() && it->name == new_name) {
// Preset with the same name found. // Preset with the same name found.
@ -762,15 +763,15 @@ void PresetCollection::save_current_preset(const std::string &new_name)
return; return;
// Overwriting an existing preset. // Overwriting an existing preset.
preset.config = std::move(m_edited_preset.config); preset.config = std::move(m_edited_preset.config);
// The newly saved preset will be activated -> make it visible. // The newly saved preset will be activated -> make it visible.
preset.is_visible = true; preset.is_visible = true;
} else { } else {
// Creating a new preset. // Creating a new preset.
Preset &preset = *m_presets.insert(it, m_edited_preset); Preset &preset = *m_presets.insert(it, m_edited_preset);
std::string &inherits = preset.inherits(); std::string &inherits = preset.inherits();
std::string old_name = preset.name; std::string old_name = preset.name;
preset.name = new_name; preset.name = new_name;
preset.file = this->path_from_name(new_name); preset.file = this->path_from_name(new_name);
preset.vendor = nullptr; preset.vendor = nullptr;
if (preset.is_system) { if (preset.is_system) {
// Inheriting from a system preset. // Inheriting from a system preset.
@ -779,30 +780,30 @@ void PresetCollection::save_current_preset(const std::string &new_name)
// Inheriting from a user preset. Link the new preset to the old preset. // Inheriting from a user preset. Link the new preset to the old preset.
// inherits = old_name; // inherits = old_name;
} else { } else {
// Inherited from a user preset. Just maintain the "inherited" flag, // Inherited from a user preset. Just maintain the "inherited" flag,
// meaning it will inherit from either the system preset, or the inherited user preset. // meaning it will inherit from either the system preset, or the inherited user preset.
} }
preset.is_default = false; preset.is_default = false;
preset.is_system = false; preset.is_system = false;
preset.is_external = false; preset.is_external = false;
// The newly saved preset will be activated -> make it visible. // The newly saved preset will be activated -> make it visible.
preset.is_visible = true; preset.is_visible = true;
} }
// 2) Activate the saved preset. // 2) Activate the saved preset.
this->select_preset_by_name(new_name, true); this->select_preset_by_name(new_name, true);
// 2) Store the active preset to disk. // 2) Store the active preset to disk.
this->get_selected_preset().save(); this->get_selected_preset().save();
} }
bool PresetCollection::delete_current_preset() bool PresetCollection::delete_current_preset()
{ {
const Preset &selected = this->get_selected_preset(); const Preset &selected = this->get_selected_preset();
if (selected.is_default) if (selected.is_default)
return false; return false;
if (! selected.is_external && ! selected.is_system) { if (! selected.is_external && ! selected.is_system) {
// Erase the preset file. // Erase the preset file.
boost::nowide::remove(selected.file.c_str()); boost::nowide::remove(selected.file.c_str());
} }
// Remove the preset from the list. // Remove the preset from the list.
m_presets.erase(m_presets.begin() + m_idx_selected); m_presets.erase(m_presets.begin() + m_idx_selected);
// Find the next visible preset. // Find the next visible preset.
@ -810,9 +811,9 @@ bool PresetCollection::delete_current_preset()
if (new_selected_idx < m_presets.size()) if (new_selected_idx < m_presets.size())
for (; new_selected_idx < m_presets.size() && ! m_presets[new_selected_idx].is_visible; ++ new_selected_idx) ; for (; new_selected_idx < m_presets.size() && ! m_presets[new_selected_idx].is_visible; ++ new_selected_idx) ;
if (new_selected_idx == m_presets.size()) if (new_selected_idx == m_presets.size())
for (--new_selected_idx; new_selected_idx > 0 && !m_presets[new_selected_idx].is_visible; --new_selected_idx); for (--new_selected_idx; new_selected_idx > 0 && !m_presets[new_selected_idx].is_visible; --new_selected_idx);
this->select_preset(new_selected_idx); this->select_preset(new_selected_idx);
return true; return true;
} }
void PresetCollection::load_bitmap_default(wxWindow *window, const std::string &file_name) void PresetCollection::load_bitmap_default(wxWindow *window, const std::string &file_name)
@ -836,18 +837,18 @@ const Preset* PresetCollection::get_selected_preset_parent() const
return nullptr; return nullptr;
// const std::string &inherits = this->get_edited_preset().inherits(); // const std::string &inherits = this->get_edited_preset().inherits();
// if (inherits.empty()) // if (inherits.empty())
// return this->get_selected_preset().is_system ? &this->get_selected_preset() : nullptr; // return this->get_selected_preset().is_system ? &this->get_selected_preset() : nullptr;
std::string inherits = this->get_edited_preset().inherits(); std::string inherits = this->get_edited_preset().inherits();
if (inherits.empty()) if (inherits.empty())
{ {
if (this->get_selected_preset().is_system || this->get_selected_preset().is_default) if (this->get_selected_preset().is_system || this->get_selected_preset().is_default)
return &this->get_selected_preset(); return &this->get_selected_preset();
if (this->get_selected_preset().is_external) if (this->get_selected_preset().is_external)
return nullptr; return nullptr;
inherits = m_type != Preset::Type::TYPE_PRINTER ? "- default -" : inherits = m_type != Preset::Type::TYPE_PRINTER ? "- default -" :
this->get_edited_preset().printer_technology() == ptFFF ? this->get_edited_preset().printer_technology() == ptFFF ?
"- default FFF -" : "- default SLA -" ; "- default FFF -" : "- default SLA -" ;
} }
@ -859,14 +860,14 @@ const Preset* PresetCollection::get_preset_parent(const Preset& child) const
{ {
const std::string &inherits = child.inherits(); const std::string &inherits = child.inherits();
if (inherits.empty()) if (inherits.empty())
// return this->get_selected_preset().is_system ? &this->get_selected_preset() : nullptr; // return this->get_selected_preset().is_system ? &this->get_selected_preset() : nullptr;
return nullptr; return nullptr;
const Preset* preset = this->find_preset(inherits, false); const Preset* preset = this->find_preset(inherits, false);
return (preset == nullptr/* || preset->is_default */|| preset->is_external) ? nullptr : preset; return (preset == nullptr/* || preset->is_default */|| preset->is_external) ? nullptr : preset;
} }
const std::string& PresetCollection::get_suffix_modified() { const std::string& PresetCollection::get_suffix_modified() {
return g_suffix_modified; return g_suffix_modified;
} }
// Return a preset by its name. If the preset is active, a temporary copy is returned. // Return a preset by its name. If the preset is active, a temporary copy is returned.
@ -876,7 +877,7 @@ Preset* PresetCollection::find_preset(const std::string &name, bool first_visibl
Preset key(m_type, name, false); Preset key(m_type, name, false);
auto it = this->find_preset_internal(name); auto it = this->find_preset_internal(name);
// Ensure that a temporary copy is returned if the preset found is currently selected. // Ensure that a temporary copy is returned if the preset found is currently selected.
return (it != m_presets.end() && it->name == key.name) ? &this->preset(it - m_presets.begin()) : return (it != m_presets.end() && it->name == key.name) ? &this->preset(it - m_presets.begin()) :
first_visible_if_not_found ? &this->first_visible() : nullptr; first_visible_if_not_found ? &this->first_visible() : nullptr;
} }
@ -896,9 +897,9 @@ void PresetCollection::set_default_suppressed(bool default_suppressed)
{ {
if (m_default_suppressed != default_suppressed) { if (m_default_suppressed != default_suppressed) {
m_default_suppressed = default_suppressed; m_default_suppressed = default_suppressed;
bool default_visible = ! default_suppressed || m_idx_selected < m_num_default_presets; bool default_visible = ! default_suppressed || m_idx_selected < m_num_default_presets;
for (size_t i = 0; i < m_num_default_presets; ++ i) for (size_t i = 0; i < m_num_default_presets; ++ i)
m_presets[i].is_visible = default_visible; m_presets[i].is_visible = default_visible;
} }
} }
@ -931,7 +932,7 @@ size_t PresetCollection::update_compatible_internal(const Preset &active_printer
//void PresetCollection::delete_current_preset(); //void PresetCollection::delete_current_preset();
// Update the wxChoice UI component from this list of presets. // Update the wxChoice UI component from this list of presets.
// Hide the // Hide the
void PresetCollection::update_platter_ui(GUI::PresetComboBox *ui) void PresetCollection::update_platter_ui(GUI::PresetComboBox *ui)
{ {
if (ui == nullptr) if (ui == nullptr)
@ -940,12 +941,12 @@ void PresetCollection::update_platter_ui(GUI::PresetComboBox *ui)
// Otherwise fill in the list from scratch. // Otherwise fill in the list from scratch.
ui->Freeze(); ui->Freeze();
ui->Clear(); ui->Clear();
size_t selected_preset_item = 0; size_t selected_preset_item = 0;
const Preset &selected_preset = this->get_selected_preset(); const Preset &selected_preset = this->get_selected_preset();
// Show wide icons if the currently selected preset is not compatible with the current printer, // Show wide icons if the currently selected preset is not compatible with the current printer,
// and draw a red flag in front of the selected preset. // and draw a red flag in front of the selected preset.
bool wide_icons = ! selected_preset.is_compatible && m_bitmap_incompatible != nullptr; bool wide_icons = ! selected_preset.is_compatible && m_bitmap_incompatible != nullptr;
/* It's supposed that standard size of an icon is 16px*16px for 100% scaled display. /* It's supposed that standard size of an icon is 16px*16px for 100% scaled display.
* So set sizes for solid_colored icons used for filament preset * So set sizes for solid_colored icons used for filament preset
@ -957,87 +958,87 @@ void PresetCollection::update_platter_ui(GUI::PresetComboBox *ui)
const int thin_space_icon_width = 4 * scale_f + 0.5f; const int thin_space_icon_width = 4 * scale_f + 0.5f;
const int wide_space_icon_width = 6 * scale_f + 0.5f; const int wide_space_icon_width = 6 * scale_f + 0.5f;
std::map<wxString, wxBitmap*> nonsys_presets; std::map<wxString, wxBitmap*> nonsys_presets;
wxString selected = ""; wxString selected = "";
if (!this->m_presets.front().is_visible) if (!this->m_presets.front().is_visible)
ui->set_label_marker(ui->Append(PresetCollection::separator(L("System presets")), wxNullBitmap)); ui->set_label_marker(ui->Append(PresetCollection::separator(L("System presets")), wxNullBitmap));
for (size_t i = this->m_presets.front().is_visible ? 0 : m_num_default_presets; i < this->m_presets.size(); ++ i) { for (size_t i = this->m_presets.front().is_visible ? 0 : m_num_default_presets; i < this->m_presets.size(); ++ i) {
const Preset &preset = this->m_presets[i]; const Preset &preset = this->m_presets[i];
if (! preset.is_visible || (! preset.is_compatible && i != m_idx_selected)) if (! preset.is_visible || (! preset.is_compatible && i != m_idx_selected))
continue; continue;
std::string bitmap_key = ""; std::string bitmap_key = "";
// If the filament preset is not compatible and there is a "red flag" icon loaded, show it left // If the filament preset is not compatible and there is a "red flag" icon loaded, show it left
// to the filament color image. // to the filament color image.
if (wide_icons) if (wide_icons)
bitmap_key += preset.is_compatible ? ",cmpt" : ",ncmpt"; bitmap_key += preset.is_compatible ? ",cmpt" : ",ncmpt";
bitmap_key += (preset.is_system || preset.is_default) ? ",syst" : ",nsyst"; bitmap_key += (preset.is_system || preset.is_default) ? ",syst" : ",nsyst";
wxBitmap *bmp = m_bitmap_cache->find(bitmap_key); wxBitmap *bmp = m_bitmap_cache->find(bitmap_key);
if (bmp == nullptr) { if (bmp == nullptr) {
// Create the bitmap with color bars. // Create the bitmap with color bars.
std::vector<wxBitmap> bmps; std::vector<wxBitmap> bmps;
if (wide_icons) if (wide_icons)
// Paint a red flag for incompatible presets. // Paint a red flag for incompatible presets.
bmps.emplace_back(preset.is_compatible ? m_bitmap_cache->mkclear(icon_width, icon_height) : *m_bitmap_incompatible); bmps.emplace_back(preset.is_compatible ? m_bitmap_cache->mkclear(icon_width, icon_height) : *m_bitmap_incompatible);
// Paint the color bars. // Paint the color bars.
bmps.emplace_back(m_bitmap_cache->mkclear(thin_space_icon_width, icon_height)); bmps.emplace_back(m_bitmap_cache->mkclear(thin_space_icon_width, icon_height));
bmps.emplace_back(*m_bitmap_main_frame); bmps.emplace_back(*m_bitmap_main_frame);
// Paint a lock at the system presets. // Paint a lock at the system presets.
bmps.emplace_back(m_bitmap_cache->mkclear(wide_space_icon_width, icon_height)); bmps.emplace_back(m_bitmap_cache->mkclear(wide_space_icon_width, icon_height));
bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmap_lock : m_bitmap_cache->mkclear(icon_width, icon_height)); bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmap_lock : m_bitmap_cache->mkclear(icon_width, icon_height));
bmp = m_bitmap_cache->insert(bitmap_key, bmps); bmp = m_bitmap_cache->insert(bitmap_key, bmps);
} }
if (preset.is_default || preset.is_system) { if (preset.is_default || preset.is_system) {
ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()),
(bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp);
if (i == m_idx_selected) if (i == m_idx_selected)
selected_preset_item = ui->GetCount() - 1; selected_preset_item = ui->GetCount() - 1;
} }
else else
{ {
nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), bmp/*preset.is_compatible*/); nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), bmp/*preset.is_compatible*/);
if (i == m_idx_selected) if (i == m_idx_selected)
selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str());
} }
if (i + 1 == m_num_default_presets) if (i + 1 == m_num_default_presets)
ui->set_label_marker(ui->Append(PresetCollection::separator(L("System presets")), wxNullBitmap)); ui->set_label_marker(ui->Append(PresetCollection::separator(L("System presets")), wxNullBitmap));
} }
if (!nonsys_presets.empty()) if (!nonsys_presets.empty())
{ {
ui->set_label_marker(ui->Append(PresetCollection::separator(L("User presets")), wxNullBitmap)); ui->set_label_marker(ui->Append(PresetCollection::separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
ui->Append(it->first, *it->second); ui->Append(it->first, *it->second);
if (it->first == selected) if (it->first == selected)
selected_preset_item = ui->GetCount() - 1; selected_preset_item = ui->GetCount() - 1;
} }
} }
if (m_type == Preset::TYPE_PRINTER) { if (m_type == Preset::TYPE_PRINTER) {
std::string bitmap_key = ""; std::string bitmap_key = "";
// If the filament preset is not compatible and there is a "red flag" icon loaded, show it left // If the filament preset is not compatible and there is a "red flag" icon loaded, show it left
// to the filament color image. // to the filament color image.
if (wide_icons) if (wide_icons)
bitmap_key += "wide,"; bitmap_key += "wide,";
bitmap_key += "add_printer"; bitmap_key += "add_printer";
wxBitmap *bmp = m_bitmap_cache->find(bitmap_key); wxBitmap *bmp = m_bitmap_cache->find(bitmap_key);
if (bmp == nullptr) { if (bmp == nullptr) {
// Create the bitmap with color bars. // Create the bitmap with color bars.
std::vector<wxBitmap> bmps; std::vector<wxBitmap> bmps;
if (wide_icons) if (wide_icons)
// Paint a red flag for incompatible presets. // Paint a red flag for incompatible presets.
bmps.emplace_back(m_bitmap_cache->mkclear(icon_width, icon_height)); bmps.emplace_back(m_bitmap_cache->mkclear(icon_width, icon_height));
// Paint the color bars. // Paint the color bars.
bmps.emplace_back(m_bitmap_cache->mkclear(thin_space_icon_width, icon_height)); bmps.emplace_back(m_bitmap_cache->mkclear(thin_space_icon_width, icon_height));
bmps.emplace_back(*m_bitmap_main_frame); bmps.emplace_back(*m_bitmap_main_frame);
// Paint a lock at the system presets. // Paint a lock at the system presets.
bmps.emplace_back(m_bitmap_cache->mkclear(wide_space_icon_width, icon_height)); bmps.emplace_back(m_bitmap_cache->mkclear(wide_space_icon_width, icon_height));
bmps.emplace_back(m_bitmap_add ? *m_bitmap_add : wxNullBitmap); bmps.emplace_back(m_bitmap_add ? *m_bitmap_add : wxNullBitmap);
bmp = m_bitmap_cache->insert(bitmap_key, bmps); bmp = m_bitmap_cache->insert(bitmap_key, bmps);
} }
ui->set_label_marker(ui->Append(PresetCollection::separator(L("Add a new printer")), *bmp), GUI::PresetComboBox::LABEL_ITEM_CONFIG_WIZARD); ui->set_label_marker(ui->Append(PresetCollection::separator(L("Add a new printer")), *bmp), GUI::PresetComboBox::LABEL_ITEM_CONFIG_WIZARD);
} }
ui->SetSelection(selected_preset_item); ui->SetSelection(selected_preset_item);
ui->SetToolTip(ui->GetString(selected_preset_item)); ui->SetToolTip(ui->GetString(selected_preset_item));
ui->check_selection(); ui->check_selection();
ui->Thaw(); ui->Thaw();
@ -1052,7 +1053,7 @@ size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompati
return 0; return 0;
ui->Freeze(); ui->Freeze();
ui->Clear(); ui->Clear();
size_t selected_preset_item = 0; size_t selected_preset_item = 0;
/* It's supposed that standard size of an icon is 16px*16px for 100% scaled display. /* It's supposed that standard size of an icon is 16px*16px for 100% scaled display.
* So set sizes for solid_colored(empty) icons used for preset * So set sizes for solid_colored(empty) icons used for preset
@ -1062,52 +1063,52 @@ size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompati
const int icon_height = 16 * scale_f + 0.5f; const int icon_height = 16 * scale_f + 0.5f;
const int icon_width = 16 * scale_f + 0.5f; const int icon_width = 16 * scale_f + 0.5f;
std::map<wxString, wxBitmap*> nonsys_presets; std::map<wxString, wxBitmap*> nonsys_presets;
wxString selected = ""; wxString selected = "";
if (!this->m_presets.front().is_visible) if (!this->m_presets.front().is_visible)
ui->Append(PresetCollection::separator(L("System presets")), wxNullBitmap); ui->Append(PresetCollection::separator(L("System presets")), wxNullBitmap);
for (size_t i = this->m_presets.front().is_visible ? 0 : m_num_default_presets; i < this->m_presets.size(); ++i) { for (size_t i = this->m_presets.front().is_visible ? 0 : m_num_default_presets; i < this->m_presets.size(); ++i) {
const Preset &preset = this->m_presets[i]; const Preset &preset = this->m_presets[i];
if (! preset.is_visible || (! show_incompatible && ! preset.is_compatible && i != m_idx_selected)) if (! preset.is_visible || (! show_incompatible && ! preset.is_compatible && i != m_idx_selected))
continue; continue;
std::string bitmap_key = "tab"; std::string bitmap_key = "tab";
bitmap_key += preset.is_compatible ? ",cmpt" : ",ncmpt"; bitmap_key += preset.is_compatible ? ",cmpt" : ",ncmpt";
bitmap_key += (preset.is_system || preset.is_default) ? ",syst" : ",nsyst"; bitmap_key += (preset.is_system || preset.is_default) ? ",syst" : ",nsyst";
wxBitmap *bmp = m_bitmap_cache->find(bitmap_key); wxBitmap *bmp = m_bitmap_cache->find(bitmap_key);
if (bmp == nullptr) { if (bmp == nullptr) {
// Create the bitmap with color bars. // Create the bitmap with color bars.
std::vector<wxBitmap> bmps; std::vector<wxBitmap> bmps;
const wxBitmap* tmp_bmp = preset.is_compatible ? m_bitmap_compatible : m_bitmap_incompatible; const wxBitmap* tmp_bmp = preset.is_compatible ? m_bitmap_compatible : m_bitmap_incompatible;
bmps.emplace_back((tmp_bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *tmp_bmp); bmps.emplace_back((tmp_bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *tmp_bmp);
// Paint a lock at the system presets. // Paint a lock at the system presets.
bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmap_lock : m_bitmap_cache->mkclear(icon_width, icon_height)); bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmap_lock : m_bitmap_cache->mkclear(icon_width, icon_height));
bmp = m_bitmap_cache->insert(bitmap_key, bmps); bmp = m_bitmap_cache->insert(bitmap_key, bmps);
} }
if (preset.is_default || preset.is_system) { if (preset.is_default || preset.is_system) {
ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()),
(bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp);
if (i == m_idx_selected) if (i == m_idx_selected)
selected_preset_item = ui->GetCount() - 1; selected_preset_item = ui->GetCount() - 1;
} }
else else
{ {
nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), bmp/*preset.is_compatible*/); nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), bmp/*preset.is_compatible*/);
if (i == m_idx_selected) if (i == m_idx_selected)
selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str());
} }
if (i + 1 == m_num_default_presets) if (i + 1 == m_num_default_presets)
ui->Append(PresetCollection::separator(L("System presets")), wxNullBitmap); ui->Append(PresetCollection::separator(L("System presets")), wxNullBitmap);
}
if (!nonsys_presets.empty())
{
ui->Append(PresetCollection::separator(L("User presets")), wxNullBitmap);
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
ui->Append(it->first, *it->second);
if (it->first == selected)
selected_preset_item = ui->GetCount() - 1;
}
} }
if (!nonsys_presets.empty())
{
ui->Append(PresetCollection::separator(L("User presets")), wxNullBitmap);
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
ui->Append(it->first, *it->second);
if (it->first == selected)
selected_preset_item = ui->GetCount() - 1;
}
}
if (m_type == Preset::TYPE_PRINTER) { if (m_type == Preset::TYPE_PRINTER) {
wxBitmap *bmp = m_bitmap_cache->find("add_printer_tab"); wxBitmap *bmp = m_bitmap_cache->find("add_printer_tab");
if (bmp == nullptr) { if (bmp == nullptr) {
@ -1119,10 +1120,10 @@ size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompati
} }
ui->Append(PresetCollection::separator("Add a new printer"), *bmp); ui->Append(PresetCollection::separator("Add a new printer"), *bmp);
} }
ui->SetSelection(selected_preset_item); ui->SetSelection(selected_preset_item);
ui->SetToolTip(ui->GetString(selected_preset_item)); ui->SetToolTip(ui->GetString(selected_preset_item));
ui->Thaw(); ui->Thaw();
return selected_preset_item; return selected_preset_item;
} }
// Update a dirty floag of the current preset, update the labels of the UI component accordingly. // Update a dirty floag of the current preset, update the labels of the UI component accordingly.
@ -1142,11 +1143,11 @@ bool PresetCollection::update_dirty_ui(wxBitmapComboBox *ui)
const Preset *preset = this->find_preset(preset_name, false); const Preset *preset = this->find_preset(preset_name, false);
// The old_label could be the "----- system presets ------" or the "------- user presets --------" separator. // The old_label could be the "----- system presets ------" or the "------- user presets --------" separator.
// assert(preset != nullptr); // assert(preset != nullptr);
if (preset != nullptr) { if (preset != nullptr) {
std::string new_label = preset->is_dirty ? preset->name + g_suffix_modified : preset->name; std::string new_label = preset->is_dirty ? preset->name + g_suffix_modified : preset->name;
if (old_label != new_label) if (old_label != new_label)
ui->SetString(ui_id, wxString::FromUTF8(new_label.c_str())); ui->SetString(ui_id, wxString::FromUTF8(new_label.c_str()));
} }
} }
#ifdef __APPLE__ #ifdef __APPLE__
// wxWidgets on OSX do not upload the text of the combo box line automatically. // wxWidgets on OSX do not upload the text of the combo box line automatically.
@ -1159,15 +1160,15 @@ bool PresetCollection::update_dirty_ui(wxBitmapComboBox *ui)
template<class T> template<class T>
void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys& vec, const ConfigBase &other, const ConfigBase &this_c) void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys& vec, const ConfigBase &other, const ConfigBase &this_c)
{ {
const T* opt_init = static_cast<const T*>(other.option(opt_key)); const T* opt_init = static_cast<const T*>(other.option(opt_key));
const T* opt_cur = static_cast<const T*>(this_c.option(opt_key)); const T* opt_cur = static_cast<const T*>(this_c.option(opt_key));
int opt_init_max_id = opt_init->values.size() - 1; int opt_init_max_id = opt_init->values.size() - 1;
for (int i = 0; i < opt_cur->values.size(); i++) for (int i = 0; i < opt_cur->values.size(); i++)
{ {
int init_id = i <= opt_init_max_id ? i : 0; int init_id = i <= opt_init_max_id ? i : 0;
if (opt_cur->values[i] != opt_init->values[init_id]) if (opt_cur->values[i] != opt_init->values[init_id])
vec.emplace_back(opt_key + "#" + std::to_string(i)); vec.emplace_back(opt_key + "#" + std::to_string(i));
} }
} }
// Use deep_diff to correct return of changed options, considering individual options for each extruder. // Use deep_diff to correct return of changed options, considering individual options for each extruder.
@ -1201,10 +1202,10 @@ inline t_config_option_keys deep_diff(const ConfigBase &config_this, const Confi
std::vector<std::string> PresetCollection::dirty_options(const Preset *edited, const Preset *reference, const bool deep_compare /*= false*/) std::vector<std::string> PresetCollection::dirty_options(const Preset *edited, const Preset *reference, const bool deep_compare /*= false*/)
{ {
std::vector<std::string> changed; std::vector<std::string> changed;
if (edited != nullptr && reference != nullptr) { if (edited != nullptr && reference != nullptr) {
changed = deep_compare ? changed = deep_compare ?
deep_diff(edited->config, reference->config) : deep_diff(edited->config, reference->config) :
reference->config.diff(edited->config); reference->config.diff(edited->config);
// The "compatible_printers" option key is handled differently from the others: // The "compatible_printers" option key is handled differently from the others:
// It is not mandatory. If the key is missing, it means it is compatible with any printer. // It is not mandatory. If the key is missing, it means it is compatible with any printer.
// If the key exists and it is empty, it means it is compatible with no printer. // If the key exists and it is empty, it means it is compatible with no printer.
@ -1227,19 +1228,19 @@ Preset& PresetCollection::select_preset(size_t idx)
idx = first_visible_idx(); idx = first_visible_idx();
m_idx_selected = idx; m_idx_selected = idx;
m_edited_preset = m_presets[idx]; m_edited_preset = m_presets[idx];
bool default_visible = ! m_default_suppressed || m_idx_selected < m_num_default_presets; bool default_visible = ! m_default_suppressed || m_idx_selected < m_num_default_presets;
for (size_t i = 0; i < m_num_default_presets; ++i) for (size_t i = 0; i < m_num_default_presets; ++i)
m_presets[i].is_visible = default_visible; m_presets[i].is_visible = default_visible;
return m_presets[idx]; return m_presets[idx];
} }
bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, bool force) bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, bool force)
{ {
std::string name = Preset::remove_suffix_modified(name_w_suffix); std::string name = Preset::remove_suffix_modified(name_w_suffix);
// 1) Try to find the preset by its name. // 1) Try to find the preset by its name.
auto it = this->find_preset_internal(name); auto it = this->find_preset_internal(name);
size_t idx = 0; size_t idx = 0;
if (it != m_presets.end() && it->name == name && it->is_visible) if (it != m_presets.end() && it->name == name && it->is_visible)
// Preset found by its name and it is visible. // Preset found by its name and it is visible.
idx = it - m_presets.begin(); idx = it - m_presets.begin();
else { else {
@ -1262,11 +1263,11 @@ bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, b
} }
bool PresetCollection::select_preset_by_name_strict(const std::string &name) bool PresetCollection::select_preset_by_name_strict(const std::string &name)
{ {
// 1) Try to find the preset by its name. // 1) Try to find the preset by its name.
auto it = this->find_preset_internal(name); auto it = this->find_preset_internal(name);
size_t idx = (size_t)-1; size_t idx = (size_t)-1;
if (it != m_presets.end() && it->name == name && it->is_visible) if (it != m_presets.end() && it->name == name && it->is_visible)
// Preset found by its name. // Preset found by its name.
idx = it - m_presets.begin(); idx = it - m_presets.begin();
// 2) Select the new preset. // 2) Select the new preset.
@ -1333,9 +1334,9 @@ std::vector<std::string> PresetCollection::system_preset_names() const
++ num; ++ num;
std::vector<std::string> out; std::vector<std::string> out;
out.reserve(num); out.reserve(num);
for (const Preset &preset : m_presets) for (const Preset &preset : m_presets)
if (preset.is_system) if (preset.is_system)
out.emplace_back(preset.name); out.emplace_back(preset.name);
std::sort(out.begin(), out.end()); std::sort(out.begin(), out.end());
return out; return out;
} }
@ -1343,7 +1344,7 @@ std::vector<std::string> PresetCollection::system_preset_names() const
// Generate a file path from a profile name. Add the ".ini" suffix if it is missing. // Generate a file path from a profile name. Add the ".ini" suffix if it is missing.
std::string PresetCollection::path_from_name(const std::string &new_name) const std::string PresetCollection::path_from_name(const std::string &new_name) const
{ {
std::string file_name = boost::iends_with(new_name, ".ini") ? new_name : (new_name + ".ini"); std::string file_name = boost::iends_with(new_name, ".ini") ? new_name : (new_name + ".ini");
return (boost::filesystem::path(m_dir_path) / file_name).make_preferred().string(); return (boost::filesystem::path(m_dir_path) / file_name).make_preferred().string();
} }
@ -1354,13 +1355,13 @@ void PresetCollection::clear_bitmap_cache()
wxString PresetCollection::separator(const std::string &label) wxString PresetCollection::separator(const std::string &label)
{ {
return wxString::FromUTF8(PresetCollection::separator_head()) + _(label) + wxString::FromUTF8(PresetCollection::separator_tail()); return wxString::FromUTF8(PresetCollection::separator_head()) + _(label) + wxString::FromUTF8(PresetCollection::separator_tail());
} }
const Preset& PrinterPresetCollection::default_preset_for(const DynamicPrintConfig &config) const const Preset& PrinterPresetCollection::default_preset_for(const DynamicPrintConfig &config) const
{ {
const ConfigOptionEnumGeneric *opt_printer_technology = config.opt<ConfigOptionEnumGeneric>("printer_technology"); const ConfigOptionEnumGeneric *opt_printer_technology = config.opt<ConfigOptionEnumGeneric>("printer_technology");
return this->default_preset((opt_printer_technology == nullptr || opt_printer_technology->value == ptFFF) ? 0 : 1); return this->default_preset((opt_printer_technology == nullptr || opt_printer_technology->value == ptFFF) ? 0 : 1);
} }
const Preset* PrinterPresetCollection::find_by_model_id(const std::string &model_id) const const Preset* PrinterPresetCollection::find_by_model_id(const std::string &model_id) const

File diff suppressed because it is too large Load Diff