Add material_type config option for SLA materials, use in Wizard

This commit is contained in:
Vojtech Kral 2019-08-02 16:15:27 +02:00
parent 235b659cf9
commit 270008a3fd
6 changed files with 71 additions and 41 deletions

View file

@ -1966,6 +1966,7 @@ exposure_time = 6
initial_exposure_time = 40 initial_exposure_time = 40
[sla_material:BlueCast Keramaster Dental 0.025] [sla_material:BlueCast Keramaster Dental 0.025]
material_type = Dental
inherits = *common 0.025* inherits = *common 0.025*
exposure_time = 6 exposure_time = 6
initial_exposure_time = 45 initial_exposure_time = 45
@ -2042,6 +2043,7 @@ initial_exposure_time = 45
material_vendor = Bluecast material_vendor = Bluecast
[sla_material:BlueCast Keramaster Dental 0.05] [sla_material:BlueCast Keramaster Dental 0.05]
material_type = Dental
inherits = *common 0.05* inherits = *common 0.05*
exposure_time = 7 exposure_time = 7
initial_exposure_time = 50 initial_exposure_time = 50

View file

@ -2401,6 +2401,18 @@ void PrintConfigDef::init_sla_params()
// SLA Material settings. // SLA Material settings.
def = this->add("material_type", coString);
def->label = L("SLA material type");
def->tooltip = L("SLA material type");
def->gui_type = "f_enum_open"; // TODO: ???
def->gui_flags = "show_value";
def->enum_values.push_back("Tough");
def->enum_values.push_back("Flexible");
def->enum_values.push_back("Casting");
def->enum_values.push_back("Dental");
def->enum_values.push_back("Heat-resistant");
def->set_default_value(new ConfigOptionString("Tough"));
def = this->add("initial_layer_height", coFloat); def = this->add("initial_layer_height", coFloat);
def->label = L("Initial layer height"); def->label = L("Initial layer height");
def->tooltip = L("Initial layer height"); def->tooltip = L("Initial layer height");

View file

@ -52,6 +52,14 @@ enum FilamentType {
}; };
*/ */
enum SLAMaterial {
slamTough,
slamFlex,
slamCasting,
slamDental,
slamHeatResistant,
};
enum SLADisplayOrientation { enum SLADisplayOrientation {
sladoLandscape, sladoLandscape,
sladoPortrait sladoPortrait

View file

@ -235,7 +235,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
auto *cbox = new Checkbox(variants_panel, label, model_id, variant.name); auto *cbox = new Checkbox(variants_panel, label, model_id, variant.name);
i == 0 ? cboxes.push_back(cbox) : cboxes_alt.push_back(cbox); i == 0 ? cboxes.push_back(cbox) : cboxes_alt.push_back(cbox);
bool enabled = appconfig.get_variant(vendor.id, model_id, variant.name); const bool enabled = appconfig.get_variant(vendor.id, model_id, variant.name);
cbox->SetValue(enabled); cbox->SetValue(enabled);
variants_sizer->Add(cbox, 0, wxBOTTOM, 3); variants_sizer->Add(cbox, 0, wxBOTTOM, 3);
@ -731,10 +731,7 @@ PageUpdate::PageUpdate(ConfigWizard *parent)
PageVendors::PageVendors(ConfigWizard *parent) PageVendors::PageVendors(ConfigWizard *parent)
: ConfigWizardPage(parent, _(L("Other Vendors")), _(L("Other Vendors"))) : ConfigWizardPage(parent, _(L("Other Vendors")), _(L("Other Vendors")))
{ {
const AppConfig &appconfig = this->wizard_p()->appconfig_new;
// FIXME: persistence: this doesn't reload choices
append_text(wxString::Format(_(L("Pick another vendor supported by %s: (FIXME: this text)")), SLIC3R_APP_NAME)); append_text(wxString::Format(_(L("Pick another vendor supported by %s: (FIXME: this text)")), SLIC3R_APP_NAME));
@ -750,6 +747,16 @@ PageVendors::PageVendors(ConfigWizard *parent)
wizard_p()->on_3rdparty_install(vendor, cbox->IsChecked()); wizard_p()->on_3rdparty_install(vendor, cbox->IsChecked());
}); });
const auto &vendors = appconfig.vendors();
const bool enabled = vendors.find(pair.first) != vendors.end();
if (enabled) {
cbox->SetValue(true);
auto pair = wizard_p()->pages_3rdparty.find(vendor->id);
wxCHECK_RET(pair != wizard_p()->pages_3rdparty.end(), "Internal error: 3rd party vendor printers page not created");
pair->second->install = true;
}
append(cbox); append(cbox);
} }
} }
@ -1176,19 +1183,11 @@ const std::string& Materials::get_filament_vendor(const Preset &preset)
const std::string& Materials::get_material_type(Preset &preset) const std::string& Materials::get_material_type(Preset &preset)
{ {
// XXX: The initial_layer_height is of a float type and contains no string to reference, const auto *opt = preset.config.opt<ConfigOptionString>("material_type");
// and so here we serialize it into an ad-hoc option initial_layer_height_str, which is then referenced if (opt != nullptr) {
return opt->value;
const auto *opt_str = preset.config.opt<ConfigOptionString>("initial_layer_height_str");
if (opt_str == nullptr) {
const auto *opt = preset.config.opt<ConfigOptionFloat>("initial_layer_height");
if (opt == nullptr) { return UNKNOWN; }
auto *new_opt_str = new ConfigOptionString(opt->serialize());
preset.config.set_key_value("initial_layer_height_str", new_opt_str);
return new_opt_str->value;
} else { } else {
return opt_str->value; return UNKNOWN;
} }
} }
@ -1366,12 +1365,17 @@ void ConfigWizard::priv::load_vendors()
// apply defaults from vendor profiles if there are no selections yet. // apply defaults from vendor profiles if there are no selections yet.
// bundle.init_materials_selection(*app_config); // bundle.init_materials_selection(*app_config);
// XXX: ? // TODO: load up sane defaults if no previous data in AppConfig
// wxCHECK_RET(app_config->has_section(AppConfig::SECTION_FILAMENTS) && app_config->has_section(AppConfig::SECTION_MATERIALS), // as per the design doc:
// "Failed to initialize default material selections"); // - all f/m for installed printers if prev Slicer version
// - default f/m set from bundle + default for each printer from bundle if fresh install
if (app_config->has_section(AppConfig::SECTION_FILAMENTS)) {
appconfig_new.set_section(AppConfig::SECTION_FILAMENTS, app_config->get_section(AppConfig::SECTION_FILAMENTS)); appconfig_new.set_section(AppConfig::SECTION_FILAMENTS, app_config->get_section(AppConfig::SECTION_FILAMENTS));
}
if (app_config->has_section(AppConfig::SECTION_MATERIALS)) {
appconfig_new.set_section(AppConfig::SECTION_MATERIALS, app_config->get_section(AppConfig::SECTION_MATERIALS)); appconfig_new.set_section(AppConfig::SECTION_MATERIALS, app_config->get_section(AppConfig::SECTION_MATERIALS));
} }
}
void ConfigWizard::priv::add_page(ConfigWizardPage *page) void ConfigWizard::priv::add_page(ConfigWizardPage *page)
{ {
@ -1437,6 +1441,10 @@ void ConfigWizard::priv::on_3rdparty_install(const VendorProfile *vendor, bool i
auto it = pages_3rdparty.find(vendor->id); auto it = pages_3rdparty.find(vendor->id);
wxCHECK_RET(it != pages_3rdparty.end(), "Internal error: GUI page not found for 3rd party vendor profile"); wxCHECK_RET(it != pages_3rdparty.end(), "Internal error: GUI page not found for 3rd party vendor profile");
PagePrinters *page = it->second; PagePrinters *page = it->second;
if (page->install && !install) {
page->select_all(false);
}
page->install = install; page->install = install;
page->Layout(); page->Layout();
@ -1525,7 +1533,7 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
// The default is the first selected printer model (one with at least 1 variant selected). // The default is the first selected printer model (one with at least 1 variant selected).
// The default is only applied by load_presets() if the user doesn't have a (visible) printer // The default is only applied by load_presets() if the user doesn't have a (visible) printer
// selected already. // selected already.
// TODO // TODO:
// const auto vendor_prusa = bundle.vendors.find("PrusaResearch"); // const auto vendor_prusa = bundle.vendors.find("PrusaResearch");
// const auto config_prusa = enabled_vendors.find("PrusaResearch"); // const auto config_prusa = enabled_vendors.find("PrusaResearch");
// if (vendor_prusa != bundle.vendors.end() && config_prusa != enabled_vendors.end()) { // if (vendor_prusa != bundle.vendors.end() && config_prusa != enabled_vendors.end()) {
@ -1617,13 +1625,14 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
p->add_page(p->page_custom = new PageCustom(this)); p->add_page(p->page_custom = new PageCustom(this));
p->add_page(p->page_update = new PageUpdate(this)); p->add_page(p->page_update = new PageUpdate(this));
p->add_page(p->page_vendors = new PageVendors(this));
p->add_page(p->page_firmware = new PageFirmware(this)); p->add_page(p->page_firmware = new PageFirmware(this));
p->add_page(p->page_bed = new PageBedShape(this)); p->add_page(p->page_bed = new PageBedShape(this));
p->add_page(p->page_diams = new PageDiameters(this)); p->add_page(p->page_diams = new PageDiameters(this));
p->add_page(p->page_temps = new PageTemperatures(this)); p->add_page(p->page_temps = new PageTemperatures(this));
p->create_3rdparty_pages(); // Pages for 3rd party vendors
p->create_3rdparty_pages(); // Needs to ne done _before_ creating PageVendors
p->add_page(p->page_vendors = new PageVendors(this));
p->any_sla_selected = p->page_msla->any_selected(); p->any_sla_selected = p->page_msla->any_selected();
p->any_fff_selected = p->page_fff->any_selected(); p->any_fff_selected = p->page_fff->any_selected();

View file

@ -96,7 +96,7 @@ struct Bundle
const std::string& vendor_id() const { return vendor_profile->id; } const std::string& vendor_id() const { return vendor_profile->id; }
}; };
struct BundleMap: std::unordered_map<std::string, Bundle> struct BundleMap: std::unordered_map<std::string /* = vendor ID */, Bundle>
{ {
static BundleMap load(); static BundleMap load();
@ -277,11 +277,7 @@ struct PageUpdate: ConfigWizardPage
struct PageVendors: ConfigWizardPage struct PageVendors: ConfigWizardPage
{ {
// std::vector<PrinterPicker*> pickers;
PageVendors(ConfigWizard *parent); PageVendors(ConfigWizard *parent);
// void on_vendor_pick(size_t i);
}; };
struct PageFirmware: ConfigWizardPage struct PageFirmware: ConfigWizardPage
@ -319,6 +315,8 @@ struct PageTemperatures: ConfigWizardPage
virtual void apply_custom_config(DynamicPrintConfig &config); virtual void apply_custom_config(DynamicPrintConfig &config);
}; };
typedef std::map<std::string /* = vendor ID */, PagePrinters*> Pages3rdparty;
class ConfigWizardIndex: public wxPanel class ConfigWizardIndex: public wxPanel
{ {
@ -412,7 +410,7 @@ struct ConfigWizard::priv
PageCustom *page_custom = nullptr; PageCustom *page_custom = nullptr;
PageUpdate *page_update = nullptr; PageUpdate *page_update = nullptr;
PageVendors *page_vendors = nullptr; // XXX: ? PageVendors *page_vendors = nullptr; // XXX: ?
std::map<std::string, PagePrinters*> pages_3rdparty; Pages3rdparty pages_3rdparty;
// Custom setup pages // Custom setup pages
PageFirmware *page_firmware = nullptr; PageFirmware *page_firmware = nullptr;

View file

@ -531,6 +531,7 @@ 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 = {
"material_type",
"initial_layer_height", "initial_layer_height",
"exposure_time", "exposure_time",
"initial_exposure_time", "initial_exposure_time",