diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index d4a351e74..5e33ea784 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -547,8 +547,11 @@ boost::any& Choice::get_value() // boost::any m_value; wxString ret_str = static_cast(window)->GetValue(); - if (m_opt_id == "support") - return m_value = boost::any(ret_str);//ret_str; + // options from right panel + std::vector right_panel_options{ "support", "scale_unit" }; + for (auto rp_option: right_panel_options) + if (m_opt_id == rp_option) + return m_value = boost::any(ret_str); if (m_opt.type != coEnum) /*m_value = */get_value_by_opt_type(ret_str); diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 04ee8c87b..54dc596b5 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -188,6 +188,10 @@ public: return false; } + void set_side_text_ptr(wxStaticText* side_text) { + m_side_text = side_text; + } + protected: MyButton* m_Undo_btn = nullptr; // Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. @@ -202,6 +206,8 @@ protected: // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. const wxColour* m_label_color = nullptr; + wxStaticText* m_side_text = nullptr; + // current value boost::any m_value; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 0262e20e5..82cd21efe 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -909,47 +909,6 @@ void add_expert_mode_part( wxWindow* parent, wxBoxSizer* sizer, // add_collapsible_panes(parent, sizer); } -Line add_og_to_object_settings(const std::string& option_name, const std::string& sidetext, int def_value = 0) -{ - Line line = { _(option_name), "" }; - ConfigOptionDef def; - - def.label = L("X"); - def.type = coInt; - def.default_value = new ConfigOptionInt(def_value); - def.sidetext = sidetext; - def.width = 70; - - const std::string lower_name = boost::algorithm::to_lower_copy(option_name); - - Option option = Option(def, lower_name + "_X"); - option.opt.full_width = true; - line.append_option(option); - - def.label = L("Y"); - option = Option(def, lower_name + "_Y"); - line.append_option(option); - - def.label = L("Z"); - option = Option(def, lower_name + "_Z"); - line.append_option(option); - - if (option_name == "Scale") - { - def.label = L("Units"); - def.type = coStrings; - def.gui_type = "select_open"; - def.enum_labels.push_back(L("%")); - def.enum_labels.push_back(L("mm")); - def.default_value = new ConfigOptionStrings{ "%" }; - def.sidetext = " "; - - option = Option(def, lower_name + "_unit"); - line.append_option(option); - } - return line; -} - void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) { DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; @@ -1078,37 +1037,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl add_objects_list(parent, sizer); // Frequently Object Settings - optgroup = std::make_shared(parent, _(L("Object Settings")), config); - optgroup->label_width = 100; - optgroup->set_grid_vgap(5); - -// def.label = L("Name"); -// def.type = coString; -// def.tooltip = L("Object name"); -// def.full_width = true; -// def.default_value = new ConfigOptionString{ "BlaBla_object.stl" }; -// optgroup->append_single_option_line(Option(def, "object_name")); - - optgroup->set_flag(ogSIDE_OPTIONS_VERTICAL); - optgroup->sidetext_width = 25; - - optgroup->append_line(add_og_to_object_settings(L("Position"), L("mm"))); - optgroup->append_line(add_og_to_object_settings(L("Rotation"), "°", 1)); - optgroup->append_line(add_og_to_object_settings(L("Scale"), "%", 2)); - - optgroup->set_flag(ogDEFAULT); - - def.label = L("Place on bed"); - def.type = coBool; - def.tooltip = L("Automatic placing of models on printing bed in Y axis"); - def.gui_type = ""; - def.sidetext = ""; - def.default_value = new ConfigOptionBool{ false }; - optgroup->append_single_option_line(Option(def, "place_on_bed")); - - sizer->Add(optgroup->sizer, 0, wxEXPAND | wxLEFT | wxTOP, 20); - - m_optgroups.push_back(optgroup); // ogFrequentlyObjectSettings + add_object_settings(parent, sizer); } void show_frequently_changed_parameters(bool show) diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index 682ed2f26..6909c274b 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -65,7 +65,7 @@ void init_mesh_icons(){ bool is_parts_changed(){return m_parts_changed;} bool is_part_settings_changed(){ return m_part_settings_changed; } -static wxString dots("…", wxConvUTF8); +static wxString dots("…", wxConvUTF8); // ****** from GUI.cpp wxBoxSizer* content_objects_list(wxWindow *win) @@ -308,6 +308,98 @@ wxBoxSizer* content_settings(wxWindow *win) return sizer; } +void add_objects_list(wxWindow* parent, wxBoxSizer* sizer) +{ + const auto ol_sizer = content_objects_list(parent); + sizer->Add(ol_sizer, 1, wxEXPAND | wxTOP, 20); + set_objects_list_sizer(ol_sizer); +} + +Line add_og_to_object_settings(const std::string& option_name, const std::string& sidetext, int def_value = 0) +{ + Line line = { _(option_name), "" }; + + ConfigOptionDef def; + def.type = coInt; + def.default_value = new ConfigOptionInt(def_value); + def.sidetext = sidetext; + def.width = 70; + + const std::string lower_name = boost::algorithm::to_lower_copy(option_name); + + std::vector axes{ "x", "y", "z" }; + for (auto axis : axes) { + def.label = boost::algorithm::to_upper_copy(axis); + Option option = Option(def, lower_name + "_" + axis); + option.opt.full_width = true; + line.append_option(option); + } + + if (option_name == "Scale") + { + def.label = L("Units"); + def.type = coStrings; + def.gui_type = "select_open"; + def.enum_labels.push_back(L("%")); + def.enum_labels.push_back(L("mm")); + def.default_value = new ConfigOptionStrings{ "%" }; + def.sidetext = " "; + + Option option = Option(def, lower_name + "_unit"); + line.append_option(option); + } + return line; +} + +void add_object_settings(wxWindow* parent, wxBoxSizer* sizer) +{ + auto optgroup = std::make_shared(parent, _(L("Object Settings"))); + optgroup->label_width = 100; + optgroup->set_grid_vgap(5); + + optgroup->m_on_change = [](t_config_option_key opt_key, boost::any value){ + if (opt_key == "scale_unit"){ + const wxString& selection = boost::any_cast(value); + std::vector axes{ "x", "y", "z" }; + for (auto axis : axes) { + std::string key = "scale_" + axis; + get_optgroup(ogFrequentlyObjectSettings)->set_side_text(key, selection); + } + } + }; + +// def.label = L("Name"); +// def.type = coString; +// def.tooltip = L("Object name"); +// def.full_width = true; +// def.default_value = new ConfigOptionString{ "BlaBla_object.stl" }; +// optgroup->append_single_option_line(Option(def, "object_name")); + + optgroup->set_flag(ogSIDE_OPTIONS_VERTICAL); + optgroup->sidetext_width = 25; + + optgroup->append_line(add_og_to_object_settings(L("Position"), L("mm"))); + optgroup->append_line(add_og_to_object_settings(L("Rotation"), "°", 1)); + optgroup->append_line(add_og_to_object_settings(L("Scale"), "%", 2)); + + optgroup->set_flag(ogDEFAULT); + + ConfigOptionDef def; + def.label = L("Place on bed"); + def.type = coBool; + def.tooltip = L("Automatic placing of models on printing bed in Y axis"); + def.gui_type = ""; + def.sidetext = ""; + def.default_value = new ConfigOptionBool{ false }; + optgroup->append_single_option_line(Option(def, "place_on_bed")); + + sizer->Add(optgroup->sizer, 0, wxEXPAND | wxLEFT | wxTOP, 20); + + optgroup->disable(); + + get_optgroups().push_back(optgroup); // ogFrequentlyObjectSettings +} + // add Collapsible Pane to sizer wxCollapsiblePane* add_collapsible_pane(wxWindow* parent, wxBoxSizer* sizer_parent, const wxString& name, std::function content_function) @@ -331,13 +423,6 @@ wxCollapsiblePane* add_collapsible_pane(wxWindow* parent, wxBoxSizer* sizer_pare return collpane; } -void add_objects_list(wxWindow* parent, wxBoxSizer* sizer) -{ - const auto ol_sizer = content_objects_list(parent); - sizer->Add(ol_sizer, 1, wxEXPAND | wxTOP, 20); - set_objects_list_sizer(ol_sizer); -} - void add_collapsible_panes(wxWindow* parent, wxBoxSizer* sizer) { // *** Objects List *** diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp index a0015c146..8d54fa29b 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp @@ -40,6 +40,7 @@ struct OBJECT_PARAMETERS void add_collapsible_panes(wxWindow* parent, wxBoxSizer* sizer); void add_objects_list(wxWindow* parent, wxBoxSizer* sizer); +void add_object_settings(wxWindow* parent, wxBoxSizer* sizer); void show_collpane_settings(bool expert_mode); // Add object to the list diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 4778047be..ca612e95c 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -230,6 +230,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* wxSize(sidetext_width, -1)/*wxDefaultSize*/, wxALIGN_LEFT); sidetext->SetFont(sidetext_font); sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, m_flag == ogSIDE_OPTIONS_VERTICAL ? 0 : 4); + field->set_side_text_ptr(sidetext); } // add side widget if any diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index cd604fc8e..6697ed75a 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -128,6 +128,14 @@ public: return out; } + bool set_side_text(const t_config_option_key& opt_key, const wxString& side_text) { + if (m_fields.find(opt_key) == m_fields.end()) return false; + auto st = m_fields.at(opt_key)->m_side_text; + if (!st) return false; + st->SetLabel(side_text); + return true; + } + inline void enable() { for (auto& field : m_fields) field.second->enable(); } inline void disable() { for (auto& field : m_fields) field.second->disable(); } void set_flag(ogDrawFlag flag) { m_flag = flag; }