Filled content_object_settings

This commit is contained in:
YuSanka 2018-05-22 16:14:41 +02:00
parent 2a8391dfbf
commit ec5b98477d
5 changed files with 73 additions and 33 deletions

View file

@ -118,7 +118,7 @@ std::vector<Tab *> g_tabs_list;
wxLocale* g_wxLocale; wxLocale* g_wxLocale;
std::shared_ptr<ConfigOptionsGroup> m_optgroup; std::vector <std::shared_ptr<ConfigOptionsGroup>> m_optgroups;
double m_brim_width = 0.0; double m_brim_width = 0.0;
wxButton* g_wiping_dialog_button = nullptr; wxButton* g_wiping_dialog_button = nullptr;
@ -379,7 +379,6 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l
// local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); // local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates")));
local_menu->AppendSeparator(); local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences"))+"\u2026\tCtrl+,", _(L("Application preferences"))); local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences"))+"\u2026\tCtrl+,", _(L("Application preferences")));
local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language")));
local_menu->AppendSeparator(); local_menu->AppendSeparator();
auto mode_menu = new wxMenu(); auto mode_menu = new wxMenu();
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("&Simple")), _(L("Simple View Mode"))); mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("&Simple")), _(L("Simple View Mode")));
@ -389,6 +388,11 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l
local_menu->AppendSubMenu(mode_menu, _(L("&Mode")), _(L("Slic3r View Mode"))); local_menu->AppendSubMenu(mode_menu, _(L("&Mode")), _(L("Slic3r View Mode")));
local_menu->AppendSeparator(); local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language")));
local_menu->AppendSeparator();
local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _(L("Flash printer firmware")), _(L("Upload a firmware image into an Arduino based printer")));
// TODO: for when we're able to flash dictionaries
// local_menu->Append(config_id_base + FirmwareMenuDict, _(L("Flash language file")), _(L("Upload a language dictionary file into a Prusa printer")));
local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){
switch (event.GetId() - config_id_base) { switch (event.GetId() - config_id_base) {
case ConfigMenuWizard: case ConfigMenuWizard:
@ -876,8 +880,36 @@ wxBoxSizer* content_objects_list(wxWindow *win)
wxBoxSizer* content_object_settings(wxWindow *win) wxBoxSizer* content_object_settings(wxWindow *win)
{ {
DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config;
std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(win, "", config, false, ogSIDE_OPTIONS_VERTICAL);
optgroup->label_width = 100;
Line line = { _(L("Position")), "" };
ConfigOptionDef def;
def.label = L("X");
def.type = coInt;
def.default_value = new ConfigOptionInt(1);
def.sidetext = L("mm");
Option option = Option(def, "position_X");
option.opt.full_width = true;
line.append_option(option);
def.label = L("Y");
option = Option(def, "position_Y");
line.append_option(option);
def.label = L("Z");
option = Option(def, "position_Z");
line.append_option(option);
optgroup->append_line(line);
m_optgroups.push_back(optgroup); // ogObjectSettings
auto sizer = new wxBoxSizer(wxVERTICAL); auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(new wxStaticText(win, wxID_ANY, "Some object text")); sizer->Add(optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2);
return sizer; return sizer;
} }
@ -929,10 +961,10 @@ void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer)
void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer)
{ {
DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config;
m_optgroup = std::make_shared<ConfigOptionsGroup>(parent, "", config); std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(parent, "", config);
const wxArrayInt& ar = preset_sizer->GetColWidths(); const wxArrayInt& ar = preset_sizer->GetColWidths();
m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front()-4; // doesn't work optgroup->label_width = ar.IsEmpty() ? 100 : ar.front()-4; // doesn't work
m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){
TabPrint* tab_print = nullptr; TabPrint* tab_print = nullptr;
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));
@ -947,7 +979,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
return; return;
if (opt_key == "fill_density"){ if (opt_key == "fill_density"){
value = m_optgroup->get_config_value(*config, opt_key); value = m_optgroups[ogFrequentlyChangingParameters]->get_config_value(*config, opt_key);
tab_print->set_value(opt_key, value); tab_print->set_value(opt_key, value);
tab_print->update(); tab_print->update();
} }
@ -985,10 +1017,10 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
tab_print->update_dirty(); tab_print->update_dirty();
}; };
Option option = m_optgroup->get_option("fill_density"); Option option = optgroup->get_option("fill_density");
option.opt.sidetext = ""; option.opt.sidetext = "";
option.opt.full_width = true; option.opt.full_width = true;
m_optgroup->append_single_option_line(option); optgroup->append_single_option_line(option);
ConfigOptionDef def; ConfigOptionDef def;
@ -1007,7 +1039,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
def.default_value = new ConfigOptionStrings { selection }; def.default_value = new ConfigOptionStrings { selection };
option = Option(def, "support"); option = Option(def, "support");
option.opt.full_width = true; option.opt.full_width = true;
m_optgroup->append_single_option_line(option); optgroup->append_single_option_line(option);
m_brim_width = config->opt_float("brim_width"); m_brim_width = config->opt_float("brim_width");
def.label = L("Brim"); def.label = L("Brim");
@ -1016,7 +1048,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
def.gui_type = ""; def.gui_type = "";
def.default_value = new ConfigOptionBool{ m_brim_width > 0.0 ? true : false }; def.default_value = new ConfigOptionBool{ m_brim_width > 0.0 ? true : false };
option = Option(def, "brim"); option = Option(def, "brim");
m_optgroup->append_single_option_line(option); optgroup->append_single_option_line(option);
Line line = { "", "" }; Line line = { "", "" };
@ -1041,9 +1073,11 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
})); }));
return sizer; return sizer;
}; };
m_optgroup->append_line(line); optgroup->append_line(line);
sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); sizer->Add(optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2);
m_optgroups.push_back(optgroup);// ogFrequentlyChangingParameters
} }
void show_frequently_changed_parameters(bool show) void show_frequently_changed_parameters(bool show)
@ -1094,9 +1128,9 @@ void update_mode()
g_right_panel->Layout(); g_right_panel->Layout();
} }
ConfigOptionsGroup* get_optgroup() ConfigOptionsGroup* get_optgroup(size_t i)
{ {
return m_optgroup.get(); return m_optgroups[i].get();
} }

View file

@ -47,9 +47,10 @@ class TabIface;
namespace GUI { namespace GUI {
enum ogDrawFlag{ enum ogGroup{
ogDEFAULT, ogFrequentlyChangingParameters,
ogSIDE_OPTIONS_TO_GRID ogObjectSettings,
ogPartSettings
}; };
class Tab; class Tab;
@ -173,7 +174,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
// Update view mode according to selected menu // Update view mode according to selected menu
void update_mode(); void update_mode();
ConfigOptionsGroup* get_optgroup(); ConfigOptionsGroup* get_optgroup(size_t i);
wxButton* get_wiping_dialog_button(); wxButton* get_wiping_dialog_button();
void add_export_option(wxFileDialog* dlg, const std::string& format); void add_export_option(wxFileDialog* dlg, const std::string& format);

View file

@ -175,9 +175,9 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
// If we're here, we have more than one option or a single option with sidetext // If we're here, we have more than one option or a single option with sidetext
// so we need a horizontal sizer to arrange these things // so we need a horizontal sizer to arrange these things
// If we have a single option with no sidetext just add it directly to the grid sizer auto sizer = new wxBoxSizer((m_flag & ogSIDE_OPTIONS_VERTICAL) != 0 ? wxVERTICAL :wxHORIZONTAL);
auto sizer = new wxBoxSizer(wxHORIZONTAL);
grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM|wxTOP|wxLEFT), staticbox ? 0 : 1); grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM|wxTOP|wxLEFT), staticbox ? 0 : 1);
// If we have a single option with no sidetext just add it directly to the grid sizer
if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 && if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) { option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) {
const auto& option = option_set.front(); const auto& option = option_set.front();

View file

@ -26,6 +26,11 @@
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
enum ogDrawFlag{
ogDEFAULT,
ogSIDE_OPTIONS_VERTICAL
};
/// Widget type describes a function object that returns a wxWindow (our widget) and accepts a wxWidget (parent window). /// Widget type describes a function object that returns a wxWindow (our widget) and accepts a wxWidget (parent window).
using widget_t = std::function<wxSizer*(wxWindow*)>;//!std::function<wxWindow*(wxWindow*)>; using widget_t = std::function<wxSizer*(wxWindow*)>;//!std::function<wxWindow*(wxWindow*)>;
using column_t = std::function<wxSizer*(const Line&)>; using column_t = std::function<wxSizer*(const Line&)>;
@ -183,8 +188,8 @@ protected:
class ConfigOptionsGroup: public OptionsGroup { class ConfigOptionsGroup: public OptionsGroup {
public: public:
ConfigOptionsGroup(wxWindow* parent, const wxString& title, DynamicPrintConfig* _config = nullptr, bool is_tab_opt = false) : ConfigOptionsGroup(wxWindow* parent, const wxString& title, DynamicPrintConfig* _config = nullptr, bool is_tab_opt = false, ogDrawFlag flag = ogDEFAULT) :
OptionsGroup(parent, title, is_tab_opt), m_config(_config) {} OptionsGroup(parent, title, is_tab_opt, flag), m_config(_config) {}
/// reference to libslic3r config, non-owning pointer (?). /// reference to libslic3r config, non-owning pointer (?).
DynamicPrintConfig* m_config {nullptr}; DynamicPrintConfig* m_config {nullptr};

View file

@ -679,8 +679,8 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
} }
if (opt_key == "fill_density") if (opt_key == "fill_density")
{ {
boost::any val = get_optgroup()->get_config_value(*m_config, opt_key); boost::any val = get_optgroup(ogFrequentlyChangingParameters)->get_config_value(*m_config, opt_key);
get_optgroup()->set_value(opt_key, val); get_optgroup(ogFrequentlyChangingParameters)->set_value(opt_key, val);
} }
if (opt_key == "support_material" || opt_key == "support_material_buildplate_only") if (opt_key == "support_material" || opt_key == "support_material_buildplate_only")
{ {
@ -689,12 +689,12 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
m_config->opt_bool("support_material_buildplate_only") ? m_config->opt_bool("support_material_buildplate_only") ?
_("Support on build plate only") : _("Support on build plate only") :
_("Everywhere"); _("Everywhere");
get_optgroup()->set_value("support", new_selection); get_optgroup(ogFrequentlyChangingParameters)->set_value("support", new_selection);
} }
if (opt_key == "brim_width") if (opt_key == "brim_width")
{ {
bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; bool val = m_config->opt_float("brim_width") > 0.0 ? true : false;
get_optgroup()->set_value("brim", val); get_optgroup(ogFrequentlyChangingParameters)->set_value("brim", val);
} }
if (opt_key == "wipe_tower" || opt_key == "single_extruder_multi_material" || opt_key == "extruders_count" ) if (opt_key == "wipe_tower" || opt_key == "single_extruder_multi_material" || opt_key == "extruders_count" )
@ -784,18 +784,18 @@ void Tab::update_preset_description_line()
void Tab::update_frequently_changed_parameters() void Tab::update_frequently_changed_parameters()
{ {
boost::any value = get_optgroup()->get_config_value(*m_config, "fill_density"); boost::any value = get_optgroup(ogFrequentlyChangingParameters)->get_config_value(*m_config, "fill_density");
get_optgroup()->set_value("fill_density", value); get_optgroup(ogFrequentlyChangingParameters)->set_value("fill_density", value);
wxString new_selection = !m_config->opt_bool("support_material") ? wxString new_selection = !m_config->opt_bool("support_material") ?
_("None") : _("None") :
m_config->opt_bool("support_material_buildplate_only") ? m_config->opt_bool("support_material_buildplate_only") ?
_("Support on build plate only") : _("Support on build plate only") :
_("Everywhere"); _("Everywhere");
get_optgroup()->set_value("support", new_selection); get_optgroup(ogFrequentlyChangingParameters)->set_value("support", new_selection);
bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; bool val = m_config->opt_float("brim_width") > 0.0 ? true : false;
get_optgroup()->set_value("brim", val); get_optgroup(ogFrequentlyChangingParameters)->set_value("brim", val);
update_wiping_button_visibility(); update_wiping_button_visibility();
} }