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

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

Inheritance diagram for Slic3r::GUI::PlaterPresetComboBox:
Collaboration diagram for Slic3r::GUI::PlaterPresetComboBox:

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

 PlaterPresetComboBox (wxWindow *parent, Preset::Type preset_type)
 ~PlaterPresetComboBox ()
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 () override
void msw_rescale () override
void OnSelect (wxCommandEvent &evt) override
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 (std::string select_preset)
void update_from_bundle ()
void add_connected_printers (std::string selected, bool alias_name=false)
int selected_connected_printer () const
bool add_ams_filaments (std::string selected, bool alias_name=false)
int selected_ams_filament () const
void set_filament_idx (const int extr_idx)
int get_filament_idx () const
std::string get_selected_dev_id () const
void clear_selected_dev_id ()
wxString get_tooltip (const Preset &preset)
wxString get_preset_item_name (unsigned int index)
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

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

◆ PlaterPresetComboBox()

Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox ( wxWindow * parent,
Preset::Type preset_type )
872 :
873 PresetComboBox(parent, preset_type, wxSize(25 * wxGetApp().em_unit(), 30 * wxGetApp().em_unit() / 10))
874{
875 GetDropDown().SetUseContentWidth(true,true);
876
878 {
879 // BBS: not show color picker
880#if 0
881 Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) {
882 const Preset* selected_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_filament_idx]);
883 // Wide icons are shown if the currently selected preset is not compatible with the current printer,
884 // and red flag is drown in front of the selected preset.
885 bool wide_icons = selected_preset && !selected_preset->is_compatible;
886 float scale = m_em_unit*0.1f;
887
888 int shifl_Left = wide_icons ? int(scale * 16 + 0.5) : 0;
889#if defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
890 shifl_Left += int(scale * 4 + 0.5f); // IMAGE_SPACING_RIGHT = 4 for wxBitmapComboBox -> Space left of image
891#endif
892 int icon_right_pos = shifl_Left + int(scale * (24+4) + 0.5);
893 int mouse_pos = event.GetLogicalPosition(wxClientDC(this)).x;
894 if (mouse_pos < shifl_Left || mouse_pos > icon_right_pos ) {
895 // Let the combo box process the mouse click.
896 event.Skip();
897 return;
898 }
899
900 // BBS
901 // Swallow the mouse click and open the color picker.
902 //change_extruder_color();
903 });
904#endif
905 }
906
907 // BBS
909 int em = wxGetApp().em_unit();
910 clr_picker = new wxBitmapButton(parent, wxID_ANY, {}, wxDefaultPosition, wxSize(FromDIP(20), FromDIP(20)), wxBU_EXACTFIT | wxBU_AUTODRAW | wxBORDER_NONE);
911 clr_picker->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
912 clr_picker->SetToolTip(_L("Click to select filament color"));
913#ifdef __WXGTK__
914 RemoveButtonBorder(clr_picker);
915#endif
916 clr_picker->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
917 // Check if it's an official filament
918 auto fila_type = Preset::remove_suffix_modified(GetValue().ToUTF8().data());
919 bool is_official = boost::algorithm::starts_with(fila_type, "Bambu");
920 if (is_official) {
921 // Get filament_id from filament_presets. FilamentPickerDialog looks up
922 // filaments_color_codes.json, which is downloaded from Bambu and keyed by the
923 // printer's own ids, so translate our OF id (the "GFA00" fallback is already one).
924 const std::string& preset_name = m_preset_bundle->filament_presets[m_filament_idx];
925 const Preset* selected_preset = m_collection->find_preset(preset_name);
926 auto* agent = wxGetApp().getAgent();
927 wxString fila_id = "GFA00";
928 if (selected_preset)
929 fila_id = wxString::FromUTF8(agent ? agent->from_orca_filament_id(selected_preset->filament_id) : selected_preset->filament_id);
930 FilamentColor fila_color = get_cur_color_info();
931
932 // Show filament picker dialog
933 FilamentPickerDialog dialog(this, fila_id, fila_color, fila_type,
935
936 if (!dialog.IsDataLoaded()) {
937 // If FilamentPicker fails, fallback to default color picker
939 } else if (dialog.ShowModal() == wxID_OK && dialog.HasSelectionChanged()) {
940 if (const auto& custom = dialog.GetCustomColorSelection()) {
941 const auto value = filament_color_picker_result(*custom);
942 sync_colour_config(value.colors, value.gradient);
943 } else {
944 // Get selected filament color data
945 FilamentColor fila_color = dialog.GetSelectedFilamentColor();
946
947 // Check if we have valid color data
948 if (!fila_color.m_colors.empty()) {
949 // Convert to storage format
950 std::vector<std::string> colors;
951 for (const wxColour& color : fila_color.m_colors) {
952 colors.push_back(color.GetAsString(wxC2S_HTML_SYNTAX).ToStdString());
953 }
954
955 bool is_gradient = (fila_color.m_color_type == FilamentColor::ColorType::GRADIENT_CLR);
956 this->sync_colour_config(colors, is_gradient);
957 } else {
958 // Fallback to basic color if no FilamentColor data
959 wxColour selected_color = dialog.GetSelectedColour();
960 if (selected_color.IsOk()) {
961 std::vector<std::string> color = {selected_color.GetAsString(wxC2S_HTML_SYNTAX).ToStdString()};
962 this->sync_colour_config(color, false);
963 }
964 }
965 }
966 }
967 } else {
969 }
970 wxCommandEvent *evt = new wxCommandEvent(EVT_FILAMENT_COLOR_CHANGED);
971 evt->SetInt(m_filament_idx);
972 wxQueueEvent(wxGetApp().plater(), evt);
973 });
974 }
975 else {
976 edit_btn = new ScalableButton(parent, wxID_ANY, "cog");
977 edit_btn->SetToolTip(_L("Click to edit preset"));
978
979 edit_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent)
980 {
981 // In a case of a physical printer, for its editing open PhysicalPrinterDialog
983#ifdef __linux__
984 // To edit extruder color from the sidebar
986#endif //__linux__
987 )
989 else
991 });
992#ifdef __linux__
993 edit_btn->Hide();
994#endif //__linux__
995 }
996}
#define _L(s)
Definition OBJ.cpp:34
int scale(const int val)
Definition WipeTowerDialog.cpp:58
DropDown & GetDropDown()
Definition ComboBox.hpp:43
wxString GetValue() const
Definition ComboBox.cpp:140
void SetUseContentWidth(bool use, bool limit_max_content_width=false)
Definition DropDown.cpp:165
void show_default_color_picker()
Definition PresetComboBoxes.cpp:1612
ScalableButton * edit_btn
Definition PresetComboBoxes.hpp:199
FilamentColor get_cur_color_info()
Definition PresetComboBoxes.cpp:1581
void show_edit_menu()
Definition PresetComboBoxes.cpp:1135
wxButton * clr_picker
Definition PresetComboBoxes.hpp:202
void sync_colour_config(const std::vector< std::string > &clrs, bool is_gradient)
Definition PresetComboBoxes.cpp:1623
bool switch_to_tab()
Definition PresetComboBoxes.cpp:1062
PresetBundle * m_preset_bundle
Definition PresetComboBoxes.hpp:123
PresetComboBox(wxWindow *parent, Preset::Type preset_type, const wxSize &size=wxDefaultSize, PresetBundle *preset_bundle=nullptr)
Definition PresetComboBoxes.cpp:123
int m_filament_idx
Definition PresetComboBoxes.hpp:138
Preset::Type m_type
Definition PresetComboBoxes.hpp:120
int m_em_unit
Definition PresetComboBoxes.hpp:135
PresetCollection * m_collection
Definition PresetComboBoxes.hpp:124
static std::string remove_suffix_modified(const std::string &name)
Definition Preset.cpp:516
@ TYPE_PRINTER
Definition Preset.hpp:250
@ TYPE_FILAMENT
Definition Preset.hpp:248
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
wxMouseEvent
Definition CameraPopup.cpp:47
static FilamentColorPickerValue filament_color_picker_value(const DynamicPrintConfig &config, std::size_t index)
Definition PresetComboBoxes.cpp:88
static Plater * plater()
Definition GUI_Factories.cpp:400
FilamentColorPickerValue filament_color_picker_result(const ColorSelection &selection)
Definition ColorPickerDialog.cpp:259
@ Preset
Definition calib.hpp:39
@ GRADIENT_CLR
Definition EncodedFilament.hpp:82
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424

References Slic3r::GUI::PresetComboBox::PresetComboBox(), _L, clr_picker, StateColor::darkModeColorFor(), edit_btn, em_unit(), Slic3r::GUI::filament_color_picker_result(), Slic3r::GUI::filament_color_picker_value(), Slic3r::Preset::filament_id, get_cur_color_info(), Slic3r::GUI::FilamentPickerDialog::GetCustomColorSelection(), ComboBox::GetDropDown(), Slic3r::GUI::FilamentPickerDialog::GetSelectedColour(), Slic3r::GUI::FilamentPickerDialog::GetSelectedFilamentColor(), ComboBox::GetValue(), Slic3r::FilamentColor::GRADIENT_CLR, Slic3r::GUI::FilamentPickerDialog::HasSelectionChanged(), Slic3r::Preset::is_compatible, Slic3r::GUI::FilamentPickerDialog::IsDataLoaded(), Slic3r::GUI::PresetComboBox::m_collection, Slic3r::FilamentColor::m_color_type, Slic3r::FilamentColor::m_colors, Slic3r::GUI::PresetComboBox::m_em_unit, Slic3r::GUI::PresetComboBox::m_filament_idx, Slic3r::GUI::PresetComboBox::m_preset_bundle, Slic3r::GUI::PresetComboBox::m_type, Slic3r::GUI::plater(), Slic3r::Preset::remove_suffix_modified(), scale(), DropDown::SetUseContentWidth(), show_default_color_picker(), show_edit_menu(), Slic3r::GUI::DPIAware< P >::ShowModal(), switch_to_tab(), sync_colour_config(), Slic3r::Preset::TYPE_FILAMENT, Slic3r::Preset::TYPE_PRINTER, and Slic3r::GUI::wxMouseEvent.

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

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

◆ ~PlaterPresetComboBox()

Slic3r::GUI::PlaterPresetComboBox::~PlaterPresetComboBox ( )
999{
1000 if (edit_btn)
1001 edit_btn->Destroy();
1002
1003 // BBS.
1004 if (clr_picker)
1005 clr_picker->Destroy();
1006}

References clr_picker, and edit_btn.

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
void SetFlag(unsigned int n, int value)
Definition ComboBox.cpp:203
int Append(const wxString &item, const wxBitmap &bitmap=wxNullBitmap, int item_style=0)
Definition ComboBox.cpp:227
unsigned int GetCount() const override
Definition ComboBox.cpp:311
void set_label_marker(int item, LabelItemType label_item_type=LABEL_ITEM_MARKER)
Definition PresetComboBoxes.cpp:201
virtual wxString get_preset_name(const Preset &preset)
Definition PresetComboBoxes.cpp:431
int m_first_ams_filament
Definition PresetComboBoxes.hpp:139
int m_last_ams_filament
Definition PresetComboBoxes.hpp:140
CGALMeshPtr clone(const CGALMesh &m)
Definition MeshBoolean.cpp:658
zaa_minimize_perimeter_height filament_type((ConfigOptionBools, filament_soluble))((ConfigOptionStrings
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 ( )
1118{
1119 // The Linux sidebar menu edits the same ordered project color as its swatch.
1121}

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 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
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}

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 ( )
inline
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 ( )
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)
overridevirtual

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

◆ keyDown()

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

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

Here is the call graph for this function:

◆ mouseDown()

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

References drop, drop_down, and items.

◆ mouseWheelMoved()

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

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

Here is the call graph for this function:

◆ msw_rescale()

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

Reimplemented from Slic3r::GUI::PresetComboBox.

1569{
1571 SetMinSize({-1, 30 * m_em_unit / 10});
1572
1573 if (clr_picker)
1574 clr_picker->SetSize(20 * m_em_unit / 10, 20 * m_em_unit / 10);
1575 // BBS
1576 if (edit_btn != nullptr)
1577 edit_btn->msw_rescale();
1578}
virtual void msw_rescale()
Definition PresetComboBoxes.cpp:650

References clr_picker, edit_btn, Slic3r::GUI::PresetComboBox::m_em_unit, msw_rescale(), and Slic3r::GUI::PresetComboBox::msw_rescale().

Referenced by msw_rescale(), and Slic3r::GUI::Sidebar::msw_rescale().

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

◆ OnEdit()

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

References SetValue().

Here is the call graph for this function:

◆ onMove()

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

References drop.

Referenced by ComboBox().

Here is the caller graph for this function:

◆ OnSelect()

void Slic3r::GUI::PlaterPresetComboBox::OnSelect ( wxCommandEvent & evt)
overridevirtual

Reimplemented from Slic3r::GUI::PresetComboBox.

1014{
1015 auto selected_item = evt.GetSelection();
1016
1017 auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
1018 if (marker >= LABEL_ITEM_DISABLED && marker < LABEL_ITEM_MAX) {
1020 if (LABEL_ITEM_WIZARD_ADD_PRINTERS == marker) {
1021 evt.Skip();
1022 return;
1023 }
1024 evt.StopPropagation();
1025 if (marker == LABEL_ITEM_MARKER || marker == LABEL_ITEM_DISABLED)
1026 return;
1027 //if (marker == LABEL_ITEM_WIZARD_PRINTERS)
1028 // show_add_menu();
1029 //else {
1031 switch (marker) {
1035 default: break;
1036 }
1037 wxTheApp->CallAfter([sp]() { run_wizard(sp); });
1038 //}
1039 return;
1040 } else if (marker == LABEL_ITEM_PHYSICAL_PRINTER || selected_item >= 0 || m_collection->current_is_dirty()) {
1041 m_last_selected = selected_item;
1044 }
1045
1046 evt.Skip();
1047}
StartPage
Definition ConfigWizard.hpp:31
@ SP_MATERIALS
Definition ConfigWizard.hpp:35
@ SP_PRINTERS
Definition ConfigWizard.hpp:33
@ SP_FILAMENTS
Definition ConfigWizard.hpp:34
@ SP_WELCOME
Definition ConfigWizard.hpp:32
int update_ams_color()
Definition PresetComboBoxes.cpp:274
static void run_wizard(ConfigWizard::StartPage sp)
Definition PresetComboBoxes.cpp:1008

References Slic3r::GUI::PresetComboBox::LABEL_ITEM_DISABLED, Slic3r::GUI::PresetComboBox::LABEL_ITEM_MARKER, Slic3r::GUI::PresetComboBox::LABEL_ITEM_MAX, Slic3r::GUI::PresetComboBox::LABEL_ITEM_PHYSICAL_PRINTER, Slic3r::GUI::PresetComboBox::LABEL_ITEM_WIZARD_ADD_PRINTERS, Slic3r::GUI::PresetComboBox::LABEL_ITEM_WIZARD_FILAMENTS, Slic3r::GUI::PresetComboBox::LABEL_ITEM_WIZARD_MATERIALS, Slic3r::GUI::PresetComboBox::LABEL_ITEM_WIZARD_PRINTERS, Slic3r::GUI::PresetComboBox::m_collection, Slic3r::GUI::PresetComboBox::m_last_selected, Slic3r::GUI::PresetComboBox::m_type, Slic3r::GUI::run_wizard(), ComboBox::SetSelection(), Slic3r::GUI::ConfigWizard::SP_FILAMENTS, Slic3r::GUI::ConfigWizard::SP_MATERIALS, Slic3r::GUI::ConfigWizard::SP_PRINTERS, Slic3r::GUI::ConfigWizard::SP_WELCOME, Slic3r::Preset::TYPE_FILAMENT, and Slic3r::GUI::PresetComboBox::update_ams_color().

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

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

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::PlaterPresetComboBox::update ( )
overridevirtual

Reimplemented from Slic3r::GUI::PresetComboBox.

1168{
1170 (m_preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA ||
1171 m_preset_bundle->filament_presets.size() <= (size_t)m_filament_idx) )
1172 return;
1173
1174 // Otherwise fill in the list from scratch.
1175 this->Freeze();
1176 this->Clear();
1178
1179 const Preset* selected_filament_preset = nullptr;
1181 {
1182 std::vector<wxBitmap *> bitmaps = get_extruder_color_icons(true);
1183 if (m_filament_idx < bitmaps.size()) {
1184 clr_picker->SetBitmap(*bitmaps[m_filament_idx]);
1185 } else {
1186 return;
1187 }
1188#ifdef __WXOSX__
1189 clr_picker->SetLabel(clr_picker->GetLabel()); // Let setBezelStyle: be called
1190 clr_picker->Refresh();
1191#endif
1192 selected_filament_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_filament_idx]);
1193 if (!selected_filament_preset) {
1194 //can not find this filament, should be caused by project embedded presets, will be updated later
1195 Thaw();
1196 return;
1197 }
1198 //assert(selected_filament_preset);
1199 }
1200
1201 bool has_selection = m_collection->get_selected_idx() != size_t(-1);
1202 const Preset* selected_preset = m_type == Preset::TYPE_FILAMENT ? selected_filament_preset : has_selection ? &m_collection->get_selected_preset() : nullptr;
1203 // Show wide icons if the currently selected preset is not compatible with the current printer,
1204 // and draw a red flag in front of the selected preset.
1205 bool wide_icons = selected_preset && !selected_preset->is_compatible;
1206
1207 std::map<wxString, wxBitmap*> nonsys_presets;
1208 //BBS: add project embedded presets logic
1209 std::map<wxString, wxBitmap*> project_embedded_presets;
1210 // ORCA: add bundle presets
1211 std::map<wxString, wxBitmap*> bundle_presets;
1212 std::map<wxString, wxBitmap *> system_presets;
1213 std::map<wxString, wxBitmap *> uncompatible_presets;
1214 std::unordered_set<std::string> system_printer_models;
1215 std::map<wxString, wxString> preset_descriptions;
1216 std::map<wxString, std::string> preset_filament_vendors;
1217 std::map<wxString, std::string> preset_filament_types;
1218 std::map<wxString, std::string> preset_aliases; // ORCA
1219 std::map<wxString, std::string> preset_bundle_ids;
1220 std::map<wxString, std::string> preset_bundle_names;
1221 //BBS: move system to the end
1222 wxString selected_system_preset;
1223 wxString selected_user_preset;
1224 wxString selected_bundle_preset;
1225 wxString tooltip;
1226 const std::deque<Preset>& presets = m_collection->get_presets();
1227
1228 //BBS: move system to the end
1229 /*if (!presets.front().is_visible)
1230 this->set_label_marker(this->Append(separator(L("System presets")), wxNullBitmap));*/
1231
1232 for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
1233 {
1234 const Preset& preset = presets[i];
1235 bool is_selected = m_type == Preset::TYPE_FILAMENT ?
1236 m_preset_bundle->filament_presets[m_filament_idx] == preset.name :
1237 // The case, when some physical printer is selected
1238 m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection() ? false :
1239 i == m_collection->get_selected_idx();
1240
1241 if (!is_selected && !preset.is_visible)
1242 {
1243 continue;
1244 }
1245 else if (is_selected && !preset.is_visible)
1246 {
1247 Preset& selected_preset = const_cast<Preset&>(preset);
1248 selected_preset.is_visible = true;
1249 }
1250
1251 bool single_bar = false;
1252 wxString name = from_u8(preset.name);
1253 preset_aliases[name] = get_preset_name(preset).utf8_string(); // ORCA
1254
1255 // Track bundle names for bundled presets
1256 if (preset.is_from_bundle()) {
1257 m_preset_bundle->bundles.ReadLock();
1258 auto bundle_it = m_preset_bundle->bundles.m_bundles.find(preset.bundle_id);
1259 if (bundle_it != m_preset_bundle->bundles.m_bundles.end()) {
1260 preset_bundle_ids[name] = bundle_it->second.id;
1261 preset_bundle_names[name] = bundle_it->second.name;
1262 }
1263 m_preset_bundle->bundles.ReadUnlock();
1264
1265 }
1266
1268 {
1269#if 0
1270 // Assign an extruder color to the selected item if the extruder color is defined.
1271 filament_rgb = is_selected ? selected_filament_preset->config.opt_string("filament_colour", 0) :
1272 preset.config.opt_string("filament_colour", 0);
1273 extruder_rgb = (is_selected && !filament_color.empty()) ? filament_color : filament_rgb;
1274 single_bar = filament_rgb == extruder_rgb;
1275
1276 bitmap_key += single_bar ? filament_rgb : filament_rgb + extruder_rgb;
1277#endif
1278 // ORCA allow caching vendor and type values for all presets instead just system ones
1279 // if (preset.is_system) {
1280 if (!preset.is_compatible && preset_filament_vendors.count(name) > 0)
1281 continue;
1282 else if (preset.is_compatible && preset_filament_vendors.count(name) > 0)
1283 uncompatible_presets.erase(name);
1284 preset_filament_vendors[name] = preset.config.option<ConfigOptionStrings>("filament_vendor")->values.at(0);
1285 if (preset_filament_vendors[name] == "Bambu Lab")
1286 preset_filament_vendors[name] = "Bambu";
1287 preset_filament_types[name] = preset.config.option<ConfigOptionStrings>("filament_type")->values.at(0);
1288 //}
1289 }
1290 wxBitmap* bmp = get_bmp(preset);
1291 assert(bmp);
1292
1293 preset_descriptions.emplace(name, from_u8(preset.description));
1294
1295 if (!preset.is_compatible) {
1296 if (boost::ends_with(name, " template"))
1297 continue;
1298 uncompatible_presets.emplace(name, bmp);
1299 }
1300 else if (preset.is_default || preset.is_system) {
1301 //BBS: move system to the end
1303 auto printer_model = preset.config.opt_string("printer_model");
1304
1305 // ORCA: Make system printer presets display the dirty "*" prefix when edited.
1306 name = from_u8(is_selected && preset.is_dirty ? Preset::suffix_modified() + printer_model : printer_model);
1307
1308 if (system_printer_models.count(printer_model) == 0) {
1309 preset_aliases[name] = name.utf8_string(); // ORCA
1310 system_presets.emplace(name, bmp);
1311 system_printer_models.insert(printer_model);
1312 }
1313 else if (is_selected) {
1314 const wxString alternate_name = from_u8(preset.is_dirty ? printer_model : Preset::suffix_modified() + printer_model);
1315 // Remove the old preset name if exists, and add the new one with the same name but with modified suffix if needed.
1316 if (system_presets.erase(alternate_name))
1317 system_presets.emplace(name, bmp);
1318
1319 preset_aliases.erase(alternate_name); // ORCA: do this to aliases too
1320 preset_aliases[name] = name.utf8_string();
1321 }
1322 } else {
1323 system_presets.emplace(name, bmp);
1324 }
1325
1326 if (is_selected) {
1327 tooltip = get_tooltip(preset);
1328 selected_system_preset = name;
1329 }
1330 //Append(get_preset_name(preset), *bmp);
1331 //validate_selection(is_selected);
1332 //if (is_selected)
1333 //BBS set tooltip
1334 // tooltip = get_tooltip(preset);
1335 }
1336 //BBS: add project embedded preset logic
1337 else if (preset.is_project_embedded)
1338 {
1339 project_embedded_presets.emplace(name, bmp);
1340 if (is_selected) {
1341 selected_user_preset = name;
1342 tooltip = wxString::FromUTF8(preset.name.c_str());
1343 }
1344 }
1345 // ORCA: add bundle presets
1346 else if (preset.is_from_bundle())
1347 {
1348 bundle_presets.emplace(name, bmp);
1349 if (is_selected) {
1350 selected_bundle_preset = name;
1351 tooltip = get_tooltip(preset);
1352 }
1353 }
1354 else
1355 {
1356 nonsys_presets.emplace(name, bmp);
1357 if (is_selected) {
1358 selected_user_preset = name;
1359 //BBS set tooltip
1360 tooltip = get_tooltip(preset);
1361 }
1362 }
1363 //BBS: move system to the end
1364 //if (i + 1 == m_collection->num_default_presets())
1365 // set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
1366 }
1367 //if (m_type == Preset::TYPE_PRINTER)
1368 // add_connected_printers("", true);
1369 bool selected_in_ams = false;
1371 set_replace_text("Bambu", "BambuStudioBlack");
1372 // Orca: selected_system/user_preset hold the FULL preset name because Orca keys the maps above by
1373 // full name to avoid alias collisions (BBS keys by alias). add_ams_filaments() compares against
1374 // get_preset_name() which returns the alias, so resolve the selection back to its alias here.
1375 // Without this, e.g. "Bambu PLA Basic @BBL H2C" never equals the AMS tray alias "Bambu PLA Basic",
1376 // so the FROM_AMS flag is never set and update_sync_status() wipes the AMS sync check mark on the
1377 // filament cards for connected Bambu printers.
1378 wxString selected_full = selected_user_preset.empty() ? selected_system_preset : selected_user_preset;
1379 auto alias_it = preset_aliases.find(selected_full);
1380 wxString selected_alias = alias_it != preset_aliases.end() ? from_u8(alias_it->second) : selected_full;
1381 selected_in_ams = add_ams_filaments(into_u8(selected_alias), true);
1382 }
1383
1384 std::vector<wxString> filament_orders = {"Bambu PLA Basic", "Bambu PLA Matte", "Bambu PETG HF", "Bambu ABS", "Bambu PLA Silk", "Bambu PLA-CF",
1385 "Bambu PLA Galaxy", "Bambu PLA Metal", "Bambu PLA Marble", "Bambu PETG-CF", "Bambu PETG Translucent", "Bambu ABS-GF"};
1386 std::vector<std::string> first_vendors = {"", "Bambu", "Generic"}; // Empty vendor for non-system presets
1387 std::vector<std::string> first_types = {"PLA", "PETG", "ABS", "TPU"};
1388 auto add_presets = [this, &preset_descriptions, &filament_orders, &preset_filament_vendors, &first_vendors, &preset_filament_types, &preset_aliases, &preset_bundle_ids, &preset_bundle_names, &first_types, &selected_in_ams]
1389 (std::map<wxString, wxBitmap *> const &presets, wxString const &selected, std::string const &group, wxString const &groupName) {
1390 if (!presets.empty()) {
1391 set_label_marker(Append(_L(group), wxNullBitmap, DD_ITEM_STYLE_SPLIT_ITEM));
1393 std::vector<std::map<wxString, wxBitmap *>::value_type const*> list(presets.size(), nullptr);
1394 std::transform(presets.begin(), presets.end(), list.begin(), [](auto & pair) { return &pair; });
1395 bool groupByGroup = group != "System presets";
1396 //if (groupByGroup) {
1397 // if (GetCount() == 1) Clear();
1398 // else SetString(GetCount() - 1, "");
1399 //}
1400 if (m_type == Preset::TYPE_FILAMENT && (group == "System presets" || group == "Unsupported presets"))
1401 std::sort(list.begin(), list.end(), [&filament_orders, &preset_filament_vendors, &first_vendors, &preset_filament_types, &first_types](auto *l, auto *r) {
1402 { // Compare order
1403 auto iter1 = std::find(filament_orders.begin(), filament_orders.end(), l->first);
1404 auto iter2 = std::find(filament_orders.begin(), filament_orders.end(), r->first);
1405 if (iter1 != iter2)
1406 return iter1 < iter2;
1407 }
1408 { // Compare vendor
1409 auto iter1 = std::find(first_vendors.begin(), first_vendors.end(), preset_filament_vendors[l->first]);
1410 auto iter2 = std::find(first_vendors.begin(), first_vendors.end(), preset_filament_vendors[r->first]);
1411 if (iter1 != iter2)
1412 return iter1 < iter2;
1413 }
1414 { // Compare type
1415 auto iter1 = std::find(first_types.begin(), first_types.end(), preset_filament_types[l->first]);
1416 auto iter2 = std::find(first_types.begin(), first_types.end(), preset_filament_types[r->first]);
1417 if (iter1 != iter2)
1418 return iter1 < iter2;
1419 }
1420 return l->first < r->first;
1421 });
1422 // ORCA add sorting support for vendor / type for user presets. also non grouped items
1423 if (groupName == "by_bundle" || groupName == "by_vendor" || groupName == "by_type" || groupName == ""){
1424 auto by = groupName == "by_bundle" ? preset_bundle_names
1425 : groupName == "by_vendor" ? preset_filament_vendors
1426 : groupName == "by_type" ? preset_filament_types
1427 : preset_aliases;
1428 std::sort(list.begin(), list.end(), [&by](auto *l, auto *r) {
1429 auto get_key = [&](auto* item) -> std::pair<bool, std::string> {
1430 std::string str = by.count(item->first) ? by.at(item->first) : "";
1431 std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c) { return std::tolower(c);});
1432 return {!str.empty(), str}; // is_valid, lower_case
1433 };
1434 auto [l_valid, l_lower] = get_key(l);
1435 auto [r_valid, r_lower] = get_key(r);
1436 return (l_valid != r_valid) ? l_valid > r_valid
1437 : (l_lower != r_lower) ? l_lower < r_lower
1438 : l->first < r->first;
1439 });
1440 }
1441 bool unsupported = group == "Unsupported presets";
1442 for (auto it : list) {
1443 // ORCA add sorting support for vendor / type for user presets
1444 auto groupName2 = groupName == "by_bundle" ? (preset_bundle_names[it->first].empty() ? _L("Unspecified") : from_u8(preset_bundle_names[it->first]))
1445 : groupName == "by_type" ? (preset_filament_types[it->first].empty() ? _L("Unspecified") : from_u8(preset_filament_types[it->first]))
1446 : groupName == "by_vendor" ? (preset_filament_vendors[it->first].empty() ? _L("Unspecified") : from_u8(preset_filament_vendors[it->first]))
1447 : groupByGroup ? groupName
1448 : from_u8(preset_filament_vendors[it->first]);
1449 int index = groupName == "by_bundle"
1450 ? Append(from_u8(preset_aliases[it->first]), *it->second,
1451 from_u8(preset_bundle_ids[it->first]), groupName2, nullptr,
1452 unsupported ? DD_ITEM_STYLE_DISABLED : 0)
1453 : Append(from_u8(preset_aliases[it->first]), *it->second, groupName2, nullptr,
1454 unsupported ? DD_ITEM_STYLE_DISABLED : 0);
1455 SetItemAlias(index, it->first);
1456 if (unsupported)
1458 else if (m_type == Preset::TYPE_PRINTER && group == "System presets" )
1460 SetItemTooltip(index, preset_descriptions[it->first]);
1461 bool is_selected = it->first == selected;
1462 validate_selection(is_selected);
1463 if (is_selected && selected_in_ams) {
1465 }
1466 }
1467 } else {
1468 for (std::map<wxString, wxBitmap *>::const_iterator it = presets.begin(); it != presets.end(); ++it) {
1469 int index = Append(from_u8(preset_aliases[it->first]), *it->second);
1470 SetItemAlias(index, it->first);
1471 SetItemTooltip(index, preset_descriptions[it->first]);
1472 if (group == "System presets")
1474 validate_selection(it->first == selected);
1475 }
1476 }
1477 }
1478 };
1479
1480 //BBS: add project embedded preset logic
1481 add_presets(project_embedded_presets, selected_user_preset, L("Project-inside presets"), _L("Project") + " ");
1482 // ORCA add sorting support for vendor / type for user presets
1483 auto group_filament_presets = wxGetApp().app_config->get("group_filament_presets");
1484 auto group_filament_presets_by = group_filament_presets == "0" ? (_L("Custom") + " ") // Append all to "Custom" sub menu
1485 : group_filament_presets == "2" ? "by_type" // Create sub menus with filament type
1486 : group_filament_presets == "3" ? "by_vendor" // Create sub menus with filament vendor
1487 : ""; // Use without sub menu
1488 // ORCA: the by_type/by_vendor grouping is derived from filament-only attributes
1489 // (filament_type/filament_vendor), which are empty for printer and material presets.
1490 // Applying it to non-filament combos buckets every user preset under "Unspecified",
1491 // so only group user presets by those attributes for the filament combobox.
1492 add_presets(nonsys_presets, selected_user_preset, L("User presets"),
1493 m_type == Preset::TYPE_FILAMENT ? group_filament_presets_by : wxString(""));
1494 // ORCA: add bundle presets with sub-dropdown grouping for filament and printer
1495 auto bundle_group_name = (m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_PRINTER) ? "by_bundle" : "";
1496 add_presets(bundle_presets, selected_bundle_preset, L("Bundle presets"), bundle_group_name);
1497 // BBS: move system to the end
1498 add_presets(system_presets, selected_system_preset, L("System presets"), _L("System"));
1499 // Orca: optionally show unsupported presets (controlled by developer preference, default off)
1500 if (wxGetApp().app_config->get_bool("show_unsupported_presets"))
1501 add_presets(uncompatible_presets, {}, L("Unsupported presets"), _L("Unsupported") + " ");
1502
1503 //BBS: remove unused pysical printer logic
1504 /*if (m_type == Preset::TYPE_PRINTER)
1505 {
1506 // add Physical printers, if any exists
1507 if (!m_preset_bundle->physical_printers.empty()) {
1508 set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
1509 const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
1510
1511 for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
1512 for (const std::string& preset_name : it->get_preset_names()) {
1513 Preset* preset = m_collection->find_preset(preset_name);
1514 if (!preset || !preset->is_visible)
1515 continue;
1516 std::string main_icon_name, bitmap_key = main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
1517 wxBitmap* bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
1518 assert(bmp);
1519
1520 set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
1521 validate_selection(ph_printers.is_selected(it, preset_name));
1522 }
1523 }
1524 }
1525 }*/
1526
1528 wxBitmap* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
1529 assert(bmp);
1530
1532 set_label_marker(Append(separator(L("Add/Remove filament")), *bmp), LABEL_ITEM_WIZARD_FILAMENTS);
1534 set_label_marker(Append(separator(L("Add/Remove materials")), *bmp), LABEL_ITEM_WIZARD_MATERIALS);
1535 else {
1536 set_label_marker(Append(separator(L("Select/Remove printers (system presets)")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
1538 }
1539 }
1540
1543 if (wxGetApp().plater()->is_same_printer_for_connected_and_selected(false)) {
1545 }
1546 }
1547 Thaw();
1548
1549 if (!tooltip.IsEmpty()) {
1550#ifdef __WXMSW__
1551 // From the Windows 2004 the tooltip for preset combobox doesn't work after next call of SetTooltip()
1552 // (There was an issue, when tooltip doesn't appears after changing of the preset selection)
1553 // But this workaround seems to work: We should to kill tooltip and than set new tooltip value
1554 // See, https://groups.google.com/g/wx-users/c/mOEe3fgHrzk
1555 SetToolTip(NULL);
1556#endif
1557 SetToolTip(tooltip);
1558 }
1559
1560#ifdef __WXMSW__
1561 // Use this part of code just on Windows to avoid of some layout issues on Linux
1562 // Update control min size after rescale (changed Display DPI under MSW)
1563 if (GetMinWidth() != 10 * m_em_unit)
1564 SetMinSize(wxSize(10 * m_em_unit, GetSize().GetHeight()));
1565#endif //__WXMSW__
1566}
#define L(s)
Definition ExtrusionEntity.cpp:25
void SetItemTooltip(unsigned int n, wxString const &value)
Definition ComboBox.cpp:337
void SetItemAlias(unsigned int n, wxString const &value)
Definition ComboBox.cpp:349
void set_replace_text(wxString text, wxString image_name)
Definition ComboBox.cpp:313
void update_badge_according_flag()
Definition PresetComboBoxes.cpp:1049
wxString get_preset_name(const Preset &preset) override
Definition PresetComboBoxes.cpp:1160
static wxString separator(const std::string &label)
Definition PresetComboBoxes.cpp:692
bool add_ams_filaments(std::string selected, bool alias_name=false)
Definition PresetComboBoxes.cpp:555
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
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
@ ptSLA
Definition Config.hpp:233
std::vector< wxBitmap * > get_extruder_color_icons(bool thin_icon)
Definition wxExtensions.cpp:572

References _L, Slic3r::GUI::PresetComboBox::add_ams_filaments(), ComboBox::Append(), Slic3r::Preset::bundle_id, clr_picker, Slic3r::Preset::config, DD_ITEM_STYLE_DISABLED, DD_ITEM_STYLE_SPLIT_ITEM, Slic3r::Preset::description, Slic3r::GUI::PresetComboBox::FROM_AMS, Slic3r::GUI::from_u8(), Slic3r::GUI::PresetComboBox::get_bmp(), get_extruder_color_icons(), get_preset_name(), Slic3r::GUI::PresetComboBox::get_tooltip(), ComboBox::GetCount(), Slic3r::GUI::into_u8(), Slic3r::GUI::PresetComboBox::invalidate_selection(), Slic3r::Preset::is_compatible, Slic3r::Preset::is_default, Slic3r::Preset::is_dirty, Slic3r::Preset::is_from_bundle(), Slic3r::Preset::is_project_embedded, Slic3r::Preset::is_system, Slic3r::Preset::is_visible, Slic3r::GUI::PresetComboBox::LABEL_ITEM_DISABLED, Slic3r::GUI::PresetComboBox::LABEL_ITEM_PRINTER_MODELS, Slic3r::GUI::PresetComboBox::m_collection, Slic3r::GUI::PresetComboBox::m_filament_idx, Slic3r::GUI::PresetComboBox::m_preset_bundle, Slic3r::GUI::PresetComboBox::m_type, Slic3r::Preset::name, Slic3r::DynamicConfig::opt_string(), Slic3r::ConfigBase::option(), Slic3r::ptSLA, Slic3r::GUI::PresetComboBox::set_label_marker(), ComboBox::set_replace_text(), ComboBox::SetFlag(), ComboBox::SetItemAlias(), ComboBox::SetItemTooltip(), Slic3r::Preset::suffix_modified(), Slic3r::Preset::TYPE_FILAMENT, Slic3r::Preset::TYPE_PRINTER, and Slic3r::GUI::PresetComboBox::validate_selection().

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

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

◆ update() [2/2]

void Slic3r::GUI::PresetComboBox::update ( std::string select_preset)
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

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

Referenced by get_color().

◆ m_em_unit

◆ m_filament_idx

◆ 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_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_preset_bundle

◆ m_selected_dev_id

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

◆ 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}
private
226{false};

Referenced by set_sync_badge(), and update_badge_according_flag().

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