From 5716f53c378d654fa6ff5d898344ebee58c23bcd Mon Sep 17 00:00:00 2001 From: cjw Date: Thu, 6 Feb 2025 10:17:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libslic3r/Preset.cpp | 4 ++++ libslic3r/Preset.hpp | 1 + libslic3r/PresetBundle.cpp | 34 +++++++++++++++++++++++++++++---- libslic3r/PresetBundle.hpp | 2 +- slic3r/GUI/GUI_App.cpp | 39 ++++++++++++++++++++------------------ slic3r/GUI/MainFrame.cpp | 2 +- slic3r/GUI/Plater.cpp | 5 ++++- 7 files changed, 62 insertions(+), 25 deletions(-) diff --git a/libslic3r/Preset.cpp b/libslic3r/Preset.cpp index a5835fd..c2ccdb1 100644 --- a/libslic3r/Preset.cpp +++ b/libslic3r/Preset.cpp @@ -996,6 +996,9 @@ static std::vector s_Preset_sla_printer_options { "min_initial_exposure_time", "max_initial_exposure_time", "inherits" }; +static std::vector s_Preset_config_options{ + "initial_layer_line_width","outer_wall_line_width","inner_wall_line_width","top_surface_line_width","sparse_infill_line_width","support_line_width","resolution","wall_sequence" +}; const std::vector& Preset::print_options() { return s_Preset_print_options; } const std::vector& Preset::filament_options() { return s_Preset_filament_options; } @@ -1006,6 +1009,7 @@ const std::vector& Preset::nozzle_options() { return print_ const std::vector& Preset::sla_print_options() { return s_Preset_sla_print_options; } const std::vector& Preset::sla_material_options() { return s_Preset_sla_material_options; } const std::vector& Preset::sla_printer_options() { return s_Preset_sla_printer_options; } +const std::vector& Preset::config_options() { return s_Preset_config_options; } const std::vector& Preset::printer_options() { diff --git a/libslic3r/Preset.hpp b/libslic3r/Preset.hpp index f8f2243..5d29bdc 100644 --- a/libslic3r/Preset.hpp +++ b/libslic3r/Preset.hpp @@ -339,6 +339,7 @@ public: static const std::vector& sla_printer_options(); static const std::vector& sla_material_options(); static const std::vector& sla_print_options(); + static const std::vector& config_options(); static void update_suffix_modified(const std::string& new_suffix_modified); static const std::string& suffix_modified(); diff --git a/libslic3r/PresetBundle.cpp b/libslic3r/PresetBundle.cpp index 5eb43dc..5030142 100644 --- a/libslic3r/PresetBundle.cpp +++ b/libslic3r/PresetBundle.cpp @@ -55,6 +55,7 @@ PresetBundle::PresetBundle() , sla_materials(Preset::TYPE_SLA_MATERIAL, Preset::sla_material_options(), static_cast(SLAFullPrintConfig::defaults())) , sla_prints(Preset::TYPE_SLA_PRINT, Preset::sla_print_options(), static_cast(SLAFullPrintConfig::defaults())) , printers(Preset::TYPE_PRINTER, Preset::printer_options(), static_cast(FullPrintConfig::defaults()), "Default Printer") + , configs(Preset::TYPE_CONFIG, Preset::config_options(), static_cast(FullPrintConfig::defaults()), "Default Config") , physical_printers(PhysicalPrinter::printer_options()) { // The following keys are handled by the UI, they do not have a counterpart in any StaticPrintConfig derived classes, @@ -101,13 +102,16 @@ PresetBundle::PresetBundle() // default_sla_material_profile preset.inherits(); } - + /* this->configs.default_preset().config.option("config_settings_id", true)->values = { "" }; + this->configs.default_preset().compatible_printers_condition(); + this->configs.default_preset().inherits();*/ // Re-activate the default presets, so their "edited" preset copies will be updated with the additional configuration values above. this->prints.select_preset(0); this->sla_prints.select_preset(0); this->filaments.select_preset(0); this->sla_materials.select_preset(0); this->printers.select_preset(0); + this->configs.select_preset(0); this->project_config.apply_only(FullPrintConfig::defaults(), s_project_options); } @@ -124,6 +128,7 @@ PresetBundle& PresetBundle::operator=(const PresetBundle &rhs) filaments = rhs.filaments; sla_materials = rhs.sla_materials; printers = rhs.printers; + configs = rhs.configs; physical_printers = rhs.physical_printers; filament_presets = rhs.filament_presets; @@ -137,6 +142,7 @@ PresetBundle& PresetBundle::operator=(const PresetBundle &rhs) filaments .update_vendor_ptrs_after_copy(this->vendors); sla_materials.update_vendor_ptrs_after_copy(this->vendors); printers .update_vendor_ptrs_after_copy(this->vendors); + configs .update_vendor_ptrs_after_copy(this->vendors); return *this; } @@ -150,6 +156,7 @@ void PresetBundle::reset(bool delete_files) this->filaments .reset(delete_files); this->sla_materials.reset(delete_files); this->printers .reset(delete_files); + this->configs .reset(delete_files); // BBS: filament_presets is load from project config, not handled here //this->filament_presets.clear(); if (this->filament_presets.empty()) @@ -159,6 +166,7 @@ void PresetBundle::reset(bool delete_files) this->obsolete_presets.filaments.clear(); this->obsolete_presets.sla_materials.clear(); this->obsolete_presets.printers.clear(); + this->obsolete_presets.configs.clear(); } void PresetBundle::setup_directories() @@ -280,6 +288,9 @@ Preset* PresetBundle::get_preset_differed_for_save(Preset& preset) break; case Preset::TYPE_FILAMENT: preset_collection = &(this->filaments); + break; + case Preset::TYPE_CONFIG: + preset_collection = &(this->configs); break; default: BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" invalid type %1%, return directly")%preset.type; @@ -302,6 +313,9 @@ int PresetBundle::get_differed_values_to_update(Preset& preset, std::mapfilaments); + break; + case Preset::TYPE_CONFIG: + preset_collection = &(this->configs); break; default: BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" invalid type %1%, return directly")%preset.type; @@ -348,7 +362,7 @@ PresetsConfigSubstitutions PresetBundle::load_project_embedded_presets(std::vect errors_cummulative += err.what(); } try { - this->printers.load_project_embedded_presets(project_presets, PRESET_CONFIG_NAME, substitutions, substitution_rule); + this->configs.load_project_embedded_presets(project_presets, PRESET_CONFIG_NAME, substitutions, substitution_rule); }catch (const std::runtime_error& err) { errors_cummulative += err.what(); } @@ -528,7 +542,7 @@ PresetsConfigSubstitutions PresetBundle::load_user_presets(std::string user, For BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", " << __LINE__ << " entry and user is: " << user; PresetsConfigSubstitutions substitutions; std::string errors_cummulative; - + std::string test = data_dir(); fs::path user_folder(data_dir() + "/" + PRESET_USER_DIR); if (!fs::exists(user_folder)) fs::create_directory(user_folder); @@ -559,6 +573,14 @@ PresetsConfigSubstitutions PresetBundle::load_user_presets(std::string user, For } catch (const std::runtime_error &err) { errors_cummulative += err.what(); } + try { + std::string config_selected_preset_name = configs.get_selected_preset().name; + this->configs.load_presets(dir_user_presets, PRESET_CONFIG_NAME, substitutions, substitution_rule); + configs.select_preset_by_name(config_selected_preset_name, false); + } + catch (const std::runtime_error& err) { + errors_cummulative += err.what(); + } if (!errors_cummulative.empty()) throw Slic3r::RuntimeError(errors_cummulative); this->update_multi_material_filament_presets(); this->update_compatible(PresetSelectCompatibleType::Never); @@ -575,7 +597,7 @@ PresetsConfigSubstitutions PresetBundle::load_user_presets(AppConfig & // First load the vendor specific system presets. PresetsConfigSubstitutions substitutions; std::string errors_cummulative; - bool process_added = false, filament_added = false, machine_added = false; + bool process_added = false, filament_added = false, machine_added = false,config_added = false; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" enter, substitution_rule %1%, preset toltal count %2%")%substitution_rule%my_presets.size(); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" print's selected_idx %1%, selected_name %2%") %prints.get_selected_idx() %prints.get_selected_preset_name(); @@ -615,6 +637,10 @@ PresetsConfigSubstitutions PresetBundle::load_user_presets(AppConfig & preset_collection = &(this->printers); machine_added |= preset_collection->load_user_preset(name, value_map, substitutions, substitution_rule); } + else if (type_iter->second == PRESET_IOT_CONFIG_TYPE) { + preset_collection = &(this->configs); + config_added |= preset_collection->load_user_preset(name, value_map, substitutions, substitution_rule); + } else { BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format("invalid type %1% for setting %2%") %type_iter->second %name; continue; diff --git a/libslic3r/PresetBundle.hpp b/libslic3r/PresetBundle.hpp index d15eef9..a26c581 100644 --- a/libslic3r/PresetBundle.hpp +++ b/libslic3r/PresetBundle.hpp @@ -149,7 +149,7 @@ public: ObsoletePresets obsolete_presets; bool has_defauls_only() const - { return prints.has_defaults_only() && filaments.has_defaults_only() && printers.has_defaults_only(); } + { return prints.has_defaults_only() && filaments.has_defaults_only() && printers.has_defaults_only() && configs.has_defaults_only(); } DynamicPrintConfig full_config() const; // full_config() with the some "useless" config removed. diff --git a/slic3r/GUI/GUI_App.cpp b/slic3r/GUI/GUI_App.cpp index 263cbd6..a08891d 100644 --- a/slic3r/GUI/GUI_App.cpp +++ b/slic3r/GUI/GUI_App.cpp @@ -418,13 +418,13 @@ public: int width = FromDIP(1000, nullptr); int height = FromDIP(550, nullptr); - /*wxImage image(width, height); - wxBitmap new_bmp(image); - - wxMemoryDC memDC; - memDC.SelectObject(new_bmp); - memDC.SetBrush(StateColor::darkModeColorFor(wxColor(0, 157, 244,128))); - memDC.DrawRectangle(-1, -1, width + 2, height + 2); + /*wxImage image(width, height);111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 + wxBitmap new_bmp(image);2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 + 333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 + wxMemoryDC memDC;41234444444444444444444444444444444444344444444444444444555555555555555555555555555555555555555555555555555555555555555555555555555 + memDC.SelectObject(new_bmp);12344444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 + memDC.SetBrush(StateColor::darkModeColorFor(wxColor(0, 157, 244,128)));2341324132444444444444444444444444444444444444444444444444444444444444444442 + memDC.DrawRectangle(-1, -1, width + 2, height + 2);23411111111111111111111111111111111111111111111111111111111111111111111111111111111121341234234 memDC.DrawBitmap(new_bmp, 0, 0, true);*/ // StateColor::darkModeColorFor(wxColor(0, 157, 244) //fangfa1 @@ -484,20 +484,23 @@ public: bitmap.SetMask(new wxMask(mask, wxColour(0, 0, 0)));*/ - wxBitmap bitmap(width, height, 24); + //wxBitmap bitmap(width, height, 24); + ////wxBitmap bitmap("back.png", wxBITMAP_TYPE_PNG); + //wxMemoryDC memDC; + //memDC.SelectObject(bitmap); - wxMemoryDC memDC; - memDC.SelectObject(bitmap); - - memDC.SetBackground(*wxWHITE_BRUSH); - memDC.Clear(); - wxImage image = bitmap.ConvertToImage(); + //memDC.SetBackground(*wxWHITE_BRUSH); + //memDC.Clear(); + //wxImage image = bitmap.ConvertToImage(); - image.SetMask(true); - image.SetMaskColour(255,255,255); - bitmap = wxBitmap(image); - return bitmap; + //image.SetMask(true); + //image.SetMaskColour(255,255,255); + //bitmap = wxBitmap(image); + //BitmapCache bmp_cache; + //*bmp_cache.load_png + wxBitmap new_bmp("E:\\Code\\Projects\\BambuStudio\\resources\\images\\back1234.png", wxBITMAP_TYPE_PNG); + return new_bmp; } void set_bitmap(wxBitmap& bmp) diff --git a/slic3r/GUI/MainFrame.cpp b/slic3r/GUI/MainFrame.cpp index f9aa28e..7e95b32 100644 --- a/slic3r/GUI/MainFrame.cpp +++ b/slic3r/GUI/MainFrame.cpp @@ -1308,7 +1308,7 @@ void MainFrame::create_preset_tabs() //add_created_tab(new TabSLAPrint(m_param_panel)); //add_created_tab(new TabSLAMaterial(m_param_panel)); add_created_tab(new TabPrinter(m_param_dialog->panel()), "printer"); - //add_created_tab(new TabConfig(m_param_dialog->panel()), "config"); + add_created_tab(new TabConfig(m_param_dialog->panel()), "config"); m_param_panel->rebuild_panels(); m_param_dialog->panel()->rebuild_panels(); diff --git a/slic3r/GUI/Plater.cpp b/slic3r/GUI/Plater.cpp index 3f18ed0..4585b7e 100644 --- a/slic3r/GUI/Plater.cpp +++ b/slic3r/GUI/Plater.cpp @@ -1026,7 +1026,7 @@ Sidebar::Sidebar(Plater *parent) p->m_panel_config_content = new wxPanel(p->scrolled, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); p->m_panel_config_content->SetBackgroundColour(wxColour(255, 255, 255)); - PlaterPresetComboBox* combo_config = new PlaterPresetComboBox(p->m_panel_config_content, Preset::TYPE_PRINTER); + PlaterPresetComboBox* combo_config = new PlaterPresetComboBox(p->m_panel_config_content, Preset::TYPE_CONFIG); ScalableButton* edit_btn = new ScalableButton(p->m_panel_config_content, wxID_ANY, "edit"); edit_btn->SetToolTip(_L("Click to edit preset")); edit_btn->Bind(wxEVT_BUTTON, [this, combo_config](wxCommandEvent) @@ -1331,6 +1331,9 @@ void Sidebar::update_all_preset_comboboxes() if (p->combo_printer) p->combo_printer->update(); + + if (p->combo_config) + p->combo_config->update(); } void Sidebar::update_presets(Preset::Type preset_type)