mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 08:25:57 +08:00
Merge branch 'lm_ys_spe2469'
This commit is contained in:
commit
150db9912c
@ -477,7 +477,7 @@ void PresetBundle::reset_extruder_filaments()
|
|||||||
this->extruders_filaments.emplace_back(ExtruderFilaments(&filaments, id, names[id]));
|
this->extruders_filaments.emplace_back(ExtruderFilaments(&filaments, id, names[id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
PresetCollection&PresetBundle::get_presets(Preset::Type type)
|
const PresetCollection& PresetBundle::get_presets(Preset::Type type) const
|
||||||
{
|
{
|
||||||
assert(type >= Preset::TYPE_PRINT && type <= Preset::TYPE_PRINTER);
|
assert(type >= Preset::TYPE_PRINT && type <= Preset::TYPE_PRINTER);
|
||||||
|
|
||||||
@ -488,6 +488,12 @@ PresetCollection&PresetBundle::get_presets(Preset::Type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PresetCollection& PresetBundle::get_presets(Preset::Type type)
|
||||||
|
{
|
||||||
|
return const_cast<PresetCollection&>(const_cast<const PresetBundle*>(this)->get_presets(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::string& PresetBundle::get_preset_name_by_alias( const Preset::Type& preset_type, const std::string& alias, int extruder_id /*= -1*/)
|
const std::string& PresetBundle::get_preset_name_by_alias( const Preset::Type& preset_type, const std::string& alias, int extruder_id /*= -1*/)
|
||||||
{
|
{
|
||||||
// there are not aliases for Printers profiles
|
// there are not aliases for Printers profiles
|
||||||
|
@ -87,6 +87,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const PresetCollection& get_presets(Preset::Type preset_type) const;
|
||||||
PresetCollection& get_presets(Preset::Type preset_type);
|
PresetCollection& get_presets(Preset::Type preset_type);
|
||||||
|
|
||||||
// The project configuration values are kept separated from the print/filament/printer preset,
|
// The project configuration values are kept separated from the print/filament/printer preset,
|
||||||
|
@ -1503,7 +1503,7 @@ PageCustom::PageCustom(ConfigWizard *parent)
|
|||||||
auto *label = new wxStaticText(this, wxID_ANY, _L("Custom profile name:"));
|
auto *label = new wxStaticText(this, wxID_ANY, _L("Custom profile name:"));
|
||||||
|
|
||||||
wxBoxSizer* profile_name_sizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* profile_name_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
profile_name_editor = new SavePresetDialog::Item{ this, profile_name_sizer, default_profile_name, &wxGetApp().preset_bundle->printers};
|
profile_name_editor = new SavePresetDialog::Item{ this, profile_name_sizer, default_profile_name, wxGetApp().preset_bundle};
|
||||||
profile_name_editor->Enable(false);
|
profile_name_editor->Enable(false);
|
||||||
|
|
||||||
cb_custom->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &) {
|
cb_custom->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &) {
|
||||||
|
@ -33,7 +33,7 @@ constexpr auto BORDER_W = 10;
|
|||||||
|
|
||||||
std::string SavePresetDialog::Item::get_init_preset_name(const std::string &suffix)
|
std::string SavePresetDialog::Item::get_init_preset_name(const std::string &suffix)
|
||||||
{
|
{
|
||||||
PresetBundle* preset_bundle = dynamic_cast<SavePresetDialog*>(m_parent)->get_preset_bundle();
|
const PresetBundle* preset_bundle = dynamic_cast<SavePresetDialog*>(m_parent)->get_preset_bundle();
|
||||||
if (!preset_bundle)
|
if (!preset_bundle)
|
||||||
preset_bundle = wxGetApp().preset_bundle;
|
preset_bundle = wxGetApp().preset_bundle;
|
||||||
m_presets = &preset_bundle->get_presets(m_type);
|
m_presets = &preset_bundle->get_presets(m_type);
|
||||||
@ -55,11 +55,30 @@ std::string SavePresetDialog::Item::get_init_preset_name(const std::string &suff
|
|||||||
void SavePresetDialog::Item::init_casei_preset_names()
|
void SavePresetDialog::Item::init_casei_preset_names()
|
||||||
{
|
{
|
||||||
m_casei_preset_names.clear();
|
m_casei_preset_names.clear();
|
||||||
m_casei_preset_names.reserve(m_presets->size());
|
|
||||||
|
|
||||||
for (const Preset& preset : *m_presets)
|
auto add_names_from_collection = [this](const PresetCollection& presets) {
|
||||||
|
for (const Preset& preset : presets)
|
||||||
if (!preset.is_default)
|
if (!preset.is_default)
|
||||||
m_casei_preset_names.emplace_back(PresetName({ boost::to_lower_copy<std::string>(preset.name), preset.name }));
|
m_casei_preset_names.emplace_back(PresetName({ boost::to_lower_copy<std::string>(preset.name), preset.name }));
|
||||||
|
};
|
||||||
|
|
||||||
|
if (m_presets) {
|
||||||
|
// This item is a part of SavePresetDialog and will check names inside selected PresetCollection
|
||||||
|
m_casei_preset_names.reserve(m_presets->size());
|
||||||
|
add_names_from_collection(*m_presets);
|
||||||
|
}
|
||||||
|
else // This item is a part of ConfigWizard and will check names inside all PresetCollections in respect to the m_printer_technology
|
||||||
|
if (m_preset_bundle) {
|
||||||
|
auto types_list = PresetBundle::types_list(m_printer_technology);
|
||||||
|
|
||||||
|
size_t presets_cnt = 0;
|
||||||
|
for (const Preset::Type& type : types_list)
|
||||||
|
presets_cnt += m_preset_bundle->get_presets(type).size();
|
||||||
|
m_casei_preset_names.reserve(presets_cnt);
|
||||||
|
|
||||||
|
for (const Preset::Type& type : types_list)
|
||||||
|
add_names_from_collection(m_preset_bundle->get_presets(type));
|
||||||
|
}
|
||||||
|
|
||||||
std::sort(m_casei_preset_names.begin(), m_casei_preset_names.end());
|
std::sort(m_casei_preset_names.begin(), m_casei_preset_names.end());
|
||||||
}
|
}
|
||||||
@ -139,9 +158,9 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string& suffix, wxBox
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
SavePresetDialog::Item::Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PresetCollection* presets, PrinterTechnology pt /*= ptFFF*/):
|
SavePresetDialog::Item::Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PresetBundle* preset_bundle, PrinterTechnology pt /*= ptFFF*/):
|
||||||
m_preset_name(def_name),
|
m_preset_name(def_name),
|
||||||
m_presets(presets),
|
m_preset_bundle(preset_bundle),
|
||||||
m_printer_technology(pt),
|
m_printer_technology(pt),
|
||||||
m_parent(parent),
|
m_parent(parent),
|
||||||
m_valid_bmp(new wxStaticBitmap(m_parent, wxID_ANY, *get_bmp_bundle("tick_mark"))),
|
m_valid_bmp(new wxStaticBitmap(m_parent, wxID_ANY, *get_bmp_bundle("tick_mark"))),
|
||||||
@ -196,11 +215,13 @@ const Preset* SavePresetDialog::Item::get_existing_preset() const
|
|||||||
if (m_presets)
|
if (m_presets)
|
||||||
return m_presets->find_preset(existed_preset_name, false);
|
return m_presets->find_preset(existed_preset_name, false);
|
||||||
|
|
||||||
|
if (m_preset_bundle) {
|
||||||
for (const Preset::Type& type : PresetBundle::types_list(m_printer_technology)) {
|
for (const Preset::Type& type : PresetBundle::types_list(m_printer_technology)) {
|
||||||
const PresetCollection& presets = wxGetApp().preset_bundle->get_presets(type);
|
const PresetCollection& presets = m_preset_bundle->get_presets(type);
|
||||||
if (const Preset* preset = presets.find_preset(existed_preset_name, false))
|
if (const Preset* preset = presets.find_preset(existed_preset_name, false))
|
||||||
return preset;
|
return preset;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,11 @@ public:
|
|||||||
Warning
|
Warning
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Item as an item inside of the SavePresetDialog
|
||||||
Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent, bool is_for_multiple_save);
|
Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent, bool is_for_multiple_save);
|
||||||
Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PresetCollection* presets, PrinterTechnology pt = ptFFF);
|
|
||||||
|
// Item as a separate control(f.e. as a part of ConfigWizard to check name of the new custom priter)
|
||||||
|
Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PresetBundle* preset_bundle, PrinterTechnology pt = ptFFF);
|
||||||
|
|
||||||
void update_valid_bmp();
|
void update_valid_bmp();
|
||||||
void accept();
|
void accept();
|
||||||
@ -71,7 +74,8 @@ public:
|
|||||||
wxTextCtrl* m_text_ctrl {nullptr};
|
wxTextCtrl* m_text_ctrl {nullptr};
|
||||||
wxStaticText* m_valid_label {nullptr};
|
wxStaticText* m_valid_label {nullptr};
|
||||||
|
|
||||||
PresetCollection* m_presets {nullptr};
|
const PresetCollection* m_presets {nullptr};
|
||||||
|
const PresetBundle* m_preset_bundle {nullptr};
|
||||||
|
|
||||||
std::vector<PresetName> m_casei_preset_names;
|
std::vector<PresetName> m_casei_preset_names;
|
||||||
|
|
||||||
@ -108,7 +112,7 @@ public:
|
|||||||
|
|
||||||
void AddItem(Preset::Type type, const std::string& suffix, bool is_for_multiple_save);
|
void AddItem(Preset::Type type, const std::string& suffix, bool is_for_multiple_save);
|
||||||
|
|
||||||
PresetBundle* get_preset_bundle() const { return m_preset_bundle; }
|
const PresetBundle* get_preset_bundle() const { return m_preset_bundle; }
|
||||||
std::string get_name();
|
std::string get_name();
|
||||||
std::string get_name(Preset::Type type);
|
std::string get_name(Preset::Type type);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user