mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-10 18:56:13 +00:00
Make printer profile swithing faster (#14437)
* Fix issue that switching printer profile is slow.
`wxGetApp().get_tab(preset_type)->select_preset(preset_name);` is called twice when switching printer profiles. Only one needed.
* Avoid unnecessary type conversion & function call during printer profile switching:
- Don't call `config->opt_string("printer_model")` repeatedly
- Use ref when possible during iterating
- Avoid unnecessary `wxString` to `std::string` conversion
This commit is contained in:
@@ -890,12 +890,11 @@ std::string Preset::get_printer_type(PresetBundle *preset_bundle)
|
|||||||
{
|
{
|
||||||
if (preset_bundle) {
|
if (preset_bundle) {
|
||||||
auto config = &preset_bundle->printers.get_edited_preset().config;
|
auto config = &preset_bundle->printers.get_edited_preset().config;
|
||||||
std::string vendor_name;
|
const auto& printer_model = config->opt_string("printer_model");
|
||||||
for (auto vendor_profile : preset_bundle->vendors) {
|
for (const auto& vendor_profile : preset_bundle->vendors) {
|
||||||
for (auto vendor_model : vendor_profile.second.models)
|
for (const auto& vendor_model : vendor_profile.second.models)
|
||||||
if (vendor_model.name == config->opt_string("printer_model"))
|
if (vendor_model.name == printer_model)
|
||||||
{
|
{
|
||||||
vendor_name = vendor_profile.first;
|
|
||||||
return vendor_model.model_id;
|
return vendor_model.model_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -907,11 +906,10 @@ std::string Preset::get_current_printer_type(PresetBundle *preset_bundle)
|
|||||||
{
|
{
|
||||||
if (preset_bundle) {
|
if (preset_bundle) {
|
||||||
auto config = &(this->config);
|
auto config = &(this->config);
|
||||||
std::string vendor_name;
|
const auto& printer_model = config->opt_string("printer_model");
|
||||||
for (auto vendor_profile : preset_bundle->vendors) {
|
for (const auto& vendor_profile : preset_bundle->vendors) {
|
||||||
for (auto vendor_model : vendor_profile.second.models)
|
for (const auto& vendor_model : vendor_profile.second.models)
|
||||||
if (vendor_model.name == config->opt_string("printer_model")) {
|
if (vendor_model.name == printer_model) {
|
||||||
vendor_name = vendor_profile.first;
|
|
||||||
return vendor_model.model_id;
|
return vendor_model.model_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9684,11 +9684,14 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// BBS
|
||||||
|
// wxWindowUpdateLocker noUpdates1(sidebar->print_panel());
|
||||||
|
wxWindowUpdateLocker noUpdates2(sidebar->filament_panel());
|
||||||
|
wxGetApp().get_tab(preset_type)->select_preset(preset_name);
|
||||||
|
// update plater with new config
|
||||||
|
q->on_config_change(wxGetApp().preset_bundle->full_config());
|
||||||
}
|
}
|
||||||
//BBS
|
|
||||||
//wxWindowUpdateLocker noUpdates1(sidebar->print_panel());
|
|
||||||
wxWindowUpdateLocker noUpdates2(sidebar->filament_panel());
|
|
||||||
wxGetApp().get_tab(preset_type)->select_preset(preset_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ORCA: Always refresh the selected filament combo so its color swatch (clr_picker)
|
// ORCA: Always refresh the selected filament combo so its color swatch (clr_picker)
|
||||||
|
|||||||
@@ -1310,7 +1310,7 @@ void PlaterPresetComboBox::update()
|
|||||||
selected_in_ams = add_ams_filaments(into_u8(selected_user_preset.empty() ? selected_system_preset : selected_user_preset), true);
|
selected_in_ams = add_ams_filaments(into_u8(selected_user_preset.empty() ? selected_system_preset : selected_user_preset), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> filament_orders = {"Bambu PLA Basic", "Bambu PLA Matte", "Bambu PETG HF", "Bambu ABS", "Bambu PLA Silk", "Bambu PLA-CF",
|
std::vector<wxString> filament_orders = {"Bambu PLA Basic", "Bambu PLA Matte", "Bambu PETG HF", "Bambu ABS", "Bambu PLA Silk", "Bambu PLA-CF",
|
||||||
"Bambu PLA Galaxy", "Bambu PLA Metal", "Bambu PLA Marble", "Bambu PETG-CF", "Bambu PETG Translucent", "Bambu ABS-GF"};
|
"Bambu PLA Galaxy", "Bambu PLA Metal", "Bambu PLA Marble", "Bambu PETG-CF", "Bambu PETG Translucent", "Bambu ABS-GF"};
|
||||||
std::vector<std::string> first_vendors = {"", "Bambu", "Generic"}; // Empty vendor for non-system presets
|
std::vector<std::string> first_vendors = {"", "Bambu", "Generic"}; // Empty vendor for non-system presets
|
||||||
std::vector<std::string> first_types = {"PLA", "PETG", "ABS", "TPU"};
|
std::vector<std::string> first_types = {"PLA", "PETG", "ABS", "TPU"};
|
||||||
|
|||||||
Reference in New Issue
Block a user