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

@ -204,6 +204,17 @@ void CheckBox::BUILD() {
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
void SpinCtrl::BUILD() {

View file

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

View file

@ -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<Tab *> g_tabs_list;
wxLocale* g_wxLocale;
std::shared_ptr<ConfigOptionsGroup> 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<Tab *>& 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<Tab*>(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<bool>(value)));
break;
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);
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();

View file

@ -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);

View file

@ -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++;

View file

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