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

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

Inheritance diagram for Slic3r::GUI::PresetComboBox:
Collaboration diagram for Slic3r::GUI::PresetComboBox:

Public Types

enum  LabelItemType : std::size_t {
  LABEL_ITEM_PHYSICAL_PRINTER = 0xffffff01 , LABEL_ITEM_PRINTER_MODELS , LABEL_ITEM_DISABLED , LABEL_ITEM_MARKER ,
  LABEL_ITEM_PHYSICAL_PRINTERS , LABEL_ITEM_WIZARD_PRINTERS , LABEL_ITEM_WIZARD_FILAMENTS , LABEL_ITEM_WIZARD_MATERIALS ,
  LABEL_ITEM_WIZARD_ADD_PRINTERS , LABEL_ITEM_MAX
}
enum  FilamentAMSType : unsigned int { ORIGINAL , FROM_AMS }

Public Member Functions

 PresetComboBox (wxWindow *parent, Preset::Type preset_type, const wxSize &size=wxDefaultSize, PresetBundle *preset_bundle=nullptr)
 ~PresetComboBox ()
void set_label_marker (int item, LabelItemType label_item_type=LABEL_ITEM_MARKER)
bool set_printer_technology (PrinterTechnology pt)
void set_selection_changed_function (std::function< void(int)> sel_changed)
bool is_selected_physical_printer ()
bool is_selected_printer_model ()
bool selection_is_changed_according_to_physical_printers ()
void update (std::string select_preset)
void update_from_bundle ()
void add_connected_printers (std::string selected, bool alias_name=false)
int selected_connected_printer () const
bool add_ams_filaments (std::string selected, bool alias_name=false)
int selected_ams_filament () const
void set_filament_idx (const int extr_idx)
int get_filament_idx () const
std::string get_selected_dev_id () const
void clear_selected_dev_id ()
wxString get_tooltip (const Preset &preset)
wxString get_preset_item_name (unsigned int index)
virtual wxString get_preset_name (const Preset &preset)
Preset::Type get_type ()
void show_all (bool show_all)
virtual void update ()
virtual void msw_rescale ()
virtual void sys_color_changed ()
virtual void OnSelect (wxCommandEvent &evt)
DropDown & GetDropDown ()
void SetKeepDropArrow (bool keep)
virtual bool SetFont (wxFont const &font) override
int Append (const wxString &item, const wxBitmap &bitmap=wxNullBitmap, int item_style=0)
int Append (const wxString &item, const wxBitmap &bitmap, void *clientData, int item_style=0)
int Append (const wxString &item, const wxBitmap &bitmap, const wxString &group, void *clientData=nullptr, int item_style=0)
int Append (const wxString &item, const wxBitmap &bitmap, const wxString &group_key, const wxString &group_label, void *clientData=nullptr, int item_style=0)
int SetItems (const std::vector< DropDown::Item > &the_items)
void set_replace_text (wxString text, wxString image_name)
unsigned int GetCount () const override
int GetSelection () const override
void SetSelection (int n) override
void SelectAndNotify (int n)
virtual void Rescale () override
wxString GetValue () const
void SetValue (const wxString &value)
void SetLabel (const wxString &label) override
wxString GetLabel () const override
int GetFlag (unsigned int n)
void SetFlag (unsigned int n, int value)
void SetTextLabel (const wxString &label)
wxString GetTextLabel () const
wxString GetString (unsigned int n) const override
void SetString (unsigned int n, wxString const &value) override
wxString GetItemTooltip (unsigned int n) const
void SetItemTooltip (unsigned int n, wxString const &value)
wxString GetItemAlias (unsigned int n) const
void SetItemAlias (unsigned int n, wxString const &value)
wxBitmap GetItemBitmap (unsigned int n)
void SetItemBitmap (unsigned int n, wxBitmap const &bitmap)
void SetItemActionBitmap (unsigned int n, wxBitmap const &bitmap)
bool is_drop_down ()
void DeleteOneItem (unsigned int pos)
void ForceDropdownOpen ()
void CloseDropdown ()

Static Public Member Functions

static wxColor different_color (wxColor const &color)

Protected Types

typedef std::size_t Marker

Protected Member Functions

void invalidate_selection ()
void validate_selection (bool predicate=false)
void update_selection ()
int update_ams_color ()
wxBitmap * get_bmp (std::string bitmap_key, bool wide_icons, const std::string &main_icon_name, bool is_compatible=true, bool is_system=false, bool is_single_bar=false, const std::string &filament_rgb="", const std::string &extruder_rgb="", const std::string &material_rgb="")
wxBitmap * get_bmp (std::string bitmap_key, const std::string &main_icon_name, const std::string &next_icon_name, bool is_enabled=true, bool is_compatible=true, bool is_system=false)
wxBitmap * get_bmp (Preset const &preset)
virtual int DoInsertItems (const wxArrayStringsAdapter &items, unsigned int pos, void **clientData, wxClientDataType type) override
virtual void DoClear () override
void DoDeleteOneItem (unsigned int pos) override
void * DoGetItemClientData (unsigned int n) const override
void DoSetItemClientData (unsigned int n, void *data) override
void OnEdit () override
void sendComboBoxEvent ()

Static Protected Member Functions

static BitmapCache & bitmap_cache ()
static const char * separator_head ()
static const char * separator_tail ()
static wxString separator (const std::string &label)

Protected Attributes

std::function< void(int)> on_selection_changed { nullptr }
Preset::Type m_type
std::string m_main_bitmap_name
PresetBundle * m_preset_bundle {nullptr}
PresetCollection * m_collection {nullptr}
ScalableBitmap m_bitmapCompatible
ScalableBitmap m_bitmapIncompatible
int m_last_selected
int m_em_unit
int m_filament_idx = -1
int m_first_ams_filament = 0
int m_last_ams_filament = 0
int icon_height
int norm_icon_width
int thin_icon_width
int wide_icon_width
int space_icon_width
int thin_space_icon_width
int wide_space_icon_width
int m_first_printer_idx = 0
int m_last_printer_idx = 0
std::string m_selected_dev_id
PrinterTechnology printer_technology {ptAny}

Private Types

typedef DropDown::Item Item

Private Member Functions

void fill_width_height ()
void mouseDown (wxMouseEvent &event)
void mouseWheelMoved (wxMouseEvent &event)
void keyDown (wxKeyEvent &event)
void onMove (wxMoveEvent &event)

Private Attributes

bool m_show_all { false }
std::vector< Item > items
DropDown drop
bool drop_down = false
bool text_off = false
bool is_replace_text_to_image = false
bool m_keep_drop_arrow = false
wxString replace_text
wxString image_for_text

Detailed Description

Member Typedef Documentation

◆ Item

typedef DropDown::Item ComboBox::Item
privateinherited

◆ Marker

typedef std::size_t Slic3r::GUI::PresetComboBox::Marker
protected

Member Enumeration Documentation

◆ FilamentAMSType

Enumerator
ORIGINAL 
FROM_AMS 
65 :unsigned int {
66 ORIGINAL ,
68 };
@ ORIGINAL
Definition PresetComboBoxes.hpp:66
@ FROM_AMS
Definition PresetComboBoxes.hpp:67

◆ LabelItemType

Enumerator
LABEL_ITEM_PHYSICAL_PRINTER 
LABEL_ITEM_PRINTER_MODELS 
LABEL_ITEM_DISABLED 
LABEL_ITEM_MARKER 
LABEL_ITEM_PHYSICAL_PRINTERS 
LABEL_ITEM_WIZARD_PRINTERS 
LABEL_ITEM_WIZARD_FILAMENTS 
LABEL_ITEM_WIZARD_MATERIALS 
LABEL_ITEM_WIZARD_ADD_PRINTERS 
LABEL_ITEM_MAX 
51 : std::size_t {
52 LABEL_ITEM_PHYSICAL_PRINTER = 0xffffff01,
61
63 };
@ LABEL_ITEM_WIZARD_PRINTERS
Definition PresetComboBoxes.hpp:57
@ LABEL_ITEM_PHYSICAL_PRINTER
Definition PresetComboBoxes.hpp:52
@ LABEL_ITEM_WIZARD_ADD_PRINTERS
Definition PresetComboBoxes.hpp:60
@ LABEL_ITEM_MAX
Definition PresetComboBoxes.hpp:62
@ LABEL_ITEM_PHYSICAL_PRINTERS
Definition PresetComboBoxes.hpp:56
@ LABEL_ITEM_WIZARD_FILAMENTS
Definition PresetComboBoxes.hpp:58
@ LABEL_ITEM_WIZARD_MATERIALS
Definition PresetComboBoxes.hpp:59
@ LABEL_ITEM_PRINTER_MODELS
Definition PresetComboBoxes.hpp:53
@ LABEL_ITEM_DISABLED
Definition PresetComboBoxes.hpp:54
@ LABEL_ITEM_MARKER
Definition PresetComboBoxes.hpp:55

Constructor & Destructor Documentation

◆ PresetComboBox()

Slic3r::GUI::PresetComboBox::PresetComboBox ( wxWindow * parent,
Preset::Type preset_type,
const wxSize & size = wxDefaultSize,
PresetBundle * preset_bundle = nullptr )
123 :
124 ::ComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, size, 0, nullptr, wxCB_READONLY),
125 m_type(preset_type),
126 m_last_selected(wxNOT_FOUND),
127 m_em_unit(em_unit(this)),
128 m_preset_bundle(preset_bundle ? preset_bundle : wxGetApp().preset_bundle)
129{
130#ifdef __WXMSW__
131 if (preset_type == Preset::TYPE_FILAMENT)
133#endif // __WXMSW__
134
135 switch (m_type)
136 {
137 case Preset::TYPE_PRINT: {
138 m_collection = &m_preset_bundle->prints;
139 m_main_bitmap_name = "cog";
140 break;
141 }
143 m_collection = &m_preset_bundle->filaments;
144 m_main_bitmap_name = "spool";
145 break;
146 }
148 m_collection = &m_preset_bundle->sla_prints;
149 m_main_bitmap_name = "cog";
150 break;
151 }
153 m_collection = &m_preset_bundle->sla_materials;
154 m_main_bitmap_name = "blank_16";
155 break;
156 }
158 m_collection = &m_preset_bundle->printers;
159 m_main_bitmap_name = "printer";
160 break;
161 }
162 default: break;
163 }
164
165 m_bitmapCompatible = ScalableBitmap(this, "flag_green");
166 m_bitmapIncompatible = ScalableBitmap(this, "flag_red");
167
168 // parameters for an icon's drawing
170 Bind(wxEVT_COMBOBOX, &PresetComboBox::OnSelect, this);
171}
ComboBox(wxWindow *parent, wxWindowID id, const wxString &value=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL, long style=0)
Definition ComboBox.cpp:47
virtual bool SetFont(wxFont const &font) override
Definition ComboBox.cpp:219
static wxFont Body_13
Definition Label.hpp:54
PresetBundle * m_preset_bundle
Definition PresetComboBoxes.hpp:123
ScalableBitmap m_bitmapIncompatible
Definition PresetComboBoxes.hpp:132
ScalableBitmap m_bitmapCompatible
Definition PresetComboBoxes.hpp:130
virtual void OnSelect(wxCommandEvent &evt)
Definition PresetComboBoxes.cpp:173
Preset::Type m_type
Definition PresetComboBoxes.hpp:120
int m_em_unit
Definition PresetComboBoxes.hpp:135
std::string m_main_bitmap_name
Definition PresetComboBoxes.hpp:121
void fill_width_height()
Definition PresetComboBoxes.cpp:671
int m_last_selected
Definition PresetComboBoxes.hpp:134
PresetCollection * m_collection
Definition PresetComboBoxes.hpp:124
@ TYPE_SLA_PRINT
Definition Preset.hpp:247
@ TYPE_PRINTER
Definition Preset.hpp:250
@ TYPE_PRINT
Definition Preset.hpp:246
@ TYPE_SLA_MATERIAL
Definition Preset.hpp:249
@ TYPE_FILAMENT
Definition Preset.hpp:248
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424

References ComboBox::ComboBox(), Label::Body_13, em_unit(), fill_width_height(), m_bitmapCompatible, m_bitmapIncompatible, m_collection, m_em_unit, m_last_selected, m_main_bitmap_name, m_preset_bundle, m_type, OnSelect(), ComboBox::SetFont(), Slic3r::Preset::TYPE_FILAMENT, Slic3r::Preset::TYPE_PRINT, Slic3r::Preset::TYPE_PRINTER, Slic3r::Preset::TYPE_SLA_MATERIAL, and Slic3r::Preset::TYPE_SLA_PRINT.

Referenced by Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox(), and Slic3r::GUI::TabPresetComboBox::TabPresetComboBox().

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

◆ ~PresetComboBox()

Slic3r::GUI::PresetComboBox::~PresetComboBox ( )
192{
193}

Member Function Documentation

◆ add_ams_filaments()

bool Slic3r::GUI::PresetComboBox::add_ams_filaments ( std::string selected,
bool alias_name = false )
556{
557 bool selected_in_ams = false;
558 bool is_bbl_vendor_preset = m_preset_bundle->is_bbl_vendor();
559 if (is_bbl_vendor_preset && !m_preset_bundle->filament_ams_list.empty()) {
560 // When a filament track switch is installed and calibrated, every AMS filament is reachable
561 // from both extruders, so present one deduplicated group instead of the Left/Right split.
562 bool fila_switch_ready = wxGetApp().sidebar().is_fila_switch_ready();
563 bool dual_extruder = (m_preset_bundle->filament_ams_list.begin()->first & 0x10000) == 0;
564 if (fila_switch_ready)
565 set_label_marker(Append(_L("AMS filaments"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
566 else
567 set_label_marker(Append(dual_extruder ? _L("Left filaments") : _L("AMS filament"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
569 auto &filaments = m_collection->get_presets();
570
571 int icon_width = 24;
572 for (auto &entry : m_preset_bundle->filament_ams_list) {
573 auto & tray = entry.second;
574 auto name = tray.opt_string("tray_name", 0u);
575 if (name.size() > 3)
576 icon_width = 32;
577 }
578
579 // Deduplicate by (tray_name, filament_id) so a filament shared by both extruders is
580 // listed once when the switch is ready. Uses Orca's tray naming/lookup, not BBS's.
581 std::set<std::pair<std::string, std::string>> added_filaments;
582
583 for (auto &entry : m_preset_bundle->filament_ams_list) {
584 if (!fila_switch_ready && dual_extruder && (entry.first & 0x10000)) {
585 dual_extruder = false;
586 set_label_marker(Append(_L("Right filaments"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
587 }
588 auto & tray = entry.second;
589 std::string filament_id = tray.opt_string("filament_id", 0u);
590 auto name = tray.opt_string("tray_name", 0u);
591 if (filament_id.empty()) {
592 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1% 's filament_id is empty.") % name;
593 continue;
594 }
595 if (fila_switch_ready) {
596 // skip the external spool and collapse duplicates shared across both extruders
597 if (name == "Ext")
598 continue;
599 if (!added_filaments.insert(std::make_pair(name, filament_id)).second)
600 continue;
601 }
602 auto iter = std::find_if(filaments.begin(), filaments.end(),
603 [&filament_id, this](auto &f) { return f.is_compatible && m_collection->get_preset_base(f) == &f && f.filament_id == filament_id; });
604 if (iter == filaments.end()) {
605 auto filament_type = tray.opt_string("filament_type", 0u);
606 if (!filament_type.empty()) {
607 filament_type = "Generic " + filament_type;
608 iter = std::find_if(filaments.begin(), filaments.end(),
609 [&filament_type](auto &f) { return f.is_compatible && f.is_system && boost::algorithm::starts_with(f.name, filament_type); });
610 }
611 }
612 if (iter == filaments.end()) {
613 BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id;
614 continue;
615 }
616 const_cast<Preset&>(*iter).is_visible = true;
617 auto color = tray.opt_string("filament_colour", 0u);
618 auto multi_color = tray.opt<ConfigOptionStrings>("filament_multi_colour")->values;
619 wxBitmap bmp(*get_extruder_color_icon(color, name, icon_width, 16));
620 auto text = get_preset_name(*iter);
621 int item_id = Append(text, bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
623 if (text == selected) {
624 DynamicPrintConfig *cfg = &wxGetApp().preset_bundle->project_config;
625 if (cfg) {
626 auto colors = static_cast<ConfigOptionStrings *>(cfg->option("filament_colour")->clone());
627 if (m_filament_idx < colors->values.size()) {
628 auto cur_color = colors->values[m_filament_idx];
629 if (color == cur_color) {
630 selected_in_ams = true;
631 }
632 }
633 }
634 }
635 //validate_selection(id->value == selected); // can not select
636 }
638 }
639 return selected_in_ams;
640}
#define DD_ITEM_STYLE_SPLIT_ITEM
Definition DropDown.hpp:26
#define _L(s)
Definition OBJ.cpp:34
void SetFlag(unsigned int n, int value)
Definition ComboBox.cpp:203
int Append(const wxString &item, const wxBitmap &bitmap=wxNullBitmap, int item_style=0)
Definition ComboBox.cpp:227
unsigned int GetCount() const override
Definition ComboBox.cpp:311
void set_label_marker(int item, LabelItemType label_item_type=LABEL_ITEM_MARKER)
Definition PresetComboBoxes.cpp:201
int m_filament_idx
Definition PresetComboBoxes.hpp:138
virtual wxString get_preset_name(const Preset &preset)
Definition PresetComboBoxes.cpp:431
int m_first_ams_filament
Definition PresetComboBoxes.hpp:139
int m_last_ams_filament
Definition PresetComboBoxes.hpp:140
CGALMeshPtr clone(const CGALMesh &m)
Definition MeshBoolean.cpp:658
zaa_minimize_perimeter_height filament_type((ConfigOptionBools, filament_soluble))((ConfigOptionStrings
@ Preset
Definition calib.hpp:39
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124
wxBitmap * get_extruder_color_icon(std::vector< std::string > colors, bool is_gradient, std::string label, int icon_width, int icon_height, const std::vector< wxColour > *ramp)
Definition wxExtensions.cpp:633

References _L, ComboBox::Append(), DD_ITEM_STYLE_SPLIT_ITEM, Slic3r::f(), Slic3r::filament_type(), FROM_AMS, get_extruder_color_icon(), get_preset_name(), ComboBox::GetCount(), Slic3r::Preset::is_visible, m_collection, m_filament_idx, m_first_ams_filament, m_last_ams_filament, m_preset_bundle, Slic3r::ConfigBase::option(), set_label_marker(), and ComboBox::SetFlag().

Referenced by Slic3r::GUI::PlaterPresetComboBox::update(), and Slic3r::GUI::TabPresetComboBox::update().

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

◆ add_connected_printers()

void Slic3r::GUI::PresetComboBox::add_connected_printers ( std::string selected,
bool alias_name = false )
521{
522 DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
523 if (!dev)
524 return;
525
526 std::map<std::string, MachineObject *> machine_list =
527 dev->get_my_machine_list(dev->get_current_printer_agent_id());
528 if (machine_list.empty())
529 return;
530
531 set_label_marker(Append(_L("My Printer"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
533 for (auto iter = machine_list.begin(); iter != machine_list.end(); ++iter) {
534 Preset* printer_preset = get_printer_preset(iter->second);
535 if (!printer_preset)
536 continue;
537 printer_preset->is_visible = true;
538 auto printer_model = printer_preset->config.opt_string("printer_model");
539 boost::replace_all(printer_model, "Bambu Lab ", "");
540 auto text = iter->second->get_dev_name() + " (" + printer_model + ")";
541 int item_id = Append(from_u8(text), wxNullBitmap, &m_first_printer_idx + std::distance(machine_list.begin(), iter));
543 }
545}
int m_last_printer_idx
Definition PresetComboBoxes.hpp:153
void validate_selection(bool predicate=false)
Definition PresetComboBoxes.cpp:220
int m_first_printer_idx
Definition PresetComboBoxes.hpp:152
std::string m_selected_dev_id
Definition PresetComboBoxes.hpp:155
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
Preset * get_printer_preset(const MachineObject *obj)
Definition Plater.cpp:19913

References _L, ComboBox::Append(), Slic3r::Preset::config, DD_ITEM_STYLE_SPLIT_ITEM, Slic3r::GUI::from_u8(), Slic3r::DeviceManager::get_current_printer_agent_id(), Slic3r::DeviceManager::get_my_machine_list(), Slic3r::GUI::get_printer_preset(), ComboBox::GetCount(), Slic3r::Preset::is_visible, m_first_printer_idx, m_last_printer_idx, m_selected_dev_id, Slic3r::DynamicConfig::opt_string(), set_label_marker(), and validate_selection().

Here is the call graph for this function:

◆ Append() [1/4]

int ComboBox::Append ( const wxString & item,
const wxBitmap & bitmap,
const wxString & group,
void * clientData = nullptr,
int item_style = 0 )
inherited
247{
248 return Append(text, bitmap, group, group, clientData, style);
249}
#define style
Definition WipeTowerDialog.cpp:101

References Append(), and style.

Here is the call graph for this function:

◆ Append() [2/4]

int ComboBox::Append ( const wxString & item,
const wxBitmap & bitmap,
const wxString & group_key,
const wxString & group_label,
void * clientData = nullptr,
int item_style = 0 )
inherited
257{
258 auto valid_bit_map = bitmap.IsOk() ? bitmap : wxNullBitmap;
259 Item item{text, wxEmptyString, valid_bit_map, valid_bit_map, wxNullBitmap, clientData, group_key, group_label};
260 item.style = style;
261 items.push_back(item);
262 SetClientDataType(wxClientData_Void);
263 drop.Invalidate();
264 return items.size() - 1;
265}
DropDown::Item Item
Definition ComboBox.hpp:22
std::vector< Item > items
Definition ComboBox.hpp:23
DropDown drop
Definition ComboBox.hpp:25

References drop, items, DropDown::Item::style, and style.

◆ Append() [3/4]

int ComboBox::Append ( const wxString & item,
const wxBitmap & bitmap,
void * clientData,
int item_style = 0 )
inherited
239{
240 if (bitmap.IsOk()) {
241 return Append(text, bitmap, wxString{}, clientData, style);
242 }
243 return Append(text, wxNullBitmap, wxString{}, clientData, style);
244}

References Append(), and style.

Here is the call graph for this function:

◆ Append() [4/4]

int ComboBox::Append ( const wxString & item,
const wxBitmap & bitmap = wxNullBitmap,
int item_style = 0 )
inherited

◆ bitmap_cache()

BitmapCache & Slic3r::GUI::PresetComboBox::bitmap_cache ( )
staticprotected
196{
197 static BitmapCache bmps;
198 return bmps;
199}

Referenced by get_bmp(), get_bmp(), and get_bmp().

Here is the caller graph for this function:

◆ clear_selected_dev_id()

void Slic3r::GUI::PresetComboBox::clear_selected_dev_id ( )
inline
99{ m_selected_dev_id.clear(); }

References m_selected_dev_id.

◆ CloseDropdown()

void ComboBox::CloseDropdown ( )
inherited
306{
307 if (drop.IsShown())
308 drop.DismissAndNotify();
309}

References drop.

◆ DeleteOneItem()

void ComboBox::DeleteOneItem ( unsigned int pos)
inlineinherited
101{ DoDeleteOneItem(pos); }
void DoDeleteOneItem(unsigned int pos) override
Definition ComboBox.cpp:281

References DoDeleteOneItem().

Here is the call graph for this function:

◆ different_color()

wxColor Slic3r::GUI::PresetComboBox::different_color ( wxColor const & color)
static
341{
342 if (clr.GetLuminance() < 0.51) return *wxWHITE;
343 return *wxBLACK;
344}

◆ DoClear()

void ComboBox::DoClear ( )
overrideprotectedvirtualinherited
275{
276 SetIcon("drop_down");
277 items.clear();
278 drop.Invalidate(true);
279}

References drop, and items.

◆ DoDeleteOneItem()

void ComboBox::DoDeleteOneItem ( unsigned int pos)
overrideprotectedinherited
282{
283 if (pos >= items.size()) return;
284 items.erase(items.begin() + pos);
285 drop.Invalidate(true);
286}

References drop, and items.

Referenced by DeleteOneItem().

Here is the caller graph for this function:

◆ DoGetItemClientData()

void * ComboBox::DoGetItemClientData ( unsigned int n) const
overrideprotectedinherited
386{ return n < items.size() ? items[n].data : NULL; }

References items.

◆ DoInsertItems()

int ComboBox::DoInsertItems ( const wxArrayStringsAdapter & items,
unsigned int pos,
void ** clientData,
wxClientDataType type )
overrideprotectedvirtualinherited
375{
376 if (pos > this->items.size()) return -1;
377 for (int i = 0; i < items.GetCount(); ++i) {
378 Item item { items[i], wxEmptyString, wxNullBitmap, wxNullBitmap, wxNullBitmap, clientData ? clientData[i] : NULL };
379 this->items.insert(this->items.begin() + pos, item);
380 ++pos;
381 }
382 drop.Invalidate(true);
383 return pos - 1;
384}
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References drop, and items.

◆ DoSetItemClientData()

void ComboBox::DoSetItemClientData ( unsigned int n,
void * data )
overrideprotectedinherited
389{
390 if (n < items.size())
391 items[n].data = data;
392}

References items.

◆ fill_width_height()

void Slic3r::GUI::PresetComboBox::fill_width_height ( )
private
672{
673 // To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size, so
674 // set a bitmap's height to m_bitmapCompatible->GetHeight() and norm_icon_width to m_bitmapCompatible->GetWidth()
675 icon_height = m_bitmapCompatible.GetBmpHeight();
676 norm_icon_width = m_bitmapCompatible.GetBmpWidth();
677
678 /* It's supposed that standard size of an icon is 16px*16px for 100% scaled display.
679 * So set sizes for solid_colored icons used for filament preset
680 * and scale them in respect to em_unit value
681 */
682 const float scale_f = (float)m_em_unit * 0.1f;
683
684 thin_icon_width = lroundf(8 * scale_f); // analogue to 8px;
686
687 space_icon_width = lroundf(2 * scale_f);
688 thin_space_icon_width = lroundf(4 * scale_f);
689 wide_space_icon_width = lroundf(6 * scale_f);
690}
int wide_icon_width
Definition PresetComboBoxes.hpp:146
int norm_icon_width
Definition PresetComboBoxes.hpp:144
int icon_height
Definition PresetComboBoxes.hpp:143
int wide_space_icon_width
Definition PresetComboBoxes.hpp:149
int thin_space_icon_width
Definition PresetComboBoxes.hpp:148
int thin_icon_width
Definition PresetComboBoxes.hpp:145
int space_icon_width
Definition PresetComboBoxes.hpp:147

References icon_height, m_bitmapCompatible, m_em_unit, norm_icon_width, space_icon_width, thin_icon_width, thin_space_icon_width, wide_icon_width, and wide_space_icon_width.

Referenced by PresetComboBox(), and msw_rescale().

Here is the caller graph for this function:

◆ ForceDropdownOpen()

void ComboBox::ForceDropdownOpen ( )
inherited
289{
290 if (!IsEnabled() || items.empty())
291 return;
292
293 if (!drop_down) {
294 drop.need_sync = true;
295 drop.messureSize();
296 drop.autoPosition();
297 drop_down = true;
298 drop.Popup(&drop);
299
300 wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
301 GetEventHandler()->ProcessEvent(e);
302 }
303}
bool drop_down
Definition ComboBox.hpp:26
bool IsEnabled()
Definition dark_mode.cpp:32

References drop, drop_down, and items.

Referenced by BitmapChoiceRenderer::CreateEditorCtrl().

Here is the caller graph for this function:

◆ get_bmp() [1/3]

wxBitmap * Slic3r::GUI::PresetComboBox::get_bmp ( Preset const & preset)
protected
755{
756 static wxBitmap sbmp;
758 Preset const & preset2 = &m_collection->get_selected_preset() == &preset ? m_collection->get_edited_preset() : preset;
759 wxString color = preset2.config.opt_string("default_filament_colour", 0);
760 wxColour clr(color);
761 if (clr.IsOk()) {
762 std::string bitmap_key = "default_filament_colour_" + color.ToStdString();
763 wxBitmap *bmp = bitmap_cache().find(bitmap_key);
764 if (bmp == nullptr) {
765 wxImage img(16, 16);
766 if (clr.Red() > 224 && clr.Blue() > 224 && clr.Green() > 224) {
767 img.SetRGB(wxRect({0, 0}, img.GetSize()), 128, 128, 128);
768 img.SetRGB(wxRect({1, 1}, img.GetSize() - wxSize{2, 2}), clr.Red(), clr.Green(), clr.Blue());
769 } else {
770 img.SetRGB(wxRect({0, 0}, img.GetSize()), clr.Red(), clr.Green(), clr.Blue());
771 }
772 bmp = new wxBitmap(img);
773 bmp = bitmap_cache().insert(bitmap_key, *bmp);
774 }
775 return bmp;
776 }
777 }
778 return &sbmp;
779}
wxBitmap * find(const std::string &name)
Definition BitmapCache.hpp:29
wxBitmap * insert(const std::string &name, size_t width, size_t height)
Definition BitmapCache.cpp:81
static BitmapCache & bitmap_cache()
Definition PresetComboBoxes.cpp:195

References bitmap_cache(), Slic3r::Preset::config, Slic3r::GUI::BitmapCache::find(), Slic3r::GUI::BitmapCache::insert(), m_collection, m_type, Slic3r::DynamicConfig::opt_string(), and Slic3r::Preset::TYPE_FILAMENT.

Here is the call graph for this function:

◆ get_bmp() [2/3]

wxBitmap * Slic3r::GUI::PresetComboBox::get_bmp ( std::string bitmap_key,
bool wide_icons,
const std::string & main_icon_name,
bool is_compatible = true,
bool is_system = false,
bool is_single_bar = false,
const std::string & filament_rgb = "",
const std::string & extruder_rgb = "",
const std::string & material_rgb = "" )
protected
700{
701 // BBS: no icon
702#if 1
703 static wxBitmap bmp;
704 return &bmp;
705#else
706 // If the filament preset is not compatible and there is a "red flag" icon loaded, show it left
707 // to the filament color image.
708 if (wide_icons)
709 bitmap_key += is_compatible ? ",cmpt" : ",ncmpt";
710
711 bitmap_key += is_system ? ",syst" : ",nsyst";
712 bitmap_key += ",h" + std::to_string(icon_height);
713 bool dark_mode = wxGetApp().dark_mode();
714 if (dark_mode)
715 bitmap_key += ",dark";
716 bitmap_key += material_rgb;
717
718 wxBitmap* bmp = bitmap_cache().find(bitmap_key);
719 if (bmp == nullptr) {
720 // Create the bitmap with color bars.
721 std::vector<wxBitmap> bmps;
722 if (wide_icons)
723 // Paint a red flag for incompatible presets.
724 bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp());
725
726 if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty())
727 {
728 // BBS
729 // Paint a lock at the system presets.
730 bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
731 }
732 else
733 {
734 // BBS
735#if 0
736 // Paint the color bars.
737 bmps.emplace_back(bitmap_cache().mkclear(thin_space_icon_width, icon_height));
739 bmps.emplace_back(create_scaled_bitmap(main_icon_name, this, 16, false, material_rgb));
740 else
741 bmps.emplace_back(create_scaled_bitmap(main_icon_name));
742#endif
743 // Paint a lock at the system presets.
744 bmps.emplace_back(bitmap_cache().mkclear(wide_space_icon_width, icon_height));
745 }
746 bmps.emplace_back(is_system ? create_scaled_bitmap("unlock_normal") : bitmap_cache().mkclear(norm_icon_width, icon_height));
747 bmp = bitmap_cache().insert(bitmap_key, bmps);
748 }
749
750 return bmp;
751#endif
752}
wxBitmap create_scaled_bitmap(const std::string &bmp_name_in, wxWindow *win, const int px_cnt, const bool grayscale, const std::string &new_color, const bool menu_bitmap, const bool resize, const bool bitmap2, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:448

References bitmap_cache(), create_scaled_bitmap(), Slic3r::GUI::BitmapCache::find(), icon_height, Slic3r::GUI::BitmapCache::insert(), m_bitmapIncompatible, m_type, norm_icon_width, space_icon_width, thin_space_icon_width, Slic3r::Preset::TYPE_FILAMENT, Slic3r::Preset::TYPE_SLA_MATERIAL, and wide_space_icon_width.

Referenced by Slic3r::GUI::CalibrateFilamentComboBox::update(), Slic3r::GUI::PlaterPresetComboBox::update(), update(), Slic3r::GUI::TabPresetComboBox::update(), and Slic3r::GUI::TabPresetComboBox::update_dirty().

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

◆ get_bmp() [3/3]

wxBitmap * Slic3r::GUI::PresetComboBox::get_bmp ( std::string bitmap_key,
const std::string & main_icon_name,
const std::string & next_icon_name,
bool is_enabled = true,
bool is_compatible = true,
bool is_system = false )
protected
785{
786 // BBS: no icon
787#if 1
788 static wxBitmap bmp;
789 return &bmp;
790#else
791 bitmap_key += !is_enabled ? "_disabled" : "";
792 bitmap_key += is_compatible ? ",cmpt" : ",ncmpt";
793 bitmap_key += is_system ? ",syst" : ",nsyst";
794 bitmap_key += ",h" + std::to_string(icon_height);
795 if (wxGetApp().dark_mode())
796 bitmap_key += ",dark";
797
798 wxBitmap* bmp = bitmap_cache().find(bitmap_key);
799 if (bmp == nullptr) {
800 // Create the bitmap with color bars.
801 std::vector<wxBitmap> bmps;
802 bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? create_scaled_bitmap(main_icon_name, this, 16, !is_enabled) :
803 is_compatible ? m_bitmapCompatible.bmp() : m_bitmapIncompatible.bmp());
804 // Paint a lock at the system presets.
805 bmps.emplace_back(is_system ? create_scaled_bitmap(next_icon_name, this, 16, !is_enabled) : bitmap_cache().mkclear(norm_icon_width, icon_height));
806 bmp = bitmap_cache().insert(bitmap_key, bmps);
807 }
808
809 return bmp;
810#endif
811}

References bitmap_cache(), create_scaled_bitmap(), Slic3r::GUI::BitmapCache::find(), icon_height, Slic3r::GUI::BitmapCache::insert(), m_bitmapCompatible, m_bitmapIncompatible, m_type, norm_icon_width, and Slic3r::Preset::TYPE_PRINTER.

Here is the call graph for this function:

◆ get_filament_idx()

int Slic3r::GUI::PresetComboBox::get_filament_idx ( ) const
inline
96{ return m_filament_idx; }

References m_filament_idx.

Referenced by Slic3r::GUI::Plater::priv::on_select_preset().

Here is the caller graph for this function:

◆ get_preset_item_name()

wxString Slic3r::GUI::PresetComboBox::get_preset_item_name ( unsigned int index)
392{
394 int idx = selected_connected_printer();
395 if (idx < 0) {
396 m_selected_dev_id.clear();
397 return GetString(index);
398 }
399 else {
400 DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
401 if (!dev) {
402 assert(false);
403 m_selected_dev_id.clear();
404 return GetString(index);
405 }
406
407 std::map<std::string, MachineObject *> machine_list =
408 dev->get_my_machine_list(dev->get_current_printer_agent_id());
409 if (machine_list.empty()) {
410 assert(false);
411 m_selected_dev_id.clear();
412 return GetString(index);
413 }
414
415 auto iter = machine_list.begin();
416 std::advance(iter, idx);
417 if (iter != machine_list.end()) {
418 m_selected_dev_id = iter->first;
419 Preset* machine_preset = get_printer_preset(iter->second);
420 if (machine_preset) {
421 return from_u8(machine_preset->name);
422 }
423 }
424 }
425 }
426
427 m_selected_dev_id.clear();
428 return GetString(index);
429}
wxString GetString(unsigned int n) const override
Definition ComboBox.cpp:320
int selected_connected_printer() const
Definition PresetComboBoxes.cpp:547

References Slic3r::GUI::from_u8(), Slic3r::DeviceManager::get_current_printer_agent_id(), Slic3r::DeviceManager::get_my_machine_list(), Slic3r::GUI::get_printer_preset(), ComboBox::GetString(), m_selected_dev_id, m_type, Slic3r::Preset::name, selected_connected_printer(), and Slic3r::Preset::TYPE_PRINTER.

Here is the call graph for this function:

◆ get_preset_name()

wxString Slic3r::GUI::PresetComboBox::get_preset_name ( const Preset & preset)
virtual

Reimplemented in Slic3r::GUI::PlaterPresetComboBox, and Slic3r::GUI::TabPresetComboBox.

432{
433 return from_u8(preset.name/* + suffix(preset)*/);
434}

References Slic3r::GUI::from_u8(), and Slic3r::Preset::name.

Referenced by add_ams_filaments(), and update().

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

◆ get_selected_dev_id()

std::string Slic3r::GUI::PresetComboBox::get_selected_dev_id ( ) const
inline
98{ return m_selected_dev_id; }

References m_selected_dev_id.

◆ get_tooltip()

wxString Slic3r::GUI::PresetComboBox::get_tooltip ( const Preset & preset)
347{
348 wxString tooltip = from_u8(preset.name);
349
350 // Add filament notes if available for filament presets
352 const DynamicConfig* config = &preset.config;
353 Tab* tab = wxGetApp().get_tab(m_type);
354 if (tab && tab->current_preset_is_dirty() && tab->get_presets()->get_selected_preset().name == preset.name) {
355 config = tab->get_config();
356 }
357
358 if (config->has("filament_notes")) {
359 const ConfigOptionStrings* notes_opt = config->option<ConfigOptionStrings>("filament_notes");
360 if (notes_opt && !notes_opt->values.empty() && !notes_opt->values[0].empty()) {
361 std::string notes = notes_opt->values[0];
362 // Truncate if longer than 200 characters
363 if (notes.length() > 200) {
364 notes = notes.substr(0, 197) + "...";
365 }
366 tooltip += "\n" + from_u8(notes);
367 }
368 }
369 }
370
371 // BBS: FIXME
372#if 0
374 int temperature[4] = { 0,0,0,0 };
375 if (preset.config.has("nozzle_temperature_initial_layer")) //get the nozzle_temperature_initial_layer
376 temperature[0] = preset.config.opt_int("nozzle_temperature_initial_layer", 0);
377 if (preset.config.has("nozzle_temperature")) //get the nozzle temperature
378 temperature[1] = preset.config.opt_int("nozzle_temperature", 0);
379 if (preset.config.has("bed_temperature_initial_layer")) //get the bed_temperature_initial_layer
380 temperature[2] = preset.config.opt_int("bed_temperature_initial_layer", 0);
381 if (preset.config.has("bed_temperature")) //get the bed_temperature
382 temperature[3] = preset.config.opt_int("bed_temperature", 0);
383
384 tooltip += wxString::Format("\nNozzle First Layer:%d, Other Layer:%d\n Bed First Layer:%d, Other Layers:%d",
385 temperature[0], temperature[1], temperature[2], temperature[3]);
386 }
387#endif
388 return tooltip;
389}
zaa_minimize_perimeter_height notes((ConfigOptionString, printer_notes))((ConfigOptionBools

References Slic3r::Preset::config, Slic3r::GUI::Tab::current_preset_is_dirty(), Slic3r::GUI::from_u8(), Slic3r::GUI::Tab::get_config(), Slic3r::GUI::Tab::get_presets(), Slic3r::PresetCollection::get_selected_preset(), Slic3r::ConfigOptionResolver::has(), m_type, Slic3r::Preset::name, Slic3r::notes(), Slic3r::DynamicConfig::opt_int(), Slic3r::ConfigBase::option(), Slic3r::Preset::TYPE_FILAMENT, and Slic3r::ConfigOptionVector< T >::values.

Referenced by Slic3r::GUI::CalibrateFilamentComboBox::update(), and Slic3r::GUI::PlaterPresetComboBox::update().

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

◆ get_type()

Preset::Type Slic3r::GUI::PresetComboBox::get_type ( )
inline
109{ return m_type; }

References m_type.

Referenced by Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), Slic3r::GUI::Plater::priv::on_select_preset(), and Slic3r::GUI::DiffPresetDialog::update_compatibility().

Here is the caller graph for this function:

◆ GetCount()

◆ GetDropDown()

DropDown & ComboBox::GetDropDown ( )
inlineinherited
43{ return drop; }

References drop.

Referenced by Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox(), Slic3r::GUI::TabPresetComboBox::TabPresetComboBox(), Slic3r::GUI::Choice::BUILD(), Slic3r::GUI::PrinterAgentChoice::BUILD(), BitmapChoiceRenderer::CreateEditorCtrl(), and Slic3r::GUI::use_nozzle_row_font().

Here is the caller graph for this function:

◆ GetFlag()

int ComboBox::GetFlag ( unsigned int n)
inherited
197{
198 if (n >= items.size())
199 return -1;
200 return items[n].flag;
201}

References items.

Referenced by Slic3r::anonymous_namespace{PluginHostPresets.cpp}::bind_filament_target(), Slic3r::GUI::Plater::priv::on_select_preset(), and Slic3r::GUI::PlaterPresetComboBox::update_badge_according_flag().

Here is the caller graph for this function:

◆ GetItemAlias()

wxString ComboBox::GetItemAlias ( unsigned int n) const
inherited
344{
345 if (n >= items.size()) return wxString();
346 return items[n].alias;
347}

References items.

Referenced by Slic3r::anonymous_namespace{PluginHostPresets.cpp}::combo_item_for_preset(), Slic3r::GUI::Plater::priv::on_select_preset(), Slic3r::anonymous_namespace{PluginHostPresets.cpp}::resolve_combo_preset(), and Slic3r::GUI::PresetComboBox::update_ams_color().

Here is the caller graph for this function:

◆ GetItemBitmap()

wxBitmap ComboBox::GetItemBitmap ( unsigned int n)
inherited
355{ return items[n].icon; }

References items.

◆ GetItemTooltip()

wxString ComboBox::GetItemTooltip ( unsigned int n) const
inherited
332{
333 if (n >= items.size()) return wxString();
334 return items[n].tip;
335}

References items.

◆ GetLabel()

wxString ComboBox::GetLabel ( ) const
overrideinherited
189{
190 if (GetTextCtrl()->IsShown() || text_off)
191 return GetTextCtrl()->GetValue();
192 else
193 return TextInput::GetLabel();
194}
bool text_off
Definition ComboBox.hpp:27

References text_off.

Referenced by GetValue().

Here is the caller graph for this function:

◆ GetSelection()

◆ GetString()

◆ GetTextLabel()

wxString ComboBox::GetTextLabel ( ) const
inherited
215{
216 return TextInput::GetLabel();
217}

◆ GetValue()

wxString ComboBox::GetValue ( ) const
inherited
141{
142 return drop.GetSelection() >= 0 ? drop.GetValue() : GetLabel();
143}
wxString GetLabel() const override
Definition ComboBox.cpp:188

References drop, and GetLabel().

Referenced by Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox(), Slic3r::GUI::Choice::BUILD(), Slic3r::GUI::PrinterAgentChoice::BUILD(), Slic3r::GUI::GridCellChoiceEditor::EndEdit(), Slic3r::GUI::GridCellFilamentsEditor::EndEdit(), Slic3r::GUI::IMEXModesCtrl::fix_row_name(), Slic3r::GUI::Choice::get_value(), Slic3r::GUI::IMEXModesCtrl::snapshot_row(), Slic3r::GUI::TabPrint::toggle_options(), Slic3r::GUI::CalibrateFilamentComboBox::update(), and Slic3r::GUI::PresetComboBox::update_ams_color().

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

◆ invalidate_selection()

void Slic3r::GUI::PresetComboBox::invalidate_selection ( )
protected
216{
217 m_last_selected = INT_MAX; // this value means that no one item is selected
218}

References m_last_selected.

Referenced by Slic3r::GUI::CalibrateFilamentComboBox::update(), Slic3r::GUI::PlaterPresetComboBox::update(), update(), and Slic3r::GUI::TabPresetComboBox::update().

Here is the caller graph for this function:

◆ is_drop_down()

bool ComboBox::is_drop_down ( )
inlineinherited
100{return drop_down;}

References drop_down.

◆ is_selected_physical_printer()

bool Slic3r::GUI::PresetComboBox::is_selected_physical_printer ( )
814{
815 auto selected_item = this->GetSelection();
816 auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
817 return marker == LABEL_ITEM_PHYSICAL_PRINTER;
818}
int GetSelection() const override
Definition ComboBox.cpp:98
std::size_t Marker
Definition PresetComboBoxes.hpp:117

References ComboBox::GetSelection(), and LABEL_ITEM_PHYSICAL_PRINTER.

Referenced by Slic3r::GUI::Plater::priv::on_select_preset(), and selection_is_changed_according_to_physical_printers().

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

◆ is_selected_printer_model()

bool Slic3r::GUI::PresetComboBox::is_selected_printer_model ( )
821{
822 auto selected_item = this->GetSelection();
823 auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
824 return marker == LABEL_ITEM_PRINTER_MODELS;
825}

References ComboBox::GetSelection(), and LABEL_ITEM_PRINTER_MODELS.

Referenced by Slic3r::GUI::Plater::priv::on_select_preset().

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

◆ keyDown()

void ComboBox::keyDown ( wxKeyEvent & event)
privateinherited
423{
424 switch (event.GetKeyCode()) {
425 case WXK_RETURN:
426 case WXK_SPACE:
427 if (drop_down) {
428 drop.DismissAndNotify();
429 } else if (!items.empty() && drop.HasDismissLongTime()) {
430 drop.autoPosition();
431 drop_down = true;
432 drop.Popup();
433 wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
434 GetEventHandler()->ProcessEvent(e);
435 }
436 break;
437 case WXK_UP:
438 case WXK_DOWN:
439 case WXK_LEFT:
440 case WXK_RIGHT: {
441 // Step over disabled rows: the mouse cannot select them either.
442 const int step = (event.GetKeyCode() == WXK_UP || event.GetKeyCode() == WXK_LEFT) ? -1 : 1;
443 int n = GetSelection() + step;
444 while (n >= 0 && n < int(items.size()) && (items[n].style & DD_ITEM_STYLE_DISABLED))
445 n += step;
446 if (n < 0 || n >= int(items.size()))
447 break;
448 SetSelection(n);
450 break;
451 }
452 case WXK_TAB:
453 HandleAsNavigationKey(event);
454 break;
455 default:
456 event.Skip();
457 break;
458 }
459}
#define DD_ITEM_STYLE_DISABLED
Definition DropDown.hpp:27
void sendComboBoxEvent()
Definition ComboBox.cpp:485
void SetSelection(int n) override
Definition ComboBox.cpp:102
void step(Coord &crd, const Dir d, const long n=1)
Definition MarchingSquares.hpp:213

References DD_ITEM_STYLE_DISABLED, drop, drop_down, GetSelection(), items, sendComboBoxEvent(), and SetSelection().

Here is the call graph for this function:

◆ mouseDown()

void ComboBox::mouseDown ( wxMouseEvent & event)
privateinherited
395{
396 if (!IsEnabled()) { return; } /*on mac, the event may triggered even disabled*/
397
398 SetFocus();
399 if (drop_down) {
400 drop.Hide();
401 } else if (!items.empty() && drop.HasDismissLongTime()) { // DropDown paints nothing for an empty list
402 drop.autoPosition();
403 drop_down = true;
404 drop.Popup(&drop);
405 wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
406 GetEventHandler()->ProcessEvent(e);
407 }
408}

References drop, drop_down, and items.

◆ mouseWheelMoved()

void ComboBox::mouseWheelMoved ( wxMouseEvent & event)
privateinherited
411{
412 event.Skip();
413 if (drop_down) return;
414 auto delta = event.GetWheelRotation() < 0 ? 1 : -1;
415 unsigned int n = GetSelection() + delta;
416 if (n < GetCount()) {
417 SetSelection((int) n);
419 }
420}

References drop_down, GetCount(), GetSelection(), sendComboBoxEvent(), and SetSelection().

Here is the call graph for this function:

◆ msw_rescale()

void Slic3r::GUI::PresetComboBox::msw_rescale ( )
virtual

Reimplemented in Slic3r::GUI::CalibrateFilamentComboBox, Slic3r::GUI::PlaterPresetComboBox, and Slic3r::GUI::TabPresetComboBox.

651{
652 m_em_unit = em_unit(this);
653 Rescale();
654
655 m_bitmapIncompatible.msw_rescale();
656 m_bitmapCompatible.msw_rescale();
657
658 // parameters for an icon's drawing
660
661 // update the control to redraw the icons
662 update();
663}
virtual void Rescale() override
Definition ComboBox.cpp:134
virtual void update()
Definition PresetComboBoxes.cpp:510

References em_unit(), fill_width_height(), m_bitmapCompatible, m_bitmapIncompatible, m_em_unit, ComboBox::Rescale(), and update().

Referenced by Slic3r::GUI::PlaterPresetComboBox::msw_rescale(), Slic3r::GUI::TabPresetComboBox::msw_rescale(), and sys_color_changed().

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

◆ OnEdit()

void ComboBox::OnEdit ( )
overrideprotectedinherited
468{
469 auto value = GetTextCtrl()->GetValue();
470 SetValue(value);
471}
void SetValue(const wxString &value)
Definition ComboBox.cpp:145

References SetValue().

Here is the call graph for this function:

◆ onMove()

void ComboBox::onMove ( wxMoveEvent & event)
privateinherited
462{
463 event.Skip();
464 drop.Hide();
465}

References drop.

Referenced by ComboBox().

Here is the caller graph for this function:

◆ OnSelect()

void Slic3r::GUI::PresetComboBox::OnSelect ( wxCommandEvent & evt)
virtual

Reimplemented in Slic3r::GUI::CalibrateFilamentComboBox, Slic3r::GUI::PlaterPresetComboBox, and Slic3r::GUI::TabPresetComboBox.

174{
175 // Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender")
176 // m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive.
177 // So, use GetSelection() from event parameter
178 auto selected_item = evt.GetSelection();
179
180 auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
181 if (marker >= LABEL_ITEM_DISABLED && marker < LABEL_ITEM_MAX)
183 else if (on_selection_changed && (m_last_selected != selected_item || m_collection->current_is_dirty())) {
184 m_last_selected = selected_item;
185 on_selection_changed(selected_item);
186 evt.StopPropagation();
187 }
188 evt.Skip();
189}
std::function< void(int)> on_selection_changed
Definition PresetComboBoxes.hpp:118

References LABEL_ITEM_DISABLED, LABEL_ITEM_MAX, m_collection, m_last_selected, on_selection_changed, and ComboBox::SetSelection().

Referenced by PresetComboBox().

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

◆ Rescale()

void ComboBox::Rescale ( )
overridevirtualinherited
135{
137 drop.Rescale();
138}
virtual void Rescale()
Definition TextInput.cpp:175

References drop, and TextInput::Rescale().

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

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

◆ SelectAndNotify()

void ComboBox::SelectAndNotify ( int n)
inherited
129 {
130 SetSelection(n);
132}

References sendComboBoxEvent(), and SetSelection().

Here is the call graph for this function:

◆ selected_ams_filament()

int Slic3r::GUI::PresetComboBox::selected_ams_filament ( ) const
643{
645 return reinterpret_cast<int *>(GetClientData(m_last_selected)) - &m_first_ams_filament;
646 }
647 return -1;
648}

References m_first_ams_filament, m_last_ams_filament, and m_last_selected.

Referenced by update_ams_color().

Here is the caller graph for this function:

◆ selected_connected_printer()

int Slic3r::GUI::PresetComboBox::selected_connected_printer ( ) const
548{
550 return reinterpret_cast<int *>(GetClientData(m_last_selected)) - &m_first_printer_idx;
551 }
552 return -1;
553}

References m_first_printer_idx, m_last_printer_idx, and m_last_selected.

Referenced by get_preset_item_name().

Here is the caller graph for this function:

◆ selection_is_changed_according_to_physical_printers()

bool Slic3r::GUI::PresetComboBox::selection_is_changed_according_to_physical_printers ( )
828{
830 return false;
831
832 PhysicalPrinterCollection& physical_printers = m_preset_bundle->physical_printers;
833
834 std::string selected_string = this->GetString(this->GetSelection()).ToUTF8().data();
835
836 std::string old_printer_full_name, old_printer_preset;
837 if (physical_printers.has_selection()) {
838 old_printer_full_name = physical_printers.get_selected_full_printer_name();
839 old_printer_preset = physical_printers.get_selected_printer_preset_name();
840 }
841 else
842 old_printer_preset = m_collection->get_edited_preset().name;
843 // Select related printer preset on the Printer Settings Tab
844 physical_printers.select_printer(selected_string);
845 std::string preset_name = physical_printers.get_selected_printer_preset_name();
846
847 // if new preset wasn't selected, there is no need to call update preset selection
848 if (old_printer_preset == preset_name) {
849 // we need just to update according Plater<->Tab PresetComboBox
850 if (dynamic_cast<PlaterPresetComboBox*>(this)!=nullptr) {
851 wxGetApp().get_tab(m_type)->update_preset_choice();
852 // Synchronize config.ini with the current selections.
853 m_preset_bundle->export_selections(*wxGetApp().app_config);
854 }
855 else if (dynamic_cast<TabPresetComboBox*>(this)!=nullptr)
856 wxGetApp().sidebar().update_presets(m_type);
857
858 this->update();
859 return true;
860 }
861
862 Tab* tab = wxGetApp().get_tab(Preset::TYPE_PRINTER);
863 if (tab)
864 tab->select_preset(preset_name, false, old_printer_full_name);
865 return true;
866}
bool is_selected_physical_printer()
Definition PresetComboBoxes.cpp:813

References Slic3r::PhysicalPrinterCollection::get_selected_full_printer_name(), Slic3r::PhysicalPrinterCollection::get_selected_printer_preset_name(), ComboBox::GetSelection(), ComboBox::GetString(), Slic3r::PhysicalPrinterCollection::has_selection(), is_selected_physical_printer(), m_collection, m_preset_bundle, m_type, Slic3r::GUI::Tab::select_preset(), Slic3r::PhysicalPrinterCollection::select_printer(), Slic3r::Preset::TYPE_PRINTER, and update().

Referenced by Slic3r::GUI::Plater::priv::on_select_preset().

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

◆ sendComboBoxEvent()

void ComboBox::sendComboBoxEvent ( )
protectedinherited
486{
487 wxCommandEvent event(wxEVT_COMBOBOX, GetId());
488 event.SetEventObject(this);
489 event.SetInt(drop.GetSelection());
490 event.SetString(drop.GetValue());
491 GetEventHandler()->ProcessEvent(event);
492}

References drop.

Referenced by keyDown(), mouseWheelMoved(), and SelectAndNotify().

Here is the caller graph for this function:

◆ separator()

wxString Slic3r::GUI::PresetComboBox::separator ( const std::string & label)
staticprotected
693{
694 return wxString::FromUTF8(separator_head()) + _(label) + wxString::FromUTF8(separator_tail());
695}
#define _(s)
Definition 3mf.cpp:306
static const char * separator_head()
Definition PresetComboBoxes.hpp:170
static const char * separator_tail()
Definition PresetComboBoxes.hpp:171

References _, separator_head(), and separator_tail().

Here is the call graph for this function:

◆ separator_head()

const char * Slic3r::GUI::PresetComboBox::separator_head ( )
inlinestaticprotected
170{ return "--"; }

Referenced by separator().

Here is the caller graph for this function:

◆ separator_tail()

const char * Slic3r::GUI::PresetComboBox::separator_tail ( )
inlinestaticprotected
171{ return " --"; }

Referenced by separator().

Here is the caller graph for this function:

◆ set_filament_idx()

void Slic3r::GUI::PresetComboBox::set_filament_idx ( const int extr_idx)
inline
95{ m_filament_idx = extr_idx; }

References m_filament_idx.

◆ set_label_marker()

void Slic3r::GUI::PresetComboBox::set_label_marker ( int item,
LabelItemType label_item_type = LABEL_ITEM_MARKER )
202{
203 this->SetClientData(item, (void*)label_item_type);
204}

Referenced by add_ams_filaments(), add_connected_printers(), Slic3r::GUI::CalibrateFilamentComboBox::update(), Slic3r::GUI::PlaterPresetComboBox::update(), update(), and Slic3r::GUI::TabPresetComboBox::update().

Here is the caller graph for this function:

◆ set_printer_technology()

bool Slic3r::GUI::PresetComboBox::set_printer_technology ( PrinterTechnology pt)
207{
208 if (printer_technology != pt) {
210 return true;
211 }
212 return false;
213}
PrinterTechnology printer_technology
Definition PresetComboBoxes.hpp:157

References printer_technology.

◆ set_replace_text()

void ComboBox::set_replace_text ( wxString text,
wxString image_name )
inherited
314{
315 replace_text = text;
316 image_for_text = image_name;
318}
wxString image_for_text
Definition ComboBox.hpp:31
wxString replace_text
Definition ComboBox.hpp:30
bool is_replace_text_to_image
Definition ComboBox.hpp:28

References image_for_text, is_replace_text_to_image, and replace_text.

Referenced by Slic3r::GUI::PlaterPresetComboBox::update().

Here is the caller graph for this function:

◆ set_selection_changed_function()

void Slic3r::GUI::PresetComboBox::set_selection_changed_function ( std::function< void(int)> sel_changed)
inline
73{ on_selection_changed = sel_changed; }

References on_selection_changed.

Referenced by Slic3r::GUI::DiffPresetDialog::create_presets_sizer().

Here is the caller graph for this function:

◆ SetFlag()

void ComboBox::SetFlag ( unsigned int n,
int value )
inherited
203 {
204 if (n >= items.size()) return;
205 items[n].flag = value;
206 drop.Invalidate();
207}

References drop, and items.

Referenced by Slic3r::GUI::PresetComboBox::add_ams_filaments(), and Slic3r::GUI::PlaterPresetComboBox::update().

Here is the caller graph for this function:

◆ SetFont()

bool ComboBox::SetFont ( wxFont const & font)
overridevirtualinherited
220{
221 if (GetTextCtrl() && GetTextCtrl()->IsShown())
222 return GetTextCtrl()->SetFont(font);
223 else
224 return TextInput::SetFont(font);
225}

Referenced by Slic3r::GUI::PresetComboBox::PresetComboBox(), Slic3r::GUI::GridCellChoiceEditor::Create(), and Slic3r::GUI::use_nozzle_row_font().

Here is the caller graph for this function:

◆ SetItemActionBitmap()

void ComboBox::SetItemActionBitmap ( unsigned int n,
wxBitmap const & bitmap )
inherited
365{
366 if (n >= items.size()) return;
367 items[n].action_icon = bitmap.IsOk() ? bitmap : wxNullBitmap;
368 drop.Invalidate();
369}

References drop, and items.

◆ SetItemAlias()

void ComboBox::SetItemAlias ( unsigned int n,
wxString const & value )
inherited
350{
351 if (n >= items.size()) return;
352 items[n].alias = value;
353}

References items.

Referenced by Slic3r::GUI::PlaterPresetComboBox::update(), and Slic3r::GUI::TabPresetComboBox::update().

Here is the caller graph for this function:

◆ SetItemBitmap()

void ComboBox::SetItemBitmap ( unsigned int n,
wxBitmap const & bitmap )
inherited
358{
359 if (n >= items.size()) return;
360 items[n].icon = bitmap.IsOk() ? bitmap : wxNullBitmap;
361 drop.Invalidate();
362}

References drop, and items.

Referenced by Slic3r::GUI::TabPresetComboBox::update_dirty().

Here is the caller graph for this function:

◆ SetItems()

int ComboBox::SetItems ( const std::vector< DropDown::Item > & the_items)
inherited
268{
269 items = the_items;
270 drop.Invalidate();
271 return items.size() - 1;
272}

References drop, and items.

◆ SetItemTooltip()

void ComboBox::SetItemTooltip ( unsigned int n,
wxString const & value )
inherited
337 {
338 if (n >= items.size()) return;
339 items[n].tip = value;
340 if (n == drop.GetSelection()) drop.SetToolTip(value);
341}

References drop, and items.

Referenced by Slic3r::GUI::PlaterPresetComboBox::update(), and Slic3r::GUI::TabPresetComboBox::update().

Here is the caller graph for this function:

◆ SetKeepDropArrow()

void ComboBox::SetKeepDropArrow ( bool keep)
inlineinherited
48{ m_keep_drop_arrow = keep; }
bool m_keep_drop_arrow
Definition ComboBox.hpp:29

References m_keep_drop_arrow.

◆ SetLabel()

void ComboBox::SetLabel ( const wxString & label)
overrideinherited
170{
171 if (GetTextCtrl()->IsShown() || text_off)
172 GetTextCtrl()->SetValue(value);
173 else {
175 auto new_value = value;
176 if (new_value.starts_with(replace_text)) {
177 new_value.Replace(replace_text, "", false); // replace first text
179 TextInput::SetLabel(new_value);
180 return;
181 }
182 }
184 TextInput::SetLabel(value);
185 }
186}
void SetLabel(const wxString &label) override
Definition TextInput.cpp:113
void SetIcon_1(const wxString &icon)
Definition TextInput.cpp:143

References image_for_text, is_replace_text_to_image, replace_text, TextInput::SetIcon_1(), TextInput::SetLabel(), and text_off.

Referenced by Slic3r::GUI::create_select_filament_preset_checkbox(), SetSelection(), SetString(), SetValue(), and Slic3r::GUI::LayerNumberTextInput::update_label().

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

◆ SetSelection()

void ComboBox::SetSelection ( int n)
overrideinherited
103{
104 if (n == drop.selection)
105 return;
106 drop.SetSelection(n);
107 SetLabel(drop.GetValue());
108 if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk()) {
109 if (m_keep_drop_arrow) {
110 SetIcon("drop_down");
111 SetIcon_1(items[drop.selection].icon_textctrl);
112 } else {
113 SetIcon(items[drop.selection].icon_textctrl);
114 }
115 } else {
116 SetIcon("drop_down");
118 SetIcon_1(wxNullBitmap);
119 }
120
121 if (drop.selection >= 0) {
122 SetStaticTips(items[drop.selection].text_static_tips, wxNullBitmap);
123 } else {
124 SetStaticTips(wxEmptyString, wxNullBitmap);
125 }
126
127}
void SetLabel(const wxString &label) override
Definition ComboBox.cpp:169

References drop, items, m_keep_drop_arrow, and SetLabel().

Referenced by ComboBox(), Slic3r::GUI::DesignPanel::DesignPanel(), Slic3r::GUI::LayerNumberTextInput::LayerNumberTextInput(), Slic3r::GUI::GridCellChoiceEditor::BeginEdit(), Slic3r::GUI::GridCellFilamentsEditor::BeginEdit(), BitmapChoiceRenderer::CreateEditorCtrl(), Slic3r::GUI::DesignPanel::fill_body_choice(), Slic3r::GUI::DesignPanel::fill_revolve_axes(), keyDown(), mouseWheelMoved(), Slic3r::GUI::Sidebar::on_filament_count_change(), Slic3r::GUI::CalibrateFilamentComboBox::OnSelect(), Slic3r::GUI::PlaterPresetComboBox::OnSelect(), Slic3r::GUI::PresetComboBox::OnSelect(), Slic3r::GUI::TabPresetComboBox::OnSelect(), Slic3r::GUI::DesignPanel::populate_body_choices(), Slic3r::GUI::DesignPanel::populate_plane_choices(), Slic3r::GUI::DesignPanel::populate_sheet_body_choices(), Slic3r::GUI::select_nozzle_volume(), Slic3r::GUI::DesignPanel::select_sheet_choice(), SelectAndNotify(), Slic3r::GUI::LayerNumberTextInput::set_layer_number(), Slic3r::GUI::Choice::set_selection(), Slic3r::GUI::Choice::set_value(), Slic3r::GUI::Choice::set_value(), Slic3r::GUI::TabPresetComboBox::update_dirty(), Slic3r::GUI::Sidebar::update_presets(), and Slic3r::GUI::PresetComboBox::update_selection().

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

◆ SetString()

void ComboBox::SetString ( unsigned int n,
wxString const & value )
overrideinherited
324{
325 if (n >= items.size()) return;
326 items[n].text = value;
327 drop.Invalidate();
328 if (n == drop.GetSelection()) SetLabel(value);
329}

References drop, items, and SetLabel().

Referenced by Slic3r::GUI::TabPresetComboBox::update_dirty().

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

◆ SetTextLabel()

void ComboBox::SetTextLabel ( const wxString & label)
inherited
210{
211 TextInput::SetLabel(label);
212}

References TextInput::SetLabel().

Referenced by Slic3r::GUI::Choice::BUILD(), and Slic3r::GUI::PrinterAgentChoice::BUILD().

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

◆ SetValue()

void ComboBox::SetValue ( const wxString & value)
inherited
146{
147 drop.SetValue(value);
148 SetLabel(value);
149 if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk()) {
150 if (m_keep_drop_arrow) {
151 SetIcon("drop_down");
152 SetIcon_1(items[drop.selection].icon_textctrl);
153 } else {
154 SetIcon(items[drop.selection].icon_textctrl);
155 }
156 } else {
157 SetIcon("drop_down");
159 SetIcon_1(wxNullBitmap);
160 }
161
162 if (drop.selection >= 0) {
163 SetStaticTips(items[drop.selection].text_static_tips, wxNullBitmap);
164 } else {
165 SetStaticTips(wxEmptyString, wxNullBitmap);
166 }
167}

References drop, items, m_keep_drop_arrow, and SetLabel().

Referenced by Slic3r::GUI::CalibrateFilamentComboBox::load_tray(), OnEdit(), Slic3r::GUI::Choice::set_selection(), Slic3r::GUI::Choice::set_value(), and Slic3r::GUI::Choice::set_value().

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

◆ show_all()

void Slic3r::GUI::PresetComboBox::show_all ( bool show_all)
505{
507 update();
508}
bool m_show_all
Definition PresetComboBoxes.hpp:46
void show_all(bool show_all)
Definition PresetComboBoxes.cpp:504

References m_show_all, show_all(), and update().

Referenced by show_all().

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

◆ sys_color_changed()

void Slic3r::GUI::PresetComboBox::sys_color_changed ( )
virtual

Reimplemented in Slic3r::GUI::PlaterPresetComboBox.

666{
667 wxGetApp().UpdateDarkUI(this);
668 msw_rescale();
669}
virtual void msw_rescale()
Definition PresetComboBoxes.cpp:650

References msw_rescale().

Referenced by Slic3r::GUI::PlaterPresetComboBox::sys_color_changed().

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

◆ update() [1/2]

void Slic3r::GUI::PresetComboBox::update ( )
virtual

Reimplemented in Slic3r::GUI::CalibrateFilamentComboBox, Slic3r::GUI::PlaterPresetComboBox, and Slic3r::GUI::TabPresetComboBox.

511{
512 this->update(into_u8(this->GetString(this->GetSelection())));
513}
std::string into_u8(const wxString &str)
Definition GUI.cpp:549

References ComboBox::GetSelection(), ComboBox::GetString(), Slic3r::GUI::into_u8(), and update().

Referenced by msw_rescale(), selection_is_changed_according_to_physical_printers(), show_all(), update(), and update_from_bundle().

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

◆ update() [2/2]

void Slic3r::GUI::PresetComboBox::update ( std::string select_preset)
437{
438 Freeze();
439 Clear();
441
442 const std::deque<Preset>& presets = m_collection->get_presets();
443
444 std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
445 std::map<wxString, wxBitmap*> incomp_presets;
446
447 wxString selected = "";
448 if (!presets.front().is_visible)
449 set_label_marker(Append(_L("System presets"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
450
451 for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
452 {
453 const Preset& preset = presets[i];
454 if (!m_show_all && (!preset.is_visible || !preset.is_compatible))
455 continue;
456
457 // marker used for disable incompatible printer models for the selected physical printer
458 bool is_enabled = m_type == Preset::TYPE_PRINTER && printer_technology != ptAny ? preset.printer_technology() == printer_technology : true;
459 if (select_preset_name.empty() && is_enabled)
460 select_preset_name = preset.name;
461
462 wxBitmap* bmp = get_bmp(preset);
463 assert(bmp);
464
465 if (!is_enabled)
466 incomp_presets.emplace(get_preset_name(preset), bmp);
467 else if (preset.is_default || preset.is_system)
468 {
469 Append(get_preset_name(preset), *bmp);
470 validate_selection(preset.name == select_preset_name);
471 }
472 else
473 {
474 nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
475 if (preset.name == select_preset_name || (select_preset_name.empty() && is_enabled))
476 selected = get_preset_name(preset);
477 }
478 if (i + 1 == m_collection->num_default_presets())
479 set_label_marker(Append(_L("System presets"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
480 }
481 if (!nonsys_presets.empty())
482 {
483 set_label_marker(Append(_L("User presets"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
484 for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
485 int item_id = Append(it->first, *it->second.first);
486 bool is_enabled = it->second.second;
487 if (!is_enabled)
489 validate_selection(it->first == selected);
490 }
491 }
492 if (!incomp_presets.empty())
493 {
494 set_label_marker(Append(_L("Incompatible presets"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
495 for (std::map<wxString, wxBitmap*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
496 set_label_marker(Append(it->first, *it->second), LABEL_ITEM_DISABLED);
497 }
498 }
499
501 Thaw();
502}
wxBitmap * get_bmp(std::string bitmap_key, bool wide_icons, const std::string &main_icon_name, bool is_compatible=true, bool is_system=false, bool is_single_bar=false, const std::string &filament_rgb="", const std::string &extruder_rgb="", const std::string &material_rgb="")
Definition PresetComboBoxes.cpp:697
void update_selection()
Definition PresetComboBoxes.cpp:228
void invalidate_selection()
Definition PresetComboBoxes.cpp:215
@ ptAny
Definition Config.hpp:237

References _L, ComboBox::Append(), DD_ITEM_STYLE_SPLIT_ITEM, get_bmp(), get_preset_name(), invalidate_selection(), Slic3r::Preset::is_compatible, Slic3r::Preset::is_default, Slic3r::Preset::is_system, Slic3r::Preset::is_visible, LABEL_ITEM_DISABLED, m_collection, m_show_all, m_type, Slic3r::Preset::name, printer_technology, Slic3r::Preset::printer_technology(), Slic3r::ptAny, set_label_marker(), Slic3r::Preset::TYPE_PRINTER, update_selection(), and validate_selection().

Referenced by Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), and Slic3r::GUI::DiffPresetDialog::update_compatibility().

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

◆ update_ams_color()

int Slic3r::GUI::PresetComboBox::update_ams_color ( )
protected
275{
276 if (m_filament_idx < 0) return -1;
277 int idx = selected_ams_filament();
278 std::string color;
279 std::string ctype;
280 std::vector<std::string> colors;
281 if (idx < 0) {
282 // ORCA: The combo displays the preset alias while
283 // the stored preset name usually carries a printer suffix. Resolving with the raw display
284 // value via find_preset() fails for such presets, so this returned early and the
285 // filament color swatch (clr_picker) kept showing the previous color. Prefer the
286 // internal preset name stored per item, then fall back to alias resolution.
287 std::string name;
288 if (m_last_selected >= 0) {
289 wxString stored = GetItemAlias(m_last_selected);
290 if (!stored.empty())
291 name = Preset::remove_suffix_modified(stored.ToUTF8().data());
292 }
293 if (name.empty())
294 name = m_collection->get_preset_name_by_alias(Preset::remove_suffix_modified(GetValue().ToUTF8().data()));
295 auto *preset = m_collection->find_preset(name);
296 if (preset)
297 color = preset->config.opt_string("default_filament_colour", 0u);
298 if (color.empty()) return -1;
299 } else {
300 auto &ams_list = wxGetApp().preset_bundle->filament_ams_list;
301 auto iter = ams_list.find(idx);
302 if (iter == ams_list.end()) {
303 BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": ams %1% out of range %2%") % idx % ams_list.size();
304 return -1;
305 }
306 color = iter->second.opt_string("filament_colour", 0u);
307 ctype = iter->second.opt_string("filament_colour_type", 0u);
308 colors = iter->second.opt<ConfigOptionStrings>("filament_multi_colour")->values;
309 }
310 DynamicPrintConfig *cfg = &wxGetApp().preset_bundle->project_config;
311 auto color_head = static_cast<ConfigOptionStrings*>(cfg->option("filament_colour")->clone()); // single color (the first color if multi-color filament)
312 auto color_pack = static_cast<ConfigOptionStrings *>(cfg->option("filament_multi_colour")->clone()); // multi color (all colors in all kinds of filament)
313 auto color_type = static_cast<ConfigOptionStrings*>(cfg->option("filament_colour_type")->clone()); // color type
314
315 color_head->values[m_filament_idx] = color;
316 color_type->values[m_filament_idx] = ctype;
317 std::string color_str = ""; // Translate multi color info to config storage format
318 for (auto &c : colors) {
319 if (c.empty()) continue;
320 color_str += c + " ";
321 }
322 if (color_str.empty()) color_str = color;
323 else color_str.erase(color_str.size() - 1);
324 color_pack->values[m_filament_idx] = color_str;
325
326 // Update color informations in config
327 DynamicPrintConfig new_cfg;
328 new_cfg.set_key_value("filament_colour", color_head);
329 new_cfg.set_key_value("filament_colour_type", color_type);
330 new_cfg.set_key_value("filament_multi_colour", color_pack);
331 cfg->apply(new_cfg);
332 wxGetApp().plater()->on_config_change(new_cfg);
333 //trigger the filament color changed
334 wxCommandEvent *evt = new wxCommandEvent(EVT_FILAMENT_COLOR_CHANGED);
335 evt->SetInt(m_filament_idx);
336 wxQueueEvent(wxGetApp().plater(), evt);
337 return idx;
338}
wxString GetItemAlias(unsigned int n) const
Definition ComboBox.cpp:343
wxString GetValue() const
Definition ComboBox.cpp:140
int selected_ams_filament() const
Definition PresetComboBoxes.cpp:642
static std::string remove_suffix_modified(const std::string &name)
Definition Preset.cpp:516
static Plater * plater()
Definition GUI_Factories.cpp:400

References Slic3r::ConfigBase::apply(), ComboBox::GetItemAlias(), ComboBox::GetValue(), m_collection, m_filament_idx, m_last_selected, Slic3r::ConfigBase::option(), Slic3r::GUI::plater(), Slic3r::Preset::remove_suffix_modified(), selected_ams_filament(), Slic3r::DynamicConfig::set_key_value(), and Slic3r::ConfigOptionVector< T >::values.

Referenced by Slic3r::GUI::PlaterPresetComboBox::OnSelect(), and Slic3r::GUI::TabPresetComboBox::OnSelect().

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

◆ update_from_bundle()

void Slic3r::GUI::PresetComboBox::update_from_bundle ( )
516{
517 this->update(m_collection->get_selected_preset().name);
518}

References m_collection, and update().

Here is the call graph for this function:

◆ update_selection()

void Slic3r::GUI::PresetComboBox::update_selection ( )
protected
229{
230 /* If selected_preset_item is still equal to INT_MAX, it means that
231 * there is no presets added to the list.
232 * So, select last combobox item ("Add/Remove preset")
233 */
234 //validate_selection();
235 if (m_last_selected == INT_MAX)
236 m_last_selected = 1;
237
239#ifdef __WXMSW__
240 // From the Windows 2004 the tooltip for preset combobox doesn't work after next call of SetTooltip()
241 // (There was an issue, when tooltip doesn't appears after changing of the preset selection)
242 // But this workaround seems to work: We should to kill tooltip and than set new tooltip value
243 SetToolTip(NULL);
244#endif
245 SetToolTip(GetString(m_last_selected));
246
247// A workaround for a set of issues related to text fitting into gtk widgets:
248#if defined(__WXGTK20__) || defined(__WXGTK3__)
249 GtkWidget* widget = m_widget;
250 if (GTK_IS_CONTAINER(widget)) {
251 GList* children = gtk_container_get_children(GTK_CONTAINER(widget));
252 if (children) {
253 widget = GTK_WIDGET(children->data);
254 g_list_free(children);
255 }
256 }
257 if (GTK_IS_ENTRY(widget)) {
258 // Set ellipsization for the entry
259 gtk_entry_set_width_chars(GTK_ENTRY(widget), 20); // Adjust this value as needed
260 gtk_entry_set_max_width_chars(GTK_ENTRY(widget), 20); // Adjust this value as needed
261 // Create a PangoLayout for the entry and set ellipsization
262 PangoLayout* layout = gtk_entry_get_layout(GTK_ENTRY(widget));
263 if (layout) {
264 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
265 } else {
266 g_warning("Unable to get PangoLayout from GtkEntry");
267 }
268 } else {
269 g_warning("Expected GtkEntry, but got %s", G_OBJECT_TYPE_NAME(widget));
270 }
271#endif
272}

References ComboBox::GetString(), m_last_selected, and ComboBox::SetSelection().

Referenced by update(), and Slic3r::GUI::TabPresetComboBox::update().

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

◆ validate_selection()

void Slic3r::GUI::PresetComboBox::validate_selection ( bool predicate = false)
protected
221{
222 if (predicate &&
223 // just in case: mark m_last_selected as a first added element
224 m_last_selected == INT_MAX)
226}

References ComboBox::GetCount(), and m_last_selected.

Referenced by add_connected_printers(), Slic3r::GUI::CalibrateFilamentComboBox::update(), Slic3r::GUI::PlaterPresetComboBox::update(), update(), and Slic3r::GUI::TabPresetComboBox::update().

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

Member Data Documentation

◆ drop

◆ drop_down

bool ComboBox::drop_down = false
privateinherited

◆ icon_height

int Slic3r::GUI::PresetComboBox::icon_height
protected

Referenced by fill_width_height(), get_bmp(), and get_bmp().

◆ image_for_text

wxString ComboBox::image_for_text
privateinherited

Referenced by set_replace_text(), and SetLabel().

◆ is_replace_text_to_image

bool ComboBox::is_replace_text_to_image = false
privateinherited

Referenced by set_replace_text(), and SetLabel().

◆ items

◆ m_bitmapCompatible

ScalableBitmap Slic3r::GUI::PresetComboBox::m_bitmapCompatible
protected

◆ m_bitmapIncompatible

ScalableBitmap Slic3r::GUI::PresetComboBox::m_bitmapIncompatible
protected

◆ m_collection

◆ m_em_unit

◆ m_filament_idx

◆ m_first_ams_filament

int Slic3r::GUI::PresetComboBox::m_first_ams_filament = 0
protected

◆ m_first_printer_idx

int Slic3r::GUI::PresetComboBox::m_first_printer_idx = 0
protected

◆ m_keep_drop_arrow

bool ComboBox::m_keep_drop_arrow = false
privateinherited

◆ m_last_ams_filament

int Slic3r::GUI::PresetComboBox::m_last_ams_filament = 0
protected

◆ m_last_printer_idx

int Slic3r::GUI::PresetComboBox::m_last_printer_idx = 0
protected

◆ m_last_selected

◆ m_main_bitmap_name

std::string Slic3r::GUI::PresetComboBox::m_main_bitmap_name
protected

Referenced by PresetComboBox().

◆ m_preset_bundle

◆ m_selected_dev_id

std::string Slic3r::GUI::PresetComboBox::m_selected_dev_id
protected

◆ m_show_all

bool Slic3r::GUI::PresetComboBox::m_show_all { false }
private
46{ false };

Referenced by show_all(), and update().

◆ m_type

◆ norm_icon_width

int Slic3r::GUI::PresetComboBox::norm_icon_width
protected

Referenced by fill_width_height(), get_bmp(), and get_bmp().

◆ on_selection_changed

std::function<void(int)> Slic3r::GUI::PresetComboBox::on_selection_changed { nullptr }
protected

◆ printer_technology

PrinterTechnology Slic3r::GUI::PresetComboBox::printer_technology {ptAny}
protected
157{ptAny};

Referenced by set_printer_technology(), and update().

◆ replace_text

wxString ComboBox::replace_text
privateinherited

Referenced by set_replace_text(), and SetLabel().

◆ space_icon_width

int Slic3r::GUI::PresetComboBox::space_icon_width
protected

Referenced by fill_width_height(), and get_bmp().

◆ text_off

bool ComboBox::text_off = false
privateinherited

Referenced by ComboBox(), GetLabel(), and SetLabel().

◆ thin_icon_width

int Slic3r::GUI::PresetComboBox::thin_icon_width
protected

Referenced by fill_width_height().

◆ thin_space_icon_width

int Slic3r::GUI::PresetComboBox::thin_space_icon_width
protected

Referenced by fill_width_height(), and get_bmp().

◆ wide_icon_width

int Slic3r::GUI::PresetComboBox::wide_icon_width
protected

Referenced by fill_width_height().

◆ wide_space_icon_width

int Slic3r::GUI::PresetComboBox::wide_space_icon_width
protected

Referenced by fill_width_height(), and get_bmp().


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