From 00e9062e15cce3e737f37e77ad2012e5b78e6c77 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Mon, 16 Oct 2023 21:19:00 +0800 Subject: [PATCH] ENH:add no warnings option while loading 3mf with modified gcodes JIRA: STUDIO-4628 Change-Id: I82e6e518de06873f34a4a65fea78d5f535a95dae (cherry picked from commit 1de5dba55955836962307305b918cdbfe1a5a8d5) --- src/slic3r/GUI/MsgDialog.cpp | 5 ++-- src/slic3r/GUI/Plater.cpp | 55 +++++++++++++++++++++------------- src/slic3r/GUI/Preferences.cpp | 8 +++-- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 8db746330..761951e34 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -55,12 +55,11 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he topsizer->Add(LOGO_GAP, 0, 0, wxEXPAND, 0); topsizer->Add(rightsizer, 1, wxTOP | wxEXPAND, BORDER); - btn_sizer->AddStretchSpacer(); - main_sizer->Add(topsizer, 1, wxEXPAND); m_dsa_sizer = new wxBoxSizer(wxHORIZONTAL); - btn_sizer->Add(m_dsa_sizer,1,wxEXPAND,0); + btn_sizer->Add(0, 0, 0, wxLEFT, FromDIP(120)); + btn_sizer->Add(m_dsa_sizer, 0, wxEXPAND,0); btn_sizer->Add(0, 0, 1, wxEXPAND, 5); main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BORDER); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f6675acae..76f018e8a 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -794,7 +794,7 @@ Sidebar::Sidebar(Plater *parent) wxPostEvent(parent, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, parent)); } })); - + bSizer39->Add(p->m_flushing_volume_btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(5)); bSizer39->Hide(p->m_flushing_volume_btn); bSizer39->Add(FromDIP(10), 0, 0, 0, 0 ); @@ -3474,25 +3474,40 @@ std::vector Plater::priv::load_files(const std::vector& input_ if (!config.empty()) { Preset::normalize(config); PresetBundle *preset_bundle = wxGetApp().preset_bundle; - // BBS: first validate the printer - // validate the system profiles - std::set modified_gcodes; - int validated = preset_bundle->validate_presets(filename.string(), config, modified_gcodes); - if (validated == VALIDATE_PRESETS_MODIFIED_GCODES) { - std::string warning_message; - warning_message += "\n"; - for (std::set::iterator it=modified_gcodes.begin(); it!=modified_gcodes.end(); ++it) - warning_message += "-" + *it + "\n"; - warning_message += "\n"; - show_info(q, _L("The 3mf has following modified G-codes in filament or printer presets:") + warning_message+ _L("Please confirm that these modified G-codes are safe to prevent any damage to the machine!"), _L("Modified G-codes")); - } - else if ((validated == VALIDATE_PRESETS_PRINTER_NOT_FOUND) || (validated == VALIDATE_PRESETS_FILAMENTS_NOT_FOUND)) { - std::string warning_message; - warning_message += "\n"; - for (std::set::iterator it=modified_gcodes.begin(); it!=modified_gcodes.end(); ++it) - warning_message += "-" + *it + "\n"; - warning_message += "\n"; - show_info(q, _L("The 3mf has following customized filament or printer presets:") + warning_message + _L("Please confirm that the G-codes within these presets are safe to prevent any damage to the machine!"), _L("Customized Preset")); + + auto choise = wxGetApp().app_config->get("no_warn_when_modified_gcodes"); + if (choise.empty() || choise != "true") { + // BBS: first validate the printer + // validate the system profiles + std::set modified_gcodes; + int validated = preset_bundle->validate_presets(filename.string(), config, modified_gcodes); + if (validated == VALIDATE_PRESETS_MODIFIED_GCODES) { + std::string warning_message; + warning_message += "\n"; + for (std::set::iterator it=modified_gcodes.begin(); it!=modified_gcodes.end(); ++it) + warning_message += "-" + *it + "\n"; + warning_message += "\n"; + //show_info(q, _L("The 3mf has following modified G-codes in filament or printer presets:") + warning_message+ _L("Please confirm that these modified G-codes are safe to prevent any damage to the machine!"), _L("Modified G-codes")); + + MessageDialog dlg(q, _L("The 3mf has following modified G-codes in filament or printer presets:") + warning_message+ _L("Please confirm that these modified G-codes are safe to prevent any damage to the machine!"), _L("Modified G-codes")); + dlg.show_dsa_button(); + auto res = dlg.ShowModal(); + if (dlg.get_checkbox_state()) + wxGetApp().app_config->set("no_warn_when_modified_gcodes", "true"); + } + else if ((validated == VALIDATE_PRESETS_PRINTER_NOT_FOUND) || (validated == VALIDATE_PRESETS_FILAMENTS_NOT_FOUND)) { + std::string warning_message; + warning_message += "\n"; + for (std::set::iterator it=modified_gcodes.begin(); it!=modified_gcodes.end(); ++it) + warning_message += "-" + *it + "\n"; + warning_message += "\n"; + //show_info(q, _L("The 3mf has following customized filament or printer presets:") + warning_message + _L("Please confirm that the G-codes within these presets are safe to prevent any damage to the machine!"), _L("Customized Preset")); + MessageDialog dlg(q, _L("The 3mf has following customized filament or printer presets:") + warning_message+ _L("Please confirm that the G-codes within these presets are safe to prevent any damage to the machine!"), _L("Customized Preset")); + dlg.show_dsa_button(); + auto res = dlg.ShowModal(); + if (dlg.get_checkbox_state()) + wxGetApp().app_config->set("no_warn_when_modified_gcodes", "true"); + } } //always load config diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index d20049a37..0b7794431 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -691,8 +691,8 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa #endif // __WXMSW__ - if (param == "developer_mode") - { + if (param == "developer_mode") + { m_developer_mode_def = app_config->get("developer_mode"); if (m_developer_mode_def == "true") { Slic3r::GUI::wxGetApp().save_mode(comDevelop); @@ -701,7 +701,7 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa } } - // webview dump_vedio + // webview dump_vedio if (param == "internal_developer_mode") { m_internal_developer_mode_def = app_config->get("internal_developer_mode"); if (m_internal_developer_mode_def == "true") { @@ -1026,6 +1026,7 @@ wxWindow* PreferencesDialog::create_general_page() wxGetApp().app_config->set("save_project_choise", ""); }); // auto item_backup = create_item_switch(_L("Backup switch"), page, _L("Backup switch"), "units"); + auto item_gcodes_warning = create_item_checkbox(_L("No warnings when loading 3MF with modified G-codes"), page,_L("No warnings when loading 3MF with modified G-codes"), 50, "no_warn_when_modified_gcodes"); auto item_backup = create_item_checkbox(_L("Auto-Backup"), page,_L("Backup your project periodically for restoring from the occasional crash."), 50, "backup_switch"); auto item_backup_interval = create_item_backup_input(_L("every"), page, _L("The peroid of backup in seconds."), "backup_interval"); @@ -1075,6 +1076,7 @@ wxWindow* PreferencesDialog::create_general_page() sizer_page->Add(title_project, 0, wxTOP| wxEXPAND, FromDIP(20)); sizer_page->Add(item_max_recent_count, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_save_choise, 0, wxTOP, FromDIP(3)); + sizer_page->Add(item_gcodes_warning, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_backup, 0, wxTOP,FromDIP(3)); item_backup->Add(item_backup_interval, 0, wxLEFT, 0);