From e8adbd730370d038c14def06cf514be4c18e2376 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 9 Mar 2018 18:34:30 +0100 Subject: [PATCH] First prototype of adding of UI for frequently changed parameters --- lib/Slic3r/GUI/Plater.pm | 1 + xs/src/slic3r/GUI/GUI.cpp | 36 ++++++++++++++++++++++++++++++++++++ xs/src/slic3r/GUI/GUI.hpp | 3 +++ xs/xsp/GUI.xsp | 5 +++++ 4 files changed, 45 insertions(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index f9321daba..a99bbddef 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -394,6 +394,7 @@ sub new { } my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxHORIZONTAL); + Slic3r::GUI::add_frequently_changed_parameters($self, $frequently_changed_parameters_sizer, $presets); my $object_info_sizer; { diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index a615081ae..281ea428a 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -604,4 +604,40 @@ wxWindow *get_widget_by_id(int id) return window; } +void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) +{ + DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; + m_optgroup = std::make_shared(parent, "", config); + //preset_sizer->RecalcSizes(); + const wxArrayInt& ar = preset_sizer->GetColWidths(); + m_optgroup->label_width = 90;//ar.IsEmpty() ? 90 : ar.front(); + m_optgroup->m_on_change = [](t_config_option_key opt_key, boost::any value){ + int i=0;// m_values[opt_key] = boost::any_cast(value) ? "1" : "0"; + }; + m_optgroup->append_single_option_line("fill_density"); + + ConfigOptionDef def; + + def.label = L("Support"); + def.type = coString; + def.gui_type = "select_open"; + def.tooltip = L("Select what kind of support do you need"); + def.enum_labels.push_back(L("None")); + def.enum_labels.push_back(L("Support on build plate only")); + def.enum_labels.push_back(L("Everywhere")); + def.default_value = new ConfigOptionString(L("None")); + Option option(def, "support"); + m_optgroup->append_single_option_line(option); + + def.label = L("Brim"); + def.type = coBool; + def.tooltip = L("This flag enables the brim that will be printed around each object on the first layer."); + def.default_value = new ConfigOptionBool{ false }; // 1; + def.gui_type = ""; + option = Option(def, "brim"); + m_optgroup->append_single_option_line(option); + + sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxBottom, 1); +} + } } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index a0e03a768..a27f13f69 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -17,6 +17,7 @@ class wxArrayString; class wxArrayLong; class wxColour; class wxBoxSizer; +class wxFlexGridSizer; namespace Slic3r { @@ -127,6 +128,8 @@ wxString from_u8(const std::string &str); wxWindow *get_widget_by_id(int id); +void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer); + } } diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index cbdd836da..be36c531f 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -62,3 +62,8 @@ void open_preferences_dialog(int preferences_event) void set_preset_bundle(PresetBundle *preset_bundle) %code%{ Slic3r::GUI::set_preset_bundle(preset_bundle); %}; + +void add_frequently_changed_parameters(SV *ui_parent, SV *ui_sizer, SV *ui_p_sizer) + %code%{ Slic3r::GUI::add_frequently_changed_parameters((wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), + (wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"), + (wxFlexGridSizer*)wxPli_sv_2_object(aTHX_ ui_p_sizer, "Wx::FlexGridSizer")); %};