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

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

Inheritance diagram for Slic3r::GUI::OptionsGroup:
Collaboration diagram for Slic3r::GUI::OptionsGroup:

Public Member Functions

wxWindow * parent () const
 Returns a copy of the pointer of the parent wxWindow. Accessor function is because users are not allowed to change the parent but defining it as const means a lot of const_casts to deal with wx functions.
wxWindow * ctrl_parent () const
void append_line (const Line &line)
void activate_line (Line &line)
Line * get_line (const std::string &opt_key)
bool activate (std::function< void()> throw_if_canceled=[](){}, int horiz_alignment=wxALIGN_LEFT)
void clear (bool destroy_custom_ctrl=false)
Line create_single_option_line (const Option &option, const std::string &path=std::string()) const
void append_single_option_line (const Option &option, const std::string &path=std::string())
void append_separator ()
Field * get_field (const t_config_option_key &id) const
bool set_value (const t_config_option_key &id, const boost::any &value, bool change_event=false)
boost::any get_value (const t_config_option_key &id)
void show_field (const t_config_option_key &opt_key, bool show=true)
void hide_field (const t_config_option_key &opt_key)
void enable_field (const t_config_option_key &opt_key, bool enable=true)
void disable_field (const t_config_option_key &opt_key)
void set_name (const wxString &new_name)
void enable ()
void disable ()
void set_grid_vgap (int gap)
void clear_fields_except_of (const std::vector< std::string > left_fields)
void hide_labels ()
 OptionsGroup (wxWindow *_parent, const wxString &title, const wxString &icon, bool is_tab_opt=false, column_t extra_clmn=nullptr)
virtual ~OptionsGroup ()
wxGridSizer * get_grid_sizer ()
const std::vector< Line > & get_lines ()
bool is_legend_line ()
void set_max_win_width (int max_win_width)
bool is_activated ()
void remove_option_if (std::function< bool(std::string const &)> const &comp)

Static Public Member Functions

static wxString get_url (const std::string &path_end)
static bool launch_browser (const std::string &path_end)

Public Attributes

const bool staticbox {true}
bool split_multi_line {false}
bool option_label_at_right {false}
wxWindow * stb { nullptr }
const wxString icon
const wxString title
bool m_labels_hidden {false}
size_t label_width = 20
wxSizer * sizer {nullptr}
OG_CustomCtrl * custom_ctrl { nullptr }
int ctrl_horiz_alignment { wxALIGN_LEFT}
column_t extra_column {nullptr}
t_change m_on_change { nullptr }
t_kill_focus m_fill_empty_value { nullptr }
std::function< DynamicPrintConfig()> m_get_initial_config { nullptr }
std::function< DynamicPrintConfig()> m_get_sys_config { nullptr }
std::function< bool()> have_sys_config { nullptr }
std::function< void(wxWindow *win)> rescale_extra_column_item { nullptr }
std::function< void(wxWindow *win)> rescale_near_label_widget { nullptr }
std::function< void(const t_config_option_key &opt_key)> edit_custom_gcode { nullptr }
wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }
wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }
int sidetext_width { -1 }
int sublabel_width { -1 }
bool draw_multi_extruder { false }

Protected Member Functions

const t_field & build_field (const t_config_option_key &id, const ConfigOptionDef &opt)
 Generate a wxSizer or wxWindow from a configuration option Precondition: opt resolves to a known ConfigOption Postcondition: fields contains a wx gui object.
const t_field & build_field (const t_config_option_key &id)
const t_field & build_field (const Option &opt)
virtual void on_kill_focus (const std::string &opt_key)
virtual void on_change_OG (const t_config_option_key &opt_id, const boost::any &value)
virtual void back_to_initial_value (const std::string &opt_key)
virtual void back_to_sys_value (const std::string &opt_key)
virtual int config_type () const
std::string pick_plugin (const ConfigOptionDef &opt)

Protected Attributes

std::map< t_config_option_key, Option > m_options
wxWindow * m_parent {nullptr}
std::vector< ConfigOptionMode > m_options_mode
std::vector< wxWindow * > m_extra_column_item_ptrs
std::vector< Line > m_lines
t_optionfield_map m_fields
 Field list, contains unique_ptrs of the derived type. using types that need to know what it is beyond the public interface need to cast based on the related ConfigOptionDef.
bool m_disabled {false}
wxGridSizer * m_grid_sizer {nullptr}
bool m_use_custom_ctrl { false }
bool m_use_custom_ctrl_as_parent { false }

Detailed Description

Constructor & Destructor Documentation

◆ OptionsGroup()

Slic3r::GUI::OptionsGroup::OptionsGroup ( wxWindow * _parent,
const wxString & title,
const wxString & icon,
bool is_tab_opt = false,
column_t extra_clmn = nullptr )
161 : m_parent(_parent)
162 , title(title)
163 , icon(icon)
164 , m_use_custom_ctrl(is_tab_opt)
165 ,
166 // BBS: new layout
167 staticbox(!is_tab_opt)
168 , extra_column(extra_clmn)
169{}
const wxString icon
Definition OptionsGroup.hpp:160
const wxString title
Definition OptionsGroup.hpp:161
const bool staticbox
Definition OptionsGroup.hpp:155
bool m_use_custom_ctrl
Definition OptionsGroup.hpp:273
column_t extra_column
Definition OptionsGroup.hpp:167
wxWindow * m_parent
Definition OptionsGroup.hpp:260

References extra_column, icon, m_parent, m_use_custom_ctrl, staticbox, and title.

Referenced by Slic3r::GUI::ConfigOptionsGroup::ConfigOptionsGroup(), Slic3r::GUI::ConfigOptionsGroup::ConfigOptionsGroup(), and Slic3r::GUI::ConfigOptionsGroup::ConfigOptionsGroup().

Here is the caller graph for this function:

◆ ~OptionsGroup()

virtual Slic3r::GUI::OptionsGroup::~OptionsGroup ( )
inlinevirtual
246{ clear(true); }
void clear(bool destroy_custom_ctrl=false)
Definition OptionsGroup.cpp:605

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ activate()

bool Slic3r::GUI::OptionsGroup::activate ( std::function< void()> throw_if_canceled = [](){},
int horiz_alignment = wxALIGN_LEFT )
537{
538 if (sizer) //(!sizer->IsEmpty())
539 return false;
540
541 try {
542 if (staticbox) {
543 // ORCA match style of wxStaticBox between platforms
544 LabeledStaticBox* stb = new LabeledStaticBox(m_parent, _(title));
545 // wxGetApp().UpdateDarkUI(stb);
546 this->stb = stb;
547 sizer = new wxStaticBoxSizer(stb, wxVERTICAL);
548 } else {
549 // BBS: new layout
550 ::StaticLine* stl = new ::StaticLine(m_parent, false, _(title), icon);
551 stl->SetFont(Label::Head_14);
552 stl->SetForegroundColour("#363636"); // ORCA Match Parameters title color with tab title color
553 sizer = new wxBoxSizer(wxVERTICAL);
554 if (title.IsEmpty()) {
555 stl->Hide();
556 } else {
557 sizer->Add(stl, 0, wxEXPAND);
558 sizer->AddSpacer(8);
559 }
560 this->stb = stl;
561 }
562
563 auto num_columns = 1U;
564 size_t grow_col = 1;
565
566 if (label_width == 0)
567 grow_col = 0;
568 else
569 num_columns++;
570
571 if (extra_column) {
572 num_columns++;
573 grow_col++;
574 }
575
576 m_grid_sizer = new wxFlexGridSizer(0, num_columns, 1, 0);
577 static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxBOTH);
578 static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(grow_col);
579
580 sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, !staticbox ? 0 : 5);
581
582 // activate lines
583 for (Line& line : m_lines) {
584 throw_if_canceled();
585 activate_line(line);
586 }
587
588 ctrl_horiz_alignment = horiz_alignment;
589 if (custom_ctrl)
590 custom_ctrl->init_max_win_width();
591 } catch (UIBuildCanceled&) {
592 auto p = sizer;
593 this->clear();
594 p->Clear(true);
595 delete p;
596 throw;
597 }
598
599 return true;
600}
#define _(s)
Definition 3mf.cpp:306
static wxFont Head_14
Definition Label.hpp:45
std::vector< Line > m_lines
Definition OptionsGroup.hpp:264
int ctrl_horiz_alignment
Definition OptionsGroup.hpp:166
wxSizer * sizer
Definition OptionsGroup.hpp:164
wxGridSizer * m_grid_sizer
Definition OptionsGroup.hpp:271
size_t label_width
Definition OptionsGroup.hpp:163
wxWindow * stb
Definition OptionsGroup.hpp:159
void activate_line(Line &line)
Definition OptionsGroup.cpp:309
OG_CustomCtrl * custom_ctrl
Definition OptionsGroup.hpp:165

References _, activate_line(), clear(), ctrl_horiz_alignment, custom_ctrl, extra_column, Label::Head_14, icon, label_width, m_grid_sizer, m_lines, m_parent, sizer, staticbox, stb, and title.

Here is the call graph for this function:

◆ activate_line()

void Slic3r::GUI::OptionsGroup::activate_line ( Line & line)

To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1

.target<wxWindow>()

requires verification

istead of (opt != option_set.back())

requires verification

310{
311 if (line.is_separator())
312 return;
313
315
316 if (line.full_width && (line.widget != nullptr || !line.get_extra_widgets().empty())) {
317 // BBS: new layout
318 const auto h_sizer = new wxBoxSizer(wxHORIZONTAL);
319 sizer->Add(h_sizer, 1, wxEXPAND | wxALL, (wxOSX && !staticbox) ? 0 : 15);
320 if (line.widget != nullptr) {
321 // description lines
322 sizer->Add(line.widget(this->ctrl_parent()), 0, wxEXPAND | wxALL, (wxOSX && !staticbox) ? 0 : 15);
323 return;
324 }
325 if (!line.get_extra_widgets().empty()) {
326 bool is_first_item = true;
327 for (auto extra_widget : line.get_extra_widgets()) {
328 h_sizer->Add(extra_widget(this->ctrl_parent()), is_first_item ? 1 : 0, wxLEFT, titleWidth * wxGetApp().em_unit());
329 is_first_item = false;
330 }
331 return;
332 }
333 }
334
335 auto option_set = line.get_options();
336 bool is_legend_line = option_set.front().opt.gui_type == ConfigOptionDef::GUIType::legend;
337
339 custom_ctrl = new OG_CustomCtrl(is_legend_line || !staticbox ? this->parent() : static_cast<wxWindow*>(this->stb), this);
340 // BBS: new layout
341 custom_ctrl->SetLabel("");
342 if (is_legend_line)
343 sizer->Add(custom_ctrl, 0, wxEXPAND | wxLEFT, (wxOSX && !staticbox) ? 0 : 10);
344 else
345 sizer->Add(custom_ctrl, 0, wxEXPAND | wxALL, !staticbox ? 0 : 5);
346 }
347
348 // Set sidetext width for a better alignment of options in line
349 // "m_show_modified_btns==true" means that options groups are in tabs
350 if (option_set.size() > 1 && m_use_custom_ctrl) {
353 }
354
355 // if we have a single option with no label, no sidetext just add it directly to sizer
356 if (option_set.size() == 1 && label_width == 0 && option_set.front().opt.full_width && option_set.front().opt.sidetext.size() == 0 &&
357 option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) {
358 const auto& option = option_set.front();
359 const auto& field = build_field(option);
360
361 // BBS: new layout
362 const auto h_sizer = new wxBoxSizer(wxHORIZONTAL);
363 sizer->Add(h_sizer, 1, wxEXPAND | wxALL, (wxOSX && !staticbox) ? 0 : 5);
364
365 int left_padding = option.opt.multiline ? 0 : titleWidth * wxGetApp().em_unit();
366 if (m_labels_hidden)
367 left_padding = 0;
368
369 if (is_window_field(field)) {
370 int flags = wxEXPAND;
371 if (left_padding > 0)
372 flags |= wxLEFT;
373 h_sizer->Add(field->getWindow(), 1, flags, left_padding);
374 }
375 if (is_sizer_field(field)) {
376 int flags = wxEXPAND;
377 if (left_padding > 0)
378 flags |= wxLEFT;
379 h_sizer->Add(field->getSizer(), 1, flags, left_padding);
380 }
381 return;
382 }
383
384 auto grid_sizer = m_grid_sizer;
385
386 if (custom_ctrl)
388
389 // if we have an extra column, build it
390 if (extra_column) {
391 m_extra_column_item_ptrs.push_back(extra_column(this->ctrl_parent(), line));
392 grid_sizer->Add(m_extra_column_item_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3);
393 }
394
395 // Build a label if we have it
396 wxStaticText* label = nullptr;
397 if (label_width != 0) {
398 if (custom_ctrl) {
399 if (line.near_label_widget)
400 line.near_label_widget_win = line.near_label_widget(this->ctrl_parent());
401 } else {
402 if (!line.near_label_widget || !line.label.IsEmpty()) {
403 // Only create the label if it is going to be displayed.
404 long label_style = staticbox ? 0 : wxALIGN_RIGHT;
405#ifdef __WXGTK__
406 // workaround for correct text align of the StaticBox on Linux
407 // flags wxALIGN_RIGHT and wxALIGN_CENTRE don't work when Ellipsize flags are _not_ given.
408 // Text is properly aligned only when Ellipsize is checked.
409 label_style |= staticbox ? 0 : wxST_ELLIPSIZE_END;
410#endif /* __WXGTK__ */
411 label = new wxStaticText(this->ctrl_parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ": "), wxDefaultPosition,
412 wxSize(label_width * wxGetApp().em_unit(), -1), label_style);
413 label->SetBackgroundStyle(wxBG_STYLE_PAINT);
414 label->SetFont(wxGetApp().normal_font());
415 label->Wrap(label_width * wxGetApp().em_unit()); // avoid a Linux/GTK bug
416 }
417 if (!line.near_label_widget)
418 grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, line.label.IsEmpty() ? 0 : 5);
419 else if (!line.label.IsEmpty()) {
420 // If we're here, we have some widget near the label
421 // so we need a horizontal sizer to arrange these things
422 auto sizer = new wxBoxSizer(wxHORIZONTAL);
423 grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
424 sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5);
425 }
426 if (label != nullptr && line.label_tooltip != "")
427 label->SetToolTip(line.label_tooltip);
428 line.label_widget = label;
429 }
430 }
431
432 // If there's a widget, build it and add the result to the sizer.
433 if (line.widget != nullptr) {
434 auto wgt = line.widget(this->ctrl_parent());
435 if (custom_ctrl)
436 line.widget_sizer = wgt;
437 else
438 grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, (wxOSX || line.label.IsEmpty()) ? 0 : 5);
439 return;
440 }
441
442 // If we're here, we have more than one option or a single option with sidetext
443 // so we need a horizontal sizer to arrange these things
444 auto sizer = custom_ctrl ? nullptr : new wxBoxSizer(wxHORIZONTAL);
445 if (!custom_ctrl)
446 grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
447 // If we have a single option with no sidetext just add it directly to the grid sizer
448 if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr &&
449 line.get_extra_widgets().size() == 0) {
450 const auto& option = option_set.front();
451 const auto& field = build_field(option);
452
453 if (!custom_ctrl) {
454 int flags = option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL;
455 if (m_labels_hidden)
456 flags &= ~wxALIGN_CENTER_VERTICAL;
457 int border = (wxOSX || !staticbox) ? 0 : 2;
458
459 if (is_window_field(field))
460 sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, wxBOTTOM | wxTOP | flags, border);
461 if (is_sizer_field(field))
462 sizer->Add(field->getSizer(), 1, flags, 0);
463 }
464 return;
465 }
466
467 bool is_multioption_line = option_set.size() > 1;
468 for (auto opt : option_set) {
469 ConfigOptionDef option = opt.opt;
470 wxSizer* sizer_tmp = sizer;
471 // add label if any
472 if ((is_multioption_line || line.label.IsEmpty()) && !option.label.empty() && !custom_ctrl) {
474 wxString str_label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ?
475 _L_CONTEXT(option.label, "Layers") :
476 _(option.label);
477 label = new wxStaticText(this->ctrl_parent(), wxID_ANY, str_label + ": ", wxDefaultPosition, // wxDefaultSize);
478 wxSize(sublabel_width != -1 ? sublabel_width * wxGetApp().em_unit() : -1, -1), wxALIGN_RIGHT);
479 label->SetBackgroundStyle(wxBG_STYLE_PAINT);
480 label->SetFont(wxGetApp().normal_font());
481 sizer_tmp->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
482 }
483
484 // add field
485 const Option& opt_ref = opt;
486 auto& field = build_field(opt_ref);
487 if (!custom_ctrl) {
488 if (option_set.size() == 1 && option_set.front().opt.full_width) {
489 const auto v_sizer = new wxBoxSizer(wxVERTICAL);
490 sizer_tmp->Add(v_sizer, 1, wxEXPAND);
491 is_sizer_field(field) ? v_sizer->Add(field->getSizer(), 0, wxEXPAND) : v_sizer->Add(field->getWindow(), 0, wxEXPAND);
492 break;
493 }
494
495 is_sizer_field(field) ? sizer_tmp->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) :
496 sizer_tmp->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0);
497
498 // add sidetext if any
499 if (!field->combine_side_text() && (!option.sidetext.empty() || sidetext_width > 0)) {
500 auto sidetext = new wxStaticText(this->ctrl_parent(), wxID_ANY, _(option.sidetext), wxDefaultPosition,
501 wxSize(sidetext_width != -1 ? sidetext_width * wxGetApp().em_unit() : -1, -1),
502 wxALIGN_LEFT);
503 sidetext->SetBackgroundStyle(wxBG_STYLE_PAINT);
504 sidetext->SetFont(wxGetApp().normal_font());
505 sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
506 }
507
508 // add side widget if any
509 if (opt.side_widget != nullptr) {
510 sizer_tmp->Add(opt.side_widget(this->ctrl_parent()) , 0, wxLEFT | wxALIGN_CENTER_VERTICAL,
511 1);
512 }
513
514 if (opt.opt_id != option_set.back().opt_id)
515 sizer_tmp->AddSpacer(6);
516 }
517 }
518
519 // add extra sizers if any
520 for (auto extra_widget : line.get_extra_widgets()) {
521 if (line.get_extra_widgets().size() == 1 && !staticbox) {
522 // extra widget for non-staticbox option group (like for the frequently used parameters on the sidebar) should be wxALIGN_RIGHT
523 const auto v_sizer = new wxBoxSizer(wxVERTICAL);
524 sizer->Add(v_sizer, option_set.size() == 1 ? 0 : 1, wxEXPAND);
525 v_sizer->Add(extra_widget(this->ctrl_parent()), 0, wxALIGN_RIGHT);
526 return;
527 }
528
529 line.extra_widget_sizer = extra_widget(this->ctrl_parent());
530 if (!custom_ctrl)
531 sizer->Add(line.extra_widget_sizer, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
532 }
533}
#define L_CONTEXT(s, context)
Definition DesignOffer.hpp:17
#define wxOSX
Definition Field.cpp:94
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
@ legend
Definition Config.hpp:2331
static int def_width()
Definition Field.cpp:401
static int def_width_thinner()
Definition Field.cpp:403
int sidetext_width
Definition OptionsGroup.hpp:183
bool m_labels_hidden
Definition OptionsGroup.hpp:162
const t_field & build_field(const t_config_option_key &id, const ConfigOptionDef &opt)
Generate a wxSizer or wxWindow from a configuration option Precondition: opt resolves to a known Conf...
Definition OptionsGroup.cpp:57
bool is_legend_line()
Definition OptionsGroup.cpp:178
int sublabel_width
Definition OptionsGroup.hpp:184
wxWindow * ctrl_parent() const
Definition OptionsGroup.cpp:171
std::vector< wxWindow * > m_extra_column_item_ptrs
Definition OptionsGroup.hpp:262
wxWindow * parent() const
Returns a copy of the pointer of the parent wxWindow. Accessor function is because users are not allo...
Definition OptionsGroup.hpp:190
bool m_use_custom_ctrl_as_parent
Definition OptionsGroup.hpp:276
bool is_window_field(const t_field &obj)
Covenience function to determine whether this field is a valid window field.
Definition Field.hpp:319
constexpr int titleWidth
Definition OG_CustomCtrl.cpp:36
bool is_sizer_field(const t_field &obj)
Covenience function to determine whether this field is a valid sizer field.
Definition Field.hpp:322
#define _L_CONTEXT(s, ctx)
Definition I18N.hpp:15
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424

References _, _L_CONTEXT, build_field(), ctrl_parent(), custom_ctrl, Slic3r::GUI::Field::def_width(), Slic3r::GUI::Field::def_width_thinner(), em_unit(), extra_column, Slic3r::GUI::Line::extra_widget_sizer, Slic3r::GUI::Line::full_width, Slic3r::GUI::Line::get_extra_widgets(), Slic3r::GUI::Line::get_options(), is_legend_line(), Slic3r::GUI::Line::is_separator(), Slic3r::GUI::is_sizer_field(), Slic3r::GUI::is_window_field(), L_CONTEXT, Slic3r::ConfigOptionDef::label, Slic3r::GUI::Line::label, Slic3r::GUI::Line::label_tooltip, Slic3r::GUI::Line::label_widget, label_width, Slic3r::ConfigOptionDef::legend, m_extra_column_item_ptrs, m_grid_sizer, m_labels_hidden, m_use_custom_ctrl, m_use_custom_ctrl_as_parent, Slic3r::GUI::Line::near_label_widget, Slic3r::GUI::Line::near_label_widget_win, parent(), Slic3r::ConfigOptionDef::sidetext, sidetext_width, sizer, staticbox, stb, sublabel_width, Slic3r::GUI::titleWidth, Slic3r::GUI::Line::widget, Slic3r::GUI::Line::widget_sizer, wxOSX, and wxStaticText.

Referenced by activate().

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

◆ append_line()

void Slic3r::GUI::OptionsGroup::append_line ( const Line & line)
260{
261 m_lines.emplace_back(line);
262
263 // Feed the searcher the row's wiki path (Line::label_path, for the Speed Dial's "open wiki"
264 // affordance) and the label the row actually draws, so a setting action is named like the page.
265 if (m_use_custom_ctrl) {
266 Search::SettingsIndex& index = wxGetApp().sidebar().settings_index();
267 const Preset::Type type = static_cast<Preset::Type>(config_type());
268 const bool multi = line.get_options().size() > 1;
269 for (const auto& opt : line.get_options()) {
270 if (!line.label_path.empty())
271 index.set_path(opt.opt_id, type, line.label_path);
272 // Mirror the sub-label OG_CustomCtrl draws for a multi-option row, so the palette
273 // names each field like the page does.
274 const std::string& leaf_src = opt.opt.label;
275 const wxString leaf = (leaf_src == L_CONTEXT("Top", "Layers") || leaf_src == L_CONTEXT("Bottom", "Layers")) ?
276 _L_CONTEXT(leaf_src, "Layers") :
277 _(leaf_src);
278 index.set_line_label(opt.opt_id, type, Search::compose_display_label(line.label, leaf, multi),
279 Search::compose_display_label(line.label_en, from_u8(leaf_src), multi));
280 }
281 }
282
283 if (line.full_width && (line.widget != nullptr || !line.get_extra_widgets().empty()))
284 return;
285
286 auto option_set = line.get_options();
287 for (auto opt : option_set)
288 m_options.emplace(opt.opt_id, opt);
289
290 // add mode value for current line to m_options_mode
291 if (!option_set.empty())
292 m_options_mode.push_back(option_set[0].opt.mode);
293}
std::vector< ConfigOptionMode > m_options_mode
Definition OptionsGroup.hpp:261
virtual int config_type() const
Definition OptionsGroup.hpp:299
std::map< t_config_option_key, Option > m_options
Definition OptionsGroup.hpp:259
Type
Definition Preset.hpp:244
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
wxString compose_display_label(const wxString &line_label, const wxString &leaf_label, bool multi)
Definition SettingsIndex.hpp:39

References _, _L_CONTEXT, Slic3r::Search::compose_display_label(), config_type(), Slic3r::GUI::from_u8(), Slic3r::GUI::Line::full_width, Slic3r::GUI::Line::get_extra_widgets(), Slic3r::GUI::Line::get_options(), L_CONTEXT, Slic3r::GUI::Line::label, Slic3r::GUI::Line::label_en, Slic3r::GUI::Line::label_path, m_lines, m_options, m_options_mode, m_use_custom_ctrl, Slic3r::Search::SettingsIndex::set_line_label(), Slic3r::Search::SettingsIndex::set_path(), and Slic3r::GUI::Line::widget.

Referenced by append_single_option_line(), Slic3r::GUI::Tab::build_preset_description_line(), and Slic3r::GUI::Tab::create_line_with_widget().

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

◆ append_separator()

void Slic3r::GUI::OptionsGroup::append_separator ( )
307{ m_lines.emplace_back(Line()); }

References m_lines.

◆ append_single_option_line()

void Slic3r::GUI::OptionsGroup::append_single_option_line ( const Option & option,
const std::string & path = std::string() )
inline
206{ append_line(create_single_option_line(option, path)); }
Line create_single_option_line(const Option &option, const std::string &path=std::string()) const
Definition OptionsGroup.cpp:650
void append_line(const Line &line)
Definition OptionsGroup.cpp:259

References append_line(), and create_single_option_line().

Referenced by Slic3r::GUI::ConfigOptionsGroup::append_single_option_line().

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

◆ back_to_initial_value()

virtual void Slic3r::GUI::OptionsGroup::back_to_initial_value ( const std::string & opt_key)
inlineprotectedvirtual

Reimplemented in Slic3r::GUI::ConfigOptionsGroup.

294{}

Referenced by build_field().

Here is the caller graph for this function:

◆ back_to_sys_value()

virtual void Slic3r::GUI::OptionsGroup::back_to_sys_value ( const std::string & opt_key)
inlineprotectedvirtual

Reimplemented in Slic3r::GUI::ConfigOptionsGroup.

295{}

Referenced by build_field().

Here is the caller graph for this function:

◆ build_field() [1/3]

const t_field & Slic3r::GUI::OptionsGroup::build_field ( const Option & opt)
protected
50{ return build_field(opt.opt_id, opt.opt); }

References build_field().

Here is the call graph for this function:

◆ build_field() [2/3]

const t_field & Slic3r::GUI::OptionsGroup::build_field ( const t_config_option_key & id)
protected
52{
53 const ConfigOptionDef& opt = m_options.at(id).opt;
54 return build_field(id, opt);
55}

References build_field(), and m_options.

Here is the call graph for this function:

◆ build_field() [3/3]

const t_field & Slic3r::GUI::OptionsGroup::build_field ( const t_config_option_key & id,
const ConfigOptionDef & opt )
protected

Generate a wxSizer or wxWindow from a configuration option Precondition: opt resolves to a known ConfigOption Postcondition: fields contains a wx gui object.

This function will be called from Field. Call OptionGroup._on_change(...)

This function will be called from Field.

58{
59 // Check the gui_type field first, fall through
60 // is the normal type.
61 switch (opt.gui_type) {
62 case ConfigOptionDef::GUIType::select_open: m_fields.emplace(id, Choice::Create<Choice>(this->ctrl_parent(), opt, id)); break;
65 case ConfigOptionDef::GUIType::i_enum_open: m_fields.emplace(id, Choice::Create<Choice>(this->ctrl_parent(), opt, id)); break;
67 case ConfigOptionDef::GUIType::legend: // StaticText
68 m_fields.emplace(id, StaticText::Create<StaticText>(this->ctrl_parent(), opt, id));
69 break;
70 case ConfigOptionDef::GUIType::one_string: m_fields.emplace(id, TextCtrl::Create<TextCtrl>(this->ctrl_parent(), opt, id)); break;
75 break;
76 default:
77 switch (opt.type) {
80 case coFloat:
81 case coFloats:
82 case coPercent:
83 case coPercents:
84 case coString:
85 case coStrings:
86 m_fields.emplace(id, TextCtrl::Create<TextCtrl>(this->ctrl_parent(), opt, id));
87 break;
88 case coBool:
89 case coBools:
90 m_fields.emplace(id, CheckBox::Create<CheckBox>(this->ctrl_parent(), opt, id));
91 break;
92 case coInt:
93 case coInts:
94 m_fields.emplace(id, SpinCtrl::Create<SpinCtrl>(this->ctrl_parent(), opt, id));
95 break;
96 case coEnum:
97 case coEnums:
98 m_fields.emplace(id, Choice::Create<Choice>(this->ctrl_parent(), opt, id));
99 break;
100 case coPoint:
101 case coPoints:
102 m_fields.emplace(id, PointCtrl::Create<PointCtrl>(this->ctrl_parent(), opt, id));
103 break;
104 case coNone: break;
105 default:
106 throw Slic3r::LogicError("This control doesn't exist till now"); break;
107 }
108 }
109 // Grab a reference to fields for convenience
110 const t_field& field = m_fields[id];
111 field->m_on_change = [this](const std::string& opt_id, const boost::any& value) {
114 if (!m_disabled)
115 this->on_change_OG(opt_id, value);
116 };
117 field->m_on_kill_focus = [this](const std::string& opt_id) {
119 if (!m_disabled)
120 this->on_kill_focus(opt_id);
121 };
122 field->m_parent = parent();
123
124 if (edit_custom_gcode && opt.is_code) {
125 field->m_fn_edit_value = [this](std::string opt_id) {
126 if (!m_disabled)
127 this->edit_custom_gcode(opt_id);
128 };
129 field->set_edit_tooltip(_L("Edit Custom G-code"));
130 }
131
132 field->m_back_to_initial_value = [this](std::string opt_id) {
133 if (!m_disabled)
134 this->back_to_initial_value(opt_id);
135 };
136 field->m_back_to_sys_value = [this](std::string opt_id) {
137 if (!this->m_disabled)
138 this->back_to_sys_value(opt_id);
139 };
140
141 if (auto plugin_field = dynamic_cast<PluginField*>(field.get())) {
142 plugin_field->set_selector([this, plugin_field]() -> std::string {
143 if (m_disabled)
144 return {};
145 return this->pick_plugin(plugin_field->m_opt);
146 });
147 }
148
149 // The dialog behind the button edits one preset's overrides, so it has to know which preset. Set
150 // here because fields are built lazily on activate() — too late for the Tab to reach in afterwards.
151 if (auto plugin_config_field = dynamic_cast<PluginConfigField*>(field.get()))
152 if (auto config_group = dynamic_cast<ConfigOptionsGroup*>(this))
153 plugin_config_field->set_preset_type(config_group->config_type());
154
155 // assign function objects for callbacks, etc.
156 return field;
157}
#define _L(s)
Definition OBJ.cpp:34
@ plugin_config
Definition Config.hpp:2336
@ printer_agent_select
Definition Config.hpp:2338
@ slider
Definition Config.hpp:2329
@ f_enum_open
Definition Config.hpp:2323
@ i_enum_open
Definition Config.hpp:2321
@ one_string
Definition Config.hpp:2333
@ color
Definition Config.hpp:2325
@ plugin_picker
Definition Config.hpp:2334
@ select_open
Definition Config.hpp:2327
static t_field Create(wxWindow *parent, const ConfigOptionDef &opt, const t_config_option_key &id)
Factory method for generating new derived classes.
Definition Field.hpp:278
virtual void on_change_OG(const t_config_option_key &opt_id, const boost::any &value)
Definition OptionsGroup.cpp:672
virtual void on_kill_focus(const std::string &opt_key)
Definition OptionsGroup.hpp:292
t_optionfield_map m_fields
Field list, contains unique_ptrs of the derived type. using types that need to know what it is beyond...
Definition OptionsGroup.hpp:269
virtual void back_to_sys_value(const std::string &opt_key)
Definition OptionsGroup.hpp:295
virtual void back_to_initial_value(const std::string &opt_key)
Definition OptionsGroup.hpp:294
bool m_disabled
Definition OptionsGroup.hpp:270
std::string pick_plugin(const ConfigOptionDef &opt)
Definition OptionsGroup.cpp:732
std::function< void(const t_config_option_key &opt_key)> edit_custom_gcode
Definition OptionsGroup.hpp:179
std::unique_ptr< Field > t_field
Definition Field.hpp:56
@ coFloatsOrPercents
Definition Config.hpp:202
@ coString
Definition Config.hpp:192
@ coPoint
Definition Config.hpp:204
@ coBools
Definition Config.hpp:212
@ coEnum
Definition Config.hpp:214
@ coPercents
Definition Config.hpp:198
@ coInts
Definition Config.hpp:190
@ coPoints
Definition Config.hpp:206
@ coInt
Definition Config.hpp:188
@ coNone
Definition Config.hpp:182
@ coBool
Definition Config.hpp:210
@ coFloat
Definition Config.hpp:184
@ coEnums
Definition Config.hpp:216
@ coFloatOrPercent
Definition Config.hpp:200
@ coStrings
Definition Config.hpp:194
@ coFloats
Definition Config.hpp:186
@ coPercent
Definition Config.hpp:196

References _L, back_to_initial_value(), back_to_sys_value(), Slic3r::coBool, Slic3r::coBools, Slic3r::coEnum, Slic3r::coEnums, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coFloats, Slic3r::coFloatsOrPercents, Slic3r::coInt, Slic3r::coInts, Slic3r::ConfigOptionDef::color, Slic3r::coNone, Slic3r::coPercent, Slic3r::coPercents, Slic3r::coPoint, Slic3r::coPoints, Slic3r::coString, Slic3r::coStrings, Slic3r::GUI::Field::Create(), ctrl_parent(), edit_custom_gcode, Slic3r::ConfigOptionDef::f_enum_open, Slic3r::ConfigOptionDef::i_enum_open, Slic3r::ConfigOptionDef::legend, m_disabled, m_fields, on_change_OG(), on_kill_focus(), Slic3r::ConfigOptionDef::one_string, parent(), pick_plugin(), Slic3r::ConfigOptionDef::plugin_config, Slic3r::ConfigOptionDef::plugin_picker, Slic3r::ConfigOptionDef::printer_agent_select, Slic3r::ConfigOptionDef::select_open, and Slic3r::ConfigOptionDef::slider.

Referenced by activate_line(), build_field(), and build_field().

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

◆ clear()

void Slic3r::GUI::OptionsGroup::clear ( bool destroy_custom_ctrl = false)
606{
607 if (!sizer)
608 return;
609
610 m_grid_sizer = nullptr;
611 sizer = nullptr;
612 stb = nullptr; // BBS: fix pointer
613
614 for (Line& line : m_lines) {
615 if (line.near_label_widget_win)
616 line.near_label_widget_win = nullptr;
617 line.label_widget = nullptr;
618
619 if (line.widget_sizer) {
620 line.widget_sizer->Clear(true);
621 line.widget_sizer = nullptr;
622 }
623
624 if (line.extra_widget_sizer) {
625 line.extra_widget_sizer->Clear(true);
626 line.extra_widget_sizer = nullptr;
627 }
628 }
629
630 if (custom_ctrl) {
631 for (auto const& item : m_fields) {
632 wxWindow* win = item.second.get()->getWindow();
633 if (win) {
634 free_window(win);
635 win = nullptr;
636 }
637 }
638 // BBS: custom_ctrl already destroyed from sizer->clear(), no need to destroy here anymore
639 if (destroy_custom_ctrl)
640 // custom_ctrl->Destroy();
641 custom_ctrl = nullptr;
642 else
643 custom_ctrl = nullptr;
644 }
645
647 m_fields.clear();
648}
void free_window(wxWindow *win)
Definition Field.cpp:937

References custom_ctrl, Slic3r::GUI::free_window(), m_extra_column_item_ptrs, m_fields, m_grid_sizer, m_lines, sizer, and stb.

Referenced by ~OptionsGroup(), and activate().

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

◆ clear_fields_except_of()

void Slic3r::GUI::OptionsGroup::clear_fields_except_of ( const std::vector< std::string > left_fields)
662{
663 auto it = m_fields.begin();
664 while (it != m_fields.end()) {
665 if (std::find(left_fields.begin(), left_fields.end(), it->first) == left_fields.end())
666 it = m_fields.erase(it);
667 else
668 it++;
669 }
670}

References m_fields.

◆ config_type()

virtual int Slic3r::GUI::OptionsGroup::config_type ( ) const
inlineprotectedvirtual

Reimplemented in Slic3r::GUI::ConfigOptionsGroup.

299{ return -1; }

Referenced by append_line().

Here is the caller graph for this function:

◆ create_single_option_line()

Line Slic3r::GUI::OptionsGroup::create_single_option_line ( const Option & option,
const std::string & path = std::string() ) const
651{
652 wxString tooltip = _(get_formatted_tooltip_text(option.opt, option.opt_id));
653
654 Line retval{from_u8(option.opt.label), tooltip};
655 retval.label_path = path;
656 retval.append_option(option);
657
658 return retval;
659}
wxString get_formatted_tooltip_text(const ConfigOptionDef &opt, const t_config_option_key &id)
Definition Field.cpp:163

References _, Slic3r::GUI::Line::append_option(), Slic3r::GUI::from_u8(), Slic3r::GUI::get_formatted_tooltip_text(), Slic3r::ConfigOptionDef::label, Slic3r::GUI::Line::label_path, Slic3r::GUI::Option::opt, and Slic3r::GUI::Option::opt_id.

Referenced by append_single_option_line(), Slic3r::GUI::ConfigOptionsGroup::create_single_option_line(), and Slic3r::GUI::ConfigOptionsGroup::create_single_option_line().

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

◆ ctrl_parent()

wxWindow * Slic3r::GUI::OptionsGroup::ctrl_parent ( ) const
172{
173 // BBS: new layout
174 return this->custom_ctrl && m_use_custom_ctrl_as_parent ? static_cast<wxWindow*>(this->custom_ctrl) :
175 (staticbox ? static_cast<wxWindow*>(this->stb) : this->parent());
176}

References custom_ctrl, m_use_custom_ctrl_as_parent, parent(), staticbox, and stb.

Referenced by activate_line(), and build_field().

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

◆ disable()

void Slic3r::GUI::OptionsGroup::disable ( )
inline
237{ for (auto& field : m_fields) field.second->disable(); }

References m_fields.

◆ disable_field()

void Slic3r::GUI::OptionsGroup::disable_field ( const t_config_option_key & opt_key)
inline
232{ enable_field(opt_key, false); }
void enable_field(const t_config_option_key &opt_key, bool enable=true)
Definition OptionsGroup.cpp:250

References enable_field().

Here is the call graph for this function:

◆ enable()

void Slic3r::GUI::OptionsGroup::enable ( )
inline
236{ for (auto& field : m_fields) field.second->enable(); }

References m_fields.

Referenced by enable_field().

Here is the caller graph for this function:

◆ enable_field()

void Slic3r::GUI::OptionsGroup::enable_field ( const t_config_option_key & opt_key,
bool enable = true )
251{
252 if (Field* f = get_field(opt_key); f) {
253 f->toggle(enable);
254 }
255}
Field * get_field(const t_config_option_key &id) const
Definition OptionsGroup.hpp:210
void enable()
Definition OptionsGroup.hpp:236
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124

References enable(), Slic3r::f(), and get_field().

Referenced by disable_field().

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

◆ get_field()

Field * Slic3r::GUI::OptionsGroup::get_field ( const t_config_option_key & id) const
inline
210 {
211 if (m_fields.find(id) == m_fields.end()) return nullptr;
212 return m_fields.at(id).get();
213 }

References m_fields.

Referenced by Slic3r::GUI::ConfigOptionsGroup::back_to_config_value(), enable_field(), Slic3r::GUI::ConfigOptionsGroup::get_fieldc(), and show_field().

Here is the caller graph for this function:

◆ get_grid_sizer()

wxGridSizer * Slic3r::GUI::OptionsGroup::get_grid_sizer ( )
inline
248{ return m_grid_sizer; }

References m_grid_sizer.

Referenced by Slic3r::GUI::ObjectTableSettings::update_extra_column_visible_status().

Here is the caller graph for this function:

◆ get_line()

Line * Slic3r::GUI::OptionsGroup::get_line ( const std::string & opt_key)
297{
298 for (int index = 0; index < m_lines.size(); index++) {
299 for (auto& opt : m_lines[index].get_options())
300 if (opt.opt_id == opt_key)
301 return &(m_lines[index]);
302 }
303
304 return nullptr;
305}

References m_lines.

Referenced by Slic3r::GUI::ObjectTableSettings::update_extra_column_visible_status().

Here is the caller graph for this function:

◆ get_lines()

const std::vector< Line > & Slic3r::GUI::OptionsGroup::get_lines ( )
inline
249{ return m_lines; }

References m_lines.

◆ get_url()

wxString Slic3r::GUI::OptionsGroup::get_url ( const std::string & path_end)
static
1405{
1406 // BBS
1407 wxString str = from_u8(path_end);
1408 auto pos = str.find(L'#');
1409 if (pos != size_t(-1)) {
1410 pos++;
1411 wxString anchor = str.Mid(pos).Lower();
1412 anchor.Replace(L" ", "-");
1413 str = str.Left(pos) + anchor;
1414 }
1415 // Orca: point to sf wiki for seam parameters
1416 return wxString::Format(L"https://www.orcaslicer.com/wiki/%s", from_u8(path_end));
1417}
#define L(s)
Definition ExtrusionEntity.cpp:25
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References Slic3r::GUI::from_u8(), and L.

Referenced by launch_browser(), Slic3r::GUI::ActionRegistry::materialize_setting_actions(), Slic3r::GUI::OG_CustomCtrl::OnMotion(), and Slic3r::GUI::ogStaticText::SetPathEnd().

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

◆ get_value()

boost::any Slic3r::GUI::OptionsGroup::get_value ( const t_config_option_key & id)
inline
220 {
221 boost::any out;
222 if (m_fields.find(id) == m_fields.end()) ;
223 else
224 out = m_fields.at(id)->get_value();
225 return out;
226 }

References m_fields.

Referenced by Slic3r::GUI::ConfigOptionsGroup::back_to_config_value().

Here is the caller graph for this function:

◆ hide_field()

void Slic3r::GUI::OptionsGroup::hide_field ( const t_config_option_key & opt_key)
inline
229{ show_field(opt_key, false); }
void show_field(const t_config_option_key &opt_key, bool show=true)
Definition OptionsGroup.cpp:208

References show_field().

Here is the call graph for this function:

◆ hide_labels()

void Slic3r::GUI::OptionsGroup::hide_labels ( )
inline
242{ label_width = 0; m_labels_hidden = true; }

References label_width, and m_labels_hidden.

◆ is_activated()

bool Slic3r::GUI::OptionsGroup::is_activated ( )
inline
255{ return sizer != nullptr; }

References sizer.

◆ is_legend_line()

bool Slic3r::GUI::OptionsGroup::is_legend_line ( )
179{
180 if (m_lines.size() == 1) {
181 const std::vector<Option>& option_set = m_lines.front().get_options();
182 return !option_set.empty() && option_set.front().opt.gui_type == ConfigOptionDef::GUIType::legend;
183 }
184 return false;
185}

References Slic3r::ConfigOptionDef::legend, and m_lines.

Referenced by activate_line().

Here is the caller graph for this function:

◆ launch_browser()

bool Slic3r::GUI::OptionsGroup::launch_browser ( const std::string & path_end)
static
1419{ return wxLaunchDefaultBrowser(OptionsGroup::get_url(path_end)); }
static wxString get_url(const std::string &path_end)
Definition OptionsGroup.cpp:1404

References get_url().

Referenced by Slic3r::GUI::OG_CustomCtrl::CtrlLine::launch_browser().

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

◆ on_change_OG()

void Slic3r::GUI::OptionsGroup::on_change_OG ( const t_config_option_key & opt_id,
const boost::any & value )
protectedvirtual

Reimplemented in Slic3r::GUI::ConfigOptionsGroup, and Slic3r::GUI::ExtruderOptionsGroup.

673{
674 if (m_on_change != nullptr)
675 m_on_change(opt_id, value);
676}
t_change m_on_change
Definition OptionsGroup.hpp:168

References m_on_change.

Referenced by Slic3r::GUI::ConfigOptionsGroup::back_to_config_value(), build_field(), Slic3r::GUI::ConfigOptionsGroup::on_change_OG(), and Slic3r::GUI::ExtruderOptionsGroup::on_change_OG().

Here is the caller graph for this function:

◆ on_kill_focus()

virtual void Slic3r::GUI::OptionsGroup::on_kill_focus ( const std::string & opt_key)
inlineprotectedvirtual

Reimplemented in Slic3r::GUI::ConfigOptionsGroup.

292{};

Referenced by build_field().

Here is the caller graph for this function:

◆ parent()

wxWindow * Slic3r::GUI::OptionsGroup::parent ( ) const
inline

Returns a copy of the pointer of the parent wxWindow. Accessor function is because users are not allowed to change the parent but defining it as const means a lot of const_casts to deal with wx functions.

190{ return m_parent; }

References m_parent.

Referenced by Slic3r::GUI::ConfigOptionsGroup::ConfigOptionsGroup(), Slic3r::GUI::ConfigOptionsGroup::ConfigOptionsGroup(), Slic3r::GUI::ConfigOptionsGroup::ConfigOptionsGroup(), Slic3r::GUI::ConfigOptionsGroup::ConfigOptionsGroup(), Slic3r::GUI::ExtruderOptionsGroup::ExtruderOptionsGroup(), activate_line(), build_field(), and ctrl_parent().

Here is the caller graph for this function:

◆ pick_plugin()

std::string Slic3r::GUI::OptionsGroup::pick_plugin ( const ConfigOptionDef & opt)
protected
733{
734 Slic3r::PluginManager& manager = Slic3r::PluginManager::instance();
736 if (plugin_type == Slic3r::PluginCapabilityType::Unknown) {
737 MessageDialog dlg(m_parent,
738 opt.plugin_type.empty() ? _L("This setting does not specify a plugin capability type.")
739 : _L("This setting specifies an unrecognized plugin capability type: ") + "'" + opt.plugin_type + "'.",
740 _L("Plugin Selection"),
741 wxOK | wxICON_WARNING
742 );
743 dlg.CenterOnParent();
744 dlg.ShowModal();
745
746 return {};
747 }
748
749 struct CapabilityRef { std::string plugin_key; std::string name; };
750 std::vector<CapabilityRef> caps;
751 for (const auto& capability : manager.get_plugin_capabilities(/*plugin_key=*/"", plugin_type, /*only_enabled=*/true))
752 caps.push_back({capability->audit_plugin_key(), capability->name()});
753 std::sort(caps.begin(), caps.end(), [](const CapabilityRef& lhs, const CapabilityRef& rhs) {
754 return lhs.name == rhs.name ? lhs.plugin_key < rhs.plugin_key : lhs.name < rhs.name;
755 });
756
757 if (caps.empty()) {
758 MessageDialog dlg(m_parent,
759 _L("No plugins capabilities available for this type.\nEnable or install some to use."),
760 _L("Plugin Selection"),
761 wxOK | wxICON_INFORMATION
762 );
763 dlg.CenterOnParent();
764 dlg.ShowModal();
765 return {};
766 }
767
768 std::vector<PluginPickerDialog::CapabilityEntry> entries;
769 entries.reserve(caps.size());
770 for (const auto& cap : caps) {
771 Slic3r::PluginDescriptor descriptor;
772 wxString package_name = manager.try_get_plugin_descriptor(cap.plugin_key, descriptor)
773 ? from_u8(descriptor.name) : from_u8(cap.plugin_key);
774 entries.push_back({
775 cap.plugin_key, cap.name, from_u8(cap.name) + from_u8(" \xE2\x80\x94 ") + package_name, package_name
776 });
777 }
778
779 PluginPickerDialog dlg(m_parent, from_u8(opt.plugin_type), std::move(entries));
780 if (dlg.ShowModal() != wxID_OK)
781 return {};
782 const auto selection = dlg.selected_capability();
783 if (selection.plugin_key.empty() || selection.name.empty())
784 return {};
785
786 // Only the bare capability name is stored; the full "name;uuid;capability" reference is derived when
787 // the preset is serialized (see ConfigBase::save_plugin_collection). Resolve here to reject bad picks.
788 Slic3r::PluginDescriptor descriptor;
789 if (!manager.try_get_plugin_descriptor(selection.plugin_key, descriptor) || descriptor.name.empty())
790 return {};
791
792 BOOST_LOG_TRIVIAL(info) << "Picked plugin capability: " << selection.name;
793 return selection.name;
794}
std::vector< std::shared_ptr< PluginCapabilityInterface > > get_plugin_capabilities(const std::string &plugin_key="", PluginCapabilityType type=PluginCapabilityType::Unknown, bool only_enabled=true) const
Definition PluginManager.cpp:592
static PluginManager & instance()
Definition PluginManager.cpp:74
bool try_get_plugin_descriptor(const std::string &plugin_key, PluginDescriptor &out) const
Definition PluginManager.cpp:502
PluginCapabilityType
Definition PythonPluginInterface.hpp:17
@ Unknown
Definition PythonPluginInterface.hpp:17
PluginCapabilityType plugin_capability_type_from_string(std::string_view value)
Definition PythonPluginInterface.hpp:72
std::string name
Definition PluginDescriptor.hpp:55

References _L, Slic3r::GUI::from_u8(), Slic3r::PluginManager::get_plugin_capabilities(), Slic3r::PluginManager::instance(), m_parent, Slic3r::PluginDescriptor::name, Slic3r::plugin_capability_type_from_string(), Slic3r::GUI::PluginPickerDialog::selected_capability(), Slic3r::GUI::DPIAware< P >::ShowModal(), Slic3r::PluginManager::try_get_plugin_descriptor(), and Slic3r::Unknown.

Referenced by build_field().

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

◆ remove_option_if()

void Slic3r::GUI::OptionsGroup::remove_option_if ( std::function< bool(std::string const &)> const & comp)
194{
195 for (auto& l : m_lines) {
196 auto& opts = const_cast<std::vector<Option>&>(l.get_options());
197 opts.erase(std::remove_if(opts.begin(), opts.end(), [&comp](Option& o) { return comp(o.opt.opt_key); }), opts.end());
198 l.undo_to_sys = true;
199 }
200 for (int i = m_lines.size() - 1; i >= 0; --i) {
201 if (m_lines[i].get_options().empty())
202 m_options_mode.erase(m_options_mode.begin() + i);
203 }
204 m_lines.erase(std::remove_if(m_lines.begin(), m_lines.end(), [](auto& l) { return l.get_options().empty(); }), m_lines.end());
205 // TODO: remove items from g->m_options;
206}
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:273

References Slic3r::empty(), m_lines, and m_options_mode.

Here is the call graph for this function:

◆ set_grid_vgap()

void Slic3r::GUI::OptionsGroup::set_grid_vgap ( int gap)
inline
238{ m_grid_sizer->SetVGap(gap); }

References m_grid_sizer.

◆ set_max_win_width()

void Slic3r::GUI::OptionsGroup::set_max_win_width ( int max_win_width)
188{
189 if (custom_ctrl)
190 custom_ctrl->set_max_win_width(max_win_width);
191}

References custom_ctrl.

◆ set_name()

void Slic3r::GUI::OptionsGroup::set_name ( const wxString & new_name)
257{ stb->SetLabel(new_name); }

References stb.

◆ set_value()

bool Slic3r::GUI::OptionsGroup::set_value ( const t_config_option_key & id,
const boost::any & value,
bool change_event = false )
inline
215 {
216 if (m_fields.find(id) == m_fields.end()) return false;
217 m_fields.at(id)->set_value(value, change_event);
218 return true;
219 }

References m_fields.

Referenced by Slic3r::GUI::ConfigOptionsGroup::back_to_config_value(), Slic3r::GUI::Tab::on_value_change(), and Slic3r::GUI::ConfigOptionsGroup::reload_config().

Here is the caller graph for this function:

◆ show_field()

void Slic3r::GUI::OptionsGroup::show_field ( const t_config_option_key & opt_key,
bool show = true )
209{
210 Field* field = get_field(opt_key);
211 if (!field)
212 return;
213 wxWindow* win = field->getWindow();
214 if (!win)
215 return;
216 wxSizerItem* win_item = m_grid_sizer->GetItem(win, true);
217 if (!win_item)
218 return;
219
220 const size_t cols = (size_t) m_grid_sizer->GetCols();
221 const size_t rows = (size_t) m_grid_sizer->GetEffectiveRowsCount();
222
223 auto show_row = [this, show, cols, win_item](wxSizerItem* item, size_t row_shift) {
224 // check if item contanes required win
225 if (!item->IsWindow() || item != win_item)
226 return false;
227 // show/hide hole line contanes this window
228 for (size_t i = 0; i < cols; ++i)
229 m_grid_sizer->Show(row_shift + i, show);
230 return true;
231 };
232
233 size_t row_shift = 0;
234 for (size_t j = 0; j < rows; ++j) {
235 for (size_t i = 0; i < cols; ++i) {
236 wxSizerItem* item = m_grid_sizer->GetItem(row_shift + i);
237 if (!item)
238 continue;
239 if (item->IsSizer()) {
240 for (wxSizerItem* child_item : item->GetSizer()->GetChildren())
241 if (show_row(child_item, row_shift))
242 return;
243 } else if (show_row(item, row_shift))
244 return;
245 }
246 row_shift += cols;
247 }
248}
size_t cols(const T &raster)
Definition MarchingSquares.hpp:173
size_t rows(const T &raster)
Definition MarchingSquares.hpp:171

References get_field(), Slic3r::GUI::Field::getWindow(), and m_grid_sizer.

Referenced by hide_field().

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

Member Data Documentation

◆ ctrl_horiz_alignment

int Slic3r::GUI::OptionsGroup::ctrl_horiz_alignment { wxALIGN_LEFT}
166{ wxALIGN_LEFT};

Referenced by activate().

◆ custom_ctrl

◆ draw_multi_extruder

bool Slic3r::GUI::OptionsGroup::draw_multi_extruder { false }
185{ false };

◆ edit_custom_gcode

std::function<void(const t_config_option_key& opt_key)> Slic3r::GUI::OptionsGroup::edit_custom_gcode { nullptr }
179{ nullptr };

Referenced by build_field().

◆ extra_column

column_t Slic3r::GUI::OptionsGroup::extra_column {nullptr}
167{nullptr};

Referenced by OptionsGroup(), activate(), and activate_line().

◆ have_sys_config

std::function<bool()> Slic3r::GUI::OptionsGroup::have_sys_config { nullptr }

◆ icon

◆ label_font

wxFont Slic3r::GUI::OptionsGroup::label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }
182{wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };

◆ label_width

size_t Slic3r::GUI::OptionsGroup::label_width = 20

◆ m_disabled

bool Slic3r::GUI::OptionsGroup::m_disabled {false}
protected
270{false};

Referenced by build_field().

◆ m_extra_column_item_ptrs

std::vector<wxWindow*> Slic3r::GUI::OptionsGroup::m_extra_column_item_ptrs
protected

◆ m_fields

t_optionfield_map Slic3r::GUI::OptionsGroup::m_fields
protected

Field list, contains unique_ptrs of the derived type. using types that need to know what it is beyond the public interface need to cast based on the related ConfigOptionDef.

Referenced by build_field(), clear(), clear_fields_except_of(), disable(), enable(), get_field(), get_value(), Slic3r::GUI::ConfigOptionsGroup::msw_rescale(), set_value(), and Slic3r::GUI::ConfigOptionsGroup::sys_color_changed().

◆ m_fill_empty_value

t_kill_focus Slic3r::GUI::OptionsGroup::m_fill_empty_value { nullptr }
171{ nullptr };

Referenced by Slic3r::GUI::ConfigOptionsGroup::on_kill_focus().

◆ m_get_initial_config

std::function<DynamicPrintConfig()> Slic3r::GUI::OptionsGroup::m_get_initial_config { nullptr }

◆ m_get_sys_config

std::function<DynamicPrintConfig()> Slic3r::GUI::OptionsGroup::m_get_sys_config { nullptr }

◆ m_grid_sizer

◆ m_labels_hidden

bool Slic3r::GUI::OptionsGroup::m_labels_hidden {false}
162{false};

Referenced by activate_line(), and hide_labels().

◆ m_lines

◆ m_on_change

t_change Slic3r::GUI::OptionsGroup::m_on_change { nullptr }
168{ nullptr };

Referenced by on_change_OG().

◆ m_options

std::map<t_config_option_key, Option> Slic3r::GUI::OptionsGroup::m_options
protected

◆ m_options_mode

◆ m_parent

wxWindow* Slic3r::GUI::OptionsGroup::m_parent {nullptr}
protected
260{nullptr};

Referenced by OptionsGroup(), activate(), parent(), and pick_plugin().

◆ m_use_custom_ctrl

bool Slic3r::GUI::OptionsGroup::m_use_custom_ctrl { false }
protected

◆ m_use_custom_ctrl_as_parent

bool Slic3r::GUI::OptionsGroup::m_use_custom_ctrl_as_parent { false }
protected
276{ false };

Referenced by activate_line(), and ctrl_parent().

◆ option_label_at_right

bool Slic3r::GUI::OptionsGroup::option_label_at_right {false}
157{false};

◆ rescale_extra_column_item

std::function<void(wxWindow* win)> Slic3r::GUI::OptionsGroup::rescale_extra_column_item { nullptr }
176{ nullptr };

Referenced by Slic3r::GUI::ConfigOptionsGroup::msw_rescale().

◆ rescale_near_label_widget

std::function<void(wxWindow* win)> Slic3r::GUI::OptionsGroup::rescale_near_label_widget { nullptr }
177{ nullptr };

◆ sidetext_font

wxFont Slic3r::GUI::OptionsGroup::sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }
181{wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };

◆ sidetext_width

int Slic3r::GUI::OptionsGroup::sidetext_width { -1 }
183{ -1 };

Referenced by activate_line().

◆ sizer

◆ split_multi_line

bool Slic3r::GUI::OptionsGroup::split_multi_line {false}
156{false};

◆ staticbox

const bool Slic3r::GUI::OptionsGroup::staticbox {true}

◆ stb

◆ sublabel_width

int Slic3r::GUI::OptionsGroup::sublabel_width { -1 }
184{ -1 };

Referenced by activate_line().

◆ title


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