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

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

Inheritance diagram for Slic3r::GUI::Choice:
Collaboration diagram for Slic3r::GUI::Choice:

Public Member Functions

 Choice (const ConfigOptionDef &opt, const t_config_option_key &id)
 Choice (wxWindow *parent, const ConfigOptionDef &opt, const t_config_option_key &id)
 ~Choice ()
void BUILD () override
 Finish constructing the Field's wxWidget-related properties, including setting its own sizer, etc.
void propagate_value () override
void set_selection ()
void set_value (const std::string &value, bool change_event=false)
 Redundant?
void set_value (const boost::any &value, bool change_event=false) override
 Sets a value for this control. subclasses should overload with a specific version Postcondition: Method does not fire the on_change event.
void set_values (const std::vector< std::string > &values)
 it's needed for _update_serial_ports()
void set_values (const wxArrayString &values)
boost::any & get_value () override
 Gets a boost::any representing this control. subclasses should overload with a specific version.
void set_last_meaningful_value () override
void set_na_value () override
void msw_rescale () override
void enable () override
void disable () override
wxWindow * getWindow () override
void suppress_scroll ()
void on_back_to_initial_value ()
 Call the attached m_back_to_initial_value method.
void on_back_to_sys_value ()
 Call the attached m_back_to_sys_value method.
void on_edit_value ()
 Call the attached m_fn_edit_value method.
virtual void update_na_value (const boost::any &value)
void toggle (bool en)
 Fires the enable or disable function, based on the input.
virtual wxString get_tooltip_text (const wxString &default_string)
void field_changed ()
virtual wxSizer * getSizer ()
 If you don't know what you are getting back, check both methods for nullptr.
bool is_matched (const std::string &string, const std::string &pattern)
void get_value_by_opt_type (wxString &str, const bool check_value=true)
virtual void sys_color_changed ()
bool get_enter_pressed () const
void set_enter_pressed (bool pressed)
const bool combine_side_text ()
bool set_undo_bitmap (const ScalableBitmap *bmp)
bool set_undo_to_sys_bitmap (const ScalableBitmap *bmp)
bool set_label_colour (const wxColour *clr)
bool set_undo_tooltip (const wxString *tip)
bool set_undo_to_sys_tooltip (const wxString *tip)
bool set_edit_bitmap (const ScalableBitmap *bmp)
bool set_edit_tooltip (const wxString &tip)
bool has_undo_ui () const
const ScalableBitmap * undo_bitmap () const
const wxString * undo_tooltip () const
const ScalableBitmap * undo_to_sys_bitmap () const
const wxString * undo_to_sys_tooltip () const
const wxColour * label_color () const
const bool blink () const
bool * get_blink_ptr ()
bool has_edit_ui () const
const wxBitmap * edit_bitmap () const
const wxString * edit_tooltip () const

Static Public Member Functions

static void register_dynamic_list (std::string const &optname, DynamicList *list)
template<class T>
static t_field Create (wxWindow *parent, const ConfigOptionDef &opt, const t_config_option_key &id)
 Factory method for generating new derived classes.
static int def_width ()
static int def_width_wider ()
static int def_width_thinner ()

Public Attributes

wxWindow * window { nullptr }
bool m_is_editable { false }
bool m_is_dropped { false }
bool m_suppress_scroll { false }
int m_last_selected { wxNOT_FOUND }
wxWindow * m_parent {nullptr}
 parent wx item, opportunity to refactor (probably not necessary - data duplication)
t_kill_focus m_on_kill_focus {nullptr}
 Function object to store callback passed in from owning object.
t_change m_on_change {nullptr}
 Function object to store callback passed in from owning object.
t_back_to_init m_back_to_initial_value { nullptr }
 Function object to store callback passed in from owning object.
t_back_to_init m_back_to_sys_value { nullptr }
t_back_to_init m_fn_edit_value { nullptr }
 Callback function to edit field value.
bool m_disable_change_event {false}
bool m_is_modified_value {false}
bool m_is_nonsys_value {true}
const ConfigOptionDef m_opt {ConfigOptionDef()}
 Copy of ConfigOption for deduction purposes.
const t_config_option_key m_opt_id
int m_opt_idx = 0
 {""};
double opt_height { 0.0 }
bool parent_is_custom_ctrl { false }

Protected Member Functions

virtual void PostInitialize ()
void on_kill_focus ()
 Call the attached on_kill_focus method. It's important to use wxEvent instead of wxFocusEvent, in another case we can't unfocused control at all.
void on_change_field ()
 Call the attached on_change method.

Protected Attributes

boost::any m_value
boost::any m_last_meaningful_value
int m_em_unit
bool m_combine_side_text = false
bool bEnterPressed = false
wxString m_na_value = _(L("N/A"))

Private Member Functions

 Field (const ConfigOptionDef &opt, const t_config_option_key &id)
 Field (wxWindow *parent, const ConfigOptionDef &opt, const t_config_option_key &id)

Private Attributes

DynamicList * m_list = nullptr
UndoValueUI m_undo_ui
EditValueUI m_edit_ui

Detailed Description

Constructor & Destructor Documentation

◆ Choice() [1/2]

Slic3r::GUI::Choice::Choice ( const ConfigOptionDef & opt,
const t_config_option_key & id )
inline
449: Field(opt, id) {}
Field(const ConfigOptionDef &opt, const t_config_option_key &id)
Definition Field.hpp:265

References Field().

Here is the call graph for this function:

◆ Choice() [2/2]

Slic3r::GUI::Choice::Choice ( wxWindow * parent,
const ConfigOptionDef & opt,
const t_config_option_key & id )
inline
450: Field(parent, opt, id) {}

References Field().

Here is the call graph for this function:

◆ ~Choice()

Slic3r::GUI::Choice::~Choice ( )
1556{
1557 if (m_list) { m_list->remove_choice(this); }
1558}
DynamicList * m_list
Definition Field.hpp:447

References m_list.

Member Function Documentation

◆ blink()

const bool Slic3r::GUI::UndoValueUIManager::blink ( ) const
inlineinherited
170{ return m_undo_ui.blink; }
UndoValueUI m_undo_ui
Definition Field.hpp:120

References m_undo_ui.

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

Here is the caller graph for this function:

◆ BUILD()

void Slic3r::GUI::Choice::BUILD ( )
overridevirtual

Finish constructing the Field's wxWidget-related properties, including setting its own sizer, etc.

Implements Slic3r::GUI::Field.

1561{
1562 wxSize size(def_width_wider() * m_em_unit, wxDefaultCoord);
1563 if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
1564 if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
1565
1566 if (m_opt.nullable)
1567 m_last_meaningful_value = dynamic_cast<ConfigOptionEnumsGenericNullable const *>(m_opt.default_value.get())->get_at(0);
1568
1569 choice_ctrl * temp;
1570 auto dynamic_list = dynamic_lists.find(m_opt.opt_key);
1571 if (dynamic_list != dynamic_lists.end())
1572 m_list = dynamic_list->second;
1574 && m_list == nullptr) {
1575 m_is_editable = true;
1576 static Builder<choice_ctrl> builder1;
1577 temp = builder1.build(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxTE_PROCESS_ENTER);
1578 }
1579 else {
1580#ifdef UNDEIFNED__WXOSX__ // __WXOSX__ // BBS
1581 /* wxBitmapComboBox with wxCB_READONLY style return NULL for GetTextCtrl(),
1582 * so ToolTip doesn't shown.
1583 * Next workaround helps to solve this problem
1584 */
1585 temp = new choice_ctrl();
1586 temp->SetTextCtrlStyle(wxTE_READONLY);
1587 temp->Create(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr);
1588#else
1589 static Builder<choice_ctrl> builder2;
1590 temp = builder2.build(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
1591#endif //__WXOSX__
1592 }
1593 // temp->SetSize(size);
1594 temp->Clear();
1595 temp->GetDropDown().SetUseContentWidth(true);
1596 if (parent_is_custom_ctrl && m_opt.height < 0)
1597 opt_height = (double) temp->GetTextCtrl()->GetSize().GetHeight() / m_em_unit;
1598
1599 // BBS
1600 temp->SetTextLabel(_L(m_opt.sidetext));
1601 m_combine_side_text = true;
1602
1603#ifdef __WXGTK3__
1604 wxSize best_sz = temp->GetBestSize();
1605 if (best_sz.x > size.x)
1606 temp->SetSize(best_sz);
1607#endif //__WXGTK3__
1608
1609 //temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
1610 if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
1611
1612 // recast as a wxWindow to fit the calling convention
1613 window = dynamic_cast<wxWindow*>(temp);
1614
1615 if (! m_opt.enum_labels.empty() || ! m_opt.enum_values.empty()) {
1616 if (m_opt.enum_labels.empty()) {
1617 // Append non-localized enum_values
1618 for (auto el : m_opt.enum_values)
1619 temp->Append(el);
1620 } else {
1621 // Append localized enum_labels
1622 int i = 0;
1623 boost::filesystem::path image_path(Slic3r::resources_dir());
1624 image_path /= "images";
1625 for (auto el : m_opt.enum_labels) {
1626 auto icon_name = "param_" + m_opt.enum_values[i];
1627 if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) {
1628 ScalableBitmap bm(temp, icon_name, 24);
1629 temp->Append(_(el), bm.bmp());
1630 } else {
1631 temp->Append(_(el));
1632 }
1633 ++i;
1634 }
1635 }
1636 set_selection();
1637 } else if (m_list) {
1638 m_list->add_choice(this);
1639 set_selection();
1640 }
1641
1642 temp->Bind(wxEVT_MOUSEWHEEL, [this](wxMouseEvent& e) {
1644 e.StopPropagation();
1645 else
1646 e.Skip();
1647 }, temp->GetId());
1648 temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; }, temp->GetId());
1649 temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_is_dropped = false; }, temp->GetId());
1650
1651 temp->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent&) { on_change_field(); }, temp->GetId());
1652
1653 if (m_is_editable) {
1654 temp->Bind(wxEVT_KILL_FOCUS, [this](wxEvent& e) {
1655 e.Skip();
1656 if (!bEnterPressed)
1658 }, temp->GetId() );
1659
1660 temp->Bind(wxEVT_TEXT_ENTER, [this](wxEvent& e) {
1661 EnterPressed enter(this);
1663 }, temp->GetId() );
1664 }
1665
1666 temp->SetToolTip(get_tooltip_text(temp->GetValue()));
1667}
#define _(s)
Definition 3mf.cpp:306
#define wxOSX
Definition Field.cpp:94
#define _L(s)
Definition OBJ.cpp:34
@ undefined
Definition Config.hpp:2319
@ select_open
Definition Config.hpp:2327
const int & get_at(size_t i) const
Definition Config.hpp:676
wxWindow * window
Definition Field.hpp:455
void propagate_value() override
Definition Field.cpp:1669
bool m_is_editable
Definition Field.hpp:463
bool m_suppress_scroll
Definition Field.hpp:465
void set_selection()
Definition Field.cpp:1710
bool m_is_dropped
Definition Field.hpp:464
Definition Field.hpp:194
double opt_height
Definition Field.hpp:239
static int def_width_wider()
Definition Field.cpp:402
virtual wxString get_tooltip_text(const wxString &default_string)
Definition Field.cpp:441
void on_change_field()
Call the attached on_change method.
Definition Field.cpp:412
bool m_combine_side_text
Definition Field.hpp:305
bool bEnterPressed
Definition Field.hpp:307
boost::any m_last_meaningful_value
Definition Field.hpp:302
int m_em_unit
Definition Field.hpp:304
wxWindow * m_parent
parent wx item, opportunity to refactor (probably not necessary - data duplication)
Definition Field.hpp:214
const ConfigOptionDef m_opt
Copy of ConfigOption for deduction purposes.
Definition Field.hpp:235
bool parent_is_custom_ctrl
Definition Field.hpp:240
wxMouseEvent
Definition CameraPopup.cpp:47
::ComboBox choice_ctrl
Definition Field.cpp:1529
static std::map< std::string, DynamicList * > dynamic_lists
Definition Field.cpp:1532
const std::string & resources_dir()
Definition utils.cpp:296
ConfigOptionEnumsGenericTempl< true > ConfigOptionEnumsGenericNullable
Definition Config.hpp:2312

References _, _L, ComboBox::Append(), Slic3r::GUI::Field::bEnterPressed, ScalableBitmap::bmp(), Slic3r::GUI::Builder< T >::build(), Slic3r::GUI::Field::def_width_wider(), Slic3r::GUI::dynamic_lists, Slic3r::GUI::Field::get_tooltip_text(), ComboBox::GetDropDown(), ComboBox::GetValue(), Slic3r::GUI::Field::m_combine_side_text, Slic3r::GUI::Field::m_em_unit, m_is_dropped, m_is_editable, Slic3r::GUI::Field::m_last_meaningful_value, m_list, Slic3r::GUI::Field::m_opt, Slic3r::GUI::Field::m_parent, m_suppress_scroll, Slic3r::GUI::Field::on_change_field(), Slic3r::GUI::Field::opt_height, Slic3r::GUI::Field::parent_is_custom_ctrl, propagate_value(), Slic3r::resources_dir(), Slic3r::ConfigOptionDef::select_open, set_selection(), ComboBox::SetTextLabel(), DropDown::SetUseContentWidth(), Slic3r::ConfigOptionDef::undefined, window, Slic3r::GUI::wxMouseEvent, and wxOSX.

Here is the call graph for this function:

◆ combine_side_text()

const bool Slic3r::GUI::Field::combine_side_text ( )
inlineinherited
296{ return m_combine_side_text; } // BBS: new param style

References m_combine_side_text.

Referenced by Slic3r::GUI::OG_CustomCtrl::get_pos(), and Slic3r::GUI::OG_CustomCtrl::CtrlLine::render().

Here is the caller graph for this function:

◆ Create()

template<class T>
t_field Slic3r::GUI::Field::Create ( wxWindow * parent,
const ConfigOptionDef & opt,
const t_config_option_key & id )
inlinestaticinherited

Factory method for generating new derived classes.

p;

279 {
280 auto p = Slic3r::make_unique<T>(parent, opt, id);
281 p->PostInitialize();
282 return std::move(p);
283 }
std::unique_ptr< T > make_unique(Args &&... args)
Definition libslic3r.h:239

References Slic3r::make_unique().

Referenced by Slic3r::GUI::OptionsGroup::build_field().

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

◆ def_width()

int Slic3r::GUI::Field::def_width ( )
staticinherited
401{ return 8; }

Referenced by Slic3r::GUI::OptionsGroup::activate_line().

Here is the caller graph for this function:

◆ def_width_thinner()

int Slic3r::GUI::Field::def_width_thinner ( )
staticinherited
403{ return 4; }

Referenced by Slic3r::GUI::DiamTextCtrl::DiamTextCtrl(), Slic3r::GUI::OptionsGroup::activate_line(), and Slic3r::GUI::ObjectTableSettings::update_settings_list().

Here is the caller graph for this function:

◆ def_width_wider()

◆ disable()

void Slic3r::GUI::Choice::disable ( )
overridevirtual

Implements Slic3r::GUI::Field.

2032{ dynamic_cast<choice_ctrl*>(window)->Disable(); }
@ Disable
Definition Config.hpp:243

References Slic3r::Disable, and window.

◆ edit_bitmap()

const wxBitmap * Slic3r::GUI::UndoValueUIManager::edit_bitmap ( ) const
inlineinherited
175{ return &m_edit_ui.bitmap->bmp(); }
EditValueUI m_edit_ui
Definition Field.hpp:144

References m_edit_ui.

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

Here is the caller graph for this function:

◆ edit_tooltip()

const wxString * Slic3r::GUI::UndoValueUIManager::edit_tooltip ( ) const
inlineinherited
176{ return &m_edit_ui.tooltip; }

References m_edit_ui.

◆ enable()

void Slic3r::GUI::Choice::enable ( )
overridevirtual

Implements Slic3r::GUI::Field.

2031{ dynamic_cast<choice_ctrl*>(window)->Enable(); }
@ Enable
Definition Config.hpp:245

References Slic3r::Enable, and window.

◆ Field() [1/2]

Slic3r::GUI::Field::Field ( const ConfigOptionDef & opt,
const t_config_option_key & id )
inlineprivate
265: m_opt(opt), m_opt_id(id) {}
const t_config_option_key m_opt_id
Definition Field.hpp:236

Referenced by Choice(), and Choice().

Here is the caller graph for this function:

◆ Field() [2/2]

Slic3r::GUI::Field::Field ( wxWindow * parent,
const ConfigOptionDef & opt,
const t_config_option_key & id )
inlineprivate
266: m_parent(parent), m_opt(opt), m_opt_id(id) {}

◆ field_changed()

void Slic3r::GUI::Field::field_changed ( )
inlineinherited
263{ on_change_field(); }

References on_change_field().

Referenced by Slic3r::GUI::Tab::commit_preset_config_value().

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

◆ get_blink_ptr()

bool * Slic3r::GUI::UndoValueUIManager::get_blink_ptr ( )
inlineinherited
171{ return &m_undo_ui.blink; }

References m_undo_ui.

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

Here is the caller graph for this function:

◆ get_enter_pressed()

bool Slic3r::GUI::Field::get_enter_pressed ( ) const
inlineinherited
288{ return bEnterPressed; }

References bEnterPressed.

◆ get_tooltip_text()

wxString Slic3r::GUI::Field::get_tooltip_text ( const wxString & default_string)
virtualinherited
442{
443 wxString tooltip_text = get_formatted_tooltip_text(m_opt, m_opt_id);
444
445 return tooltip_text.length() > 0 ? tooltip_text : default_string;
446}
wxString get_formatted_tooltip_text(const ConfigOptionDef &opt, const t_config_option_key &id)
Definition Field.cpp:163

References Slic3r::GUI::get_formatted_tooltip_text(), m_opt, and m_opt_id.

Referenced by Slic3r::GUI::PluginField::add_plugin_row(), Slic3r::GUI::CheckBox::BUILD(), Slic3r::GUI::Choice::BUILD(), Slic3r::GUI::ColourPicker::BUILD(), Slic3r::GUI::PluginConfigField::BUILD(), Slic3r::GUI::PointCtrl::BUILD(), Slic3r::GUI::PrinterAgentChoice::BUILD(), Slic3r::GUI::SpinCtrl::BUILD(), Slic3r::GUI::StaticText::BUILD(), Slic3r::GUI::TextCtrl::BUILD(), and Slic3r::GUI::PluginField::set_row_value().

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

◆ get_value()

boost::any & Slic3r::GUI::Choice::get_value ( )
overridevirtual

Gets a boost::any representing this control. subclasses should overload with a specific version.

Implements Slic3r::GUI::Field.

1949{
1950 choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
1951
1952 wxString ret_str = field->GetValue();
1953
1954 // options from right panel
1955 std::vector <std::string> right_panel_options{ "support", "pad", "scale_unit" };
1956 for (auto rp_option: right_panel_options)
1957 if (m_opt_id == rp_option)
1958 return m_value = boost::any(ret_str);
1959
1960 // BBS
1961 if (m_opt.type == coEnum || m_opt.type == coEnums)
1962 {
1963 if (m_opt.nullable && field->GetSelection() == -1)
1965 else if (m_opt_id == "input_shaping_type")
1966 {
1967 int selection = field->GetSelection();
1968 if (selection >= 0) {
1969 if (void* data = field->GetClientData(selection))
1970 m_value = static_cast<int>(reinterpret_cast<uintptr_t>(data));
1971 else
1972 m_value = selection;
1973 } else
1974 m_value = 0;
1975 }
1976 else if ( m_opt_id == "top_surface_pattern" || m_opt_id == "bottom_surface_pattern" ||
1977 m_opt_id == "internal_solid_infill_pattern" || m_opt_id == "sparse_infill_pattern" ||
1978 m_opt_id == "support_base_pattern" || m_opt_id == "support_interface_pattern" ||
1979 m_opt_id == "ironing_pattern" || m_opt_id == "support_ironing_pattern" ||
1980 m_opt_id == "support_style" || m_opt_id == "curr_bed_type" || m_opt_id == "wipe_tower_wall_type")
1981 {
1982 const std::string &key = m_opt.enum_values[field->GetSelection()];
1983 m_value = int(m_opt.enum_keys_map->at(key));
1984 }
1985 // Support ThirdPartyPrinter
1986 else if (m_opt_id.compare("host_type") == 0 && m_opt.enum_values.size() > field->GetCount())
1987 {
1988 // for case, when PrusaLink isn't used as a HostType
1989 m_value = field->GetSelection() + 1;
1990 }
1991 else
1992 m_value = field->GetSelection();
1993 }
1995 const int ret_enum = field->GetSelection();
1996 if (m_list) {
1997 ret_str = m_list->get_value(ret_enum);
1998 get_value_by_opt_type(ret_str);
1999 } else if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings ||
2000 (ret_str != m_opt.enum_values[ret_enum] && ret_str != _(m_opt.enum_labels[ret_enum])))
2001 // modifies ret_string!
2002 get_value_by_opt_type(ret_str);
2003 else if (m_opt.type == coFloatOrPercent)
2004 m_value = m_opt.enum_values[ret_enum];
2005 else if (m_opt.type == coInt)
2006 m_value = atoi(m_opt.enum_values[ret_enum].c_str());
2007 else
2008 m_value = string_to_double_decimal_point(m_opt.enum_values[ret_enum]);
2009 }
2010 else
2011 // modifies ret_string!
2012 get_value_by_opt_type(ret_str);
2013
2014 return m_value;
2015}
wxString GetValue() const
Definition ComboBox.cpp:140
@ f_enum_open
Definition Config.hpp:2323
@ i_enum_open
Definition Config.hpp:2321
static int nil_value()
Definition Config.hpp:1083
boost::any m_value
Definition Field.hpp:300
void get_value_by_opt_type(wxString &str, const bool check_value=true)
Definition Field.cpp:454
@ coEnum
Definition Config.hpp:214
@ coInt
Definition Config.hpp:188
@ coEnums
Definition Config.hpp:216
@ coFloatOrPercent
Definition Config.hpp:200
@ coStrings
Definition Config.hpp:194
double string_to_double_decimal_point(const std::string_view str, size_t *pos)
Definition LocalesUtils.cpp:86

References _, Slic3r::coEnum, Slic3r::coEnums, Slic3r::coFloatOrPercent, Slic3r::coInt, Slic3r::coStrings, Slic3r::ConfigOptionDef::f_enum_open, Slic3r::GUI::Field::get_value_by_opt_type(), ComboBox::GetCount(), ComboBox::GetSelection(), ComboBox::GetValue(), Slic3r::ConfigOptionDef::i_enum_open, m_list, Slic3r::GUI::Field::m_opt, Slic3r::GUI::Field::m_opt_id, Slic3r::GUI::Field::m_value, Slic3r::ConfigOptionEnumsGenericTempl< true >::nil_value(), Slic3r::string_to_double_decimal_point(), and window.

Referenced by propagate_value().

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

◆ get_value_by_opt_type()

void Slic3r::GUI::Field::get_value_by_opt_type ( wxString & str,
const bool check_value = true )
inherited
455{
456 switch (m_opt.type) {
457 case coInts:
458 case coInt: {
459 long val = 0;
460
461 bool is_na_value = m_opt.nullable && str == m_na_value;
462
463 if (is_na_value)
465 else if (!str.ToLong(&val)) {
466 if (!check_value) {
467 m_value.clear();
468 break;
469 }
470 show_error(m_parent, _(L("Invalid numeric.")));
471 set_value(int(val), true);
472 }
473
474 if (!m_opt.is_value_valid(double(val))) {
475 if (!check_value) {
476 m_value.clear();
477 break;
478 }
479
480 if (!is_na_value) {
481 // Orca: no need to check ranges for the nil value
482 show_error(m_parent, _L("Value is out of range."));
483
484 int min = static_cast<int>(m_opt.min);
485 int max = static_cast<int>(m_opt.max);
486
487 if (min > val) val = min;
488 if (val > max) val = max;
489
490 set_value(int(val), true);
491 }
492 }
493
494 m_value = int(val);
495 break;
496 }
497 case coPercent:
498 case coPercents:
499 case coFloats:
500 case coFloat:{
501 if (m_opt.type == coPercent && !str.IsEmpty() && str.Last() == '%')
502 str.RemoveLast();
503 else if (!str.IsEmpty() && str.Last() == '%')
504 {
505 if (!check_value) {
506 m_value.clear();
507 break;
508 }
509
510 wxString label = m_opt.full_label.empty() ? _(m_opt.label) : _(m_opt.full_label);
511 show_error(m_parent, from_u8((boost::format(_utf8(L("%s can\u2019t be a percentage"))) % into_u8(label)).str()));
512 set_value(double_to_string(m_opt.min), true);
513 m_value = double(m_opt.min);
514 break;
515 }
516 double val;
517
518 bool is_na_value = m_opt.nullable && str == m_na_value;
519
520 const char dec_sep = is_decimal_separator_point() ? '.' : ',';
521 const char dec_sep_alt = dec_sep == '.' ? ',' : '.';
522 // Replace the first incorrect separator in decimal number,
523 // if this value doesn't "N/A" value in some language
524 if (!is_na_value && str.Replace(dec_sep_alt, dec_sep, false) != 0)
525 set_value(str, false);
526
527 if (str == dec_sep)
528 val = 0.0;
529 else
530 {
531 if (is_na_value)
533 else if (!str.ToDouble(&val))
534 {
535 if (!check_value) {
536 m_value.clear();
537 break;
538 }
539 show_error(m_parent, _(L("Invalid numeric.")));
540 set_value(double_to_string(val), true);
541 }
542 if (!m_opt.is_value_valid(val))
543 {
544 if (!check_value) {
545 m_value.clear();
546 break;
547 }
548 std::string opt_key_without_idx = m_opt_id.substr(0, m_opt_id.find('#'));
549 if (m_opt_id == "filament_flow_ratio") {
550 if (m_value.empty() || boost::any_cast<double>(m_value) != val) {
551 wxString msg_text = format_wxstr(_L("Value %s is out of range, continue?"), str);
552// wxMessageDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxICON_WARNING | wxYES | wxNO);
553 WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES | wxNO);
554 if (dialog.ShowModal() == wxID_NO) {
555 if (m_value.empty()) {
556 if (m_opt.min > val) val = m_opt.min;
557 if (val > m_opt.max) val = m_opt.max;
558 }
559 else
560 val = boost::any_cast<double>(m_value);
561 set_value(double_to_string(val), true);
562 }
563 }
564 }
565 else if(m_opt_id == "filament_retraction_distances_when_cut" || opt_key_without_idx == "retraction_distances_when_cut"){
566 if (m_value.empty() || boost::any_cast<double>(m_value) != val) {
567 wxString msg_text = format_wxstr(_L("Value %s is out of range. The valid range is from %d to %d."), str, m_opt.min, m_opt.max);
568 WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxOK);
569 if (dialog.ShowModal()) {
570 if (m_value.empty()) {
571 if (m_opt.min > val) val = m_opt.min;
572 if (val > m_opt.max) val = m_opt.max;
573 }
574 else
575 val = boost::any_cast<double>(m_value);
576 set_value(double_to_string(val), true);
577 }
578 }
579 }
580 else if (!is_na_value) {
581 // Orca: no need to check ranges for the nil value
582 show_error(m_parent, _L("Value is out of range."));
583 if (m_opt.min > val) val = m_opt.min;
584 if (val > m_opt.max) val = m_opt.max;
585 set_value(double_to_string(val), true);
586 }
587 }
588 }
589 m_value = val;
590 break; }
591 case coString:
592 case coStrings:
593 case coFloatOrPercent:
594 case coFloatsOrPercents: {
595 if ((m_opt.type == coFloatOrPercent || m_opt.type == coFloatsOrPercents) && !str.IsEmpty() &&
596 !(m_opt.nullable && str == m_na_value)) {
597 bool update_control = false;
598 wxString numeric_str = str;
599 double val = 0.;
600
601 const char dec_sep = is_decimal_separator_point() ? '.' : ',';
602 const char dec_sep_alt = dec_sep == '.' ? ',' : '.';
603 // Orca: normalize the decimal separator and optional unit before
604 // detecting the percentage suffix and parsing the numeric part.
605 update_control |= numeric_str.Replace(dec_sep_alt, dec_sep, false) != 0;
606 update_control |= numeric_str.Replace(" ", "", true) != 0;
607 const bool has_literal_unit = numeric_str.EndsWith("mm");
608 if (has_literal_unit) {
609 numeric_str.RemoveLast(2);
610 update_control = true;
611 }
612 bool is_percent = !numeric_str.IsEmpty() && numeric_str.Last() == '%';
613 if (is_percent)
614 numeric_str.RemoveLast();
615
616 if ((has_literal_unit && is_percent) || !numeric_str.ToDouble(&val) || !std::isfinite(val)) {
617 if (!check_value) {
618 m_value.clear();
619 break;
620 }
621 show_error(m_parent, _L("Invalid numeric."));
622 numeric_str = double_to_string(std::clamp(0., double(m_opt.min), double(m_opt.max)));
623 is_percent = false;
624 update_control = true;
625 } else {
626 const bool looks_like_missing_percent = !is_percent && !has_literal_unit &&
627 ((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) ||
628 (m_opt.sidetext.rfind("mm ") != std::string::npos && val > m_opt.max_literal));
629 // Orca: validate explicit percentages and literal values before
630 // asking whether an otherwise valid literal was meant as a percentage.
631 const bool out_of_range = !m_opt.is_value_valid(val);
632 if (out_of_range) {
633 if (!check_value) {
634 m_value.clear();
635 break;
636 }
637 show_error(m_parent, _L("Value is out of range."));
638 val = std::clamp(val, double(m_opt.min), double(m_opt.max));
639 // Orca: retain the inferred percent unit when clamping a
640 // suspicious unitless value, so 2000 becomes 100%, not 100 mm.
641 is_percent |= looks_like_missing_percent;
642 numeric_str = double_to_string(val);
643 update_control = true;
644 } else {
645 const bool value_changed = m_value.empty() || into_u8(str) != boost::any_cast<std::string>(m_value);
646 if (looks_like_missing_percent && value_changed) {
647 if (!check_value) {
648 m_value.clear();
649 break;
650 }
651
652 const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm";
653 const wxString stVal = numeric_str;
654 const wxString msg_text = from_u8((boost::format(_utf8(L("Is it %s%% or %s %s?"))) %
655 stVal % stVal % sidetext).str());
656 WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES | wxNO);
657 dialog.SetButtonLabel(wxID_YES, stVal + _L("%"));
658 dialog.SetButtonLabel(wxID_NO, stVal + " " + _L(sidetext));
659 dialog.GetSizer()->SetSizeHints(&dialog);
660 dialog.Fit();
661 dialog.CenterOnParent();
662 is_percent = dialog.ShowModal() == wxID_YES;
663 update_control = true;
664 }
665 }
666
667 // Orca: also enforce the literal limit after clamping an explicit mm input.
668 if (!is_percent && m_opt.sidetext.rfind("mm ") != std::string::npos && val > m_opt.max_literal) {
669 if (!check_value) {
670 m_value.clear();
671 break;
672 }
673 if (!out_of_range)
674 show_error(m_parent, _L("Value is out of range."));
675 val = m_opt.max_literal;
676 numeric_str = double_to_string(val);
677 update_control = true;
678 }
679 }
680
681 if (update_control) {
682 str = numeric_str + (is_percent ? "%" : "");
683 set_value(str, true);
684 }
685 }
686 if (m_opt.opt_key == "thumbnails") {
687 wxString str_out = str;
689 if (errors != enum_bitmask<ThumbnailError>()) {
690 set_value(str_out, true);
691 wxString error_str;
692 if (errors.has(ThumbnailError::InvalidVal))
693 error_str += format_wxstr(_L("Invalid input format. Expected vector of dimensions in the following format: \"%1%\""),
694 "XxY/EXT, XxY/EXT, ...");
695 if (errors.has(ThumbnailError::OutOfRange)) {
696 if (!error_str.empty())
697 error_str += "\n\n";
698 error_str += _L("Input value is out of range");
699 }
700 if (errors.has(ThumbnailError::InvalidExt)) {
701 if (!error_str.empty())
702 error_str += "\n\n";
703 error_str += _L("Some extension in the input is invalid");
704 }
705 show_error(m_parent, error_str);
706 } else if (str_out != str) {
707 str = str_out;
708 set_value(str, true);
709 }
710 } else if (m_opt.opt_key == "sparse_infill_rotate_template" || m_opt.opt_key == "solid_infill_rotate_template") {
711 std::string ustr(str.utf8_string());
713 std::string v;
714 std::smatch match;
715 std::string ps = (m_opt.opt_key == "sparse_infill_rotate_template") ?
716 u8"[BT][!]?|[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[BT]?[!*]?" :
717 u8"[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[!*]?";
718
719 while (std::regex_search(ustr, match, std::regex(ps))) {
720 for (auto x : match) v += x.str() + ", ";
721 ustr = match.suffix().str();
722 }
723 v = v.substr(0, v.length() - 2);
724 try {
725 this->set_value(from_u8(v), true);
726 m_value = into_u8(v);
727 } catch (...) {
728 show_error(m_parent, format_wxstr(_L("This parameter expects a valid template.")));
729 wxString old_value(boost::any_cast<std::string>(m_value));
730 this->set_value(old_value, true); // Revert to previous value
731 }
732 } else {
733 // Valid string, so update m_value with the new string from the control.
734 m_value = into_u8(str);
735 }
736 break;
737 } else if (m_opt.opt_key == "bed_exclude_volumes" || m_opt.opt_key == "extruder_bed_exclude_volumes") {
738 const std::string definition = into_u8(str);
739 if (!is_valid_bed_exclude_volumes_string(definition, std::numeric_limits<double>::max())) {
740 show_error(m_parent, _L("Invalid collision volume format. Use XxY, XxY, ... or ZMIN..ZMAX;XxY, XxY, ... and separate multiple volumes with |."));
741 const std::string old_value = m_value.empty() ? std::string{} : boost::any_cast<std::string>(m_value);
742 set_value(from_u8(old_value), true);
743 break;
744 }
745 } else if (m_opt.opt_key == "extra_solid_infills") {
746 std::string ustr(str.utf8_string());
747 // New rule: accept either interval form (N or N#K) or explicit list (e.g. 1,7,9), with optional quotes.
748 const std::regex rx_interval(u8R"(^\s*['"]?\s*\d+\s*(?:#\s*\d*)?\s*['"]?\s*$)");
749 // List entries may be plain numbers or number with optional #K count, e.g., 5, 9#2, 18
750 const std::regex rx_list(u8R"(^\s*['"]?\s*\d+(?:\s*#\s*\d*)?(?:\s*,\s*\d+(?:\s*#\s*\d*)?)*\s*['"]?\s*$)");
751 bool is_valid = ustr.empty() || std::regex_match(ustr, rx_interval) || std::regex_match(ustr, rx_list);
752 if (!is_valid) {
753 show_error(m_parent, format_wxstr(_L("Invalid pattern. Use N, N#K, or a comma-separated list with optional #K per entry. Examples: 5, 5#2, 1,7,9, 5,9#2,18.")));
754 wxString old_value(boost::any_cast<std::string>(m_value));
755 this->set_value(old_value, true); // Revert to previous value
756 }
757 // Valid string or empty, so update m_value with the new string from the control.
758 m_value = into_u8(str);
759 break;
760 }
761
762 m_value = into_u8(str);
763 break; }
764 case coPoint:{
765 Vec2d out_value;
766 str.Replace(" ", wxEmptyString, true);
767 if (!str.IsEmpty()) {
768 bool invalid_val = true;
769 double x, y;
770 wxStringTokenizer thumbnail(str, "x");
771 if (thumbnail.HasMoreTokens()) {
772 wxString x_str = thumbnail.GetNextToken();
773 if (x_str.ToDouble(&x) && thumbnail.HasMoreTokens()) {
774 wxString y_str = thumbnail.GetNextToken();
775 if (y_str.ToDouble(&y) && !thumbnail.HasMoreTokens()) {
776 out_value = Vec2d(x, y);
777 invalid_val = false;
778 }
779 }
780 }
781
782 if (invalid_val) {
783 wxString text_value;
784 if (!m_value.empty()) text_value = get_thumbnail_string(boost::any_cast<Vec2d>(m_value));
785 set_value(text_value, true);
786 show_error(m_parent, format_wxstr(_L("Invalid format. Expected vector format: \"%1%\""), "XxY, XxY, ..."));
787 }
788 }
789
790 m_value = out_value;
791 break; }
792
793 case coPoints: {
794 std::vector<Vec2d> out_values;
795 str.Replace(" ", wxEmptyString, true);
796 const bool bed_exclusion_volume_syntax = m_opt_id == "bed_exclude_area" &&
797 (str.Find("|") != wxNOT_FOUND || (str.Find("..") != wxNOT_FOUND && str.Find(";") != wxNOT_FOUND));
798 if (bed_exclusion_volume_syntax) {
799 // Leave volume validation and the copy prompt to the printer tab.
800 m_value = into_u8(str);
801 break;
802 }
803 if (!str.IsEmpty()) {
804 bool invalid_val = false;
805 wxStringTokenizer points(str, ",");
806 while (points.HasMoreTokens()) {
807 wxString token = points.GetNextToken();
808 double x, y;
809 wxStringTokenizer thumbnail(token, "x");
810 if (thumbnail.HasMoreTokens()) {
811 wxString x_str = thumbnail.GetNextToken();
812 if (x_str.ToDouble(&x) && thumbnail.HasMoreTokens()) {
813 wxString y_str = thumbnail.GetNextToken();
814 if (y_str.ToDouble(&y) && !thumbnail.HasMoreTokens()) {
815 out_values.push_back(Vec2d(x, y));
816 continue;
817 }
818 }
819 }
820 invalid_val = true;
821 break;
822 }
823
824 if (invalid_val) {
825 wxString text_value;
826 if (!m_value.empty() && boost::any_cast<std::vector<Vec2d>>(&m_value) != nullptr)
827 text_value = get_thumbnails_string(boost::any_cast<std::vector<Vec2d>>(m_value));
828 set_value(text_value, true);
829 show_error(m_parent, format_wxstr(_L("Invalid format. Expected vector format: \"%1%\""), "XxY, XxY, ..."));
830 break;
831 }
832 }
833
834 m_value = out_values;
835 break; }
836
837 default:
838 break;
839 }
840}
#define L(s)
Definition ExtrusionEntity.cpp:25
static double nil_value()
Definition Config.hpp:899
static bool validate_string(const std::string &str)
Definition Config.hpp:959
virtual void set_value(const boost::any &value, bool change_event)=0
Sets a value for this control. subclasses should overload with a specific version Postcondition: Meth...
wxString m_na_value
Definition Field.hpp:309
wxString double_to_string(double const value, const int max_precision)
Definition Field.cpp:99
wxString format_wxstr(const char *fmt, TArgs &&... args)
Definition format.hpp:22
void show_error(wxWindow *parent, const wxString &message, bool has_code_excerpts)
Definition GUI.cpp:296
ThumbnailErrors validate_thumbnails_string(wxString &str, const wxString &def_ext="PNG")
Definition Field.cpp:145
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
wxString get_thumbnail_string(const Vec2d &value)
Definition Field.cpp:129
wxString get_thumbnails_string(const std::vector< Vec2d > &values)
Definition Field.cpp:135
enum_bitmask< ThumbnailError > ThumbnailErrors
Definition Thumbnails.hpp:22
@ OutOfRange
Definition Thumbnails.hpp:21
@ InvalidVal
Definition Thumbnails.hpp:21
@ InvalidExt
Definition Thumbnails.hpp:21
bool is_decimal_separator_point()
Definition LocalesUtils.cpp:78
bool is_valid_bed_exclude_volumes_string(const std::string &value, const double printable_height)
Definition PrintConfig.cpp:14298
@ coFloatsOrPercents
Definition Config.hpp:202
@ coString
Definition Config.hpp:192
@ coPoint
Definition Config.hpp:204
@ coPercents
Definition Config.hpp:198
@ coInts
Definition Config.hpp:190
@ coPoints
Definition Config.hpp:206
@ coFloat
Definition Config.hpp:184
@ coFloats
Definition Config.hpp:186
@ coPercent
Definition Config.hpp:196
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
bool is_valid(const FontFile &font, unsigned int index)
Definition Emboss.cpp:284
#define _utf8(s)
Definition I18N.hpp:10

References _, _L, _utf8, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coFloats, Slic3r::coFloatsOrPercents, Slic3r::coInt, Slic3r::coInts, Slic3r::coPercent, Slic3r::coPercents, Slic3r::coPoint, Slic3r::coPoints, Slic3r::coString, Slic3r::coStrings, Slic3r::GUI::double_to_string(), Slic3r::GUI::format_wxstr(), Slic3r::GUI::from_u8(), Slic3r::GUI::get_thumbnail_string(), Slic3r::GUI::get_thumbnails_string(), Slic3r::enum_bitmask< option_type, typename >::has(), Slic3r::GUI::into_u8(), Slic3r::InvalidExt, Slic3r::InvalidVal, Slic3r::is_decimal_separator_point(), Slic3r::is_valid_bed_exclude_volumes_string(), L, m_na_value, m_opt, m_opt_id, m_parent, m_value, Slic3r::ConfigOptionFloatsTempl< true >::nil_value(), Slic3r::ConfigOptionIntsTempl< true >::nil_value(), Slic3r::OutOfRange, set_value(), Slic3r::GUI::MsgDialog::SetButtonLabel(), Slic3r::GUI::show_error(), Slic3r::GUI::DPIAware< P >::ShowModal(), Slic3r::ConfigOptionFloatsTempl< false >::validate_string(), and Slic3r::GUI::validate_thumbnails_string().

Referenced by Slic3r::GUI::Choice::get_value(), Slic3r::GUI::TextCtrl::get_value(), Slic3r::GUI::TextCtrl::set_value(), and Slic3r::GUI::TextCtrl::value_was_changed().

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

◆ getSizer()

virtual wxSizer * Slic3r::GUI::Field::getSizer ( )
inlinevirtualinherited

If you don't know what you are getting back, check both methods for nullptr.

Reimplemented in Slic3r::GUI::PointCtrl, and Slic3r::GUI::SliderCtrl.

270{ return nullptr; }

Referenced by Slic3r::GUI::OG_CustomCtrl::CtrlLine::correct_items_positions(), Slic3r::GUI::is_bad_field(), Slic3r::GUI::is_sizer_field(), Slic3r::GUI::is_window_field(), Slic3r::GUI::OG_CustomCtrl::CtrlLine::render(), and Slic3r::GUI::OG_CustomCtrl::CtrlLine::update_visibility().

Here is the caller graph for this function:

◆ getWindow()

wxWindow * Slic3r::GUI::Choice::getWindow ( )
inlineoverridevirtual

Reimplemented from Slic3r::GUI::Field.

482{ return window; }

References window.

◆ has_edit_ui()

bool Slic3r::GUI::UndoValueUIManager::has_edit_ui ( ) const
inlineinherited
174{ return !m_edit_ui.tooltip.IsEmpty(); }

References m_edit_ui.

Referenced by Slic3r::GUI::Tab::decorate(), and Slic3r::GUI::OG_CustomCtrl::CtrlLine::render().

Here is the caller graph for this function:

◆ has_undo_ui()

bool Slic3r::GUI::UndoValueUIManager::has_undo_ui ( ) const
inlineinherited
160{ return m_undo_ui.undo_bitmap != nullptr; }

References m_undo_ui.

Referenced by Slic3r::GUI::OG_CustomCtrl::get_pos().

Here is the caller graph for this function:

◆ is_matched()

bool Slic3r::GUI::Field::is_matched ( const std::string & string,
const std::string & pattern )
inherited
449{
450 std::regex regex_pattern(pattern, std::regex_constants::icase); // use ::icase to make the matching case insensitive like /i in perl
451 return std::regex_match(string, regex_pattern);
452}

Referenced by Slic3r::GUI::SliderCtrl::BUILD().

Here is the caller graph for this function:

◆ label_color()

const wxColour * Slic3r::GUI::UndoValueUIManager::label_color ( ) const
inlineinherited
165{ return m_undo_ui.label_color; }

References m_undo_ui.

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

Here is the caller graph for this function:

◆ msw_rescale()

void Slic3r::GUI::Choice::msw_rescale ( )
overridevirtual

Reimplemented from Slic3r::GUI::Field.

2035{
2037
2038 auto* field = dynamic_cast<choice_ctrl*>(window)->GetTextCtrl();
2039#ifdef UNDEFINED__WXOSX__ // BBS
2040 const wxString selection = field->GetValue();// field->GetString(index);
2041
2042 /* To correct scaling (set new controll size) of a wxBitmapCombobox
2043 * we need to refill control with new bitmaps. So, in our case :
2044 * 1. clear control
2045 * 2. add content
2046 * 3. add scaled "empty" bitmap to the at least one item
2047 */
2048 field->Clear();
2049 wxSize size(wxDefaultSize);
2050 size.SetWidth((m_opt.width > 0 ? m_opt.width : def_width_wider()) * m_em_unit);
2051
2052 // Set rescaled min height to correct layout
2053 field->SetMinSize(wxSize(-1, int(1.5f*field->GetFont().GetPixelSize().y + 0.5f)));
2054 // Set rescaled size
2055 field->SetSize(size);
2056
2057 size_t idx = 0;
2058 if (! m_opt.enum_labels.empty() || ! m_opt.enum_values.empty()) {
2059 size_t counter = 0;
2060 bool labels = ! m_opt.enum_labels.empty();
2061 for (const std::string &el : labels ? m_opt.enum_labels : m_opt.enum_values) {
2062 wxString text = labels ? _(el) : from_u8(el);
2063 field->Append(text);
2064 if (text == selection)
2065 idx = counter;
2066 ++ counter;
2067 }
2068 }
2069
2070 idx == m_opt.enum_values.size() ?
2071 field->SetValue(selection) :
2072 field->SetSelection(idx);
2073#else
2074 if (!m_opt.enum_labels.empty()) {
2075 boost::filesystem::path image_path(Slic3r::resources_dir());
2076 image_path /= "images";
2077 int i = 0;
2078 auto temp = dynamic_cast<choice_ctrl *>(window);
2079 for (auto el : m_opt.enum_values) {
2080 auto icon_name = "param_" + m_opt.enum_values[i];
2081 if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) {
2082 ScalableBitmap bm(window, icon_name, 24);
2083 temp->SetItemBitmap(i, bm.bmp());
2084 }
2085 ++i;
2086 }
2087 }
2088 auto size = wxSize(def_width_wider() * m_em_unit, wxDefaultCoord);
2089 if (m_opt.height >= 0)
2090 size.SetHeight(m_opt.height * m_em_unit);
2091 else if (parent_is_custom_ctrl && opt_height > 0)
2092 size.SetHeight(lround(opt_height * m_em_unit));
2093 if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit);
2094
2096 field->SetSize(size);
2097 else
2098 field->SetMinSize(size);
2099 window->SetSize(size);
2100 window->SetMinSize(size);
2101 dynamic_cast<choice_ctrl*>(window)->Rescale();
2102#endif
2103}
virtual void msw_rescale()
Definition Field.cpp:842

References _, ScalableBitmap::bmp(), Slic3r::GUI::Field::def_width_wider(), Slic3r::GUI::from_u8(), Slic3r::GUI::Field::m_em_unit, Slic3r::GUI::Field::m_opt, Slic3r::GUI::Field::msw_rescale(), Slic3r::GUI::Field::opt_height, Slic3r::GUI::Field::parent_is_custom_ctrl, Slic3r::resources_dir(), and window.

Here is the call graph for this function:

◆ on_back_to_initial_value()

void Slic3r::GUI::Field::on_back_to_initial_value ( )
inherited

Call the attached m_back_to_initial_value method.

420{
423}
t_back_to_init m_back_to_initial_value
Function object to store callback passed in from owning object.
Definition Field.hpp:223
bool m_is_modified_value
Definition Field.hpp:231

References m_back_to_initial_value, m_is_modified_value, and m_opt_id.

◆ on_back_to_sys_value()

void Slic3r::GUI::Field::on_back_to_sys_value ( )
inherited

Call the attached m_back_to_sys_value method.

426{
427 if (m_back_to_sys_value != nullptr && m_is_nonsys_value)
429}
t_back_to_init m_back_to_sys_value
Definition Field.hpp:224
bool m_is_nonsys_value
Definition Field.hpp:232

References m_back_to_sys_value, m_is_nonsys_value, and m_opt_id.

◆ on_change_field()

void Slic3r::GUI::Field::on_change_field ( )
protectedinherited

Call the attached on_change method.

413{
414// std::cerr << "calling Field::_on_change \n";
415 if (m_on_change != nullptr && !m_disable_change_event)
417}
t_change m_on_change
Function object to store callback passed in from owning object.
Definition Field.hpp:220
bool m_disable_change_event
Definition Field.hpp:230
virtual boost::any & get_value()=0
Gets a boost::any representing this control. subclasses should overload with a specific version.

References get_value(), m_disable_change_event, m_on_change, and m_opt_id.

Referenced by Slic3r::GUI::ColourPicker::apply_user_color(), Slic3r::GUI::CheckBox::BUILD(), Slic3r::GUI::Choice::BUILD(), Slic3r::GUI::PrinterAgentChoice::BUILD(), Slic3r::GUI::SliderCtrl::BUILD(), field_changed(), Slic3r::GUI::PluginField::on_add_clicked(), Slic3r::GUI::PluginField::on_remove_clicked(), Slic3r::GUI::PluginField::on_select_clicked(), Slic3r::GUI::PluginConfigField::open_dialog(), Slic3r::GUI::PointCtrl::propagate_input_value(), Slic3r::GUI::Choice::propagate_value(), Slic3r::GUI::SpinCtrl::propagate_value(), Slic3r::GUI::TextCtrl::propagate_value(), Slic3r::GUI::CheckBox::set_last_meaningful_value(), Slic3r::GUI::Choice::set_last_meaningful_value(), Slic3r::GUI::CheckBox::set_na_value(), Slic3r::GUI::Choice::set_na_value(), and Slic3r::GUI::PluginField::set_value().

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

◆ on_edit_value()

void Slic3r::GUI::Field::on_edit_value ( )
inherited

Call the attached m_fn_edit_value method.

432{
433 if (m_fn_edit_value)
435}
t_back_to_init m_fn_edit_value
Callback function to edit field value.
Definition Field.hpp:227

References m_fn_edit_value, and m_opt_id.

◆ on_kill_focus()

void Slic3r::GUI::Field::on_kill_focus ( )
protectedinherited

Call the attached on_kill_focus method. It's important to use wxEvent instead of wxFocusEvent, in another case we can't unfocused control at all.

406{
407 // call the registered function if it is available
408 if (m_on_kill_focus!=nullptr)
410}
t_kill_focus m_on_kill_focus
Function object to store callback passed in from owning object.
Definition Field.hpp:217

References m_on_kill_focus, and m_opt_id.

Referenced by Slic3r::GUI::PointCtrl::propagate_input_value(), Slic3r::GUI::Choice::propagate_value(), Slic3r::GUI::SpinCtrl::propagate_value(), and Slic3r::GUI::TextCtrl::propagate_value().

Here is the caller graph for this function:

◆ PostInitialize()

void Slic3r::GUI::Field::PostInitialize ( )
protectedvirtualinherited
332{
333 auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
334
335 switch (m_opt.type)
336 {
337 case coPercents:
338 case coFloats:
339 case coStrings:
340 case coBools:
341 case coInts:
342 // BBS
343 case coEnums: {
344 auto tag_pos = m_opt_id.find("#");
345 if (tag_pos != std::string::npos)
346 m_opt_idx = stoi(m_opt_id.substr(tag_pos + 1, m_opt_id.size()));
347 break;
348 }
349 default:
350 break;
351 }
352
353 // initialize m_unit_value
355 parent_is_custom_ctrl = dynamic_cast<OG_CustomCtrl*>(m_parent) != nullptr;
356
357 BUILD();
358
359 // For the mode, when settings are in non-modal dialog, neither dialog nor tabpanel doesn't receive wxEVT_KEY_UP event, when some field is selected.
360 // So, like a workaround check wxEVT_KEY_UP event for the Filed and switch between tabs if Ctrl+(1-4) was pressed
361 if (getWindow()) {
362 if (m_opt.readonly) {
363 this->disable();
364 } else {
365 this->enable();
366 }
367 getWindow()->Bind(wxEVT_KEY_UP, [](wxKeyEvent& evt) {
368 if ((evt.GetModifiers() & wxMOD_CONTROL) != 0) {
369 int tab_id = -1;
370 switch (evt.GetKeyCode()) {
371 case '1': { tab_id = 0; break; }
372 case '2': { tab_id = 1; break; }
373 case '3': { tab_id = 2; break; }
374 case '4': { tab_id = 3; break; }
375#ifdef __APPLE__
376 case 'f':
377#else /* __APPLE__ */
378 case WXK_CONTROL_F:
379#endif /* __APPLE__ */
380 case 'F': {
381 //wxGetApp().plater()->search(false, Preset::TYPE_MODEL, nullptr, nullptr);
382 break;
383 }
384 default: break;
385 }
386 if (tab_id >= 0) {
387 static constexpr const char* kShortcutTabIds[] = {TAB_ID_HOME, TAB_ID_PREPARE, TAB_ID_PREVIEW, TAB_ID_MONITOR};
388 wxGetApp().mainframe->select_tab(kShortcutTabIds[tab_id]);
389 }
390 if (tab_id > 0)
391 // tab panel should be focused for correct navigation between tabs
392 wxGetApp().tab_panel()->SetFocus();
393 }
394
395 evt.Skip();
396 }, getWindow()->GetId());
397 }
398}
#define TAB_ID_PREPARE
Definition MainFrame.hpp:60
#define TAB_ID_HOME
Definition MainFrame.hpp:56
#define TAB_ID_MONITOR
Definition MainFrame.hpp:62
#define TAB_ID_PREVIEW
Definition MainFrame.hpp:61
virtual void BUILD()=0
Finish constructing the Field's wxWidget-related properties, including setting its own sizer,...
virtual wxWindow * getWindow()
Definition Field.hpp:271
virtual void disable()=0
int m_opt_idx
{""};
Definition Field.hpp:237
virtual void enable()=0
@ coBools
Definition Config.hpp:212
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424

References BUILD(), Slic3r::coBools, Slic3r::coEnums, Slic3r::coFloats, Slic3r::coInts, Slic3r::coPercents, Slic3r::coStrings, disable(), em_unit(), enable(), getWindow(), m_em_unit, m_opt, m_opt_id, m_opt_idx, m_parent, parent_is_custom_ctrl, TAB_ID_HOME, TAB_ID_MONITOR, TAB_ID_PREPARE, and TAB_ID_PREVIEW.

Here is the call graph for this function:

◆ propagate_value()

void Slic3r::GUI::Choice::propagate_value ( )
overridevirtual

Reimplemented from Slic3r::GUI::Field.

1670{
1671 if (m_opt.type == coStrings) {
1673 return;
1674 }
1675
1677 switch (m_opt.type) {
1678 case coFloatOrPercent:
1679 {
1680 std::string old_val = !m_value.empty() ? boost::any_cast<std::string>(m_value) : "";
1681 if (old_val == boost::any_cast<std::string>(get_value()))
1682 return;
1683 break;
1684 }
1685 case coInt:
1686 {
1687 int old_val = !m_value.empty() ? boost::any_cast<int>(m_value) : 0;
1688 if (old_val == boost::any_cast<int>(get_value()))
1689 return;
1690 break;
1691 }
1692 default:
1693 {
1694 double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999;
1695 if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001)
1696 return;
1697 }
1698 }
1700 }
1701 else if (!m_value.empty()) // BBS: null value
1702 on_kill_focus();
1703}
boost::any & get_value() override
Gets a boost::any representing this control. subclasses should overload with a specific version.
Definition Field.cpp:1948
void on_kill_focus()
Call the attached on_kill_focus method. It's important to use wxEvent instead of wxFocusEvent,...
Definition Field.cpp:405
bool is_defined_input_value(wxWindow *win, const ConfigOptionType &type)
Definition Field.cpp:956

References Slic3r::coFloatOrPercent, Slic3r::coInt, Slic3r::coStrings, get_value(), Slic3r::GUI::is_defined_input_value(), Slic3r::GUI::Field::m_opt, Slic3r::GUI::Field::m_value, Slic3r::GUI::Field::on_change_field(), Slic3r::GUI::Field::on_kill_focus(), and window.

Referenced by BUILD().

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

◆ register_dynamic_list()

void Slic3r::GUI::Choice::register_dynamic_list ( std::string const & optname,
DynamicList * list )
static
1534{ dynamic_lists.emplace(optname, list); }

References Slic3r::GUI::dynamic_lists.

Referenced by Slic3r::GUI::Sidebar::Sidebar().

Here is the caller graph for this function:

◆ set_edit_bitmap()

bool Slic3r::GUI::UndoValueUIManager::set_edit_bitmap ( const ScalableBitmap * bmp)
inlineinherited
156{ return m_edit_ui.set_bitmap(bmp); }

References m_edit_ui.

Referenced by Slic3r::GUI::Tab::decorate().

Here is the caller graph for this function:

◆ set_edit_tooltip()

bool Slic3r::GUI::UndoValueUIManager::set_edit_tooltip ( const wxString & tip)
inlineinherited
157{ return m_edit_ui.set_tooltip(tip); }

References m_edit_ui.

◆ set_enter_pressed()

void Slic3r::GUI::Field::set_enter_pressed ( bool pressed)
inlineinherited
289{ bEnterPressed = pressed; }

References bEnterPressed.

◆ set_label_colour()

bool Slic3r::GUI::UndoValueUIManager::set_label_colour ( const wxColour * clr)
inlineinherited
152{ return m_undo_ui.set_label_colour(clr); }

References m_undo_ui.

Referenced by Slic3r::GUI::Tab::create_line_with_widget(), Slic3r::GUI::Tab::decorate(), and Slic3r::GUI::Tab::update_label_colours().

Here is the caller graph for this function:

◆ set_last_meaningful_value()

void Slic3r::GUI::Choice::set_last_meaningful_value ( )
overridevirtual

Reimplemented from Slic3r::GUI::Field.

2018{
2019 if (m_opt.nullable) {
2022 }
2023}
void set_value(const std::string &value, bool change_event=false)
Redundant?
Definition Field.cpp:1760

References Slic3r::GUI::Field::m_last_meaningful_value, Slic3r::GUI::Field::m_opt, Slic3r::GUI::Field::on_change_field(), and set_value().

Here is the call graph for this function:

◆ set_na_value()

void Slic3r::GUI::Choice::set_na_value ( )
overridevirtual

Reimplemented from Slic3r::GUI::Field.

2026{
2027 dynamic_cast<choice_ctrl *>(window)->SetSelection(-1);
2029}

References Slic3r::GUI::Field::on_change_field(), and window.

Here is the call graph for this function:

◆ set_selection()

void Slic3r::GUI::Choice::set_selection ( )
1711{
1712 /* To prevent earlier control updating under OSX set m_disable_change_event to true
1713 * (under OSX wxBitmapComboBox send wxEVT_COMBOBOX even after SetSelection())
1714 */
1715 //m_disable_change_event = true;
1716
1717 wxString text_value = wxString("");
1718
1719 choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
1720 switch (m_opt.type) {
1721 case coEnum:{
1722 const int val = m_opt.default_value->getInt();
1723 field->SetSelection(val);
1724 break;
1725 }
1726 case coFloat:
1727 case coPercent: {
1728 double val = m_opt.default_value->getFloat();
1729 text_value = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 1);
1730 break;
1731 }
1732 case coInt:{
1733 text_value = wxString::Format(_T("%i"), int(m_opt.default_value->getInt()));
1734 break;
1735 }
1736 case coStrings:{
1737 text_value = m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx);
1738 break;
1739 }
1740 case coFloatOrPercent: {
1741 text_value = double_to_string(m_opt.default_value->getFloat());
1742 if (m_opt.get_default_value<ConfigOptionFloatOrPercent>()->percent)
1743 text_value += "%";
1744 break;
1745 }
1746 default: break;
1747 }
1748
1749 if (!text_value.IsEmpty()) {
1750 size_t idx = 0;
1751 for (auto el : m_opt.enum_values) {
1752 if (el == text_value)
1753 break;
1754 ++idx;
1755 }
1756 idx == m_opt.enum_values.size() ? field->SetValue(text_value) : field->SetSelection(idx);
1757 }
1758}

References Slic3r::coEnum, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coInt, Slic3r::coPercent, Slic3r::coStrings, Slic3r::GUI::double_to_string(), Slic3r::GUI::Field::m_opt, Slic3r::GUI::Field::m_opt_idx, Slic3r::ConfigOptionFloatOrPercent::percent, ComboBox::SetSelection(), ComboBox::SetValue(), and window.

Referenced by BUILD(), and Slic3r::GUI::PhysicalPrinterDialog::build_printhost_settings().

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

◆ set_undo_bitmap()

bool Slic3r::GUI::UndoValueUIManager::set_undo_bitmap ( const ScalableBitmap * bmp)
inlineinherited
150{ return m_undo_ui.set_undo_bitmap(bmp); }

References m_undo_ui.

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

Here is the caller graph for this function:

◆ set_undo_to_sys_bitmap()

bool Slic3r::GUI::UndoValueUIManager::set_undo_to_sys_bitmap ( const ScalableBitmap * bmp)
inlineinherited
151{ return m_undo_ui.set_undo_to_sys_bitmap(bmp); }

References m_undo_ui.

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

Here is the caller graph for this function:

◆ set_undo_to_sys_tooltip()

bool Slic3r::GUI::UndoValueUIManager::set_undo_to_sys_tooltip ( const wxString * tip)
inlineinherited
154{ return m_undo_ui.set_undo_to_sys_tooltip(tip); }

References m_undo_ui.

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

Here is the caller graph for this function:

◆ set_undo_tooltip()

bool Slic3r::GUI::UndoValueUIManager::set_undo_tooltip ( const wxString * tip)
inlineinherited
153{ return m_undo_ui.set_undo_tooltip(tip); }

References m_undo_ui.

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

Here is the caller graph for this function:

◆ set_value() [1/2]

void Slic3r::GUI::Choice::set_value ( const boost::any & value,
bool change_event = false )
overridevirtual

Sets a value for this control. subclasses should overload with a specific version Postcondition: Method does not fire the on_change event.

Implements Slic3r::GUI::Field.

1782{
1783 m_disable_change_event = !change_event;
1784
1785 choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
1786
1787 // BBS: null value
1788 if (value.empty()) {
1789 field->SetValue("");
1790 m_value = value;
1791 m_disable_change_event = false;
1792 return;
1793 }
1794
1795 switch (m_opt.type) {
1796 case coInt:
1797 case coFloat:
1798 case coPercent:
1799 case coFloatOrPercent:
1800 case coString:
1801 case coStrings: {
1802 wxString text_value;
1803 if (m_opt.type == coInt)
1804 text_value = wxString::Format(_T("%i"), int(boost::any_cast<int>(value)));
1805 else
1806 text_value = boost::any_cast<wxString>(value);
1807 size_t idx = 0;
1808 const std::vector<std::string>& enums = m_opt.enum_values.empty() ? m_opt.enum_labels : m_opt.enum_values;
1809 for (auto el : enums)
1810 {
1811 if (el == text_value)
1812 break;
1813 ++idx;
1814 }
1815 if (m_list)
1816 field->SetSelection(m_list->index_of(text_value));
1817 else if (idx == enums.size()) {
1818 // For editable Combobox under OSX is needed to set selection to -1 explicitly,
1819 // otherwise selection doesn't be changed
1820 field->SetSelection(-1);
1821 field->SetValue(text_value);
1822 }
1823 else
1824 field->SetSelection(idx);
1825
1826 if (!m_value.empty() && m_opt.opt_key == "sparse_infill_density") {
1827 // If m_value was changed before, then update m_value here too to avoid case
1828 // when control's value is already changed from the ConfigManipulation::update_print_fff_config(),
1829 // but m_value doesn't respect it.
1830 if (double val; text_value.ToDouble(&val))
1831 m_value = val;
1832 }
1833
1834 break;
1835 }
1836 case coEnum:
1837 // BBS
1838 case coEnums: {
1839 int val = boost::any_cast<int>(value);
1840
1841 int selection = val;
1842
1843 if (m_opt_id == "input_shaping_type") {
1844 if (field != nullptr) {
1845 const unsigned int count = field->GetCount();
1846 int match_index = -1;
1847 for (unsigned int idx = 0; idx < count; ++idx) {
1848 if (void* data = field->GetClientData(idx)) {
1849 int stored = static_cast<int>(reinterpret_cast<uintptr_t>(data));
1850 if (stored == val) {
1851 match_index = static_cast<int>(idx);
1852 break;
1853 }
1854 }
1855 }
1856 if (match_index >= 0)
1857 selection = match_index;
1858 else if (val >= 0 && val < static_cast<int>(count))
1859 selection = val;
1860 else if (count > 0)
1861 selection = 0;
1862 else
1863 selection = -1;
1864 }
1865 } else {
1866 // Support ThirdPartyPrinter
1867 if (m_opt_id.compare("host_type") == 0 && val != 0 &&
1868 m_opt.enum_values.size() > field->GetCount()) // for case, when PrusaLink isn't used as a HostType
1869 selection = val - 1;
1870 else
1871 selection = val;
1872
1873 if (m_opt_id == "top_surface_pattern" || m_opt_id == "bottom_surface_pattern" ||
1874 m_opt_id == "internal_solid_infill_pattern" || m_opt_id == "sparse_infill_pattern" ||
1875 m_opt_id == "support_base_pattern" || m_opt_id == "support_interface_pattern" ||
1876 m_opt_id == "ironing_pattern" || m_opt_id == "support_ironing_pattern" ||
1877 m_opt_id == "support_style" || m_opt_id == "curr_bed_type" || m_opt_id == "wipe_tower_wall_type")
1878 {
1879 std::string key;
1880 const t_config_enum_values& map_names = *m_opt.enum_keys_map;
1881 for (auto it : map_names)
1882 if (val == it.second) {
1883 key = it.first;
1884 break;
1885 }
1886
1887 const std::vector<std::string>& values = m_opt.enum_values;
1888 auto it = std::find(values.begin(), values.end(), key);
1889 selection = it == values.end() ? 0 : static_cast<int>(it - values.begin());
1890 }
1891 }
1892 if (m_opt.nullable) {
1895 else
1896 selection = -1;
1897 }
1898 field->SetSelection(selection);
1899 break;
1900 }
1901 default:
1902 break;
1903 }
1904
1905 m_disable_change_event = false;
1906}
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246
std::map< std::string, int > t_config_enum_values
Definition Config.hpp:2072

References Slic3r::coEnum, Slic3r::coEnums, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coInt, Slic3r::coPercent, Slic3r::coString, Slic3r::coStrings, count, ComboBox::GetCount(), Slic3r::GUI::Field::m_disable_change_event, Slic3r::GUI::Field::m_last_meaningful_value, m_list, Slic3r::GUI::Field::m_opt, Slic3r::GUI::Field::m_opt_id, Slic3r::GUI::Field::m_value, Slic3r::ConfigOptionEnumsGenericTempl< true >::nil_value(), ComboBox::SetSelection(), ComboBox::SetValue(), and window.

Here is the call graph for this function:

◆ set_value() [2/2]

void Slic3r::GUI::Choice::set_value ( const std::string & value,
bool change_event = false )

Redundant?

1761{
1762 m_disable_change_event = !change_event;
1763
1764 size_t idx=0;
1765 for (auto el : m_opt.enum_values)
1766 {
1767 if (el == value)
1768 break;
1769 ++idx;
1770 }
1771
1772 choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
1773 if (idx == m_opt.enum_values.size())
1774 field->SetValue(value);
1775 else
1776 field->SetSelection(idx);
1777
1778 m_disable_change_event = false;
1779}
void SetValue(const wxString &value)
Definition ComboBox.cpp:145

References Slic3r::GUI::Field::m_disable_change_event, Slic3r::GUI::Field::m_opt, ComboBox::SetSelection(), ComboBox::SetValue(), and window.

Referenced by set_last_meaningful_value(), and Slic3r::GUI::PhysicalPrinterDialog::update_host_type().

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

◆ set_values() [1/2]

void Slic3r::GUI::Choice::set_values ( const std::vector< std::string > & values)

it's needed for _update_serial_ports()

1910{
1911 if (values.empty())
1912 return;
1914
1915// # it looks that Clear() also clears the text field in recent wxWidgets versions,
1916// # but we want to preserve it
1917 auto ww = dynamic_cast<choice_ctrl*>(window);
1918 auto value = ww->GetValue();
1919 ww->Clear();
1920 ww->Append("");
1921 for (const auto &el : values)
1922 ww->Append(wxString(el));
1923 ww->SetValue(value);
1924
1925 m_disable_change_event = false;
1926}

References Slic3r::GUI::Field::m_disable_change_event, and window.

Referenced by Slic3r::GUI::PhysicalPrinterDialog::build_printhost_settings(), Slic3r::GUI::PhysicalPrinterDialog::update_host_type(), and Slic3r::GUI::PhysicalPrinterDialog::update_printers().

Here is the caller graph for this function:

◆ set_values() [2/2]

void Slic3r::GUI::Choice::set_values ( const wxArrayString & values)
1929{
1930 if (values.empty())
1931 return;
1932
1934
1935 // # it looks that Clear() also clears the text field in recent wxWidgets versions,
1936 // # but we want to preserve it
1937 auto ww = dynamic_cast<choice_ctrl*>(window);
1938 auto value = ww->GetValue();
1939 ww->Clear();
1940// ww->Append("");
1941 for (const auto &el : values)
1942 ww->Append(el);
1943 ww->SetValue(value);
1944
1945 m_disable_change_event = false;
1946}

References Slic3r::GUI::Field::m_disable_change_event, and window.

◆ suppress_scroll()

void Slic3r::GUI::Choice::suppress_scroll ( )
1706{
1707 m_suppress_scroll = true;
1708}

References m_suppress_scroll.

◆ sys_color_changed()

void Slic3r::GUI::Field::sys_color_changed ( )
virtualinherited

Reimplemented in Slic3r::GUI::ColourPicker, and Slic3r::GUI::PointCtrl.

849{
850#ifdef _WIN32
851 if (wxWindow* win = this->getWindow())
852 wxGetApp().UpdateDarkUI(win);
853#endif
854}

References getWindow().

Here is the call graph for this function:

◆ toggle()

void Slic3r::GUI::Field::toggle ( bool en)
inherited

Fires the enable or disable function, based on the input.

439{ en && !m_opt.readonly ? enable() : disable(); }

References disable(), enable(), and m_opt.

Referenced by Slic3r::GUI::Tab::compatible_widget_reload(), Slic3r::GUI::Tab::toggle_option(), Slic3r::GUI::ObjectSettings::update_config_values(), Slic3r::GUI::ObjectTableSettings::update_config_values(), Slic3r::GUI::TabFilament::update_filament_overrides_page(), and Slic3r::GUI::ObjectTableSettings::update_settings_list().

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

◆ undo_bitmap()

const ScalableBitmap * Slic3r::GUI::UndoValueUIManager::undo_bitmap ( ) const
inlineinherited
161{ return m_undo_ui.undo_bitmap; }

References m_undo_ui.

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

Here is the caller graph for this function:

◆ undo_to_sys_bitmap()

const ScalableBitmap * Slic3r::GUI::UndoValueUIManager::undo_to_sys_bitmap ( ) const
inlineinherited
163{ return m_undo_ui.undo_to_sys_bitmap; }

References m_undo_ui.

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

Here is the caller graph for this function:

◆ undo_to_sys_tooltip()

const wxString * Slic3r::GUI::UndoValueUIManager::undo_to_sys_tooltip ( ) const
inlineinherited
164{ return m_undo_ui.undo_to_sys_tooltip; }

References m_undo_ui.

◆ undo_tooltip()

const wxString * Slic3r::GUI::UndoValueUIManager::undo_tooltip ( ) const
inlineinherited
162{ return m_undo_ui.undo_tooltip; }

References m_undo_ui.

◆ update_na_value()

virtual void Slic3r::GUI::Field::update_na_value ( const boost::any & value)
inlinevirtualinherited

Reimplemented in Slic3r::GUI::TextCtrl.

249{}

Referenced by Slic3r::GUI::TabFilament::update_filament_overrides_page().

Here is the caller graph for this function:

Member Data Documentation

◆ bEnterPressed

bool Slic3r::GUI::Field::bEnterPressed = false
protectedinherited

◆ m_back_to_initial_value

t_back_to_init Slic3r::GUI::Field::m_back_to_initial_value { nullptr }
inherited

Function object to store callback passed in from owning object.

223{ nullptr };

Referenced by ~Field(), and on_back_to_initial_value().

◆ m_back_to_sys_value

t_back_to_init Slic3r::GUI::Field::m_back_to_sys_value { nullptr }
inherited
224{ nullptr };

Referenced by ~Field(), and on_back_to_sys_value().

◆ m_combine_side_text

◆ m_disable_change_event

◆ m_edit_ui

EditValueUI Slic3r::GUI::UndoValueUIManager::m_edit_ui
privateinherited

◆ m_em_unit

◆ m_fn_edit_value

t_back_to_init Slic3r::GUI::Field::m_fn_edit_value { nullptr }
inherited

Callback function to edit field value.

227{ nullptr };

Referenced by on_edit_value().

◆ m_is_dropped

bool Slic3r::GUI::Choice::m_is_dropped { false }
464{ false };

Referenced by BUILD().

◆ m_is_editable

bool Slic3r::GUI::Choice::m_is_editable { false }
463{ false };

Referenced by BUILD().

◆ m_is_modified_value

bool Slic3r::GUI::Field::m_is_modified_value {false}
inherited

◆ m_is_nonsys_value

bool Slic3r::GUI::Field::m_is_nonsys_value {true}
inherited
232{true};

Referenced by Slic3r::GUI::Tab::decorate(), and on_back_to_sys_value().

◆ m_last_meaningful_value

◆ m_last_selected

int Slic3r::GUI::Choice::m_last_selected { wxNOT_FOUND }
466{ wxNOT_FOUND };

◆ m_list

DynamicList* Slic3r::GUI::Choice::m_list = nullptr
private

Referenced by ~Choice(), BUILD(), get_value(), and set_value().

◆ m_na_value

wxString Slic3r::GUI::Field::m_na_value = _(L("N/A"))
protectedinherited

◆ m_on_change

t_change Slic3r::GUI::Field::m_on_change {nullptr}
inherited

Function object to store callback passed in from owning object.

220{nullptr};

Referenced by ~Field(), and on_change_field().

◆ m_on_kill_focus

t_kill_focus Slic3r::GUI::Field::m_on_kill_focus {nullptr}
inherited

Function object to store callback passed in from owning object.

217{nullptr};

Referenced by ~Field(), and on_kill_focus().

◆ m_opt

const ConfigOptionDef Slic3r::GUI::Field::m_opt {ConfigOptionDef()}
inherited

Copy of ConfigOption for deduction purposes.

235{ConfigOptionDef()};

Referenced by Field(), Field(), Slic3r::GUI::PluginField::add_plugin_row(), Slic3r::GUI::CheckBox::BUILD(), Slic3r::GUI::Choice::BUILD(), Slic3r::GUI::ColourPicker::BUILD(), Slic3r::GUI::PluginConfigField::BUILD(), Slic3r::GUI::PluginField::BUILD(), Slic3r::GUI::PointCtrl::BUILD(), Slic3r::GUI::PrinterAgentChoice::BUILD(), Slic3r::GUI::SliderCtrl::BUILD(), Slic3r::GUI::SpinCtrl::BUILD(), Slic3r::GUI::StaticText::BUILD(), Slic3r::GUI::TextCtrl::BUILD(), get_tooltip_text(), Slic3r::GUI::CheckBox::get_value(), Slic3r::GUI::Choice::get_value(), Slic3r::GUI::PointCtrl::get_value(), get_value_by_opt_type(), Slic3r::GUI::Choice::msw_rescale(), Slic3r::GUI::ColourPicker::msw_rescale(), Slic3r::GUI::PluginConfigField::msw_rescale(), Slic3r::GUI::PointCtrl::msw_rescale(), Slic3r::GUI::PrinterAgentChoice::msw_rescale(), Slic3r::GUI::StaticText::msw_rescale(), Slic3r::GUI::TextCtrl::msw_rescale(), Slic3r::GUI::PluginField::on_add_clicked(), Slic3r::GUI::PluginField::on_remove_clicked(), PostInitialize(), Slic3r::GUI::Choice::propagate_value(), Slic3r::GUI::TextCtrl::propagate_value(), Slic3r::GUI::CheckBox::set_last_meaningful_value(), Slic3r::GUI::Choice::set_last_meaningful_value(), Slic3r::GUI::CheckBox::set_na_value(), Slic3r::GUI::Choice::set_selection(), Slic3r::GUI::CheckBox::set_value(), Slic3r::GUI::Choice::set_value(), Slic3r::GUI::Choice::set_value(), Slic3r::GUI::PointCtrl::set_value(), Slic3r::GUI::TextCtrl::set_value(), toggle(), Slic3r::GUI::TabPrint::toggle_options(), Slic3r::GUI::PhysicalPrinterDialog::update_host_type(), and Slic3r::GUI::TextCtrl::value_was_changed().

◆ m_opt_id

◆ m_opt_idx

◆ m_parent

◆ m_suppress_scroll

bool Slic3r::GUI::Choice::m_suppress_scroll { false }
465{ false };

Referenced by BUILD(), and suppress_scroll().

◆ m_undo_ui

◆ m_value

◆ opt_height

◆ parent_is_custom_ctrl

◆ window


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Field.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Field.cpp