From cce0e9e5019068c168977ce093aa1a1a99b68ec7 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 3 Aug 2018 13:04:41 +0200 Subject: [PATCH] First prototype for "SLA materials" Tab --- xs/src/libslic3r/PrintConfig.cpp | 4 +- xs/src/slic3r/GUI/GUI.cpp | 9 ++-- xs/src/slic3r/GUI/Preset.cpp | 18 ++++--- xs/src/slic3r/GUI/Preset.hpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 86 ++++++++++++++++++++++++++++++++ xs/src/slic3r/GUI/Tab.hpp | 12 +++++ 6 files changed, 118 insertions(+), 13 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 698156d59..881b2dd11 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -2124,13 +2124,13 @@ void PrintConfigDef::init_sla_params() def->default_value = new ConfigOptionFloat(15); def = this->add("material_correction_printing", coFloats); - def->label = L("Correction for expansion when printing"); + def->full_label = L("Correction for expansion when printing"); def->tooltip = L("Correction for expansion when printing"); def->min = 0; def->default_value = new ConfigOptionFloats( { 1. , 1., 1. } ); def = this->add("material_correction_curing", coFloats); - def->label = L("Correction for expansion after curing"); + def->full_label = L("Correction for expansion after curing"); def->tooltip = L("Correction for expansion after curing"); def->min = 0; def->default_value = new ConfigOptionFloats( { 1. , 1., 1. } ); diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 9c62fe8eb..b8632d18b 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -496,12 +496,13 @@ void open_preferences_dialog(int event_preferences) void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) { update_label_colours_from_appconfig(); - add_created_tab(new TabPrint (g_wxTabPanel, no_controller)); - add_created_tab(new TabFilament (g_wxTabPanel, no_controller)); - add_created_tab(new TabPrinter (g_wxTabPanel, no_controller)); + add_created_tab(new TabPrint (g_wxTabPanel, no_controller)); + add_created_tab(new TabFilament (g_wxTabPanel, no_controller)); + add_created_tab(new TabSLAMaterial (g_wxTabPanel, no_controller)); + add_created_tab(new TabPrinter (g_wxTabPanel, no_controller)); for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) { Tab *tab = dynamic_cast(g_wxTabPanel->GetPage(i)); - if (! tab) + if (! tab || tab->GetName()=="sla_material") continue; tab->set_event_value_change(wxEventType(event_value_change)); tab->set_event_presets_changed(wxEventType(event_presets_changed)); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 71a2bb6a5..642346d6b 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -211,11 +211,17 @@ void Preset::normalize(DynamicPrintConfig &config) // Load a config file, return a C++ class Slic3r::DynamicPrintConfig with $keys initialized from the config file. // In case of a "default" config item, return the default values. -DynamicPrintConfig& Preset::load(const std::vector &keys) +DynamicPrintConfig& Preset::load(const std::vector &keys, Preset::Type& type) { // Set the configuration from the defaults. - Slic3r::FullPrintConfig defaults; - this->config.apply_only(defaults, keys.empty() ? defaults.keys() : keys); + if (type == TYPE_SLA_MATERIAL) { + Slic3r::SLAFullPrintConfig defaults; + this->config.apply_only(defaults, keys.empty() ? defaults.keys() : keys); + } + else { + Slic3r::FullPrintConfig defaults; + this->config.apply_only(defaults, keys.empty() ? defaults.keys() : keys); + } if (! this->is_default) { // Load the preset file, apply preset values on top of defaults. try { @@ -405,7 +411,7 @@ PresetCollection::PresetCollection(Preset::Type type, const std::vectoradd_default_preset(keys, default_name); - m_presets.front().load(keys); + m_presets.front().load(keys, m_type); m_edited_preset.config.apply(m_presets.front().config); } @@ -436,7 +442,7 @@ void PresetCollection::add_default_preset(const std::vector &keys, { // Insert just the default preset. m_presets.emplace_back(Preset(this->type(), preset_name, true)); - m_presets.back().load(keys); + m_presets.back().load(keys, m_type); ++ m_num_default_presets; } @@ -462,7 +468,7 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri try { Preset preset(m_type, name, false); preset.file = dir_entry.path().string(); - preset.load(keys); + preset.load(keys, m_type); m_presets.emplace_back(preset); } catch (const std::runtime_error &err) { errors_cummulative += err.what(); diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 86356f5b7..09ad6fed5 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -126,7 +126,7 @@ public: // Load this profile for the following keys only. // Throws std::runtime_error in case the file cannot be read. - DynamicPrintConfig& load(const std::vector &keys); + DynamicPrintConfig& load(const std::vector &keys, Preset::Type& type); void save(); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 7a9484db9..f06626043 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -2759,5 +2759,91 @@ void SavePresetWindow::accept() } } +void TabSLAMaterial::build() +{ + m_presets = &m_preset_bundle->sla_materials; + load_initial_data(); + + auto page = add_options_page(_(L("General")), "spool.png"); + +/* auto optgroup = page->new_optgroup(_(L("Display"))); + optgroup->append_single_option_line("display_width"); + optgroup->append_single_option_line("display_height"); + + Line line = { _(L("Number of pixels in axes")), "" }; + line.append_option(optgroup->get_option("display_pixels_x")); + line.append_option(optgroup->get_option("display_pixels_y")); + optgroup->append_line(line); +*/ + auto optgroup = page->new_optgroup(_(L("Layers"))); + optgroup->append_single_option_line("layer_height"); + optgroup->append_single_option_line("initial_layer_height"); + + optgroup = page->new_optgroup(_(L("Exposure"))); + optgroup->append_single_option_line("exposure_time"); + optgroup->append_single_option_line("initial_exposure_time"); + + optgroup = page->new_optgroup(_(L("Corrections"))); + // Legend for OptionsGroups + optgroup->set_show_modified_btns_val(false); + optgroup->label_width = 230; + auto line = Line{ "", "" }; + + ConfigOptionDef def; + def.type = coString; + def.width = 150; + def.gui_type = "legend"; + + std::vector axes{ "X", "Y", "Z" }; + for (auto& axis : axes) { + def.tooltip = L("Values in this column are for ") + axis + L(" axis"); + def.default_value = new ConfigOptionString{ axis }; + std::string opt_key = axis + "power_legend"; + auto option = Option(def, opt_key); + line.append_option(option); + } + optgroup->append_line(line); + + std::vector corrections = { "material_correction_printing", "material_correction_curing" }; + for (auto& opt_key : corrections){ + line = Line{ m_config->def()->get(opt_key)->full_label, "" }; + for( int id = 0; id < 3; ++id) + line.append_option(optgroup->get_option(opt_key, id)); + optgroup->append_line(line); + } + + page = add_options_page(_(L("Notes")), "note.png"); + optgroup = page->new_optgroup(_(L("Notes")), 0); + optgroup->label_width = 0; + Option option = optgroup->get_option("material_notes"); + option.opt.full_width = true; + option.opt.height = 250; + optgroup->append_single_option_line(option); + + page = add_options_page(_(L("Dependencies")), "wrench.png"); + optgroup = page->new_optgroup(_(L("Profile dependencies"))); + line = { _(L("Compatible printers")), "" }; + line.widget = [this](wxWindow* parent){ + return compatible_printers_widget(parent, &m_compatible_printers_checkbox, &m_compatible_printers_btn); + }; + optgroup->append_line(line, &m_colored_Label); + + option = optgroup->get_option("compatible_printers_condition"); + option.opt.full_width = true; + optgroup->append_single_option_line(option); + + line = Line{ "", "" }; + line.full_width = 1; + line.widget = [this](wxWindow* parent) { + return description_line_widget(parent, &m_parent_preset_description_line); + }; + optgroup->append_line(line); +} + +void TabSLAMaterial::update() +{ + +} + } // GUI } // Slic3r diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 7e7a7dc6e..40b51ce29 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -342,6 +342,18 @@ public: void init_options_list() override; }; +class TabSLAMaterial : public Tab +{ +public: + TabSLAMaterial() {} + TabSLAMaterial(wxNotebook* parent, bool no_controller) : + Tab(parent, _(L("SLA Material Settings")), "sla_material", no_controller) {} + ~TabSLAMaterial(){} + + void build() override; + void update() override; +}; + class SavePresetWindow :public wxDialog { public: