Implemented the "Support for support enforcers only" quick selection.

Reduced some memory leaks due to the ConfigDef::default_value pointer.
This commit is contained in:
bubnikv 2019-05-03 18:01:39 +02:00
parent 1c6006f657
commit a61e833536
14 changed files with 559 additions and 388 deletions

View file

@ -394,16 +394,27 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
}
new_conf.set_key_value("brim_width", new ConfigOptionFloat(new_val));
}
else { //(opt_key == "support")
else {
assert(opt_key == "support");
const wxString& selection = boost::any_cast<wxString>(value);
PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
auto support_material = selection == _("None") ? false : true;
new_conf.set_key_value("support_material", new ConfigOptionBool(support_material));
if (selection == _("Everywhere"))
if (selection == _("Everywhere")) {
new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(false));
else if (selection == _("Support on build plate only"))
if (printer_technology == ptFFF)
new_conf.set_key_value("support_material_auto", new ConfigOptionBool(true));
} else if (selection == _("Support on build plate only")) {
new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(true));
if (printer_technology == ptFFF)
new_conf.set_key_value("support_material_auto", new ConfigOptionBool(true));
} else if (selection == _("For support enforcers only")) {
assert(printer_technology == ptFFF);
new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(false));
new_conf.set_key_value("support_material_auto", new ConfigOptionBool(false));
}
}
tab_print->load_config(new_conf);
}
@ -421,12 +432,9 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
support_def.tooltip = L("Select what kind of support do you need");
support_def.enum_labels.push_back(L("None"));
support_def.enum_labels.push_back(L("Support on build plate only"));
support_def.enum_labels.push_back(L("For support enforcers only"));
support_def.enum_labels.push_back(L("Everywhere"));
std::string selection = !config->opt_bool("support_material") ?
"None" : config->opt_bool("support_material_buildplate_only") ?
"Support on build plate only" :
"Everywhere";
support_def.default_value = new ConfigOptionStrings{ selection };
support_def.set_default_value(new ConfigOptionStrings{ "None" });
Option option = Option(support_def, "support");
option.opt.full_width = true;
line.append_option(option);
@ -447,7 +455,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
def.type = coBool;
def.tooltip = L("This flag enables the brim that will be printed around each object on the first layer.");
def.gui_type = "";
def.default_value = new ConfigOptionBool{ m_brim_width > 0.0 ? true : false };
def.set_default_value(new ConfigOptionBool{ m_brim_width > 0.0 ? true : false });
option = Option(def, "brim");
option.opt.sidetext = " ";
line.append_option(option);
@ -493,8 +501,9 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
tab->set_value(opt_key, value);
tab->update();
}
else //(opt_key == "support")
else
{
assert(opt_key == "support");
DynamicPrintConfig new_conf = *config_sla;
const wxString& selection = boost::any_cast<wxString>(value);
@ -514,17 +523,15 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
line = Line{ "", "" };
selection = !config_sla->opt_bool("supports_enable") ?
"None" : config_sla->opt_bool("support_buildplate_only") ?
"Support on build plate only" :
"Everywhere";
support_def.default_value = new ConfigOptionStrings{ selection };
option = Option(support_def, "support");
ConfigOptionDef support_def_sla = support_def;
support_def_sla.set_default_value(new ConfigOptionStrings{ "None" });
assert(support_def_sla.enum_labels[2] == L("For support enforcers only"));
support_def_sla.enum_labels.erase(support_def_sla.enum_labels.begin() + 2);
option = Option(support_def_sla, "support");
option.opt.full_width = true;
line.append_option(option);
m_og_sla->append_line(line);
line = Line{ "", "" };
option = m_og_sla->get_option("pad_enable");