配置项下拉框

This commit is contained in:
cjw 2025-02-06 10:17:57 +08:00
parent 4d346ba4b7
commit 5716f53c37
7 changed files with 62 additions and 25 deletions

View File

@ -996,6 +996,9 @@ static std::vector<std::string> s_Preset_sla_printer_options {
"min_initial_exposure_time", "max_initial_exposure_time",
"inherits"
};
static std::vector<std::string> 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<std::string>& Preset::print_options() { return s_Preset_print_options; }
const std::vector<std::string>& Preset::filament_options() { return s_Preset_filament_options; }
@ -1006,6 +1009,7 @@ const std::vector<std::string>& Preset::nozzle_options() { return print_
const std::vector<std::string>& Preset::sla_print_options() { return s_Preset_sla_print_options; }
const std::vector<std::string>& Preset::sla_material_options() { return s_Preset_sla_material_options; }
const std::vector<std::string>& Preset::sla_printer_options() { return s_Preset_sla_printer_options; }
const std::vector<std::string>& Preset::config_options() { return s_Preset_config_options; }
const std::vector<std::string>& Preset::printer_options()
{

View File

@ -339,6 +339,7 @@ public:
static const std::vector<std::string>& sla_printer_options();
static const std::vector<std::string>& sla_material_options();
static const std::vector<std::string>& sla_print_options();
static const std::vector<std::string>& config_options();
static void update_suffix_modified(const std::string& new_suffix_modified);
static const std::string& suffix_modified();

View File

@ -55,6 +55,7 @@ PresetBundle::PresetBundle()
, sla_materials(Preset::TYPE_SLA_MATERIAL, Preset::sla_material_options(), static_cast<const SLAMaterialConfig &>(SLAFullPrintConfig::defaults()))
, sla_prints(Preset::TYPE_SLA_PRINT, Preset::sla_print_options(), static_cast<const SLAPrintObjectConfig &>(SLAFullPrintConfig::defaults()))
, printers(Preset::TYPE_PRINTER, Preset::printer_options(), static_cast<const PrintRegionConfig &>(FullPrintConfig::defaults()), "Default Printer")
, configs(Preset::TYPE_CONFIG, Preset::config_options(), static_cast<const PrintRegionConfig &>(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<ConfigOptionStrings>("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::map<std::st
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;
@ -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;

View File

@ -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.

View File

@ -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)

View File

@ -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();

View File

@ -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)