diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 7a3b30a6b0..1aa6ba955f 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -117,6 +117,8 @@ sub OnInit { } eval { $self->{preset_bundle}->load_selections($self->{app_config}) }; $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only; + + Slic3r::GUI::set_preset_bundle($self->{preset_bundle}); # application frame Wx::Image::FindHandlerType(wxBITMAP_TYPE_PNG) || Wx::Image::AddHandler(Wx::PNGHandler->new); diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 442d0abc95..f5a9021c02 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -217,7 +217,7 @@ sub _init_tabpanel { $self->{is_disabled_button_browse} = (!eval "use Net::Bonjour; 1") ? 1 : 0 ; # A variable to inform C++ Tab implementation about user_agent $self->{is_user_agent} = (eval "use LWP::UserAgent; 1") ? 1 : 0 ; - Slic3r::GUI::create_preset_tabs(wxTheApp->{preset_bundle}, $self->{no_controller}, + Slic3r::GUI::create_preset_tabs($self->{no_controller}, $self->{is_disabled_button_browse}, $self->{is_user_agent}, $VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT, diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d48e31462e..f9321daba4 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -389,9 +389,11 @@ sub new { }); }); $presets->Add($text, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 4); - $presets->Add($choice, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxBOTTOM, 0); + $presets->Add($choice, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxBOTTOM, 1); } } + + my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxHORIZONTAL); my $object_info_sizer; { @@ -473,6 +475,7 @@ sub new { my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; + $right_sizer->Add($frequently_changed_parameters_sizer, 0, wxEXPAND | wxTOP, 10) if defined $frequently_changed_parameters_sizer; $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5); $right_sizer->Add($self->{list}, 1, wxEXPAND, 5); $right_sizer->Add($object_info_sizer, 0, wxEXPAND, 0); diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 8fe70479ff..2161e8ec65 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -204,6 +204,17 @@ void CheckBox::BUILD() { window = dynamic_cast(temp); } +boost::any CheckBox::get_value() +{ + boost::any ret_val; + bool value = dynamic_cast(window)->GetValue(); + if (m_opt.type == coBool) + ret_val = static_cast(value); + else + ret_val = static_cast(value); + return ret_val; +} + int undef_spin_val = -9999; //! Probably, It's not necessary void SpinCtrl::BUILD() { diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index b711052b51..db8ad4c9f7 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -171,9 +171,7 @@ public: dynamic_cast(window)->SetValue(boost::any_cast(value)); m_disable_change_event = false; } - boost::any get_value() override { - return boost::any(dynamic_cast(window)->GetValue()); - } + boost::any get_value() override; void enable() override { dynamic_cast(window)->Enable(); } void disable() override { dynamic_cast(window)->Disable(); } diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index a0b1bbd095..a615081ae0 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -45,6 +45,7 @@ #include "AppConfig.hpp" #include "Utils.hpp" #include "Preferences.hpp" +#include "PresetBundle.hpp" namespace Slic3r { namespace GUI { @@ -172,11 +173,14 @@ wxApp *g_wxApp = nullptr; wxFrame *g_wxMainFrame = nullptr; wxNotebook *g_wxTabPanel = nullptr; AppConfig *g_AppConfig = nullptr; +PresetBundle *g_PresetBundle= nullptr; std::vector g_tabs_list; wxLocale* g_wxLocale; +std::shared_ptr m_optgroup; + void set_wxapp(wxApp *app) { g_wxApp = app; @@ -197,6 +201,11 @@ void set_app_config(AppConfig *app_config) g_AppConfig = app_config; } +void set_preset_bundle(PresetBundle *preset_bundle) +{ + g_PresetBundle = preset_bundle; +} + std::vector& get_tabs_list() { return g_tabs_list; @@ -348,15 +357,13 @@ void open_preferences_dialog(int event_preferences) dlg->ShowModal(); } -void create_preset_tabs(PresetBundle *preset_bundle, - bool no_controller, bool is_disabled_button_browse, bool is_user_agent, +void create_preset_tabs(bool no_controller, bool is_disabled_button_browse, bool is_user_agent, int event_value_change, int event_presets_changed, int event_button_browse, int event_button_test) { - add_created_tab(new TabPrint (g_wxTabPanel, no_controller), preset_bundle); - add_created_tab(new TabFilament (g_wxTabPanel, no_controller), preset_bundle); - add_created_tab(new TabPrinter (g_wxTabPanel, no_controller, is_disabled_button_browse, is_user_agent), - preset_bundle); + add_created_tab(new TabPrint (g_wxTabPanel, no_controller)); + add_created_tab(new TabFilament (g_wxTabPanel, no_controller)); + add_created_tab(new TabPrinter (g_wxTabPanel, no_controller, is_disabled_button_browse, is_user_agent)); for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) { Tab *tab = dynamic_cast(g_wxTabPanel->GetPage(i)); if (! tab) @@ -440,7 +447,7 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b config.set_key_value(opt_key, new ConfigOptionBool(boost::any_cast(value))); break; case coBools:{ - ConfigOptionBools* vec_new = new ConfigOptionBools{ boost::any_cast(value) }; + ConfigOptionBools* vec_new = new ConfigOptionBools{ (bool)boost::any_cast(value) }; config.option(opt_key)->set_at(vec_new, opt_index, 0); break;} case coInt: @@ -480,9 +487,9 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b } } -void add_created_tab(Tab* panel, PresetBundle *preset_bundle) +void add_created_tab(Tab* panel) { - panel->create_preset_tab(preset_bundle); + panel->create_preset_tab(g_PresetBundle); // Load the currently selected preset into the GUI, update the preset selection box. panel->load_current_preset(); diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 889d31318b..a0e03a7687 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -16,6 +16,7 @@ class wxString; class wxArrayString; class wxArrayLong; class wxColour; +class wxBoxSizer; namespace Slic3r { @@ -71,6 +72,7 @@ void set_wxapp(wxApp *app); void set_main_frame(wxFrame *main_frame); void set_tab_panel(wxNotebook *tab_panel); void set_app_config(AppConfig *app_config); +void set_preset_bundle(PresetBundle *preset_bundle); AppConfig* get_app_config(); wxApp* get_app(); @@ -82,14 +84,13 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change); void open_preferences_dialog(int event_preferences); // Create a new preset tab (print, filament and printer), -void create_preset_tabs(PresetBundle *preset_bundle, - bool no_controller, bool is_disabled_button_browse, bool is_user_agent, +void create_preset_tabs(bool no_controller, bool is_disabled_button_browse, bool is_user_agent, int event_value_change, int event_presets_changed, int event_button_browse, int event_button_test); TabIface* get_preset_tab_iface(char *name); // add it at the end of the tab panel. -void add_created_tab(Tab* panel, PresetBundle *preset_bundle); +void add_created_tab(Tab* panel); // Change option value in config void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index = 0); diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 63ba91e6ca..42db222254 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -114,7 +114,7 @@ public: inline void disable() { for (auto& field : m_fields) field.second->disable(); } OptionsGroup(wxWindow* _parent, wxString title, bool is_tab_opt=false) : - m_parent(_parent), title(title), m_is_tab_opt(is_tab_opt) { + m_parent(_parent), title(title), m_is_tab_opt(is_tab_opt), staticbox(title!="") { sizer = (staticbox ? new wxStaticBoxSizer(new wxStaticBox(_parent, wxID_ANY, title), wxVERTICAL) : new wxBoxSizer(wxVERTICAL)); auto num_columns = 1U; if (label_width != 0) num_columns++; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index aef85c78d7..7250172978 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1417,8 +1417,8 @@ void TabPrinter::update(){ DynamicPrintConfig new_conf = *m_config; if (dialog->ShowModal() == wxID_YES) { - auto wipe = static_cast(m_config->option("wipe")); - wipe->values[i] = 0; + auto wipe = static_cast(m_config->option("wipe")->clone()); + wipe->values[i] = false; new_conf.set_key_value("wipe", wipe); } else { diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index cae480c2f0..cbdd836dac 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -35,12 +35,10 @@ void set_tab_panel(SV *ui) void add_debug_menu(SV *ui, int event_language_change) %code%{ Slic3r::GUI::add_debug_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_language_change); %}; -void create_preset_tabs(PresetBundle *preset_bundle, bool no_controller, - bool is_disabled_button_browse, bool is_user_agent, +void create_preset_tabs(bool no_controller, bool is_disabled_button_browse, bool is_user_agent, int event_value_change, int event_presets_changed, int event_button_browse, int event_button_test) - %code%{ Slic3r::GUI::create_preset_tabs(preset_bundle, no_controller, - is_disabled_button_browse, is_user_agent, + %code%{ Slic3r::GUI::create_preset_tabs(no_controller, is_disabled_button_browse, is_user_agent, event_value_change, event_presets_changed, event_button_browse, event_button_test); %}; @@ -61,3 +59,6 @@ void set_app_config(AppConfig *app_config) void open_preferences_dialog(int preferences_event) %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %}; + +void set_preset_bundle(PresetBundle *preset_bundle) + %code%{ Slic3r::GUI::set_preset_bundle(preset_bundle); %};