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

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

Inheritance diagram for Slic3r::GUI::CalibrateFilamentComboBox:
Collaboration diagram for Slic3r::GUI::CalibrateFilamentComboBox:

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

 CalibrateFilamentComboBox (wxWindow *parent)
 ~CalibrateFilamentComboBox ()
void load_tray (DynamicPrintConfig &config)
void update () override
void msw_rescale () override
void OnSelect (wxCommandEvent &evt) override
const Preset * get_selected_preset ()
std::string get_tray_name ()
std::string get_tag_uid ()
bool is_tray_exist ()
bool is_compatible_with_printer ()
wxColor get_color ()
bool switch_to_tab ()
void change_extruder_color ()
void show_add_menu ()
void show_edit_menu ()
wxString get_preset_name (const Preset &preset) override
void update (std::string select_preset)
void update_badge_according_flag ()
void set_sync_badge (bool show)
FilamentColor get_cur_color_info ()
void show_default_color_picker ()
void sync_colour_config (const std::vector< std::string > &clrs, bool is_gradient)
void sys_color_changed () override
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_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)
Preset::Type get_type ()
void show_all (bool show_all)
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)

Public Attributes

ScalableButton * edit_btn { nullptr }
wxButton * clr_picker { nullptr }

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

std::string m_tray_name
std::string m_filament_id
std::string m_tag_uid
std::string m_filament_type
std::string m_filament_color
bool m_filament_exist {false}
bool m_is_compatible {true}
const Preset * m_selected_preset = nullptr
std::map< wxString, std::pair< std::string, wxBitmap * > > m_nonsys_presets
std::map< wxString, std::pair< std::string, wxBitmap * > > m_system_presets
wxColor m_color
bool m_sync_badge {false}
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
protectedinherited

Member Enumeration Documentation

◆ FilamentAMSType

enum Slic3r::GUI::PresetComboBox::FilamentAMSType : unsigned int
inherited
Enumerator
ORIGINAL 
FROM_AMS 
65 :unsigned int {
66 ORIGINAL ,
68 };
@ ORIGINAL
Definition PresetComboBoxes.hpp:66
@ FROM_AMS
Definition PresetComboBoxes.hpp:67

◆ LabelItemType

enum Slic3r::GUI::PresetComboBox::LabelItemType : std::size_t
inherited
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

◆ CalibrateFilamentComboBox()

Slic3r::GUI::CalibrateFilamentComboBox::CalibrateFilamentComboBox ( wxWindow * parent)
1982{
1983 clr_picker->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
1984 clr_picker->SetToolTip("");
1985 clr_picker->Bind(wxEVT_BUTTON, [](wxCommandEvent& e) {});
1986}
wxButton * clr_picker
Definition PresetComboBoxes.hpp:202
PlaterPresetComboBox(wxWindow *parent, Preset::Type preset_type)
Definition PresetComboBoxes.cpp:872
@ TYPE_FILAMENT
Definition Preset.hpp:248
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox(), Slic3r::GUI::PlaterPresetComboBox::clr_picker, and StateColor::darkModeColorFor().

Here is the call graph for this function:

◆ ~CalibrateFilamentComboBox()

Slic3r::GUI::CalibrateFilamentComboBox::~CalibrateFilamentComboBox ( )
1989{
1990}

Member Function Documentation

◆ add_ams_filaments()

bool Slic3r::GUI::PresetComboBox::add_ams_filaments ( std::string selected,
bool alias_name = false )
inherited
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
PresetBundle * m_preset_bundle
Definition PresetComboBoxes.hpp:123
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
PresetCollection * m_collection
Definition PresetComboBoxes.hpp:124
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 )
inherited
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 ( )
staticprotectedinherited
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:

◆ change_extruder_color()

void Slic3r::GUI::PlaterPresetComboBox::change_extruder_color ( )
inherited
1118{
1119 // The Linux sidebar menu edits the same ordered project color as its swatch.
1121}
void show_default_color_picker()
Definition PresetComboBoxes.cpp:1612

References show_default_color_picker().

Referenced by show_edit_menu().

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

◆ clear_selected_dev_id()

void Slic3r::GUI::PresetComboBox::clear_selected_dev_id ( )
inlineinherited
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)
staticinherited
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 ( )
privateinherited
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
ScalableBitmap m_bitmapCompatible
Definition PresetComboBoxes.hpp:130
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 m_em_unit
Definition PresetComboBoxes.hpp:135
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)
protectedinherited
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
Preset::Type m_type
Definition PresetComboBoxes.hpp:120
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 = "" )
protectedinherited
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}
ScalableBitmap m_bitmapIncompatible
Definition PresetComboBoxes.hpp:132
@ TYPE_SLA_MATERIAL
Definition Preset.hpp:249
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 )
protectedinherited
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}
@ TYPE_PRINTER
Definition Preset.hpp:250

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_color()

wxColor Slic3r::GUI::PlaterPresetComboBox::get_color ( )
inlineinherited
204{ return m_color; }
wxColor m_color
Definition PresetComboBoxes.hpp:225

References m_color.

◆ get_cur_color_info()

FilamentColor Slic3r::GUI::PlaterPresetComboBox::get_cur_color_info ( )
inherited
1582{
1583 std::vector<std::string> filaments_multi_color = Slic3r::GUI::wxGetApp().plater()->get_filament_colors_render_info();
1584 std::vector<std::string> filament_color_type = Slic3r::GUI::wxGetApp().plater()->get_filament_color_render_type();
1585
1586 if (m_filament_idx < 0 || m_filament_idx >= static_cast<int>(filaments_multi_color.size())) {
1587 BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": m_filament_idx %1% out of range %2%") % m_filament_idx % filaments_multi_color.size();
1588 return FilamentColor();
1589 }
1590
1591 if (m_filament_idx >= static_cast<int>(filament_color_type.size())) {
1592 BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": m_filament_idx %1% out of range for color_type %2%") % m_filament_idx % filament_color_type.size();
1593 return FilamentColor();
1594 }
1595 std::string filament_color_info = filaments_multi_color[m_filament_idx];
1596 std::vector<std::string> colors;
1597 colors = Slic3r::split_string(filament_color_info, ' ');
1598 FilamentColor fila_color;
1599 for (const std::string& color_str : colors) {
1600 if (!color_str.empty()) {
1601 wxColour color(color_str);
1602 if (color.IsOk()) {
1603 fila_color.m_colors.insert(color);
1604 }
1605 }
1606 }
1607
1608 fila_color.EndSet(filament_color_type[m_filament_idx] == "0" ? 0 : 1);
1609 return fila_color;
1610}
std::vector< std::string > split_string(const std::string &str, char delimiter)
Definition utils.cpp:1424

References Slic3r::FilamentColor::EndSet(), get_cur_color_info(), Slic3r::FilamentColor::m_colors, Slic3r::GUI::PresetComboBox::m_filament_idx, and Slic3r::split_string().

Referenced by PlaterPresetComboBox(), and get_cur_color_info().

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

◆ get_filament_idx()

int Slic3r::GUI::PresetComboBox::get_filament_idx ( ) const
inlineinherited
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)
inherited
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::PlaterPresetComboBox::get_preset_name ( const Preset & preset)
overridevirtualinherited

Reimplemented from Slic3r::GUI::PresetComboBox.

1161{
1162 return from_u8(preset.label(false));
1163}

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

Referenced by Slic3r::GUI::CalibrateFilamentComboBox::load_tray(), Slic3r::GUI::CalibrateFilamentComboBox::update(), 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
inlineinherited
98{ return m_selected_dev_id; }

References m_selected_dev_id.

◆ get_selected_preset()

const Preset * Slic3r::GUI::CalibrateFilamentComboBox::get_selected_preset ( )
inline
273{ return m_selected_preset; }
const Preset * m_selected_preset
Definition PresetComboBoxes.hpp:287

References m_selected_preset.

◆ get_tag_uid()

std::string Slic3r::GUI::CalibrateFilamentComboBox::get_tag_uid ( )
inline
275{ return m_tag_uid; }
std::string m_tag_uid
Definition PresetComboBoxes.hpp:282

References m_tag_uid.

◆ get_tooltip()

wxString Slic3r::GUI::PresetComboBox::get_tooltip ( const Preset & preset)
inherited
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_tray_name()

std::string Slic3r::GUI::CalibrateFilamentComboBox::get_tray_name ( )
inline
274{ return m_tray_name; }
std::string m_tray_name
Definition PresetComboBoxes.hpp:280

References m_tray_name.

◆ get_type()

Preset::Type Slic3r::GUI::PresetComboBox::get_type ( )
inlineinherited
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 ( )
protectedinherited
216{
217 m_last_selected = INT_MAX; // this value means that no one item is selected
218}
int m_last_selected
Definition PresetComboBoxes.hpp:134

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_compatible_with_printer()

bool Slic3r::GUI::CalibrateFilamentComboBox::is_compatible_with_printer ( )
inline
277{ return m_is_compatible; }
bool m_is_compatible
Definition PresetComboBoxes.hpp:286

References m_is_compatible.

◆ 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 ( )
inherited
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 ( )
inherited
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:

◆ is_tray_exist()

bool Slic3r::GUI::CalibrateFilamentComboBox::is_tray_exist ( )
inline
276{ return m_filament_exist; }
bool m_filament_exist
Definition PresetComboBoxes.hpp:285

References m_filament_exist.

◆ 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:

◆ load_tray()

void Slic3r::GUI::CalibrateFilamentComboBox::load_tray ( DynamicPrintConfig & config)
1993{
1994 m_tray_name = config.opt_string("tray_name", 0u);
1995 size_t pos = m_tray_name.find("HT-");
1996 if (pos != std::string::npos) {
1997 m_tray_name = m_tray_name.substr(pos + 3);
1998 }
1999 m_filament_id = config.opt_string("filament_id", 0u);
2000 m_tag_uid = config.opt_string("tag_uid", 0u);
2001 m_filament_type = config.opt_string("filament_type", 0u);
2002 m_filament_color = config.opt_string("filament_colour", 0u);
2003 m_filament_exist = config.opt_bool("filament_exist", 0u);
2004 wxColor clr(m_filament_color);
2005 clr_picker->SetBitmap(*get_extruder_color_icon(m_filament_color, m_tray_name, FromDIP(20), FromDIP(20)));
2006#ifdef __WXOSX__
2007 clr_picker->SetLabel(clr_picker->GetLabel()); // Let setBezelStyle: be called
2008 clr_picker->Refresh();
2009#endif
2010 if (!m_filament_exist) {
2011 SetValue(_L("Empty"));
2012 m_selected_preset = nullptr;
2013 m_is_compatible = false;
2014 clr_picker->SetBitmap(*get_extruder_color_icon("#F0F0F0FF", m_tray_name, FromDIP(20), FromDIP(20)));
2015 } else {
2016 auto &filaments = m_collection->get_presets();
2017 auto iter = std::find_if(filaments.begin(), filaments.end(), [this](auto &f) {
2018 if (!f.is_system) // Only match system preset
2019 return false;
2020 bool is_compatible = m_preset_bundle->calibrate_filaments.find(&f) != m_preset_bundle->calibrate_filaments.end();
2021 return is_compatible && f.filament_id == m_filament_id;
2022 });
2023
2024 // Prioritize matching system presets. If there are no system presets, match all presets.
2025 if (iter == filaments.end()) {
2026 iter = std::find_if(filaments.begin(), filaments.end(), [this](auto &f) {
2027 if (f.is_system) // Only match system preset
2028 return false;
2029 bool is_compatible = m_preset_bundle->calibrate_filaments.find(&f) != m_preset_bundle->calibrate_filaments.end();
2030 return is_compatible && f.filament_id == m_filament_id;
2031 });
2032 }
2033 //if (iter == filaments.end() && !m_filament_type.empty()) {
2034 // auto filament_type = "Generic " + m_filament_type;
2035 // iter = std::find_if(filaments.begin(), filaments.end(),
2036 // [this , &filament_type](auto &f) {
2037 // bool is_compatible = m_preset_bundle->calibrate_filaments.find(&f) != m_preset_bundle->calibrate_filaments.end();
2038 // return is_compatible && f.is_system && boost::algorithm::starts_with(f.name, filament_type); });
2039 //}
2040 if (iter != filaments.end()) {
2041 m_selected_preset = &*iter;
2042 m_is_compatible = true;
2043 SetValue(get_preset_name(*iter));
2044 }
2045 else {
2046 m_selected_preset = nullptr;
2047 m_is_compatible = false;
2048 SetValue(_L("Incompatible"));
2049 }
2050 Enable();
2051 }
2052}
void SetValue(const wxString &value)
Definition ComboBox.cpp:145
std::string m_filament_color
Definition PresetComboBoxes.hpp:284
std::string m_filament_id
Definition PresetComboBoxes.hpp:281
std::string m_filament_type
Definition PresetComboBoxes.hpp:283
wxString get_preset_name(const Preset &preset) override
Definition PresetComboBoxes.cpp:1160
@ Enable
Definition Config.hpp:245

References _L, Slic3r::GUI::PlaterPresetComboBox::clr_picker, Slic3r::Enable, Slic3r::f(), get_extruder_color_icon(), Slic3r::GUI::PlaterPresetComboBox::get_preset_name(), Slic3r::GUI::PresetComboBox::m_collection, m_filament_color, m_filament_exist, m_filament_id, m_filament_type, m_is_compatible, m_selected_preset, m_tag_uid, m_tray_name, Slic3r::DynamicConfig::opt_bool(), Slic3r::DynamicConfig::opt_string(), and ComboBox::SetValue().

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::CalibrateFilamentComboBox::msw_rescale ( )
overridevirtual

Reimplemented from Slic3r::GUI::PresetComboBox.

2128{
2129 if (clr_picker) {
2130 clr_picker->SetSize(FromDIP(20), FromDIP(20));
2131 clr_picker->SetBitmap(*get_extruder_color_icon(m_filament_color, m_tray_name, FromDIP(20), FromDIP(20)));
2132 }
2133 // BBS
2134 if (edit_btn != nullptr)
2135 edit_btn->msw_rescale();
2136}
ScalableButton * edit_btn
Definition PresetComboBoxes.hpp:199

References Slic3r::GUI::PlaterPresetComboBox::clr_picker, Slic3r::GUI::PlaterPresetComboBox::edit_btn, get_extruder_color_icon(), m_filament_color, and m_tray_name.

Here is the call graph for this function:

◆ OnEdit()

void ComboBox::OnEdit ( )
overrideprotectedinherited
468{
469 auto value = GetTextCtrl()->GetValue();
470 SetValue(value);
471}

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::CalibrateFilamentComboBox::OnSelect ( wxCommandEvent & evt)
overridevirtual

Reimplemented from Slic3r::GUI::PresetComboBox.

2139{
2140 auto marker = reinterpret_cast<Marker>(this->GetClientData(evt.GetSelection()));
2141 if (marker >= LABEL_ITEM_DISABLED && marker < LABEL_ITEM_MAX) {
2142 this->SetSelection(evt.GetSelection() + 1);
2143 wxCommandEvent event(wxEVT_COMBOBOX);
2144 event.SetInt(evt.GetSelection() + 1);
2145 event.SetString(GetString(evt.GetSelection() + 1));
2146 wxPostEvent(this, event);
2147 return;
2148 }
2149 m_is_compatible = true;
2150 static_cast<FilamentComboBox*>(m_parent)->Enable(true);
2151
2152 wxString display_name = evt.GetString();
2153 std::string preset_name;
2154 if (m_system_presets.find(evt.GetString()) != m_system_presets.end()) {
2155 preset_name = m_system_presets.at(display_name).first;
2156 }
2157 else if (m_nonsys_presets.find(evt.GetString()) != m_nonsys_presets.end()) {
2158 preset_name = m_nonsys_presets.at(display_name).first;
2159 }
2160 m_selected_preset = m_collection->find_preset(preset_name);
2161
2162 // if the selected preset is null, do not send tray_change event
2163 if (!m_selected_preset) {
2164 MessageDialog msg_dlg(nullptr, _L("The selected preset is null!"), wxEmptyString, wxICON_WARNING | wxOK);
2165 msg_dlg.ShowModal();
2166 return;
2167 }
2168
2169 wxCommandEvent e(EVT_CALI_TRAY_CHANGED);
2170 e.SetEventObject(m_parent);
2171 wxPostEvent(m_parent, e);
2172}
std::map< wxString, std::pair< std::string, wxBitmap * > > m_system_presets
Definition PresetComboBoxes.hpp:289
std::map< wxString, std::pair< std::string, wxBitmap * > > m_nonsys_presets
Definition PresetComboBoxes.hpp:288

References _L, Slic3r::Enable, ComboBox::GetString(), Slic3r::GUI::PresetComboBox::LABEL_ITEM_DISABLED, Slic3r::GUI::PresetComboBox::LABEL_ITEM_MAX, Slic3r::GUI::PresetComboBox::m_collection, m_is_compatible, m_nonsys_presets, m_selected_preset, m_system_presets, ComboBox::SetSelection(), and Slic3r::GUI::DPIAware< P >::ShowModal().

Here is the call 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
inherited
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
inherited
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 ( )
inherited
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
virtual void update()
Definition PresetComboBoxes.cpp:510

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)
staticprotectedinherited
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 ( )
inlinestaticprotectedinherited
170{ return "--"; }

Referenced by separator().

Here is the caller graph for this function:

◆ separator_tail()

const char * Slic3r::GUI::PresetComboBox::separator_tail ( )
inlinestaticprotectedinherited
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)
inlineinherited
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 )
inherited
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)
inherited
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)
inlineinherited
73{ on_selection_changed = sel_changed; }
std::function< void(int)> on_selection_changed
Definition PresetComboBoxes.hpp:118

References on_selection_changed.

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

Here is the caller graph for this function:

◆ set_sync_badge()

void Slic3r::GUI::PlaterPresetComboBox::set_sync_badge ( bool show)
inherited
1057{
1058 m_sync_badge = show;
1059 ShowBadge(show);
1060}
bool m_sync_badge
Definition PresetComboBoxes.hpp:226

References m_sync_badge.

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

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_add_menu()

void Slic3r::GUI::PlaterPresetComboBox::show_add_menu ( )
inherited
1124{
1125 wxMenu* menu = new wxMenu();
1126
1127 append_menu_item(menu, wxID_ANY, _L("Add/Remove presets"), "",
1128 [](wxCommandEvent&) {
1129 wxTheApp->CallAfter([]() { run_wizard(ConfigWizard::SP_PRINTERS); });
1130 }, "menu_edit_preset", menu, []() { return true; }, wxGetApp().plater());
1131
1132 wxGetApp().plater()->PopupMenu(menu);
1133}
@ SP_PRINTERS
Definition ConfigWizard.hpp:33
static void run_wizard(ConfigWizard::StartPage sp)
Definition PresetComboBoxes.cpp:1008
wxMenuItem * append_menu_item(wxMenu *menu, int id, const wxString &string, const wxString &description, std::function< void(wxCommandEvent &event)> cb, const wxBitmap &icon, wxEvtHandler *event_handler, std::function< bool()> const cb_condition, wxWindow *parent, int insert_pos)
Definition wxExtensions.cpp:89

References _L, append_menu_item(), Slic3r::GUI::run_wizard(), and Slic3r::GUI::ConfigWizard::SP_PRINTERS.

Here is the call graph for this function:

◆ show_all()

void Slic3r::GUI::PresetComboBox::show_all ( bool show_all)
inherited
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:

◆ show_default_color_picker()

void Slic3r::GUI::PlaterPresetComboBox::show_default_color_picker ( )
inherited
1613{
1614 const auto value = filament_color_picker_value(wxGetApp().preset_bundle->project_config, m_filament_idx);
1615 const auto initial = filament_color_picker_initial(value);
1616 ColorPickerDialog dialog(this, initial, {true, true}, !filament_color_picker_selection(value), clr_picker);
1617 if (dialog.ShowModal() == wxID_OK && filament_color_picker_changed(initial, dialog.selection())) {
1618 const auto selected = filament_color_picker_result(*dialog.selection());
1619 sync_colour_config(selected.colors, selected.gradient);
1620 }
1621}
void sync_colour_config(const std::vector< std::string > &clrs, bool is_gradient)
Definition PresetComboBoxes.cpp:1623
static FilamentColorPickerValue filament_color_picker_value(const DynamicPrintConfig &config, std::size_t index)
Definition PresetComboBoxes.cpp:88
FilamentColorPickerValue filament_color_picker_result(const ColorSelection &selection)
Definition ColorPickerDialog.cpp:259
bool filament_color_picker_changed(const ColorSelection &initial, const std::optional< ColorSelection > &result)
Definition ColorPickerDialog.cpp:273
std::optional< ColorSelection > filament_color_picker_selection(const FilamentColorPickerValue &value)
Definition ColorPickerDialog.cpp:241
ColorSelection filament_color_picker_initial(const FilamentColorPickerValue &value)
Definition ColorPickerDialog.cpp:246

References clr_picker, Slic3r::GUI::filament_color_picker_changed(), Slic3r::GUI::filament_color_picker_initial(), Slic3r::GUI::filament_color_picker_result(), Slic3r::GUI::filament_color_picker_selection(), Slic3r::GUI::filament_color_picker_value(), Slic3r::GUI::PresetComboBox::m_filament_idx, show_default_color_picker(), and sync_colour_config().

Referenced by PlaterPresetComboBox(), change_extruder_color(), and show_default_color_picker().

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

◆ show_edit_menu()

void Slic3r::GUI::PlaterPresetComboBox::show_edit_menu ( )
inherited
1136{
1137 wxMenu* menu = new wxMenu();
1138
1139 append_menu_item(menu, wxID_ANY, _L("Edit preset"), "",
1140 [this](wxCommandEvent&) { this->switch_to_tab(); }, "cog", menu, []() { return true; }, wxGetApp().plater());
1141
1142#ifdef __linux__
1143 // To edit extruder color from the sidebar
1145 append_menu_item(menu, wxID_ANY, _L("Change extruder color"), "",
1146 [this](wxCommandEvent&) { this->change_extruder_color(); }, "blank_14", menu, []() { return true; }, wxGetApp().plater());
1147 wxGetApp().plater()->PopupMenu(menu);
1148 return;
1149 }
1150#endif //__linux__
1151
1152 append_menu_item(menu, wxID_ANY, _L("Add/Remove presets"), "",
1153 [](wxCommandEvent&) {
1154 wxTheApp->CallAfter([]() { run_wizard(ConfigWizard::SP_PRINTERS); });
1155 }, "menu_edit_preset", menu, []() { return true; }, wxGetApp().plater());
1156
1157 wxGetApp().plater()->PopupMenu(menu);
1158}
void change_extruder_color()
Definition PresetComboBoxes.cpp:1117
bool switch_to_tab()
Definition PresetComboBoxes.cpp:1062

References _L, append_menu_item(), change_extruder_color(), Slic3r::GUI::PresetComboBox::m_type, Slic3r::GUI::run_wizard(), Slic3r::GUI::ConfigWizard::SP_PRINTERS, switch_to_tab(), and Slic3r::Preset::TYPE_FILAMENT.

Referenced by PlaterPresetComboBox().

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

◆ switch_to_tab()

bool Slic3r::GUI::PlaterPresetComboBox::switch_to_tab ( )
inherited
1063{
1064 Tab* tab = wxGetApp().get_tab(m_type);
1065 if (!tab)
1066 return false;
1067
1068 const Preset* selected_filament_preset = nullptr;
1070 {
1071 const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data();
1072 if (!boost::algorithm::starts_with(selected_preset, Preset::suffix_modified()))
1073 {
1074 const std::string& preset_name = wxGetApp().preset_bundle->filaments.get_preset_name_by_alias(selected_preset);
1075 if (wxGetApp().get_tab(m_type)->select_preset(preset_name))
1076 wxGetApp().get_tab(m_type)->get_combo_box()->set_filament_idx(m_filament_idx);
1077 else {
1078 return false;
1079 }
1080 }
1081 }
1082
1083 /*
1084 if (int page_id = wxGetApp().tab_panel()->FindPage(tab); page_id != wxNOT_FOUND)
1085 {
1086 wxGetApp().tab_panel()->SetSelection(page_id);
1087 // Switch to Settings NotePad
1088 wxGetApp().mainframe->select_tab();
1089
1090 //In a case of a multi-material printing, for editing another Filament Preset
1091 //it's needed to select this preset for the "Filament settings" Tab
1092 if (m_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1)
1093 {
1094 const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data();
1095 // Call select_preset() only if there is new preset and not just modified
1096 if (!boost::algorithm::ends_with(selected_preset, Preset::suffix_modified()))
1097 {
1098 const std::string& preset_name = wxGetApp().preset_bundle->filaments.get_preset_name_by_alias(selected_preset);
1099 wxGetApp().get_tab(m_type)->select_preset(preset_name);
1100 }
1101 }
1102 }
1103 */
1104
1105 //BBS Select NoteBook Tab params
1106 if (tab->GetParent() == wxGetApp().params_panel())
1107 wxGetApp().mainframe->select_tab(TAB_ID_PREPARE);
1108 else {
1109 wxGetApp().params_dialog()->Popup();
1110 tab->OnActivate();
1111 }
1112 tab->restore_last_select_item();
1113
1114 return true;
1115}
#define TAB_ID_PREPARE
Definition MainFrame.hpp:60
static const std::string & suffix_modified()
Definition Preset.cpp:505

References ComboBox::GetSelection(), ComboBox::GetString(), Slic3r::GUI::PresetComboBox::m_filament_idx, Slic3r::GUI::PresetComboBox::m_type, Slic3r::GUI::Tab::OnActivate(), Slic3r::GUI::Tab::restore_last_select_item(), Slic3r::Preset::suffix_modified(), TAB_ID_PREPARE, and Slic3r::Preset::TYPE_FILAMENT.

Referenced by PlaterPresetComboBox(), Slic3r::GUI::Sidebar::init_filament_combo(), and show_edit_menu().

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

◆ sync_colour_config()

void Slic3r::GUI::PlaterPresetComboBox::sync_colour_config ( const std::vector< std::string > & clrs,
bool is_gradient )
inherited
1624{
1625 DynamicPrintConfig *cfg = &wxGetApp().preset_bundle->project_config;
1626
1627 // Clone the string vector and patch the value at current extruder index.
1628 auto multi_colour_opt = static_cast<ConfigOptionStrings *>(cfg->option("filament_multi_colour")->clone());
1629 auto colour_type_opt = static_cast<ConfigOptionStrings *>(cfg->option("filament_colour_type")->clone());
1630 auto colour_opt = static_cast<ConfigOptionStrings *>(cfg->option("filament_colour")->clone());
1631
1632 if (m_filament_idx >= multi_colour_opt->values.size()) multi_colour_opt->values.resize(m_filament_idx + 1);
1633 if (m_filament_idx >= colour_type_opt->values.size()) colour_type_opt->values.resize(m_filament_idx + 1);
1634 if (m_filament_idx >= colour_opt->values.size()) colour_opt->values.resize(m_filament_idx + 1);
1635
1636 std::string clr_str = "";
1637 for(auto &clr : clrs) {
1638 clr_str += clr + " ";
1639 }
1640 clr_str.pop_back();
1641
1642 multi_colour_opt->values[m_filament_idx] = clr_str;
1643 colour_opt->values[m_filament_idx] = clrs[0];
1644 colour_type_opt->values[m_filament_idx] = is_gradient ? "0" : "1";
1645 DynamicPrintConfig cfg_new = *cfg;
1646 cfg_new.set_key_value("filament_multi_colour", multi_colour_opt);
1647 cfg_new.set_key_value("filament_colour", colour_opt);
1648 cfg_new.set_key_value("filament_colour_type", colour_type_opt);
1649 cfg->apply(cfg_new);
1650
1651 wxGetApp().plater()->update_project_dirty_from_presets();
1652
1653 wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
1654 update(); // refresh the preset combobox with new config
1655
1656 wxGetApp().plater()->on_config_change(cfg_new);
1657}
void update() override
Definition PresetComboBoxes.cpp:1167

References Slic3r::ConfigBase::apply(), Slic3r::GUI::PresetComboBox::m_filament_idx, Slic3r::ConfigBase::option(), Slic3r::DynamicConfig::set_key_value(), sync_colour_config(), update(), and Slic3r::ConfigOptionVector< T >::values.

Referenced by PlaterPresetComboBox(), show_default_color_picker(), and sync_colour_config().

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

◆ sys_color_changed()

void Slic3r::GUI::PlaterPresetComboBox::sys_color_changed ( )
overridevirtualinherited

Reimplemented from Slic3r::GUI::PresetComboBox.

2175{
2177 if (clr_picker) {
2178 clr_picker->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
2179 }
2180}
virtual void sys_color_changed()
Definition PresetComboBoxes.cpp:665

References clr_picker, StateColor::darkModeColorFor(), and Slic3r::GUI::PresetComboBox::sys_color_changed().

Referenced by Slic3r::GUI::Sidebar::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::CalibrateFilamentComboBox::update ( )
overridevirtual

Reimplemented from Slic3r::GUI::PresetComboBox.

2055{
2056 if (m_preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA)
2057 return;
2058
2059 // Otherwise fill in the list from scratch.
2060 this->Freeze();
2061 this->Clear();
2063
2064 const Preset* selected_filament_preset = nullptr;
2065
2066 m_nonsys_presets.clear();
2067 m_system_presets.clear();
2068
2069 wxString selected_preset = m_selected_preset ? get_preset_name(*m_selected_preset) : GetValue();
2070
2071 wxString tooltip;
2072 const std::deque<Preset>& presets = m_collection->get_presets();
2073
2074 for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
2075 {
2076 const Preset& preset = presets[i];
2077 auto display_name = get_preset_name(preset);
2078 bool is_selected = m_selected_preset == &preset;
2079 if (m_preset_bundle->calibrate_filaments.empty()) {
2080 Thaw();
2081 return;
2082 }
2083 bool is_compatible = m_preset_bundle->calibrate_filaments.find(&preset) != m_preset_bundle->calibrate_filaments.end();
2084 ;
2085 if (!preset.is_visible || (!is_compatible && !is_selected))
2086 continue;
2087
2088 if (is_selected) {
2089 tooltip = get_tooltip(preset);
2090 }
2091
2092 wxBitmap* bmp = get_bmp(preset);
2093 assert(bmp);
2094
2095 if (preset.is_default || preset.is_system) {
2096 m_system_presets.emplace(display_name, std::make_pair( preset.name, bmp ));
2097 }
2098 else {
2099 m_nonsys_presets.emplace(display_name, std::make_pair( preset.name, bmp ));
2100 }
2101
2102 }
2103
2104 if (!m_nonsys_presets.empty())
2105 {
2106 set_label_marker(Append(_L("User presets"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
2107 for (auto it = m_nonsys_presets.begin(); it != m_nonsys_presets.end(); ++it) {
2108 Append(it->first, *(it->second.second));
2109 validate_selection(it->first == selected_preset);
2110 }
2111 }
2112 if (!m_system_presets.empty())
2113 {
2114 set_label_marker(Append(_L("System presets"), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
2115 for (auto it = m_system_presets.begin(); it != m_system_presets.end(); ++it) {
2116 Append(it->first, *(it->second.second));
2117 validate_selection(it->first == selected_preset);
2118 }
2119 }
2120
2122 Thaw();
2123
2124 SetToolTip(NULL);
2125}
wxString GetValue() const
Definition ComboBox.cpp:140
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
wxString get_tooltip(const Preset &preset)
Definition PresetComboBoxes.cpp:346
@ ptSLA
Definition Config.hpp:233

References _L, ComboBox::Append(), DD_ITEM_STYLE_SPLIT_ITEM, Slic3r::GUI::PresetComboBox::get_bmp(), Slic3r::GUI::PlaterPresetComboBox::get_preset_name(), Slic3r::GUI::PresetComboBox::get_tooltip(), ComboBox::GetValue(), Slic3r::GUI::PresetComboBox::invalidate_selection(), Slic3r::Preset::is_default, Slic3r::Preset::is_system, Slic3r::Preset::is_visible, Slic3r::GUI::PresetComboBox::m_collection, m_nonsys_presets, Slic3r::GUI::PresetComboBox::m_preset_bundle, m_selected_preset, m_system_presets, Slic3r::Preset::name, Slic3r::ptSLA, Slic3r::GUI::PresetComboBox::set_label_marker(), Slic3r::GUI::update_selection(), and Slic3r::GUI::PresetComboBox::validate_selection().

Here is the call graph for this function:

◆ update() [2/2]

void Slic3r::GUI::PresetComboBox::update ( std::string select_preset)
inherited
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}
@ 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 ( )
protectedinherited
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
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_badge_according_flag()

void Slic3r::GUI::PlaterPresetComboBox::update_badge_according_flag ( )
inherited
1049 {
1050 auto selection = GetSelection();
1051 auto select_flag = GetFlag(selection);
1052 auto ok = select_flag == (int) PresetComboBox::FilamentAMSType::FROM_AMS;
1053 ShowBadge(m_sync_badge || ok);
1054}
int GetFlag(unsigned int n)
Definition ComboBox.cpp:196

References Slic3r::GUI::PresetComboBox::FROM_AMS, ComboBox::GetFlag(), ComboBox::GetSelection(), and m_sync_badge.

Here is the call graph for this function:

◆ update_from_bundle()

void Slic3r::GUI::PresetComboBox::update_from_bundle ( )
inherited
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 ( )
protectedinherited
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)
protectedinherited
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

◆ clr_picker

◆ drop

◆ drop_down

bool ComboBox::drop_down = false
privateinherited

◆ edit_btn

◆ icon_height

int Slic3r::GUI::PresetComboBox::icon_height
protectedinherited

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
protectedinherited

◆ m_bitmapIncompatible

ScalableBitmap Slic3r::GUI::PresetComboBox::m_bitmapIncompatible
protectedinherited

◆ m_collection

◆ m_color

wxColor Slic3r::GUI::PlaterPresetComboBox::m_color
privateinherited

Referenced by get_color().

◆ m_em_unit

◆ m_filament_color

std::string Slic3r::GUI::CalibrateFilamentComboBox::m_filament_color
private

Referenced by load_tray(), and msw_rescale().

◆ m_filament_exist

bool Slic3r::GUI::CalibrateFilamentComboBox::m_filament_exist {false}
private
285{false};

Referenced by is_tray_exist(), and load_tray().

◆ m_filament_id

std::string Slic3r::GUI::CalibrateFilamentComboBox::m_filament_id
private

Referenced by load_tray().

◆ m_filament_idx

◆ m_filament_type

std::string Slic3r::GUI::CalibrateFilamentComboBox::m_filament_type
private

Referenced by load_tray().

◆ m_first_ams_filament

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

◆ m_first_printer_idx

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

◆ m_is_compatible

bool Slic3r::GUI::CalibrateFilamentComboBox::m_is_compatible {true}
private
286{true};

Referenced by is_compatible_with_printer(), load_tray(), and OnSelect().

◆ 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
protectedinherited

◆ m_last_printer_idx

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

◆ m_last_selected

◆ m_main_bitmap_name

std::string Slic3r::GUI::PresetComboBox::m_main_bitmap_name
protectedinherited

Referenced by PresetComboBox().

◆ m_nonsys_presets

std::map<wxString, std::pair<std::string, wxBitmap*> > Slic3r::GUI::CalibrateFilamentComboBox::m_nonsys_presets
private

Referenced by OnSelect(), and update().

◆ m_preset_bundle

◆ m_selected_dev_id

std::string Slic3r::GUI::PresetComboBox::m_selected_dev_id
protectedinherited

◆ m_selected_preset

const Preset* Slic3r::GUI::CalibrateFilamentComboBox::m_selected_preset = nullptr
private

◆ m_show_all

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

Referenced by show_all(), and update().

◆ m_sync_badge

bool Slic3r::GUI::PlaterPresetComboBox::m_sync_badge {false}
privateinherited
226{false};

Referenced by set_sync_badge(), and update_badge_according_flag().

◆ m_system_presets

std::map<wxString, std::pair<std::string, wxBitmap*> > Slic3r::GUI::CalibrateFilamentComboBox::m_system_presets
private

Referenced by OnSelect(), and update().

◆ m_tag_uid

std::string Slic3r::GUI::CalibrateFilamentComboBox::m_tag_uid
private

Referenced by get_tag_uid(), and load_tray().

◆ m_tray_name

std::string Slic3r::GUI::CalibrateFilamentComboBox::m_tray_name
private

◆ m_type

◆ norm_icon_width

int Slic3r::GUI::PresetComboBox::norm_icon_width
protectedinherited

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

◆ on_selection_changed

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

◆ printer_technology

PrinterTechnology Slic3r::GUI::PresetComboBox::printer_technology {ptAny}
protectedinherited
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
protectedinherited

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
protectedinherited

Referenced by fill_width_height().

◆ thin_space_icon_width

int Slic3r::GUI::PresetComboBox::thin_space_icon_width
protectedinherited

Referenced by fill_width_height(), and get_bmp().

◆ wide_icon_width

int Slic3r::GUI::PresetComboBox::wide_icon_width
protectedinherited

Referenced by fill_width_height().

◆ wide_space_icon_width

int Slic3r::GUI::PresetComboBox::wide_space_icon_width
protectedinherited

Referenced by fill_width_height(), and get_bmp().


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