From 2ddd2ed4c74079e81230a34b8c231426184d8a46 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 5 Mar 2019 15:33:38 +0100 Subject: [PATCH] Fixed a preset selection after a config wizard running (SPE-841) --- src/slic3r/GUI/GUI.cpp | 22 ++++++++++++++++++++-- src/slic3r/GUI/GUI_ObjectList.cpp | 10 +++++----- src/slic3r/GUI/GUI_ObjectList.hpp | 2 -- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index e09ce2466..85c8b48ab 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -30,6 +30,8 @@ #include "libslic3r/Utils.hpp" #include "libslic3r/Print.hpp" +#include "Tab.hpp" +#include "GUI_ObjectList.hpp" namespace Slic3r { namespace GUI { @@ -123,6 +125,9 @@ void config_wizard(int reason) if (! wxGetApp().check_unsaved_changes()) return; + // save selected preset before config wizard running + const auto printer_preset_name = wxGetApp().preset_bundle->printers.get_edited_preset().name; + try { ConfigWizard wizard(nullptr, static_cast(reason)); wizard.run(wxGetApp().preset_bundle, wxGetApp().preset_updater); @@ -131,8 +136,21 @@ void config_wizard(int reason) show_error(nullptr, e.what()); } - // Load the currently selected preset into the GUI, update the preset selection box. - wxGetApp().load_current_presets(); + // select old(before config wizard running) preset + wxGetApp().get_tab(Preset::TYPE_PRINTER)->select_preset(printer_preset_name); + // If old preset if invisible now, then first visible preset will be selected + // So, let control the case if multi-part object is on the scene and first visible preset is SLA + if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA && + wxGetApp().obj_list()->has_multi_part_objects()) + { + show_info(nullptr, + _(L("It's impossible to print multi-part object(s) with SLA technology.")) + "\n\n" + + _(L("Please check and fixe your object list.")), + _(L("Attention!"))); + } + + // Load the currently selected preset into the GUI, update the preset selection box. + // wxGetApp().load_current_presets(); // #ys_FIXME_to_delete presets are loaded now in select_preset function } // opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index c2ff7bfb7..a961c9ffa 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -38,6 +38,11 @@ FreqSettingsBundle FREQ_SETTINGS_BUNDLE_SLA = { L("Pad and Support") , { "supports_enable", "pad_enable" } } }; +static PrinterTechnology printer_technology() +{ + return wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology(); +} + ObjectList::ObjectList(wxWindow* parent) : wxDataViewCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_MULTIPLE), m_parent(parent) @@ -667,11 +672,6 @@ void ObjectList::get_options_menu(settings_menu_hierarchy& settings_menu, const } } -Slic3r::PrinterTechnology ObjectList::printer_technology() const -{ - return wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology(); -} - void ObjectList::get_settings_choice(const wxString& category_name) { wxArrayString names; diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 9e24b4b49..7d14eb13f 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -284,8 +284,6 @@ private: std::vector get_options(const bool is_part); const std::vector& get_options_for_bundle(const wxString& bundle_name); void get_options_menu(settings_menu_hierarchy& settings_menu, const bool is_part); - - PrinterTechnology printer_technology() const ; };