OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::ObjectSettings Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GUI_ObjectSettings.hpp>

Inheritance diagram for Slic3r::GUI::ObjectSettings:
Collaboration diagram for Slic3r::GUI::ObjectSettings:

Public Member Functions

 ObjectSettings (wxWindow *parent)
 ~ObjectSettings ()
bool update_settings_list ()
bool add_missed_options (ModelConfig *config_to, const DynamicPrintConfig &config_from)
void update_config_values (ModelConfig *config, const std::string &changed_opt_key="")
void UpdateAndShow (const bool show)
void msw_rescale ()
void sys_color_changed ()
virtual bool IsShown ()
virtual void Show (const bool show)
virtual void Hide ()
virtual wxSizer * get_sizer ()
ConfigOptionsGroup * get_og ()
wxWindow * parent () const

Protected Attributes

std::shared_ptr< ConfigOptionsGroup > m_og
wxWindow * m_parent

Private Attributes

wxBoxSizer * m_settings_list_sizer { nullptr }
std::vector< std::shared_ptr< ConfigOptionsGroup > > m_og_settings
ScalableBitmap m_bmp_delete
ScalableBitmap m_bmp_delete_focus

Detailed Description

Constructor & Destructor Documentation

◆ ObjectSettings()

Slic3r::GUI::ObjectSettings::ObjectSettings ( wxWindow * parent)
75 :
76#if !NEW_OBJECT_SETTING
77 OG_Settings(parent, true)
78#else
80#endif
81{
82#if !NEW_OBJECT_SETTING
83 m_og->activate();
84 m_og->set_name(_(L("Additional process preset")));
85
86 m_settings_list_sizer = new wxBoxSizer(wxVERTICAL);
87 m_og->sizer->Add(m_settings_list_sizer, 1, wxEXPAND | wxLEFT, 5);
88
89 m_bmp_delete = ScalableBitmap(parent, "cross");
90 m_bmp_delete_focus = ScalableBitmap(parent, "cross_focus");
91#endif
92}
#define _(s)
Definition 3mf.cpp:306
#define L(s)
Definition ExtrusionEntity.cpp:25
OG_Settings(wxWindow *parent, const bool staticbox)
Definition GUI_ObjectSettings.cpp:38
wxWindow * parent() const
Definition GUI_ObjectSettings.hpp:37
std::shared_ptr< ConfigOptionsGroup > m_og
Definition GUI_ObjectSettings.hpp:24
wxWindow * m_parent
Definition GUI_ObjectSettings.hpp:25
wxBoxSizer * m_settings_list_sizer
Definition GUI_ObjectSettings.hpp:50
ScalableBitmap m_bmp_delete_focus
Definition GUI_ObjectSettings.hpp:55
ScalableBitmap m_bmp_delete
Definition GUI_ObjectSettings.hpp:54

References Slic3r::GUI::OG_Settings::OG_Settings(), _, L, m_bmp_delete, m_bmp_delete_focus, Slic3r::GUI::OG_Settings::m_og, Slic3r::GUI::OG_Settings::m_parent, m_settings_list_sizer, NEW_OBJECT_SETTING, and Slic3r::GUI::OG_Settings::parent().

Here is the call graph for this function:

◆ ~ObjectSettings()

Slic3r::GUI::ObjectSettings::~ObjectSettings ( )
inline
63{}

Member Function Documentation

◆ add_missed_options()

bool Slic3r::GUI::ObjectSettings::add_missed_options ( ModelConfig * config_to,
const DynamicPrintConfig & config_from )
325{
326 const DynamicPrintConfig& print_config = wxGetApp().plater()->printer_technology() == ptFFF ?
327 wxGetApp().preset_bundle->prints.get_edited_preset().config :
328 wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
329 bool is_added = false;
330
331 for (auto opt_key : config_from.diff(print_config))
332 if (!config_to->has(opt_key)) {
333 config_to->set_key_value(opt_key, config_from.option(opt_key)->clone());
334 is_added = true;
335 }
336
337 return is_added;
338}
@ ptFFF
Definition Config.hpp:231

References Slic3r::ConfigOption::clone(), Slic3r::DynamicConfig::diff(), Slic3r::ModelConfig::has(), Slic3r::ConfigBase::option(), Slic3r::ptFFF, and Slic3r::ModelConfig::set_key_value().

Referenced by update_config_values().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_og()

ConfigOptionsGroup * Slic3r::GUI::OG_Settings::get_og ( )
inlineinherited
36{ return m_og.get(); }

References m_og.

◆ get_sizer()

wxSizer * Slic3r::GUI::OG_Settings::get_sizer ( )
virtualinherited
69{
70 return m_og->sizer;
71}

References m_og.

◆ Hide()

void Slic3r::GUI::OG_Settings::Hide ( )
virtualinherited
58{
59 Show(false);
60}
virtual void Show(const bool show)
Definition GUI_ObjectSettings.cpp:52

References Show().

Here is the call graph for this function:

◆ IsShown()

bool Slic3r::GUI::OG_Settings::IsShown ( )
virtualinherited
48{
49 return m_og->sizer->IsEmpty() ? false : m_og->sizer->IsShown(size_t(0));
50}

References m_og.

◆ msw_rescale()

void Slic3r::GUI::ObjectSettings::msw_rescale ( )
439{
440#if !NEW_OBJECT_SETTING
441 m_bmp_delete.msw_rescale();
442 m_bmp_delete_focus.msw_rescale();
443
444 for (auto group : m_og_settings)
445 group->msw_rescale();
446#endif
447}
std::vector< std::shared_ptr< ConfigOptionsGroup > > m_og_settings
Definition GUI_ObjectSettings.hpp:52

References m_bmp_delete, m_bmp_delete_focus, and m_og_settings.

◆ parent()

wxWindow * Slic3r::GUI::OG_Settings::parent ( ) const
inlineinherited
37{return m_parent; }

References m_parent.

Referenced by Slic3r::GUI::ObjectLayers::ObjectLayers(), Slic3r::GUI::ObjectSettings::ObjectSettings(), OG_Settings(), Slic3r::GUI::ObjectLayers::PlusMinusButton::PlusMinusButton(), and Slic3r::GUI::ObjectSettings::update_settings_list().

Here is the caller graph for this function:

◆ Show()

void Slic3r::GUI::OG_Settings::Show ( const bool show)
virtualinherited
53{
54 m_og->Show(show);
55}

References m_og.

Referenced by Hide(), and UpdateAndShow().

Here is the caller graph for this function:

◆ sys_color_changed()

void Slic3r::GUI::ObjectSettings::sys_color_changed ( )
450{
451#if !NEW_OBJECT_SETTING
452 m_og->sys_color_changed();
453
454 for (auto group : m_og_settings)
455 group->sys_color_changed();
456#endif
457}

References Slic3r::GUI::OG_Settings::m_og, and m_og_settings.

◆ update_config_values()

void Slic3r::GUI::ObjectSettings::update_config_values ( ModelConfig * config,
const std::string & changed_opt_key = "" )
341{
342 const auto objects_model = wxGetApp().obj_list()->GetModel();
343 const auto item = wxGetApp().obj_list()->GetSelection();
344 const auto printer_technology = wxGetApp().plater()->printer_technology();
345 const bool is_object_settings = objects_model->GetItemType(objects_model->GetParent(item)) == itObject;
346
347 if (!item || !objects_model->IsSettingsItem(item) || !config)
348 return;
349
350 // update config values according to configuration hierarchy
351 DynamicPrintConfig main_config = printer_technology == ptFFF ?
352 wxGetApp().preset_bundle->prints.get_edited_preset().config :
353 wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
354
355 auto load_config = [this, config, &main_config]()
356 {
357 /* Additional check for overrided options.
358 * There is a case, when some options should to be added,
359 * to avoid check loop in the next configuration update
360 */
361 bool is_added = add_missed_options(config, main_config);
362
363 // load checked values from main_config to config
364 config->apply_only(main_config, config->keys(), true);
365 // Initialize UI components with the config values.
366#if !NEW_OBJECT_SETTING
367 for (auto og : m_og_settings)
368 og->reload_config();
369#else
370#endif
371 // next config check
372 update_config_values(config);
373
374 if (is_added) {
375// #ysFIXME - Delete after testing! Very likely this CallAfret is no needed
376// wxTheApp->CallAfter([this]() {
377 wxWindowUpdateLocker noUpdates(m_parent);
379 m_parent->Layout();
380// });
381 }
382 };
383
384#if !NEW_OBJECT_SETTING
385 auto toggle_field = [this](const t_config_option_key & opt_key, bool toggle, int opt_index)
386 {
387 Field* field = nullptr;
388 for (auto og : m_og_settings) {
389 field = og->get_fieldc(opt_key, opt_index);
390 if (field != nullptr)
391 break;
392 }
393 if (field)
394 field->toggle(toggle);
395 };
396#else
397 auto toggle_field = [this](const t_config_option_key & opt_key, bool toggle, int opt_index)
398 {
399 m_tab_active->toggle_option(opt_key, toggle, opt_index);
400 };
401#endif
402
403 //BBS: change local config to DynamicPrintConfig
404 ConfigManipulation config_manipulation(load_config, toggle_field, nullptr, nullptr, &(config->get()));
405
406 config_manipulation.set_is_BBL_Printer(wxGetApp().preset_bundle->is_bbl_vendor());
407
408 if (!is_object_settings)
409 {
410 const int obj_idx = objects_model->GetObjectIdByItem(item);
411 assert(obj_idx >= 0);
412 // for object's part first of all update konfiguration from object
413 main_config.apply(wxGetApp().model().objects[obj_idx]->config.get(), true);
414 // and then from its own config
415 }
416
417 main_config.apply(config->get(), true);
418
419 if (printer_technology == ptFFF && changed_opt_key == "layer_height")
420 config_manipulation.check_layer_height(&main_config);
421
422 printer_technology == ptFFF ? config_manipulation.update_print_fff_config(&main_config) :
423 config_manipulation.update_print_sla_config(&main_config) ;
424
425 printer_technology == ptFFF ? config_manipulation.toggle_print_fff_options(&main_config, 0) :
426 config_manipulation.toggle_print_sla_options(&main_config) ;
427}
void update_config_values(ModelConfig *config, const std::string &changed_opt_key="")
Definition GUI_ObjectSettings.cpp:340
bool add_missed_options(ModelConfig *config_to, const DynamicPrintConfig &config_from)
Definition GUI_ObjectSettings.cpp:324
bool update_settings_list()
Definition GUI_ObjectSettings.cpp:96
static PrinterTechnology printer_technology()
Definition GUI_Factories.cpp:60
@ itObject
Definition ObjectDataViewModel.hpp:37
void load_config(cereal::BinaryInputArchive &ar, DynamicPrintConfig &config, const CacheDictionary &dict)
Definition PresetCacheFormat.cpp:242
std::string t_config_option_key
Definition Config.hpp:96

References add_missed_options(), Slic3r::ConfigBase::apply(), Slic3r::ModelConfig::apply_only(), Slic3r::GUI::ConfigManipulation::check_layer_height(), Slic3r::ModelConfig::get(), Slic3r::GUI::itObject, Slic3r::ModelConfig::keys(), Slic3r::load_config(), m_og_settings, Slic3r::GUI::OG_Settings::m_parent, Slic3r::GUI::printer_technology(), Slic3r::ptFFF, Slic3r::GUI::ConfigManipulation::set_is_BBL_Printer(), Slic3r::GUI::Field::toggle(), Slic3r::GUI::ConfigManipulation::toggle_print_fff_options(), Slic3r::GUI::ConfigManipulation::toggle_print_sla_options(), update_config_values(), Slic3r::GUI::ConfigManipulation::update_print_fff_config(), Slic3r::GUI::ConfigManipulation::update_print_sla_config(), and update_settings_list().

Referenced by update_config_values(), and update_settings_list().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_settings_list()

bool Slic3r::GUI::ObjectSettings::update_settings_list ( )
97{
98 m_settings_list_sizer->Clear(true);
99 m_og_settings.resize(0);
100
101 if (wxGetApp().is_closing())
102 return false;
103
104 auto objects_ctrl = wxGetApp().obj_list();
105 auto objects_model = wxGetApp().obj_list()->GetModel();
106 auto config = wxGetApp().obj_list()->config();
107
108 const auto item = objects_ctrl->GetSelection();
109
110 if (!item || !objects_model->IsSettingsItem(item) || !config || objects_ctrl->multiple_selection())
111 return false;
112
113 const bool is_object_settings = objects_model->GetItemType(objects_model->GetParent(item)) == itObject;
114 SettingsFactory::Bundle cat_options = SettingsFactory::get_bundle(&config->get(), is_object_settings);
115
116 if (!cat_options.empty())
117 {
118 std::vector<std::string> categories;
119 categories.reserve(cat_options.size());
120
121 auto extra_column = [config, this](wxWindow* parent, const Line& line)
122 {
123 auto opt_key = (line.get_options())[0].opt_id; //we assume that we have one option per line
124
125 auto btn = new ScalableButton(parent, wxID_ANY, m_bmp_delete);
126 btn->SetBackgroundColour(parent->GetBackgroundColour());
127 btn->SetToolTip(_(L("Remove parameter")));
128
129 btn->SetBitmapFocus(m_bmp_delete_focus.bmp());
130 btn->SetBitmapHover(m_bmp_delete_focus.bmp());
131
132 btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
133 wxGetApp().plater()->take_snapshot(from_u8((boost::format("Delete Option %s") % opt_key).str()).ToStdString());
134 config->erase(opt_key);
135 wxGetApp().obj_list()->changed_object();
136 wxTheApp->CallAfter([this]() {
137 wxWindowUpdateLocker noUpdates(m_parent);
139 m_parent->Layout();
140 });
141 });
142 return btn;
143 };
144
145 for (auto& cat : cat_options)
146 {
147 categories.push_back(cat.first);
148
149 auto optgroup = std::make_shared<ConfigOptionsGroup>(m_og->ctrl_parent(), _(cat.first), config, false, extra_column);
150 optgroup->label_width = 15;
151 optgroup->sidetext_width = 5;
152
153 optgroup->m_on_change = [this, config](const t_config_option_key& opt_id, const boost::any& value) {
154 this->update_config_values(config, opt_id);
155 wxGetApp().obj_list()->changed_object(); };
156
157 // call back for rescaling of the extracolumn control
158 optgroup->rescale_extra_column_item = [this](wxWindow* win) {
159 auto *ctrl = dynamic_cast<ScalableButton*>(win);
160 if (ctrl == nullptr)
161 return;
162 ctrl->SetBitmap_(m_bmp_delete);
163 ctrl->SetBitmapFocus(m_bmp_delete_focus.bmp());
164 ctrl->SetBitmapHover(m_bmp_delete_focus.bmp());
165 };
166
167 const bool is_extruders_cat = cat.first == "Extruders";
168 for (auto& opt : cat.second)
169 {
170 Option option = optgroup->get_option(opt);
171 option.opt.width = 12;
172 if (is_extruders_cat)
173 option.opt.max = wxGetApp().extruders_edited_cnt();
174 optgroup->append_single_option_line(option);
175 }
176 optgroup->activate();
177 for (auto& opt : cat.second)
178 optgroup->get_field(opt)->m_on_change = [optgroup](const std::string& opt_id, const boost::any& value) {
179 // first of all take a snapshot and then change value in configuration
180 wxGetApp().plater()->take_snapshot(from_u8((boost::format("Change Option %s")% opt_id).str()).ToStdString());
181 optgroup->on_change_OG(opt_id, value);
182 };
183
184 optgroup->reload_config();
185
186 m_settings_list_sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 0);
187 m_og_settings.push_back(optgroup);
188 }
189
190 if (!categories.empty()) {
191 objects_model->UpdateSettingsDigest(item, categories);
192 update_config_values(config);
193 }
194 }
195 else
196 {
197 objects_ctrl->select_item(objects_model->Delete(item));
198 return false;
199 }
200 return true;
201}
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
static Bundle get_bundle(const DynamicPrintConfig *config, bool is_object_settings, bool is_layer_settings=false)
Definition GUI_Factories.cpp:299
std::map< std::string, std::vector< std::string > > Bundle
Definition GUI_Factories.hpp:34

References _, Slic3r::GUI::from_u8(), Slic3r::GUI::SettingsFactory::get_bundle(), Slic3r::GUI::itObject, L, m_bmp_delete, m_bmp_delete_focus, Slic3r::GUI::OG_Settings::m_og, m_og_settings, Slic3r::GUI::OG_Settings::m_parent, m_settings_list_sizer, Slic3r::ConfigOptionDef::max, Slic3r::GUI::Option::opt, Slic3r::GUI::OG_Settings::parent(), ScalableButton::SetBitmap_(), update_config_values(), update_settings_list(), and Slic3r::ConfigOptionDef::width.

Referenced by update_config_values(), update_settings_list(), and UpdateAndShow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateAndShow()

void Slic3r::GUI::ObjectSettings::UpdateAndShow ( const bool show)
virtual

Reimplemented from Slic3r::GUI::OG_Settings.

430{
431#if !NEW_OBJECT_SETTING
433#else
435#endif
436}
virtual void UpdateAndShow(const bool show)
Definition GUI_ObjectSettings.cpp:62

References update_settings_list(), and Slic3r::GUI::OG_Settings::UpdateAndShow().

Referenced by Slic3r::GUI::ObjectList::update_settings_item_and_selection().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_bmp_delete

ScalableBitmap Slic3r::GUI::ObjectSettings::m_bmp_delete
private

◆ m_bmp_delete_focus

ScalableBitmap Slic3r::GUI::ObjectSettings::m_bmp_delete_focus
private

◆ m_og

◆ m_og_settings

std::vector<std::shared_ptr<ConfigOptionsGroup> > Slic3r::GUI::ObjectSettings::m_og_settings
private

◆ m_parent

◆ m_settings_list_sizer

wxBoxSizer* Slic3r::GUI::ObjectSettings::m_settings_list_sizer { nullptr }
private
50{ nullptr };

Referenced by ObjectSettings(), and update_settings_list().


The documentation for this class was generated from the following files: