From 28fdf252d09d524056360049aeead0203e7df759 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Wed, 19 Feb 2025 10:10:44 +0800 Subject: [PATCH] FIX: error sync behavior for customize printer preset jira: STUDIO-10331 Change-Id: I4d42ed089e515c2d74dfade1589f20f1c80ca4ca (cherry picked from commit ce963cede53a72a123f55666a1f718726eb18ab6) --- src/slic3r/GUI/CreatePresetsDialog.cpp | 198 ++++++++++++------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index f89538695d..59e8c2526e 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -35,7 +35,7 @@ #define SELECT_ALL_OPTION_COLOUR wxColour("#009688") #define DEFAULT_PROMPT_TEXT_COLOUR wxColour("#ACACAC") -namespace Slic3r { +namespace Slic3r { namespace GUI { static const std::vector filament_vendors = @@ -183,7 +183,7 @@ static bool str_is_all_digit(const std::string &str) { for (const char &c : str) { if (!std::isdigit(c)) return false; } - return true; + return true; } // Custom comparator for case-insensitive sorting @@ -271,7 +271,7 @@ static std::string get_curr_timestmp() } static void get_filament_compatible_printer(Preset* preset, vector& printers) -{ +{ auto compatible_printers = dynamic_cast(preset->config.option("compatible_printers")); if (compatible_printers == nullptr) return; for (const std::string &printer_name : compatible_printers->values) { @@ -424,7 +424,7 @@ static wxBoxSizer *create_select_filament_preset_checkbox(wxWindow * combobox_sizer->Add(combobox, 0, wxEXPAND | wxTOP, 5); wxArrayString choices; - for (Preset *preset : presets) { + for (Preset *preset : presets) { choices.Add(wxString::FromUTF8(preset->name)); } combobox->Set(choices); @@ -633,7 +633,7 @@ static void adjust_dialog_in_screen(DPIDialog* dialog) { if (pos_x != dialog_x || pos_y != dialog_y) { dialog->SetPosition(wxPoint(dialog_x, dialog_y)); } } -CreateFilamentPresetDialog::CreateFilamentPresetDialog(wxWindow *parent) +CreateFilamentPresetDialog::CreateFilamentPresetDialog(wxWindow *parent) : DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Create Filament"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxCENTRE) { m_create_type.base_filament = _L("Create Based on Current Filament"); @@ -737,14 +737,14 @@ wxBoxSizer *CreateFilamentPresetDialog::create_item(FilamentOptionType option_ty } } wxBoxSizer *CreateFilamentPresetDialog::create_vendor_item() -{ - wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL); +{ + wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer * optionSizer = new wxBoxSizer(wxVERTICAL); wxStaticText *static_vendor_text = new wxStaticText(this, wxID_ANY, _L("Vendor"), wxDefaultPosition, wxDefaultSize); optionSizer->Add(static_vendor_text, 0, wxEXPAND | wxALL, 0); optionSizer->SetMinSize(OPTION_SIZE); - horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); + horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); // Convert all std::any to std::string std::vector string_vendors; @@ -850,7 +850,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_type_item() comboBoxSizer->Add(m_filament_type_combobox, 0, wxEXPAND | wxALL, 0); horizontal_sizer->Add(comboBoxSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); - m_filament_type_combobox->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &e) { + m_filament_type_combobox->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &e) { m_filament_type_combobox->SetLabelColor(*wxBLACK); const wxString &curr_create_type = curr_create_filament_type(); clear_filament_preset_map(); @@ -859,7 +859,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_type_item() m_filament_preset_combobox->Set(filament_preset_choice); m_filament_preset_combobox->SetLabel(_L("Select Filament Preset")); m_filament_preset_combobox->SetLabelColor(DEFAULT_PROMPT_TEXT_COLOUR); - + } else if (curr_create_type == m_create_type.base_filament_preset) { get_filament_presets_by_machine(); } @@ -916,17 +916,17 @@ wxBoxSizer *CreateFilamentPresetDialog::create_filament_preset_item() wxBoxSizer * comboBoxSizer = new wxBoxSizer(wxVERTICAL); comboBoxSizer->Add(create_radio_item(m_create_type.base_filament, this, wxEmptyString, m_create_type_btns), 0, wxEXPAND | wxALL, 0); - + m_filament_preset_combobox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, FILAMENT_PRESET_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY); m_filament_preset_combobox->SetLabel(_L("Select Filament Preset")); m_filament_preset_combobox->SetLabelColor(DEFAULT_PROMPT_TEXT_COLOUR); - + m_filament_preset_combobox->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &e) { m_filament_preset_combobox->SetLabelColor(*wxBLACK); wxString filament_type = m_filament_preset_combobox->GetStringSelection(); std::unordered_map>::iterator iter = m_filament_choice_map.find(m_public_name_to_filament_id_map[filament_type]); - + m_scrolled_preset_panel->Freeze(); m_filament_presets_sizer->Clear(true); m_filament_preset.clear(); @@ -986,7 +986,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_filament_preset_item() comboBoxSizer->Add(m_filament_preset_combobox, 0, wxEXPAND | wxTOP, FromDIP(5)); comboBoxSizer->Add(create_radio_item(m_create_type.base_filament_preset, this, wxEmptyString, m_create_type_btns), 0, wxEXPAND | wxTOP, FromDIP(10)); - + horizontal_sizer->Add(comboBoxSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(10)); horizontal_sizer->Add(0, 0, 0, wxLEFT, FromDIP(30)); @@ -1014,7 +1014,7 @@ wxWindow *CreateFilamentPresetDialog::create_dialog_buttons() auto btn_ok = dlg_btns->GetOK(); btn_ok->SetLabel(_L("Create")); - btn_ok->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { + btn_ok->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { //get vendor name wxString vendor_str = m_filament_vendor_combobox->GetLabel(); std::string vendor_name; @@ -1068,7 +1068,7 @@ wxWindow *CreateFilamentPresetDialog::create_dialog_buttons() } vendor_name = remove_special_key(vendor_name); serial_name = remove_special_key(serial_name); - + if (vendor_name.empty() || serial_name.empty()) { MessageDialog dlg(this, _L("There may be escape characters in the vendor or serial input of filament. Please delete and re-enter."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); @@ -1111,11 +1111,11 @@ wxWindow *CreateFilamentPresetDialog::create_dialog_buttons() std::string user_filament_id = get_filament_id(filament_preset_name); const wxString &curr_create_type = curr_create_filament_type(); - + if (curr_create_type == m_create_type.base_filament) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":clone filament create type filament "; for (const auto& checkbox_preset : m_filament_preset) { - if (checkbox_preset.first->GetValue()) { + if (checkbox_preset.first->GetValue()) { std::string compatible_printer_name = checkbox_preset.second.first; std::vector failures; Preset const *const checked_preset = checkbox_preset.second.second; @@ -1169,18 +1169,18 @@ wxWindow *CreateFilamentPresetDialog::create_dialog_buttons() } } preset_bundle->update_compatible(PresetSelectCompatibleType::Always); - EndModal(wxID_OK); + EndModal(wxID_OK); }); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { - EndModal(wxID_CANCEL); + EndModal(wxID_CANCEL); }); return dlg_btns; } wxArrayString CreateFilamentPresetDialog::get_filament_preset_choices() -{ +{ wxArrayString choices; // get fialment type name wxString type_str = m_filament_type_combobox->GetLabel(); @@ -1205,12 +1205,12 @@ wxArrayString CreateFilamentPresetDialog::get_filament_preset_choices() m_filament_choice_map[preset->filament_id].push_back(preset); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " base user preset is:" << preset->name; } - + int suffix = 0; for (const auto& preset : m_filament_choice_map) { if (preset.second.empty()) continue; std::set preset_name_set; - for (Preset* filament_preset : preset.second) { + for (Preset* filament_preset : preset.second) { std::string preset_name = filament_preset->name; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " filament_id: " << filament_preset->filament_id << " preset name: " << filament_preset->name; size_t index_at = preset_name.find(" @"); @@ -1222,7 +1222,7 @@ wxArrayString CreateFilamentPresetDialog::get_filament_preset_choices() } assert(1 == preset_name_set.size()); if (preset_name_set.size() > 1) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " the same filament has different filament(vendor type serial)"; + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " the same filament has different filament(vendor type serial)"; } for (const wxString& public_name : preset_name_set) { if (m_public_name_to_filament_id_map.find(public_name) != m_public_name_to_filament_id_map.end()) { @@ -1283,10 +1283,10 @@ void CreateFilamentPresetDialog::select_curr_radiobox(std::vectorHide(); if (_L("Select Type") != m_filament_type_combobox->GetLabel()) { - + clear_filament_preset_map(); get_filament_presets_by_machine(); - + } } m_scrolled_preset_panel->SetSizerAndFit(m_scrolled_sizer); @@ -1322,7 +1322,7 @@ void CreateFilamentPresetDialog::get_filament_presets_by_machine() } else { type_name = into_u8(type_str); } - + std::unordered_map nozzle_diameter = nozzle_diameter_map; std::unordered_map> machine_name_to_presets; PresetBundle * preset_bundle = wxGetApp().preset_bundle; @@ -1529,7 +1529,7 @@ void CreateFilamentPresetDialog::clear_filament_preset_map() m_filament_preset_panel->Thaw(); } -CreatePrinterPresetDialog::CreatePrinterPresetDialog(wxWindow *parent) +CreatePrinterPresetDialog::CreatePrinterPresetDialog(wxWindow *parent) : DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Create Printer/Nozzle"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxCENTER) { m_create_type.create_printer = _L("Create Printer"); @@ -1594,8 +1594,8 @@ void CreatePrinterPresetDialog::on_dpi_changed(const wxRect &suggested_rect) { } wxBoxSizer *CreatePrinterPresetDialog::create_step_switch_item() -{ - wxBoxSizer *step_switch_sizer = new wxBoxSizer(wxVERTICAL); +{ + wxBoxSizer *step_switch_sizer = new wxBoxSizer(wxVERTICAL); // std::string wiki_url = "https://wiki.bambulab.com/en/software/bambu-studio/3rd-party-printer-profile"; // wxHyperlinkCtrl *m_download_hyperlink = new wxHyperlinkCtrl(this, wxID_ANY, _L("wiki"), wiki_url, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); @@ -1626,15 +1626,15 @@ wxBoxSizer *CreatePrinterPresetDialog::create_step_switch_item() line_top->SetBackgroundColour(PRINTER_LIST_COLOUR); step_switch_sizer->Add(line_top, 0, wxEXPAND | wxALL, FromDIP(10)); - + return step_switch_sizer; } void CreatePrinterPresetDialog::create_printer_page1(wxWindow *parent) -{ +{ this->SetBackgroundColour(*wxWHITE); - m_page1_sizer = new wxBoxSizer(wxVERTICAL); + m_page1_sizer = new wxBoxSizer(wxVERTICAL); m_page1_sizer->Add(create_type_item(parent), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP(5)); m_page1_sizer->Add(create_printer_item(parent), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP(5)); @@ -1669,7 +1669,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_type_item(wxWindow *parent) horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(10)); wxBoxSizer *radioBoxSizer = new wxBoxSizer(wxVERTICAL); - + radioBoxSizer->Add(create_radio_item(m_create_type.create_printer, parent, wxEmptyString, m_create_type_btns), 0, wxEXPAND | wxALL, 0); radioBoxSizer->Add(create_radio_item(m_create_type.create_nozzle, parent, wxEmptyString, m_create_type_btns), 0, wxEXPAND | wxTOP, FromDIP(10)); horizontal_sizer->Add(radioBoxSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(10)); @@ -1693,12 +1693,12 @@ wxBoxSizer *CreatePrinterPresetDialog::create_printer_item(wxWindow *parent) m_select_vendor->SetValue(_L("Select Vendor")); m_select_vendor->SetLabelColor(DEFAULT_PROMPT_TEXT_COLOUR); wxArrayString printer_vendor; - for (const std::string &vendor : printer_vendors) { + for (const std::string &vendor : printer_vendors) { assert(printer_model_map.find(vendor) != printer_model_map.end()); - printer_vendor.Add(vendor); + printer_vendor.Add(vendor); } m_select_vendor->Set(printer_vendor); - m_select_vendor->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent e) { + m_select_vendor->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent e) { m_select_vendor->SetLabelColor(*wxBLACK); std::string curr_selected_vendor = into_u8(m_select_vendor->GetStringSelection()); std::unordered_map>::const_iterator iter = printer_model_map.find(curr_selected_vendor); @@ -1706,11 +1706,11 @@ wxBoxSizer *CreatePrinterPresetDialog::create_printer_item(wxWindow *parent) { std::vector vendor_model = iter->second; wxArrayString model_choice; - for (const std::string &model : vendor_model) { + for (const std::string &model : vendor_model) { model_choice.Add(model); } m_select_model->Set(model_choice); - if (!model_choice.empty()) { + if (!model_choice.empty()) { m_select_model->SetSelection(0); m_select_model->SetLabelColor(*wxBLACK); } @@ -1720,7 +1720,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_printer_item(wxWindow *parent) } e.Skip(); }); - + comboBoxSizer->Add(m_select_vendor, 0, wxEXPAND | wxALL, 0); m_select_model = new ComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, NAME_OPTION_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY); @@ -1996,7 +1996,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_hot_bed_stl_item(wxWindow *parent) } wxBoxSizer *CreatePrinterPresetDialog::create_hot_bed_svg_item(wxWindow *parent) -{ +{ wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer * optionSizer = new wxBoxSizer(wxVERTICAL); @@ -2259,7 +2259,7 @@ void CreatePrinterPresetDialog::generate_process_presets_data(std::vectorvalue = nozzle_dia / 2; else BOOST_LOG_TRIVIAL(info) << "process template has no initial_layer_print_height"; - + auto line_width = dynamic_cast(const_cast(preset)->config.option("line_width", true)); if (line_width) line_width->value = nozzle_dia; @@ -2483,7 +2483,7 @@ void CreatePrinterPresetDialog::select_curr_radiobox(std::vectorShow(); m_can_not_find_vendor_text->Show(); m_printer_info_panel->Show(); - if (m_can_not_find_vendor_combox->GetValue()) { + if (m_can_not_find_vendor_combox->GetValue()) { m_custom_vendor_text_ctrl->Show(); m_custom_model_text_ctrl->Show(); m_select_vendor->Hide(); @@ -2510,7 +2510,7 @@ void CreatePrinterPresetDialog::select_curr_radiobox(std::vectorSetValue(false); } } - + update_preset_list_size(); } @@ -2611,14 +2611,14 @@ wxBoxSizer *CreatePrinterPresetDialog::create_presets_template_item(wxWindow *pa m_filament_preset_panel->SetSize(PRESET_TEMPLATE_SIZE); m_filament_preset_panel->SetSizer(m_filament_preset_template_sizer); m_filament_sizer->Add(m_filament_preset_panel, 0, wxEXPAND | wxALL, FromDIP(5)); - + wxBoxSizer *hori_filament_btn_sizer = new wxBoxSizer(wxHORIZONTAL); wxPanel * filament_btn_panel = new wxPanel(m_preset_template_panel); filament_btn_panel->SetBackgroundColour(FILAMENT_OPTION_COLOUR); wxStaticText *filament_sel_all_text = new wxStaticText(filament_btn_panel, wxID_ANY, _L("Select All"), wxDefaultPosition, wxDefaultSize); filament_sel_all_text->SetForegroundColour(SELECT_ALL_OPTION_COLOUR); - filament_sel_all_text->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { - select_all_preset_template(m_filament_preset); + filament_sel_all_text->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { + select_all_preset_template(m_filament_preset); e.Skip(); }); wxStaticText *filament_desel_all_text = new wxStaticText(filament_btn_panel, wxID_ANY, _L("Deselect All"), wxDefaultPosition, wxDefaultSize); @@ -2631,7 +2631,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_presets_template_item(wxWindow *pa hori_filament_btn_sizer->Add(filament_desel_all_text, 0, wxEXPAND | wxALL, FromDIP(5)); filament_btn_panel->SetSizer(hori_filament_btn_sizer); m_filament_sizer->Add(filament_btn_panel, 0, wxEXPAND, 0); - + wxPanel *split_panel = new wxPanel(m_preset_template_panel, wxID_ANY, wxDefaultPosition, wxSize(-1, FromDIP(10))); split_panel->SetBackgroundColour(wxColour(*wxWHITE)); m_filament_sizer->Add(split_panel, 0, wxEXPAND, 0); @@ -2643,7 +2643,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_presets_template_item(wxWindow *pa m_process_preset_template_sizer = new wxGridSizer(3, FromDIP(5), FromDIP(5)); m_process_preset_panel->SetSizer(m_process_preset_template_sizer); m_filament_sizer->Add(m_process_preset_panel, 0, wxEXPAND | wxALL, FromDIP(5)); - + wxBoxSizer *hori_process_btn_sizer = new wxBoxSizer(wxHORIZONTAL); wxPanel * process_btn_panel = new wxPanel(m_preset_template_panel); @@ -2849,7 +2849,7 @@ wxWindow *CreatePrinterPresetDialog::create_page2_dialog_buttons(wxWindow *paren successful_preset_names.push_back(sucessful_preset->name.substr(0, sucessful_preset->name.find(" @")) + " @" + printer_preset_name); } } - + /****************************** clone printer preset ********************************/ BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":creater printer "; try { @@ -2861,13 +2861,13 @@ wxWindow *CreatePrinterPresetDialog::create_page2_dialog_buttons(wxWindow *paren if (printer_variant) printer_variant->value = printer_nozzle_name; - auto nozzle_diameter = dynamic_cast(m_printer_preset->config.option("nozzle_diameter", true)); + auto nozzle_diameter = dynamic_cast(m_printer_preset->config.option("nozzle_diameter", true)); if (nozzle_diameter) { std::unordered_map::const_iterator iter = nozzle_diameter_map.find(printer_nozzle_name); if (nozzle_diameter_map.end() != iter) { - nozzle_diameter->values = {iter->second}; + std::fill(nozzle_diameter->values.begin(), nozzle_diameter->values.end(), iter->second); } else { - nozzle_diameter->values = {std::stof(get_nozzle_diameter())}; + std::fill(nozzle_diameter->values.begin(), nozzle_diameter->values.end(), std::stof(get_nozzle_diameter())); } } } @@ -2877,7 +2877,7 @@ wxWindow *CreatePrinterPresetDialog::create_page2_dialog_buttons(wxWindow *paren preset_bundle->printers.save_current_preset(printer_preset_name, true, false, m_printer_preset); preset_bundle->update_compatible(PresetSelectCompatibleType::Always); EndModal(wxID_OK); - + }); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); }); @@ -2908,7 +2908,7 @@ void CreatePrinterPresetDialog::show_page2() } bool CreatePrinterPresetDialog::data_init() -{ +{ std::string nozzle_type = into_u8(m_nozzle_diameter->GetStringSelection()); size_t index_mm = nozzle_type.find(" mm"); if (std::string::npos != index_mm) { @@ -2922,7 +2922,7 @@ bool CreatePrinterPresetDialog::data_init() m_printer_vendor->Set(exist_vendor_choice); m_printer_model->Bind(wxEVT_COMBOBOX, &CreatePrinterPresetDialog::on_preset_model_value_change, this); - + m_printer_vendor->Bind(wxEVT_COMBOBOX, [this, vendors, nozzle](wxCommandEvent e) { m_printer_vendor->SetLabelColor(*wxBLACK); @@ -2935,7 +2935,7 @@ bool CreatePrinterPresetDialog::data_init() dlg.ShowModal(); return; } - + wxArrayString printer_preset_model = printer_preset_sort_with_nozzle_diameter(m_printer_preset_vendor_selected, nozzle); if (printer_preset_model.size() == 0) { MessageDialog dlg(this, _L("Current vendor has no models, please reselect."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); @@ -2943,7 +2943,7 @@ bool CreatePrinterPresetDialog::data_init() return; } m_printer_model->Set(printer_preset_model); - if (!printer_preset_model.empty()) { + if (!printer_preset_model.empty()) { m_printer_model->SetSelection(0); wxCommandEvent e; on_preset_model_value_change(e); @@ -2951,7 +2951,7 @@ bool CreatePrinterPresetDialog::data_init() } rewritten = false; e.Skip(); - + }); return true; @@ -2961,7 +2961,7 @@ void CreatePrinterPresetDialog::set_current_visible_printer() { //The entire process of creating a custom printer only needs to be done once if (m_printer_name_to_preset.size() > 0) return; - PresetBundle *preset_bundle = wxGetApp().preset_bundle; + PresetBundle *preset_bundle = wxGetApp().preset_bundle; const std::deque &printer_presets = preset_bundle->printers.get_presets(); wxArrayString printer_choice; m_printer_name_to_preset.clear(); @@ -3001,9 +3001,9 @@ wxArrayString CreatePrinterPresetDialog::printer_preset_sort_with_nozzle_diamete int index_nearest_nozzle = -1; float nozzle_diameter_diff = 1; - for (int i = 0; i < preset_sort.size(); ++i) { + for (int i = 0; i < preset_sort.size(); ++i) { float curr_nozzle_diameter_diff = std::abs(nozzle_diameter - preset_sort[i].first); - if (curr_nozzle_diameter_diff < nozzle_diameter_diff) { + if (curr_nozzle_diameter_diff < nozzle_diameter_diff) { index_nearest_nozzle = i; nozzle_diameter_diff = curr_nozzle_diameter_diff; if (curr_nozzle_diameter_diff == 0) break; @@ -3011,7 +3011,7 @@ wxArrayString CreatePrinterPresetDialog::printer_preset_sort_with_nozzle_diamete } wxArrayString printer_preset_model_selection; int right_index = index_nearest_nozzle + 1; - while (index_nearest_nozzle >= 0 || right_index < preset_sort.size()) { + while (index_nearest_nozzle >= 0 || right_index < preset_sort.size()) { if (index_nearest_nozzle >= 0 && right_index < preset_sort.size()) { float left_nozzle_diff = std::abs(nozzle_diameter - preset_sort[index_nearest_nozzle].first); float right_nozzle_diff = std::abs(nozzle_diameter - preset_sort[right_index].first); @@ -3029,22 +3029,22 @@ wxArrayString CreatePrinterPresetDialog::printer_preset_sort_with_nozzle_diamete } else if (right_index < preset_sort.size()) { printer_preset_model_selection.Add(from_u8(preset_sort[right_index].second)); right_index++; - } + } } return printer_preset_model_selection; } void CreatePrinterPresetDialog::select_all_preset_template(std::vector> &preset_templates) { - for (std::pair<::CheckBox *, Preset const *> filament_preset : preset_templates) { + for (std::pair<::CheckBox *, Preset const *> filament_preset : preset_templates) { filament_preset.first->SetValue(true); } } void CreatePrinterPresetDialog::deselect_all_preset_template(std::vector> &preset_templates) { - for (std::pair<::CheckBox *, Preset const *> filament_preset : preset_templates) { - filament_preset.first->SetValue(false); + for (std::pair<::CheckBox *, Preset const *> filament_preset : preset_templates) { + filament_preset.first->SetValue(false); } } @@ -3072,7 +3072,7 @@ void CreatePrinterPresetDialog::update_presets_list(bool just_template) } for (const Preset &process_preset : process_presets) { - if (process_preset.is_compatible) { + if (process_preset.is_compatible) { if (process_preset.is_default) continue; Preset *temp_process = new Preset(process_preset); @@ -3085,9 +3085,9 @@ void CreatePrinterPresetDialog::update_presets_list(bool just_template) } void CreatePrinterPresetDialog::clear_preset_combobox() -{ +{ for (std::pair<::CheckBox *, Preset *> preset : m_filament_preset) { - if (preset.second) { + if (preset.second) { delete preset.second; preset.second = nullptr; } @@ -3281,8 +3281,8 @@ wxString CreatePrinterPresetDialog::curr_create_preset_type() const { wxString curr_selected_preset_type; for (const std::pair &presets_radio : m_create_presets_btns) { - if (presets_radio.first->GetValue()) { - curr_selected_preset_type = presets_radio.second; + if (presets_radio.first->GetValue()) { + curr_selected_preset_type = presets_radio.second; } } return curr_selected_preset_type; @@ -3323,18 +3323,18 @@ CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(wxWindow *parent, con wxStaticText *next_step_text = nullptr; bool sync_user_preset_need_enabled = wxGetApp().getAgent() && wxGetApp().app_config->get("sync_user_preset") == "false"; switch (create_success_type) { - case PRINTER: - success_text = new wxStaticText(this, wxID_ANY, _L("Printer Created")); - next_step_text = new wxStaticText(this, wxID_ANY, _L("Please go to printer settings to edit your presets")); + case PRINTER: + success_text = new wxStaticText(this, wxID_ANY, _L("Printer Created")); + next_step_text = new wxStaticText(this, wxID_ANY, _L("Please go to printer settings to edit your presets")); break; - case FILAMENT: - success_text = new wxStaticText(this, wxID_ANY, _L("Filament Created")); + case FILAMENT: + success_text = new wxStaticText(this, wxID_ANY, _L("Filament Created")); wxString prompt_text = _L("Please go to filament setting to edit your presets if you need.\nPlease note that nozzle temperature, hot bed temperature, and maximum " "volumetric speed has a significant impact on printing quality. Please set them carefully."); wxString sync_text = sync_user_preset_need_enabled ? _L("\n\nOrca has detected that your user presets synchronization function is not enabled, " "which may result in unsuccessful Filament settings on the Device page.\n" "Click \"Sync user presets\" to enable the synchronization function.") : ""; - next_step_text = new wxStaticText(this, wxID_ANY, prompt_text + sync_text); + next_step_text = new wxStaticText(this, wxID_ANY, prompt_text + sync_text); break; } success_text->SetFont(Label::Head_18); @@ -3361,7 +3361,7 @@ CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(wxWindow *parent, con } EndModal(wxID_OK); }); - + if (is_cancel_needed) dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); }); @@ -3480,7 +3480,7 @@ void ExportConfigsDialog::show_export_result(const ExportCase &export_case) msg_dlg = new MessageDialog(this, _L("Export successful"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); break; } - + if (msg_dlg) { msg_dlg->ShowModal(); delete msg_dlg; @@ -3501,9 +3501,9 @@ bool ExportConfigsDialog::has_check_box_selected() } bool ExportConfigsDialog::earse_preset_fields_for_safe(Preset *preset) -{ +{ if (preset->type != Preset::Type::TYPE_PRINTER) return true; - + boost::filesystem::path file_path(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp" + "/" + (preset->name + ".json")); preset->file = file_path.make_preferred().string(); @@ -3517,7 +3517,7 @@ bool ExportConfigsDialog::earse_preset_fields_for_safe(Preset *preset) config.erase("printhost_port"); preset->save(nullptr); - return true; + return true; } std::string ExportConfigsDialog::initial_file_path(const wxString &path, const std::string &sub_file_path) @@ -3747,7 +3747,7 @@ void ExportConfigsDialog::select_curr_radiobox(std::vectorSetLabel(_L("Only printer names with changed process presets will be displayed, \nand all user process presets in each printer name you select will be exported as a zip.")); } @@ -3776,7 +3776,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi std::string export_path = initial_file_path(path, ""); if (export_path.empty() || "initial_failed" == export_path) return ExportCase::EXPORT_CANCEL; BOOST_LOG_TRIVIAL(info) << "Export printer preset bundle"; - + for (std::pair<::CheckBox *, Preset *> checkbox_preset : m_preset) { if (checkbox_preset.first->GetValue()) { Preset *printer_preset = checkbox_preset.second; @@ -3804,7 +3804,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive"; return ExportCase::INITIALIZE_FAIL; } - + boost::filesystem::path printer_file_path = boost::filesystem::path(printer_preset->file); std::string preset_path = printer_file_path.make_preferred().string(); if (preset_path.empty()) { @@ -3958,7 +3958,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_filament_bundle_to_ } BOOST_LOG_TRIVIAL(info) << "Filament preset json add successful: " << filament_preset->name; } - + for (const auto& vendor_name_to_json : vendor_structure) { json j; std::string printer_vendor = vendor_name_to_json.first; @@ -4083,7 +4083,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_process_preset_to_f BOOST_LOG_TRIVIAL(info) << "Export process preset: " << process_preset->name << " skip because of the preset file path is empty."; continue; } - + std::string preset_name = process_preset->name + ".json"; config_paths.push_back(std::make_pair(preset_name, preset_path)); } @@ -4135,7 +4135,7 @@ wxWindow *ExportConfigsDialog::create_dialog_buttons(wxWindow* parent) } show_export_result(export_case); if (ExportCase::EXPORT_SUCCESS != export_case) return; - + EndModal(wxID_OK); }); @@ -4207,7 +4207,7 @@ void ExportConfigsDialog::data_init() const std::deque & printer_presets = preset_bundle.printers.get_presets(); for (const Preset &printer_preset : printer_presets) { - + std::string preset_name = printer_preset.name; if (!printer_preset.is_visible || printer_preset.is_default || printer_preset.is_project_embedded) continue; if (preset_bundle.printers.select_preset_by_name(preset_name, true)) { @@ -4230,7 +4230,7 @@ void ExportConfigsDialog::data_init() m_process_presets[preset_name].push_back(new_prpcess_preset); } } - + Preset *new_printer_preset = new Preset(printer_preset); earse_preset_fields_for_safe(new_printer_preset); m_printer_presets[preset_name] = new_printer_preset; @@ -4274,7 +4274,7 @@ EditFilamentPresetDialog::EditFilamentPresetDialog(wxWindow *parent, Filamentinf wxStaticText* basic_information = new wxStaticText(this, wxID_ANY, _L("Basic Information")); basic_information->SetFont(Label::Head_16); - + m_main_sizer->Add(basic_information, 0, wxALL, FromDIP(10)); m_filament_id = filament_info->filament_id; //std::string filament_name = filament_info->filament_name; @@ -4342,7 +4342,7 @@ bool EditFilamentPresetDialog::get_same_filament_id_presets(std::string filament { PresetBundle *preset_bundle = wxGetApp().preset_bundle; const std::deque &filament_presets = preset_bundle->filaments.get_presets(); - + m_printer_compatible_presets.clear(); for (Preset const &preset : filament_presets) { if (preset.is_system || preset.filament_id != filament_id) continue; @@ -4389,7 +4389,7 @@ void EditFilamentPresetDialog::update_preset_tree() m_preset_tree_window->SetMaxSize(wxSize(std::min(1000, width + width_extend), std::min(400, height + height_extend))); m_preset_tree_window->SetSize(wxSize(std::min(1000, width + width_extend), std::min(400, height + height_extend))); this->SetSizerAndFit(m_main_sizer); - + this->Layout(); this->Fit(); this->Refresh(); @@ -4645,14 +4645,14 @@ wxWindow *EditFilamentPresetDialog::create_dialog_buttons() } m_printer_compatible_presets.clear(); wxGetApp().preset_bundle->filaments.select_preset_by_name(next_selected_preset_name,true); - + for (size_t i = 0; i < wxGetApp().preset_bundle->filament_presets.size(); ++i) { auto preset = wxGetApp().preset_bundle->filaments.find_preset(wxGetApp().preset_bundle->filament_presets[i]); if (preset == nullptr) wxGetApp().preset_bundle->filament_presets[i] = wxGetApp().preset_bundle->filaments.get_selected_preset_name(); } EndModal(wxID_OK); } - e.Skip(); + e.Skip(); })); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_OK); }); @@ -4718,7 +4718,7 @@ void CreatePresetForPrinterDialog::get_visible_printer_and_compatible_filament_p } else { filament_types = dynamic_cast(const_cast(filament_preset_base)->config.option("filament_type")); } - + if (filament_types && filament_types->values.empty()) continue; const std::string filament_type = filament_types->values[0]; std::string filament_type_ = m_filament_type == "PLA Aero" ? "PLA-AERO" : m_filament_type; @@ -4738,7 +4738,7 @@ wxBoxSizer *CreatePresetForPrinterDialog::create_selected_printer_preset_sizer() select_preseter_preset_sizer->Add(printer_text, 0, wxEXPAND | wxALL, 0); m_selected_printer = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, PRINTER_PRESET_MODEL_SIZE, 0, nullptr, wxCB_READONLY); select_preseter_preset_sizer->Add(m_selected_printer, 0, wxEXPAND | wxTOP, FromDIP(5)); - + wxArrayString printer_choices; for (std::pair>> printer_to_filament_presets : m_printer_compatible_filament_presets) { auto compatible_printer_name = printer_to_filament_presets.first; @@ -4918,7 +4918,7 @@ wxPanel *PresetTree::get_child_item(wxPanel *parent, std::shared_ptr pre } else { del_preset_btn->SetStyle(ButtonStyle::Alert, ButtonType::Compact); } - + //del_preset_btn->Hide(); sizer->Add(del_preset_btn, 0, wxALL | wxALIGN_CENTER_VERTICAL, 0);