Fixed bug with updating of the value of "Wipe while retracting" CheckBox.

This commit is contained in:
YuSanka 2018-03-09 17:17:51 +01:00
parent 419721ce22
commit d5e136a6d5
10 changed files with 47 additions and 24 deletions

View file

@ -118,6 +118,8 @@ sub OnInit {
eval { $self->{preset_bundle}->load_selections($self->{app_config}) }; eval { $self->{preset_bundle}->load_selections($self->{app_config}) };
$run_wizard = 1 if $self->{preset_bundle}->has_defauls_only; $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only;
Slic3r::GUI::set_preset_bundle($self->{preset_bundle});
# application frame # application frame
Wx::Image::FindHandlerType(wxBITMAP_TYPE_PNG) || Wx::Image::AddHandler(Wx::PNGHandler->new); Wx::Image::FindHandlerType(wxBITMAP_TYPE_PNG) || Wx::Image::AddHandler(Wx::PNGHandler->new);
$self->{mainframe} = my $frame = Slic3r::GUI::MainFrame->new( $self->{mainframe} = my $frame = Slic3r::GUI::MainFrame->new(

View file

@ -217,7 +217,7 @@ sub _init_tabpanel {
$self->{is_disabled_button_browse} = (!eval "use Net::Bonjour; 1") ? 1 : 0 ; $self->{is_disabled_button_browse} = (!eval "use Net::Bonjour; 1") ? 1 : 0 ;
# A variable to inform C++ Tab implementation about user_agent # A variable to inform C++ Tab implementation about user_agent
$self->{is_user_agent} = (eval "use LWP::UserAgent; 1") ? 1 : 0 ; $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_disabled_button_browse},
$self->{is_user_agent}, $self->{is_user_agent},
$VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT, $VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT,

View file

@ -389,10 +389,12 @@ sub new {
}); });
}); });
$presets->Add($text, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 4); $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; my $object_info_sizer;
{ {
my $box = Wx::StaticBox->new($self, -1, L("Info")); my $box = Wx::StaticBox->new($self, -1, L("Info"));
@ -473,6 +475,7 @@ sub new {
my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); my $right_sizer = Wx::BoxSizer->new(wxVERTICAL);
$right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; $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($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5);
$right_sizer->Add($self->{list}, 1, wxEXPAND, 5); $right_sizer->Add($self->{list}, 1, wxEXPAND, 5);
$right_sizer->Add($object_info_sizer, 0, wxEXPAND, 0); $right_sizer->Add($object_info_sizer, 0, wxEXPAND, 0);

View file

@ -204,6 +204,17 @@ void CheckBox::BUILD() {
window = dynamic_cast<wxWindow*>(temp); window = dynamic_cast<wxWindow*>(temp);
} }
boost::any CheckBox::get_value()
{
boost::any ret_val;
bool value = dynamic_cast<wxCheckBox*>(window)->GetValue();
if (m_opt.type == coBool)
ret_val = static_cast<bool>(value);
else
ret_val = static_cast<unsigned char>(value);
return ret_val;
}
int undef_spin_val = -9999; //! Probably, It's not necessary int undef_spin_val = -9999; //! Probably, It's not necessary
void SpinCtrl::BUILD() { void SpinCtrl::BUILD() {

View file

@ -171,9 +171,7 @@ public:
dynamic_cast<wxCheckBox*>(window)->SetValue(boost::any_cast<bool>(value)); dynamic_cast<wxCheckBox*>(window)->SetValue(boost::any_cast<bool>(value));
m_disable_change_event = false; m_disable_change_event = false;
} }
boost::any get_value() override { boost::any get_value() override;
return boost::any(dynamic_cast<wxCheckBox*>(window)->GetValue());
}
void enable() override { dynamic_cast<wxCheckBox*>(window)->Enable(); } void enable() override { dynamic_cast<wxCheckBox*>(window)->Enable(); }
void disable() override { dynamic_cast<wxCheckBox*>(window)->Disable(); } void disable() override { dynamic_cast<wxCheckBox*>(window)->Disable(); }

View file

@ -45,6 +45,7 @@
#include "AppConfig.hpp" #include "AppConfig.hpp"
#include "Utils.hpp" #include "Utils.hpp"
#include "Preferences.hpp" #include "Preferences.hpp"
#include "PresetBundle.hpp"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
@ -172,11 +173,14 @@ wxApp *g_wxApp = nullptr;
wxFrame *g_wxMainFrame = nullptr; wxFrame *g_wxMainFrame = nullptr;
wxNotebook *g_wxTabPanel = nullptr; wxNotebook *g_wxTabPanel = nullptr;
AppConfig *g_AppConfig = nullptr; AppConfig *g_AppConfig = nullptr;
PresetBundle *g_PresetBundle= nullptr;
std::vector<Tab *> g_tabs_list; std::vector<Tab *> g_tabs_list;
wxLocale* g_wxLocale; wxLocale* g_wxLocale;
std::shared_ptr<ConfigOptionsGroup> m_optgroup;
void set_wxapp(wxApp *app) void set_wxapp(wxApp *app)
{ {
g_wxApp = app; g_wxApp = app;
@ -197,6 +201,11 @@ void set_app_config(AppConfig *app_config)
g_AppConfig = app_config; g_AppConfig = app_config;
} }
void set_preset_bundle(PresetBundle *preset_bundle)
{
g_PresetBundle = preset_bundle;
}
std::vector<Tab *>& get_tabs_list() std::vector<Tab *>& get_tabs_list()
{ {
return g_tabs_list; return g_tabs_list;
@ -348,15 +357,13 @@ void open_preferences_dialog(int event_preferences)
dlg->ShowModal(); dlg->ShowModal();
} }
void create_preset_tabs(PresetBundle *preset_bundle, void create_preset_tabs(bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
int event_value_change, int event_presets_changed, int event_value_change, int event_presets_changed,
int event_button_browse, int event_button_test) int event_button_browse, int event_button_test)
{ {
add_created_tab(new TabPrint (g_wxTabPanel, no_controller), preset_bundle); add_created_tab(new TabPrint (g_wxTabPanel, no_controller));
add_created_tab(new TabFilament (g_wxTabPanel, no_controller), preset_bundle); 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), add_created_tab(new TabPrinter (g_wxTabPanel, no_controller, is_disabled_button_browse, is_user_agent));
preset_bundle);
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) { for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) {
Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i)); Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
if (! tab) 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<bool>(value))); config.set_key_value(opt_key, new ConfigOptionBool(boost::any_cast<bool>(value)));
break; break;
case coBools:{ case coBools:{
ConfigOptionBools* vec_new = new ConfigOptionBools{ boost::any_cast<bool>(value) }; ConfigOptionBools* vec_new = new ConfigOptionBools{ (bool)boost::any_cast<unsigned char>(value) };
config.option<ConfigOptionBools>(opt_key)->set_at(vec_new, opt_index, 0); config.option<ConfigOptionBools>(opt_key)->set_at(vec_new, opt_index, 0);
break;} break;}
case coInt: 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. // Load the currently selected preset into the GUI, update the preset selection box.
panel->load_current_preset(); panel->load_current_preset();

View file

@ -16,6 +16,7 @@ class wxString;
class wxArrayString; class wxArrayString;
class wxArrayLong; class wxArrayLong;
class wxColour; class wxColour;
class wxBoxSizer;
namespace Slic3r { namespace Slic3r {
@ -71,6 +72,7 @@ void set_wxapp(wxApp *app);
void set_main_frame(wxFrame *main_frame); void set_main_frame(wxFrame *main_frame);
void set_tab_panel(wxNotebook *tab_panel); void set_tab_panel(wxNotebook *tab_panel);
void set_app_config(AppConfig *app_config); void set_app_config(AppConfig *app_config);
void set_preset_bundle(PresetBundle *preset_bundle);
AppConfig* get_app_config(); AppConfig* get_app_config();
wxApp* get_app(); wxApp* get_app();
@ -82,14 +84,13 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change);
void open_preferences_dialog(int event_preferences); void open_preferences_dialog(int event_preferences);
// Create a new preset tab (print, filament and printer), // Create a new preset tab (print, filament and printer),
void create_preset_tabs(PresetBundle *preset_bundle, void create_preset_tabs(bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
int event_value_change, int event_presets_changed, int event_value_change, int event_presets_changed,
int event_button_browse, int event_button_test); int event_button_browse, int event_button_test);
TabIface* get_preset_tab_iface(char *name); TabIface* get_preset_tab_iface(char *name);
// add it at the end of the tab panel. // 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 // Change option value in config
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index = 0); void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index = 0);

View file

@ -114,7 +114,7 @@ public:
inline void disable() { for (auto& field : m_fields) field.second->disable(); } inline void disable() { for (auto& field : m_fields) field.second->disable(); }
OptionsGroup(wxWindow* _parent, wxString title, bool is_tab_opt=false) : 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)); sizer = (staticbox ? new wxStaticBoxSizer(new wxStaticBox(_parent, wxID_ANY, title), wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
auto num_columns = 1U; auto num_columns = 1U;
if (label_width != 0) num_columns++; if (label_width != 0) num_columns++;

View file

@ -1417,8 +1417,8 @@ void TabPrinter::update(){
DynamicPrintConfig new_conf = *m_config; DynamicPrintConfig new_conf = *m_config;
if (dialog->ShowModal() == wxID_YES) { if (dialog->ShowModal() == wxID_YES) {
auto wipe = static_cast<ConfigOptionBools*>(m_config->option("wipe")); auto wipe = static_cast<ConfigOptionBools*>(m_config->option("wipe")->clone());
wipe->values[i] = 0; wipe->values[i] = false;
new_conf.set_key_value("wipe", wipe); new_conf.set_key_value("wipe", wipe);
} }
else { else {

View file

@ -35,12 +35,10 @@ void set_tab_panel(SV *ui)
void add_debug_menu(SV *ui, int event_language_change) 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); %}; %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, void create_preset_tabs(bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
bool is_disabled_button_browse, bool is_user_agent,
int event_value_change, int event_presets_changed, int event_value_change, int event_presets_changed,
int event_button_browse, int event_button_test) int event_button_browse, int event_button_test)
%code%{ Slic3r::GUI::create_preset_tabs(preset_bundle, no_controller, %code%{ Slic3r::GUI::create_preset_tabs(no_controller, is_disabled_button_browse, is_user_agent,
is_disabled_button_browse, is_user_agent,
event_value_change, event_presets_changed, event_value_change, event_presets_changed,
event_button_browse, event_button_test); %}; event_button_browse, event_button_test); %};
@ -61,3 +59,6 @@ void set_app_config(AppConfig *app_config)
void open_preferences_dialog(int preferences_event) void open_preferences_dialog(int preferences_event)
%code%{ Slic3r::GUI::open_preferences_dialog(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); %};