From 270008a3fd7bade37d5cd26e1c219fa26cc42738 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 2 Aug 2019 16:15:27 +0200 Subject: [PATCH] Add material_type config option for SLA materials, use in Wizard --- resources/profiles/PrusaResearch.ini | 2 + src/libslic3r/PrintConfig.cpp | 12 ++++ src/libslic3r/PrintConfig.hpp | 8 +++ src/slic3r/GUI/ConfigWizard.cpp | 79 ++++++++++++++----------- src/slic3r/GUI/ConfigWizard_private.hpp | 10 ++-- src/slic3r/GUI/Preset.cpp | 1 + 6 files changed, 71 insertions(+), 41 deletions(-) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 690471334..9add73b4d 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -1966,6 +1966,7 @@ exposure_time = 6 initial_exposure_time = 40 [sla_material:BlueCast Keramaster Dental 0.025] +material_type = Dental inherits = *common 0.025* exposure_time = 6 initial_exposure_time = 45 @@ -2042,6 +2043,7 @@ initial_exposure_time = 45 material_vendor = Bluecast [sla_material:BlueCast Keramaster Dental 0.05] +material_type = Dental inherits = *common 0.05* exposure_time = 7 initial_exposure_time = 50 diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index ac30941cb..6a57125d0 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2401,6 +2401,18 @@ void PrintConfigDef::init_sla_params() // 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->label = L("Initial layer height"); def->tooltip = L("Initial layer height"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 6a19edf84..fc1916f1b 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -52,6 +52,14 @@ enum FilamentType { }; */ +enum SLAMaterial { + slamTough, + slamFlex, + slamCasting, + slamDental, + slamHeatResistant, +}; + enum SLADisplayOrientation { sladoLandscape, sladoPortrait diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 8a850b7a0..1c70ad726 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -235,7 +235,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt auto *cbox = new Checkbox(variants_panel, label, model_id, variant.name); 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); variants_sizer->Add(cbox, 0, wxBOTTOM, 3); @@ -731,10 +731,7 @@ PageUpdate::PageUpdate(ConfigWizard *parent) PageVendors::PageVendors(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Other Vendors")), _(L("Other Vendors"))) { - - - // FIXME: persistence: this doesn't reload choices - + const AppConfig &appconfig = this->wizard_p()->appconfig_new; 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()); }); + 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); } } @@ -866,18 +873,18 @@ void PageDiameters::apply_custom_config(DynamicPrintConfig &config) auto set_extrusion_width = [&config, opt_nozzle](const char *key, double dmr) { char buf[64]; sprintf(buf, "%.2lf", dmr * opt_nozzle->values.front() / 0.4); - config.set_key_value(key, new ConfigOptionFloatOrPercent(atof(buf), false)); - }; + config.set_key_value(key, new ConfigOptionFloatOrPercent(atof(buf), false)); + }; set_extrusion_width("support_material_extrusion_width", 0.35); - set_extrusion_width("top_infill_extrusion_width", 0.40); - set_extrusion_width("first_layer_extrusion_width", 0.42); + set_extrusion_width("top_infill_extrusion_width", 0.40); + set_extrusion_width("first_layer_extrusion_width", 0.42); - set_extrusion_width("extrusion_width", 0.45); - set_extrusion_width("perimeter_extrusion_width", 0.45); - set_extrusion_width("external_perimeter_extrusion_width", 0.45); - set_extrusion_width("infill_extrusion_width", 0.45); - set_extrusion_width("solid_infill_extrusion_width", 0.45); + set_extrusion_width("extrusion_width", 0.45); + set_extrusion_width("perimeter_extrusion_width", 0.45); + set_extrusion_width("external_perimeter_extrusion_width", 0.45); + set_extrusion_width("infill_extrusion_width", 0.45); + set_extrusion_width("solid_infill_extrusion_width", 0.45); } PageTemperatures::PageTemperatures(ConfigWizard *parent) @@ -1114,7 +1121,7 @@ void ConfigWizardIndex::on_mouse_move(wxMouseEvent &evt) const ssize_t item_hover_new = pos.y / item_height(); - if (item_hover_new < ssize_t(items.size()) && item_hover_new != item_hover) { + if (item_hover_new < ssize_t(items.size()) && item_hover_new != item_hover) { item_hover = item_hover_new; Refresh(); } @@ -1176,19 +1183,11 @@ const std::string& Materials::get_filament_vendor(const 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, - // and so here we serialize it into an ad-hoc option initial_layer_height_str, which is then referenced - - const auto *opt_str = preset.config.opt("initial_layer_height_str"); - if (opt_str == nullptr) { - const auto *opt = preset.config.opt("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; + const auto *opt = preset.config.opt("material_type"); + if (opt != nullptr) { + return opt->value; } else { - return opt_str->value; + return UNKNOWN; } } @@ -1366,11 +1365,16 @@ void ConfigWizard::priv::load_vendors() // apply defaults from vendor profiles if there are no selections yet. // bundle.init_materials_selection(*app_config); - // XXX: ? - // wxCHECK_RET(app_config->has_section(AppConfig::SECTION_FILAMENTS) && app_config->has_section(AppConfig::SECTION_MATERIALS), - // "Failed to initialize default material selections"); - appconfig_new.set_section(AppConfig::SECTION_FILAMENTS, app_config->get_section(AppConfig::SECTION_FILAMENTS)); - appconfig_new.set_section(AppConfig::SECTION_MATERIALS, app_config->get_section(AppConfig::SECTION_MATERIALS)); + // TODO: load up sane defaults if no previous data in AppConfig + // as per the design doc: + // - 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)); + } + if (app_config->has_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) @@ -1437,6 +1441,10 @@ void ConfigWizard::priv::on_3rdparty_install(const VendorProfile *vendor, bool i auto it = pages_3rdparty.find(vendor->id); wxCHECK_RET(it != pages_3rdparty.end(), "Internal error: GUI page not found for 3rd party vendor profile"); PagePrinters *page = it->second; + + if (page->install && !install) { + page->select_all(false); + } page->install = install; 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 only applied by load_presets() if the user doesn't have a (visible) printer // selected already. -// TODO +// TODO: // const auto vendor_prusa = bundle.vendors.find("PrusaResearch"); // const auto config_prusa = enabled_vendors.find("PrusaResearch"); // 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_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_bed = new PageBedShape(this)); p->add_page(p->page_diams = new PageDiameters(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_fff_selected = p->page_fff->any_selected(); diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index e6f389785..708eb94fc 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -96,7 +96,7 @@ struct Bundle const std::string& vendor_id() const { return vendor_profile->id; } }; -struct BundleMap: std::unordered_map +struct BundleMap: std::unordered_map { static BundleMap load(); @@ -277,11 +277,7 @@ struct PageUpdate: ConfigWizardPage struct PageVendors: ConfigWizardPage { - // std::vector pickers; - PageVendors(ConfigWizard *parent); - - // void on_vendor_pick(size_t i); }; struct PageFirmware: ConfigWizardPage @@ -319,6 +315,8 @@ struct PageTemperatures: ConfigWizardPage virtual void apply_custom_config(DynamicPrintConfig &config); }; +typedef std::map Pages3rdparty; + class ConfigWizardIndex: public wxPanel { @@ -412,7 +410,7 @@ struct ConfigWizard::priv PageCustom *page_custom = nullptr; PageUpdate *page_update = nullptr; PageVendors *page_vendors = nullptr; // XXX: ? - std::map pages_3rdparty; + Pages3rdparty pages_3rdparty; // Custom setup pages PageFirmware *page_firmware = nullptr; diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index be53267f9..9b16d9480 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -531,6 +531,7 @@ const std::vector& Preset::sla_material_options() static std::vector s_opts; if (s_opts.empty()) { s_opts = { + "material_type", "initial_layer_height", "exposure_time", "initial_exposure_time",