OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
wxExtensions.hpp File Reference
#include <string>
#include <wx/anybutton.h>
#include <cstddef>
#include <wx/checklst.h>
#include <wx/colour.h>
#include <wx/combo.h>
#include <wx/dataview.h>
#include <wx/button.h>
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/rtti.h>
#include <wx/sizer.h>
#include <wx/menu.h>
#include <wx/bmpcbox.h>
#include <wx/statbmp.h>
#include <wx/popupwin.h>
#include <wx/scrolwin.h>
#include <wx/spinctrl.h>
#include <wx/artprov.h>
#include <vector>
#include <functional>
#include <wx/string.h>
#include "BitmapCache.hpp"
#include "Widgets/PopupWindow.hpp"
Include dependency graph for wxExtensions.hpp:

Go to the source code of this file.

Classes

class  wxCheckListBoxComboPopup
class  wxDataViewTreeCtrlComboPopup
class  ScalableBitmap
class  LockButton
class  ScalableButton
class  MenuWithSeparators
class  BlinkingBitmap
class  ImageTransientPopup

Namespaces

namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/
namespace  Slic3r::GUI

Functions

void msw_rescale_menu (wxMenu *)
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=nullptr, std::function< bool()> const cb_condition=[]() { return true;}, wxWindow *parent=nullptr, int insert_pos=wxNOT_FOUND)
wxMenuItem * append_menu_item (wxMenu *menu, int id, const wxString &string, const wxString &description, std::function< void(wxCommandEvent &event)> cb, const std::string &icon="", wxEvtHandler *event_handler=nullptr, std::function< bool()> const cb_condition=[]() { return true;}, wxWindow *parent=nullptr, int insert_pos=wxNOT_FOUND)
wxMenuItem * append_submenu (wxMenu *menu, wxMenu *sub_menu, int id, const wxString &string, const wxString &description, const std::string &icon="", std::function< bool()> const cb_condition=[]() { return true;}, wxWindow *parent=nullptr, int insert_pos=wxNOT_FOUND)
wxMenuItem * append_menu_radio_item (wxMenu *menu, int id, const wxString &string, const wxString &description, std::function< void(wxCommandEvent &event)> cb, wxEvtHandler *event_handler)
wxMenuItem * append_menu_check_item (wxMenu *menu, int id, const wxString &string, const wxString &description, std::function< void(wxCommandEvent &event)> cb, wxEvtHandler *event_handler, std::function< bool()> const enable_condition=[]() { return true;}, std::function< bool()> const check_condition=[]() { return true;}, wxWindow *parent=nullptr)
void enable_menu_item (wxUpdateUIEvent &evt, std::function< bool()> const cb_condition, wxMenuItem *item, wxWindow *win)
void edit_tooltip (wxString &tooltip)
void msw_buttons_rescale (wxDialog *dlg, const int em_unit, const std::vector< int > &btn_ids)
int em_unit (wxWindow *win)
wxBitmap create_menu_bitmap (const std::string &bmp_name)
wxBitmap create_scaled_bitmap (const std::string &bmp_name, wxWindow *win=nullptr, const int px_cnt=16, const bool grayscale=false, const std::string &new_color=std::string(), const bool menu_bitmap=false, const bool resize=false, const bool bitmap2=false, const std::vector< std::string > &array_new_color=std::vector< std::string >())
wxBitmap create_scaled_bitmap2 (const std::string &bmp_name_in, Slic3r::GUI::BitmapCache &cache, wxWindow *win=nullptr, const int px_cnt=16, const bool grayscale=false, const bool resize=false, const std::vector< std::string > &array_new_color=std::vector< std::string >())
wxBitmap * get_default_extruder_color_icon (bool thin_icon=false)
std::vector< wxBitmap * > get_extruder_color_icons (bool thin_icon=false)
wxBitmap * get_extruder_color_icon (std::string color, std::string label, int icon_width, int icon_height)
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=nullptr)
std::vector< std::vector< std::string > > read_color_pack (std::vector< std::string > color_pack)
void apply_extruder_selector (Slic3r::GUI::BitmapComboBox **ctrl, wxWindow *parent, const std::string &first_item="", wxPoint pos=wxDefaultPosition, wxSize size=wxDefaultSize, bool use_thin_icon=false)

Function Documentation

◆ append_menu_check_item()

wxMenuItem * append_menu_check_item ( wxMenu * menu,
int id,
const wxString & string,
const wxString & description,
std::function< void(wxCommandEvent &event)> cb,
wxEvtHandler * event_handler,
std::function< bool()> const enable_condition = []() { return true;},
std::function< bool()> const check_condition = []() { return true;},
wxWindow * parent = nullptr )
186{
187 if (id == wxID_ANY)
188 id = wxNewId();
189
190 wxMenuItem* item = menu->AppendCheckItem(id, string, description);
191
192#ifdef __WXMSW__
193 if (event_handler != nullptr && event_handler != menu)
194 event_handler->Bind(wxEVT_MENU, cb, id);
195 else
196#endif // __WXMSW__
197 menu->Bind(wxEVT_MENU, cb, id);
198
199 if (parent)
200 parent->Bind(wxEVT_UPDATE_UI, [enable_condition, check_condition](wxUpdateUIEvent& evt)
201 {
202 evt.Enable(enable_condition());
203 evt.Check(check_condition());
204 }, id);
205
206 return item;
207}

Referenced by Slic3r::GUI::MenuFactory::append_menu_item_auto_drop(), Slic3r::GUI::MenuFactory::append_menu_item_change_type(), Slic3r::GUI::MenuFactory::append_menu_item_precise_seam_submenu(), Slic3r::GUI::MenuFactory::append_menu_item_printable(), Slic3r::GUI::MenuFactory::append_menu_item_set_auto_drop(), Slic3r::GUI::MenuFactory::append_menu_item_set_printable(), Slic3r::GUI::MenuFactory::append_menu_items_flush_options(), Slic3r::GUI::MenuFactory::create_default_menu(), and Slic3r::GUI::MainFrame::init_menubar_as_editor().

Here is the caller graph for this function:

◆ append_menu_item() [1/2]

wxMenuItem * append_menu_item ( wxMenu * menu,
int id,
const wxString & string,
const wxString & description,
std::function< void(wxCommandEvent &event)> cb,
const std::string & icon = "",
wxEvtHandler * event_handler = nullptr,
std::function< bool()> const cb_condition = []() { return true;},
wxWindow * parent = nullptr,
int insert_pos = wxNOT_FOUND )
123{
124 if (id == wxID_ANY)
125 id = wxNewId();
126
127 const wxBitmap& bmp = !icon.empty() ? create_menu_bitmap(icon) : wxNullBitmap; // FIXME: pass window ptr
128//#ifdef __WXMSW__
129#ifndef __WXGTK__
130 if (bmp.IsOk())
131 msw_menuitem_bitmaps[id] = icon;
132#endif /* __WXMSW__ */
133
134 return append_menu_item(menu, id, string, description, cb, bmp, event_handler, cb_condition, parent, insert_pos);
135}
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
static std::map< int, std::string > msw_menuitem_bitmaps
Definition wxExtensions.cpp:49
wxBitmap create_menu_bitmap(const std::string &bmp_name)
Definition wxExtensions.cpp:440

References append_menu_item(), create_menu_bitmap(), and msw_menuitem_bitmaps.

Here is the call graph for this function:

◆ append_menu_item() [2/2]

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 = nullptr,
std::function< bool()> const cb_condition = []() { return true;},
wxWindow * parent = nullptr,
int insert_pos = wxNOT_FOUND )
92{
93 if (id == wxID_ANY)
94 id = wxNewId();
95
96 auto *item = new wxMenuItem(menu, id, string, description);
97 if (icon.IsOk()) {
98 item->SetBitmap(icon);
99 }
100 if (insert_pos == wxNOT_FOUND)
101 menu->Append(item);
102 else
103 menu->Insert(insert_pos, item);
104
105#ifdef __WXMSW__
106 if (event_handler != nullptr && event_handler != menu)
107 event_handler->Bind(wxEVT_MENU, cb, id);
108 else
109#endif // __WXMSW__
110 menu->Bind(wxEVT_MENU, cb, id);
111
112 if (parent) {
113 parent->Bind(wxEVT_UPDATE_UI, [cb_condition, item, parent](wxUpdateUIEvent& evt) {
114 enable_menu_item(evt, cb_condition, item, parent); }, id);
115 }
116
117 return item;
118}
void enable_menu_item(wxUpdateUIEvent &evt, std::function< bool()> const cb_condition, wxMenuItem *item, wxWindow *win)
Definition wxExtensions.cpp:73

References enable_menu_item().

Referenced by Slic3r::GUI::add_common_publish_menu_items(), append_menu_item(), Slic3r::GUI::MenuFactory::append_menu_item_align_distribute(), Slic3r::GUI::MenuFactory::append_menu_item_center(), Slic3r::GUI::MenuFactory::append_menu_item_change_extruder(), Slic3r::GUI::MenuFactory::append_menu_item_change_filament(), Slic3r::GUI::MenuFactory::append_menu_item_clone(), Slic3r::GUI::MenuFactory::append_menu_item_delete(), Slic3r::GUI::MenuFactory::append_menu_item_drop(), Slic3r::GUI::MenuFactory::append_menu_item_edit_svg(), Slic3r::GUI::MenuFactory::append_menu_item_edit_text(), Slic3r::GUI::MenuFactory::append_menu_item_export_drc(), Slic3r::GUI::MenuFactory::append_menu_item_export_stl(), Slic3r::GUI::MenuFactory::append_menu_item_fill_bed(), Slic3r::GUI::MenuFactory::append_menu_item_fix_through_cgal(), Slic3r::GUI::MenuFactory::append_menu_item_instance_to_object(), Slic3r::GUI::MenuFactory::append_menu_item_invalidate_cut_info(), Slic3r::GUI::MenuFactory::append_menu_item_layers_editing(), Slic3r::GUI::MenuFactory::append_menu_item_locked(), Slic3r::GUI::MenuFactory::append_menu_item_merge_to_multipart_object(), Slic3r::GUI::MenuFactory::append_menu_item_merge_to_single_object(), Slic3r::GUI::MenuFactory::append_menu_item_modify(), Slic3r::GUI::MenuFactory::append_menu_item_per_object_process(), Slic3r::GUI::MenuFactory::append_menu_item_per_object_settings(), Slic3r::GUI::MenuFactory::append_menu_item_plate_delete(), Slic3r::GUI::MenuFactory::append_menu_item_plate_name(), Slic3r::GUI::MenuFactory::append_menu_item_reload_from_disk(), Slic3r::GUI::MenuFactory::append_menu_item_rename(), Slic3r::GUI::MenuFactory::append_menu_item_replace_all_with_stl(), Slic3r::GUI::MenuFactory::append_menu_item_replace_with_stl(), Slic3r::GUI::MenuFactory::append_menu_item_scale_selection_to_fit_print_volume(), Slic3r::GUI::MenuFactory::append_menu_item_set_visible(), Slic3r::GUI::MenuFactory::append_menu_item_simplify(), Slic3r::GUI::MenuFactory::append_menu_item_smooth_mesh(), Slic3r::GUI::MenuFactory::append_menu_item_transform(), Slic3r::GUI::append_menu_itemm_add_(), Slic3r::GUI::MenuFactory::append_menu_items_convert_unit(), Slic3r::GUI::MenuFactory::append_menu_items_instance_manipulation(), Slic3r::GUI::MainFrame::append_shortcut_item(), Slic3r::GUI::MenuFactory::append_submenu_add_generic(), Slic3r::GUI::MenuFactory::append_submenu_add_handy_model(), Slic3r::GUI::MenuFactory::create_default_menu(), Slic3r::GUI::MenuFactory::create_filament_action_menu(), Slic3r::GUI::create_freq_settings_popupmenu(), Slic3r::GUI::MenuFactory::create_plate_menu(), Slic3r::GUI::create_settings_popupmenu(), Slic3r::GUI::MenuFactory::create_sla_object_menu(), Slic3r::GUI::MainFrame::generate_help_menu(), Slic3r::GUI::MainFrame::init_menubar_as_editor(), Slic3r::GUI::MainFrame::init_menubar_as_gcodeviewer(), AuxiliaryList::on_context_menu(), Slic3r::GUI::PlaterPresetComboBox::show_add_menu(), and Slic3r::GUI::PlaterPresetComboBox::show_edit_menu().

Here is the call graph for this function:

◆ append_menu_radio_item()

wxMenuItem * append_menu_radio_item ( wxMenu * menu,
int id,
const wxString & string,
const wxString & description,
std::function< void(wxCommandEvent &event)> cb,
wxEvtHandler * event_handler )
167{
168 if (id == wxID_ANY)
169 id = wxNewId();
170
171 wxMenuItem* item = menu->AppendRadioItem(id, string, description);
172
173#ifdef __WXMSW__
174 if (event_handler != nullptr && event_handler != menu)
175 event_handler->Bind(wxEVT_MENU, cb, id);
176 else
177#endif // __WXMSW__
178 menu->Bind(wxEVT_MENU, cb, id);
179
180 return item;
181}

Referenced by Slic3r::GUI::MainFrame::init_menubar_as_editor().

Here is the caller graph for this function:

◆ append_submenu()

wxMenuItem * append_submenu ( wxMenu * menu,
wxMenu * sub_menu,
int id,
const wxString & string,
const wxString & description,
const std::string & icon = "",
std::function< bool()> const cb_condition = []() { return true;},
wxWindow * parent = nullptr,
int insert_pos = wxNOT_FOUND )
139{
140 if (id == wxID_ANY)
141 id = wxNewId();
142
143 wxMenuItem* item = new wxMenuItem(menu, id, string, description, wxITEM_NORMAL, sub_menu);
144 if (!icon.empty()) {
145 item->SetBitmap(create_menu_bitmap(icon)); // FIXME: pass window ptr
146//#ifdef __WXMSW__
147#ifndef __WXGTK__
148 msw_menuitem_bitmaps[id] = icon;
149#endif /* __WXMSW__ */
150 }
151
152 if (insert_pos == wxNOT_FOUND)
153 menu->Append(item);
154 else
155 menu->Insert(insert_pos, item);
156
157 if (parent) {
158 parent->Bind(wxEVT_UPDATE_UI, [cb_condition, item, parent](wxUpdateUIEvent& evt) {
159 enable_menu_item(evt, cb_condition, item, parent); }, id);
160 }
161
162 return item;
163}

References create_menu_bitmap(), enable_menu_item(), and msw_menuitem_bitmaps.

Referenced by Slic3r::GUI::MenuFactory::append_menu_item_align_distribute(), Slic3r::GUI::MenuFactory::append_menu_item_modify(), Slic3r::GUI::MenuFactory::append_menu_item_more(), Slic3r::GUI::MenuFactory::append_menu_item_precise_seam_submenu(), Slic3r::GUI::MenuFactory::append_menu_item_transform(), Slic3r::GUI::MenuFactory::append_menu_items_add_volume(), Slic3r::GUI::MenuFactory::create_default_menu(), Slic3r::GUI::MenuFactory::create_extra_object_menu(), Slic3r::GUI::MenuFactory::create_filament_action_menu(), Slic3r::GUI::MenuFactory::create_plate_menu(), and Slic3r::GUI::MainFrame::init_menubar_as_editor().

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

◆ apply_extruder_selector()

void apply_extruder_selector ( Slic3r::GUI::BitmapComboBox ** ctrl,
wxWindow * parent,
const std::string & first_item = "",
wxPoint pos = wxDefaultPosition,
wxSize size = wxDefaultSize,
bool use_thin_icon = false )
805{
806 std::vector<wxBitmap*> icons = get_extruder_color_icons(use_thin_icon);
807
808 if (!*ctrl) {
809 *ctrl = new Slic3r::GUI::BitmapComboBox(parent, wxID_ANY, wxEmptyString, pos, size, 0, nullptr, wxCB_READONLY);
810 Slic3r::GUI::wxGetApp().UpdateDarkUI(*ctrl);
811 }
812 else
813 {
814 (*ctrl)->SetPosition(pos);
815 (*ctrl)->SetMinSize(size);
816 (*ctrl)->SetSize(size);
817 (*ctrl)->Clear();
818 }
819 if (first_item.empty())
820 (*ctrl)->Hide(); // to avoid unwanted rendering before layout (ExtruderSequenceDialog)
821
822 if (icons.empty() && !first_item.empty()) {
823 (*ctrl)->Append(_(first_item), wxNullBitmap);
824 return;
825 }
826
827 // For ObjectList we use short extruder name (just a number)
828 const bool use_full_item_name = dynamic_cast<Slic3r::GUI::ObjectList*>(parent) == nullptr;
829
830 int i = 0;
831 wxString str = _(L("Extruder"));
832 for (wxBitmap* bmp : icons) {
833 if (i == 0) {
834 if (!first_item.empty())
835 (*ctrl)->Append(_(first_item), *bmp);
836 ++i;
837 }
838
839 (*ctrl)->Append(use_full_item_name
840 ? Slic3r::GUI::from_u8((boost::format("%1% %2%") % str % i).str())
841 : wxString::Format("%d", i), *bmp);
842 ++i;
843 }
844 (*ctrl)->SetSelection(0);
845}
#define _(s)
Definition 3mf.cpp:306
#define L(s)
Definition ExtrusionEntity.cpp:25
Definition BitmapComboBox.hpp:19
Definition GUI_ObjectList.hpp:97
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
std::vector< wxBitmap * > get_extruder_color_icons(bool thin_icon)
Definition wxExtensions.cpp:572

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

Referenced by Slic3r::GUI::ObjectList::extruder_editing().

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

◆ create_menu_bitmap()

wxBitmap create_menu_bitmap ( const std::string & bmp_name)
441{
442 return create_scaled_bitmap(bmp_name, nullptr, 16, false, "", true);
443}
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 create_scaled_bitmap().

Referenced by append_menu_item(), and append_submenu().

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

◆ create_scaled_bitmap()

wxBitmap create_scaled_bitmap ( const std::string & bmp_name,
wxWindow * win = nullptr,
const int px_cnt = 16,
const bool grayscale = false,
const std::string & new_color = std::string(),
const bool menu_bitmap = false,
const bool resize = false,
const bool bitmap2 = false,
const std::vector< std::string > & array_new_color = std::vector< std::string >() )
457{
458 static Slic3r::GUI::BitmapCache cache;
459
460 // An empty name means the caller's icon lookup failed
461 if (bmp_name_in.empty() || bmp_name_in == ".png") {
462 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": empty bitmap name";
463 return wxNullBitmap;
464 }
465
466 if (bitmap2) {
467 return create_scaled_bitmap2(bmp_name_in, cache, win, px_cnt, grayscale, resize, array_new_color);
468 }
469 unsigned int width = 0;
470 // win may be nullptr; use the static overload, which falls back to the primary display DPI.
471 // Calling win->FromDIP() on a null win is UB and lets the optimizer drop later null checks.
472 unsigned int height = (unsigned int) (wxWindow::FromDIP(px_cnt, win) + 0.5f);
473
474 std::string bmp_name = bmp_name_in;
475 boost::replace_last(bmp_name, ".png", "");
476
477 bool dark_mode =
478#ifdef _WIN32
479 menu_bitmap ? Slic3r::GUI::check_dark_mode() :
480#endif
481 Slic3r::GUI::wxGetApp().dark_mode();
482
483 // Try loading an SVG first, then PNG if SVG was not found:
484 wxBitmap *bmp = cache.load_svg(bmp_name, width, height, grayscale, dark_mode, new_color, resize ? em_unit(win) * 0.1f : 0.f);
485 if (bmp == nullptr) {
486 bmp = cache.load_png(bmp_name, width, height, grayscale, resize ? wxWindow::FromDIP(10, win) * 0.1f : 0.f);
487 }
488
489 if (bmp == nullptr) {
490 // Neither SVG nor PNG has been found, raise error
491 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Could not load bitmap: " << bmp_name;
492 throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
493 }
494
495#ifdef __WXMSW__
496 // ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
497 bmp->SetScaleFactor(win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0));
498#endif
499 return *bmp;
500}
Definition BitmapCache.hpp:22
wxBitmap * load_svg(const std::string &bitmap_key, unsigned width=0, unsigned height=0, const bool grayscale=false, const bool dark_mode=false, const std::string &new_color="", const float scale_in_center=0.f)
Definition BitmapCache.cpp:326
wxBitmap * load_png(const std::string &bitmap_key, unsigned width=0, unsigned height=0, const bool grayscale=false, const float scale_in_center=0.f)
Definition BitmapCache.cpp:250
bool check_dark_mode()
Definition GUI_Utils.cpp:311
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
|/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is releas...
Definition AABBMesh.cpp:22
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424
wxBitmap create_scaled_bitmap2(const std::string &bmp_name_in, Slic3r::GUI::BitmapCache &cache, wxWindow *win, const int px_cnt, const bool grayscale, const bool resize, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:502

References Slic3r::GUI::check_dark_mode(), create_scaled_bitmap2(), em_unit(), Slic3r::GUI::BitmapCache::load_png(), and Slic3r::GUI::BitmapCache::load_svg().

Referenced by Slic3r::GUI::AddMachinePanel::AddMachinePanel(), Slic3r::GUI::AmsHumidityTipPopup::AmsHumidityTipPopup(), Slic3r::GUI::AmsIntroducePopup::AmsIntroducePopup(), Slic3r::GUI::AmsMapingTipPopup::AmsMapingTipPopup(), Slic3r::GUI::AmsTutorialPopup::AmsTutorialPopup(), AnimaIcon::AnimaIcon(), Slic3r::GUI::AuFile::AuFile(), AuxiliaryList::AuxiliaryList(), Slic3r::GUI::BaseTransparentDPIFrame::BaseTransparentDPIFrame(), Slic3r::BBLStatusBarPrint::BBLStatusBarPrint(), Slic3r::BBLStatusBarSend::BBLStatusBarSend(), Slic3r::GUI::BindMachineDialog::BindMachineDialog(), Slic3r::GUI::CapsuleButton::CapsuleButton(), Slic3r::GUI::ColorPicker::ColorPicker(), Slic3r::GUI::CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(), Slic3r::GUI::DesignPanel::DesignPanel(), Slic3r::GUI::DragCanvas::DragCanvas(), Slic3r::GUI::ErrorDialog::ErrorDialog(), Slic3r::GUI::ExtruderBadge::ExtruderBadge(), Slic3r::GUI::FilamentMapBtnPanel::FilamentMapBtnPanel(), Slic3r::GUI::ImageDPIFrame::ImageDPIFrame(), Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MappingContainer::MappingContainer(), Slic3r::GUI::MsgUpdateConfig::MsgUpdateConfig(), Slic3r::GUI::NetworkPluginRestartDialog::NetworkPluginRestartDialog(), Slic3r::GUI::Newer3mfVersionDialog::Newer3mfVersionDialog(), Slic3r::GUI::ObjectDataViewModel::ObjectDataViewModel(), Slic3r::GUI::ObjectDataViewModelNode::ObjectDataViewModelNode(), Slic3r::GUI::ObjectDataViewModelNode::ObjectDataViewModelNode(), Slic3r::GUI::OG_CustomCtrl::OG_CustomCtrl(), Slic3r::GUI::PartSkipDialog::PartSkipDialog(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PurgeModeBtnPanel::PurgeModeBtnPanel(), Slic3r::GUI::ReleaseNoteDialog::ReleaseNoteDialog(), ScalableBitmap::ScalableBitmap(), ScalableButton::ScalableButton(), Slic3r::GUI::SelectMachineDialog::SelectMachineDialog(), Slic3r::GUI::SendToPrinterDialog::SendToPrinterDialog(), Slic3r::GUI::Sidebar::Sidebar(), Slic3r::GUI::SliceInfoPopup::SliceInfoPopup(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), Slic3r::GUI::UnBindMachineDialog::UnBindMachineDialog(), Slic3r::GUI::UpdatePluginDialog::UpdatePluginDialog(), Slic3r::GUI::UpdateVersionDialog::UpdateVersionDialog(), Slic3r::GUI::MenuFactory::append_menu_item_settings(), Slic3r::GUI::DesignPanel::append_offer_item(), Slic3r::GUI::MsgDialog::apply_style(), Slic3r::GUI::PrinterInfoBox::Create(), Slic3r::GUI::AMSSetting::create(), Slic3r::GUI::CalibrationStartPage::create_bitmap(), Slic3r::GUI::CalibrationStartPage::create_bitmap(), Slic3r::GUI::StatusBasePanel::create_filament_group(), create_menu_bitmap(), Slic3r::GUI::ColorDecomposeDialog::create_mode_selection_section(), Slic3r::PluginPages::create_page(), Slic3r::GUI::CreatePrinterPresetDialog::create_step_switch_item(), Slic3r::GUI::FilamentGroupPopup::CreateBmps(), Slic3r::GUI::wgtDeviceNozzleRackNozzleItem::CreateGui(), Slic3r::GUI::GridCellSupportRenderer::Draw(), Slic3r::GUI::OG_CustomCtrl::CtrlLine::draw_blinking_bmp(), enable_menu_item(), Slic3r::GUI::StatusBasePanel::expand_filament_loading(), Slic3r::GUI::PresetComboBox::get_bmp(), Slic3r::GUI::PresetComboBox::get_bmp(), Slic3r::GUI::SettingsFactory::get_category_bitmap(), Slic3r::GUI::MenuFactory::get_svg_volume_bitmaps(), Slic3r::GUI::MenuFactory::get_text_volume_bitmaps(), Slic3r::GUI::MenuFactory::get_volume_bitmaps(), Slic3r::GUI::ParamsModel::GetValue(), BBLTopbar::Init(), Slic3r::GUI::ConnectPrinterDialog::init_bitmap(), Slic3r::GUI::MonitorPanel::init_bitmap(), Slic3r::GUI::ObjectTablePanel::init_bitmap(), Slic3r::GUI::ExtrusionCalibration::init_bitmaps(), Slic3r::GUI::HMSNotifyItem::init_bitmaps(), Slic3r::GUI::StatusBasePanel::init_bitmaps(), ScalableBitmap::msw_rescale(), ScalableButton::msw_rescale(), Slic3r::GUI::AmsHumidityTipPopup::msw_rescale(), Slic3r::GUI::ColorPicker::msw_rescale(), Slic3r::GUI::MappingContainer::msw_rescale(), Slic3r::GUI::ObjectDataViewModelNode::msw_rescale(), Slic3r::GUI::OG_CustomCtrl::CtrlLine::msw_rescale(), Slic3r::GUI::OG_CustomCtrl::msw_rescale(), Slic3r::GUI::Sidebar::msw_rescale(), Slic3r::GUI::AMSSetting::on_dpi_changed(), Slic3r::GUI::PartSkipDialog::on_dpi_changed(), Slic3r::GUI::Sidebar::on_enter_image_printer_bed(), Slic3r::GUI::BindMachineDialog::on_show(), Slic3r::GUI::UnBindMachineDialog::on_show(), Slic3r::GUI::ExtrusionCalibration::open_bitmap(), Slic3r::GUI::anonymous_namespace{UVEditorCanvas.cpp}::pane_icon(), BBLTopbar::Rescale(), Slic3r::GUI::DevIconLabel::Rescale(), Slic3r::GUI::ObjectDataViewModel::Rescale(), Slic3r::GUI::wgtDeviceNozzleRackNozzleItem::Rescale(), Slic3r::GUI::ObjectDataViewModelNode::set_action_icon(), Slic3r::GUI::ObjectDataViewModelNode::set_color_icon(), Slic3r::GUI::AmsHumidityTipPopup::set_humidity_level(), Slic3r::GUI::InputIpAddressDialog::set_machine_obj(), Slic3r::GUI::ObjectDataViewModelNode::set_printable_icon(), Slic3r::GUI::ObjectDataViewModelNode::set_sinking_icon(), Slic3r::GUI::ObjectDataViewModelNode::set_support_icon(), Slic3r::GUI::ObjectDataViewModelNode::set_variable_height_icon(), ScalableButton::SetBitmap_(), Slic3r::GUI::ExtruderBadge::SetExtruderStatus(), Slic3r::GUI::ExtruderBadge::SetExtruderValid(), Slic3r::GUI::DevIconLabel::SetIcon(), Slic3r::GUI::PrinterInfoBox::SetPrinters(), Slic3r::GUI::StatusBasePanel::show_filament_load_group(), Slic3r::GUI::CreatePrinterPresetDialog::show_page1(), Slic3r::GUI::CreatePrinterPresetDialog::show_page2(), Slic3r::GUI::SelectMachineDialog::show_timelapse_folder_popup(), Slic3r::GUI::SelectMachineDialog::show_timelapse_storage_dialog(), Slic3r::GUI::ObjectDataViewModelNode::sys_color_changed(), Slic3r::GUI::AMSSetting::update_ams_img(), Slic3r::GUI::SyncAmsInfoDialog::update_more_setting(), Slic3r::GUI::Sidebar::update_presets(), Slic3r::GUI::Sidebar::update_printer_thumbnail(), Slic3r::GUI::SelectMachineDialog::update_timelapse_folder_btn_icon(), Slic3r::GUI::SavePresetDialog::Item::update_valid_bmp(), Slic3r::GUI::ObjectDataViewModel::UpdateBitmapForNode(), Slic3r::GUI::ModelNode::UpdateIcons(), Slic3r::GUI::PrinterInfoBox::UpdatePlate(), Slic3r::GUI::TexturePreviewCanvas::upload_reset_icon_texture(), and ScalableButton::UseDefaultBitmapDisabled().

Here is the call graph for this function:

◆ create_scaled_bitmap2()

wxBitmap create_scaled_bitmap2 ( const std::string & bmp_name_in,
Slic3r::GUI::BitmapCache & cache,
wxWindow * win = nullptr,
const int px_cnt = 16,
const bool grayscale = false,
const bool resize = false,
const std::vector< std::string > & array_new_color = std::vector< std::string >() )
505{
506 unsigned int width = 0;
507 // win may be nullptr; see create_scaled_bitmap() above.
508 unsigned int height = (unsigned int)(wxWindow::FromDIP(px_cnt, win) + 0.5f);
509
510 std::string bmp_name = bmp_name_in;
511 boost::replace_last(bmp_name, ".png", "");
512
513 wxBitmap* bmp = cache.load_svg2(bmp_name, width, height, grayscale, false, array_new_color, resize ? em_unit(win) * 0.1f : 0.f);
514 if (bmp == nullptr) {
515 // No SVG found
516 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Could not load bitmap: " << bmp_name;
517 throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
518 }
519#ifdef __WXMSW__
520 // ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
521 bmp->SetScaleFactor(win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0));
522#endif
523 return *bmp;
524}
wxBitmap * load_svg2(const std::string &bitmap_key, unsigned width=0, unsigned height=0, const bool grayscale=false, const bool dark_mode=false, const std::vector< std::string > &array_new_color=std::vector< std::string >(), const float scale_in_center=0.0f)
Definition BitmapCache.cpp:418

References em_unit(), and Slic3r::GUI::BitmapCache::load_svg2().

Referenced by create_scaled_bitmap().

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

◆ edit_tooltip()

void edit_tooltip ( wxString & tooltip)
399{
400 tooltip.Replace("Slic3r", SLIC3R_APP_KEY, true);
401}

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

Here is the caller graph for this function:

◆ em_unit()

int em_unit ( wxWindow * win)
425{
426 if (win)
427 {
428 wxTopLevelWindow *toplevel = Slic3r::GUI::find_toplevel_parent(win);
429 Slic3r::GUI::DPIDialog* dlg = dynamic_cast<Slic3r::GUI::DPIDialog*>(toplevel);
430 if (dlg)
431 return dlg->em_unit();
432 Slic3r::GUI::DPIFrame* frame = dynamic_cast<Slic3r::GUI::DPIFrame*>(toplevel);
433 if (frame)
434 return frame->em_unit();
435 }
436
437 return Slic3r::GUI::wxGetApp().em_unit();
438}
int em_unit() const
Definition GUI_Utils.hpp:203
Definition GUI_Utils.hpp:300
wxTopLevelWindow * find_toplevel_parent(wxWindow *window)
Definition GUI_Utils.cpp:155
DPIAware< wxFrame > DPIFrame
Definition GUI_Utils.hpp:298

References Slic3r::GUI::DPIAware< P >::em_unit(), and Slic3r::GUI::find_toplevel_parent().

Referenced by Slic3r::GUI::Bed_2D::Bed_2D(), BlinkingBitmap::BlinkingBitmap(), ButtonsListCtrl::ButtonsListCtrl(), Slic3r::GUI::DiamTextCtrl::DiamTextCtrl(), Slic3r::GUI::DiffViewCtrl::DiffViewCtrl(), Slic3r::GUI::LayerRangeEditor::LayerRangeEditor(), Slic3r::GUI::MediaFilePanel::MediaFilePanel(), Slic3r::GUI::ObjectLayers::ObjectLayers(), Slic3r::GUI::OG_CustomCtrl::OG_CustomCtrl(), Slic3r::GUI::ParamsPanel::ParamsPanel(), Slic3r::GUI::ParamsViewCtrl::ParamsViewCtrl(), Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox(), Slic3r::GUI::PresetComboBox::PresetComboBox(), ScalableButton::ScalableButton(), Slic3r::Search::SearchItem::SearchItem(), Slic3r::GUI::Sidebar::Sidebar(), Slic3r::GUI::Tab::Tab(), TabButtonsListCtrl::TabButtonsListCtrl(), Slic3r::GUI::TabPresetComboBox::TabPresetComboBox(), Slic3r::GUI::GLCanvas3D::_render_paint_toolbar(), Slic3r::GUI::OptionsGroup::activate_line(), Slic3r::GUI::Sidebar::change_top_border_for_mode_sizer(), Slic3r::GUI::ParamsPanel::create_layout(), Slic3r::GUI::Tab::create_preset_tab(), create_scaled_bitmap(), create_scaled_bitmap2(), Slic3r::GUI::wxRenderer::DrawTreeItemButton(), Slic3r::GUI::ModelNode::get_bitmap(), Slic3r::GUI::ImGuiWrapper::init_font(), ButtonsListCtrl::InsertPage(), TabButtonsListCtrl::InsertPage(), Slic3r::GUI::ObjectList::list_manipulation(), msw_buttons_rescale(), ScalableButton::msw_rescale(), Slic3r::GUI::Field::msw_rescale(), Slic3r::GUI::ObjectLayers::msw_rescale(), Slic3r::GUI::OG_CustomCtrl::msw_rescale(), Slic3r::GUI::ParamsPanel::msw_rescale(), Slic3r::GUI::PresetComboBox::msw_rescale(), Slic3r::GUI::Sidebar::msw_rescale(), Slic3r::GUI::Tab::msw_rescale(), Slic3r::GUI::StatusPanel::on_switch_speed(), Slic3r::GUI::Field::PostInitialize(), Slic3r::PluginPages::relayout(), Slic3r::GUI::ImageGrid::renderContent2(), BBLTopbar::Rescale(), ButtonsListCtrl::Rescale(), Slic3r::GUI::ImageGrid::Rescale(), Slic3r::GUI::MediaFilePanel::Rescale(), TabButtonsListCtrl::Rescale(), Slic3r::GUI::ObjectList::set_min_height(), Slic3r::GUI::ObjectList::set_tooltip_for_item(), ButtonsListCtrl::SetCompact(), TabButtonsListCtrl::SetFooterText(), Slic3r::GUI::ogStaticText::SetText(), Slic3r::GUI::AuiMgr::sidebar_pane_info(), Slic3r::GUI::ObjectList::update_name_column_width(), Slic3r::GUI::ObjectList::update_objects_list_filament_column(), Slic3r::GUI::ObjectDataViewModelNode::update_settings_digest_bitmaps(), Slic3r::GUI::ObjectDataViewModel::UpdateBitmapForNode(), Slic3r::GUI::ImageGrid::UpdateFileSystem(), and Slic3r::GUI::ImageGrid::UpdateLayout().

Here is the call graph for this function:

◆ enable_menu_item()

void enable_menu_item ( wxUpdateUIEvent & evt,
std::function< bool()> const cb_condition,
wxMenuItem * item,
wxWindow * win )
74{
75 const bool enable = cb_condition();
76 evt.Enable(enable);
77
78#ifdef __WXOSX__
79 const auto it = msw_menuitem_bitmaps.find(item->GetId());
80 if (it != msw_menuitem_bitmaps.end())
81 {
82 const wxBitmap& item_icon = create_scaled_bitmap(it->second, win, 16, !enable);
83 if (item_icon.IsOk())
84 item->SetBitmap(item_icon);
85 }
86#endif // __WXOSX__
87}

References create_scaled_bitmap(), and msw_menuitem_bitmaps.

Referenced by append_menu_item(), and append_submenu().

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

◆ get_default_extruder_color_icon()

wxBitmap * get_default_extruder_color_icon ( bool thin_icon = false)
528{
529 static Slic3r::GUI::BitmapCache bmp_cache;
530
531 const double em = Slic3r::GUI::wxGetApp().em_unit();
532 const int icon_width = lround((thin_icon ? 2 : 4.5) * em);
533 const int icon_height = lround(2 * em);
534 bool dark_mode = Slic3r::GUI::wxGetApp().dark_mode();
535
536 auto win = (wxWindow*)Slic3r::GUI::wxGetApp().mainframe;
537 wxClientDC cdc(win);
538 wxMemoryDC dc(&cdc);
539 dc.SetFont(::Label::Body_12);
540
541 wxString label = _L("default");
542 std::string bitmap_key = std::string("default_color") + "-h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width)
543 + "-i" + label.ToStdString();
544
545 wxBitmap* bitmap = bmp_cache.find(bitmap_key);
546 if (bitmap == nullptr) {
547 // Paint the color icon.
548 //Slic3r::GUI::BitmapCache::parse_color(color, rgb);
549 // there is no neede to scale created solid bitmap
550 wxColor clr(255, 255, 255, 0);
551 bitmap = bmp_cache.insert(bitmap_key, wxBitmap(icon_width, icon_height));
552 dc.SelectObject(*bitmap);
553 dc.SetBackground(wxBrush(clr));
554 dc.Clear();
555 dc.SetBrush(wxBrush(clr));
556 dc.SetPen(*wxGREY_PEN);
557 auto size = dc.GetTextExtent(wxString(label));
558 dc.SetTextForeground(clr.GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK);
559 dc.DrawText(label, (icon_width - size.x) / 2, (icon_height - size.y) / 2);
560 dc.SelectObject(wxNullBitmap);
561 }
562
563 #ifdef __WXMSW__
564 // ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
565 double scale = win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0);
566 bitmap->SetScaleFactor(scale);
567 #endif
568
569 return bitmap;
570}
#define _L(s)
Definition OBJ.cpp:34
int scale(const int val)
Definition WipeTowerDialog.cpp:58
static wxFont Body_12
Definition Label.hpp:55
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

References _L, Label::Body_12, Slic3r::GUI::BitmapCache::find(), Slic3r::GUI::BitmapCache::insert(), and scale().

Referenced by BitmapChoiceRenderer::CreateEditorCtrl(), and Slic3r::GUI::ObjectDataViewModelNode::UpdateExtruderAndColorIcon().

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

◆ get_extruder_color_icon() [1/2]

wxBitmap * get_extruder_color_icon ( std::string color,
std::string label,
int icon_width,
int icon_height )
739{
740 static Slic3r::GUI::BitmapCache bmp_cache;
741
742 std::string bitmap_key = color + "-h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width) + "-i" + label;
743
744 wxBitmap *bitmap = bmp_cache.find(bitmap_key);
745 #ifdef __WXMSW__
746 auto win = (wxWindow *) Slic3r::GUI::wxGetApp().mainframe;
747 #endif
748 if (bitmap == nullptr) {
749 // Paint the color icon.
750 // Slic3r::GUI::BitmapCache::parse_color(color, rgb);
751 // there is no neede to scale created solid bitmap
752 wxColor clr(color);
753 bitmap = bmp_cache.insert(bitmap_key, wxBitmap(icon_width, icon_height));
754#ifdef __WXOSX__
755 bitmap->UseAlpha();
756 wxMemoryDC dc(*bitmap);
757#elif defined(__WXMSW__)
758 wxClientDC cdc(win);
759 wxMemoryDC dc(&cdc);
760 dc.SelectObject(*bitmap);
761#else
762 wxMemoryDC dc;
763 dc.SelectObject(*bitmap);
764#endif
765 dc.SetFont(::Label::Body_12);
767 if (clr.Alpha() == 0) {
768 int size = icon_height * 2;
769 static wxBitmap transparent = *Slic3r::GUI::BitmapCache().load_svg("transparent", size, size);
770 if (transparent.GetHeight() != size) transparent = *Slic3r::GUI::BitmapCache().load_svg("transparent", size, size);
771 wxPoint pt(0, 0);
772 while (pt.x < icon_width) {
773 dc.DrawBitmap(transparent, pt);
774 pt.x += size;
775 }
776 clr.SetRGB(0xffffff); // for text color
777 dc.SetBrush(*wxTRANSPARENT_BRUSH);
778 } else {
779 dc.SetBackground(wxBrush(clr));
780 dc.Clear();
781 dc.SetBrush(wxBrush(clr));
782 }
783 if (clr.Red() > 224 && clr.Blue() > 224 && clr.Green() > 224) {
784 dc.SetPen(*wxGREY_PEN);
785 dc.DrawRectangle(0, 0, icon_width, icon_height);
786 }
787 auto size = dc.GetTextExtent(wxString(label));
788 dc.SetTextForeground(clr.GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK);
789 dc.DrawText(label, (icon_width - size.x) / 2, (icon_height - size.y) / 2);
790 dc.SelectObject(wxNullBitmap);
791 }
792 #ifdef __WXMSW__
793 // ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
794 double scale = win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0);
795 bitmap->SetScaleFactor(scale);
796 #endif
797 return bitmap;
798}
static void get_suitable_font_size(int max_height, wxDC &dc)
Definition WxFontUtils.cpp:309

References Label::Body_12, Slic3r::GUI::BitmapCache::find(), Slic3r::GUI::WxFontUtils::get_suitable_font_size(), Slic3r::GUI::BitmapCache::insert(), Slic3r::GUI::BitmapCache::load_svg(), and scale().

Here is the call graph for this function:

◆ get_extruder_color_icon() [2/2]

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 = nullptr )
634 {
635
636 static Slic3r::GUI::BitmapCache bmp_cache;
637
638 // build cache key, include all color info. A ramp already encodes its slot's components,
639 // colours and curve, so keying on it rebuilds the icon whenever any of them change.
640 std::string bitmap_key = "";
641 if (ramp != nullptr) {
642 static const char hex_digits[] = "0123456789ABCDEF";
643 bitmap_key = "grad_";
644 for (const wxColour &c : *ramp)
645 for (unsigned char v : {c.Red(), c.Green(), c.Blue()}) {
646 bitmap_key += hex_digits[v >> 4];
647 bitmap_key += hex_digits[v & 0x0F];
648 }
649 bitmap_key += "_";
650 } else {
651 for (const auto& color : colors) {
652 bitmap_key += color + "_";
653 }
654 }
655 bitmap_key += "h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width) + "-i" + label;
656
657 wxBitmap *bitmap = bmp_cache.find(bitmap_key);
658 #ifdef __WXMSW__
659 auto win = (wxWindow *) Slic3r::GUI::wxGetApp().mainframe;
660 #endif
661 if (bitmap == nullptr) {
662
663 wxBitmap base_bitmap;
664 if (ramp != nullptr) {
665 base_bitmap = Slic3r::GUI::create_gradient_ramp_bitmap(*ramp, wxSize(icon_width, icon_height));
666 } else {
667 std::vector<wxColour> wx_colors;
668 for (const auto& color_str : colors) {
669 wx_colors.push_back(wxColour(color_str));
670 }
671 if (wx_colors.empty()) {
672 wx_colors.push_back(wxColour("#636363")); // default color if no colors provided
673 }
674
675 // create filament bitmap in multi color
676 base_bitmap = Slic3r::GUI::create_filament_bitmap(wx_colors, wxSize(icon_width, icon_height), is_gradient);
677 }
678
679 if (!base_bitmap.IsOk()) {
680 // if create failed, return nullptr
681 return nullptr;
682 }
683
684 // add text label directly on base_bitmap
685 if (!label.empty()) {
686#ifndef __WXMSW__
687 wxMemoryDC dc(base_bitmap);
688#else
689 wxClientDC cdc(win);
690 wxMemoryDC dc(&cdc);
691 // ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
692 double scale = win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0);
693 base_bitmap.SetScaleFactor(scale);
694 dc.SelectObject(base_bitmap);
695#endif
696
697 // Ensure no background contamination
698 dc.SetBrush(*wxTRANSPARENT_BRUSH);
699 dc.SetPen(*wxTRANSPARENT_PEN);
700
701 dc.SetFont(::Label::Body_12);
703
704 auto size = dc.GetTextExtent(wxString(label));
705
706 // Set transparent background mode for text rendering
707 dc.SetBackgroundMode(wxTRANSPARENT);
708
709 // draw text with black border effect
710 int text_x = (icon_width - size.x) / 2;
711 int text_y = (icon_height - size.y) / 2;
712
713 // Draw very thin border with lighter color and fewer directions
714 dc.SetTextForeground(wxColor("262E30")); // Semi-transparent dark gray
715 dc.DrawText(label, text_x - 1, text_y); // Left
716 dc.DrawText(label, text_x + 1, text_y); // Right
717 dc.DrawText(label, text_x, text_y - 1); // Up
718 dc.DrawText(label, text_x, text_y + 1); // Down
719
720 // Draw main white text on top
721 dc.SetTextForeground(*wxWHITE);
722 dc.DrawText(label, text_x, text_y);
723
724 dc.SelectObject(wxNullBitmap);
725 }
726
727 // cache result
728 bitmap = bmp_cache.insert(bitmap_key, base_bitmap);
729 }
730 #ifdef __WXMSW__
731 // ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
732 double scale = win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0);
733 bitmap->SetScaleFactor(scale);
734 #endif
735 return bitmap;
736}
wxBitmap create_filament_bitmap(const std::vector< wxColour > &colors, const wxSize &size, bool force_gradient)
Definition FilamentBitmapUtils.cpp:415
wxBitmap create_gradient_ramp_bitmap(const std::vector< wxColour > &ramp, const wxSize &size)
Definition FilamentBitmapUtils.cpp:222

References Label::Body_12, Slic3r::GUI::create_filament_bitmap(), Slic3r::GUI::create_gradient_ramp_bitmap(), Slic3r::GUI::BitmapCache::find(), Slic3r::GUI::WxFontUtils::get_suitable_font_size(), Slic3r::GUI::BitmapCache::insert(), and scale().

Referenced by Slic3r::GUI::MixedFilamentWarningDialog::MixedFilamentWarningDialog(), Slic3r::GUI::PresetComboBox::add_ams_filaments(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::PublishSettingsDialog::category_index_for(), Slic3r::GUI::MixedFilamentDialog::create_material_selection(), get_extruder_color_icons(), Slic3r::GUI::CrealityPrintHostSendDialog::init(), Slic3r::GUI::CalibrateFilamentComboBox::load_tray(), Slic3r::GUI::MixedFilamentDialog::make_swatch_bitmap(), Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::mixed_filament_chip_bitmap(), Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::mixed_filament_tab_bitmap(), Slic3r::GUI::CalibrateFilamentComboBox::msw_rescale(), Slic3r::GUI::PublishSettingsDialog::on_dpi_changed(), Slic3r::GUI::DragCanvas::set_shape_list(), Slic3r::GUI::CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(), and Slic3r::GUI::MixedFilamentDialog::update_gradient_direction_items().

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

◆ get_extruder_color_icons()

std::vector< wxBitmap * > get_extruder_color_icons ( bool thin_icon = false)
573{
574 // Create the bitmap with color bars.
575 std::vector<wxBitmap*> bmps;
576 std::vector<std::string> filaments_color_info = Slic3r::GUI::wxGetApp().plater()->get_filament_colors_render_info();
577 std::vector<std::string> ctype = Slic3r::GUI::wxGetApp().plater()->get_filament_color_render_type();
578
579 if (!filaments_color_info.empty() && !ctype.empty() && ctype.size() == filaments_color_info.size()) {
580 std::vector<std::vector<std::string>> readable_color_info = read_color_pack(filaments_color_info);
581 /* It's supposed that standard size of an icon is 36px*16px for 100% scaled display.
582 * So set sizes for solid_colored icons used for filament preset
583 * and scale them in respect to em_unit value
584 */
585 const double em = Slic3r::GUI::wxGetApp().em_unit();
586 const int icon_width = lround((thin_icon ? 2 : 4.4) * em);
587 const int icon_height = lround(2 * em);
588
589 // A gradient mixed filament fades over the model's height, so it gets the same
590 // curve-sampled ramp the editor previews instead of a fade between two endpoints.
591 const auto& gradient_ramps = Slic3r::GUI::wxGetApp().plater()->get_filament_gradient_ramps();
592
593 int index = 0;
594 for (const auto &colors : readable_color_info) {
595 auto label = std::to_string(++index);
596 const size_t slot = index - 1;
597 bool is_gradient = ctype[slot] == "0";
598 const std::vector<wxColour>* ramp = (slot < gradient_ramps.size() && !gradient_ramps[slot].empty()) ? &gradient_ramps[slot] : nullptr;
599 if (ramp == nullptr && colors.size() == 1) {
600 bmps.push_back(get_extruder_color_icon(colors[0], label, icon_width, icon_height));
601 } else {
602 bmps.push_back(get_extruder_color_icon(colors, is_gradient, label, icon_width, icon_height, ramp));
603 }
604 }
605 } else {
606 std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
607 if (colors.empty()) return bmps;
608
609 const double em = Slic3r::GUI::wxGetApp().em_unit();
610 const int icon_width = lround((thin_icon ? 2 : 4.4) * em);
611 const int icon_height = lround(2 * em);
612 int index = 0;
613 for (const auto &color : colors) {
614 auto label = std::to_string(++index);
615 bmps.push_back(get_extruder_color_icon(color, label, icon_width, icon_height));
616 }
617 }
618 return bmps;
619
620
621}
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:273
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
std::vector< std::vector< std::string > > read_color_pack(std::vector< std::string > color_pack)
Definition wxExtensions.cpp:623

References get_extruder_color_icon(), and read_color_pack().

Referenced by Slic3r::GUI::MenuFactory::append_menu_item_change_extruder(), Slic3r::GUI::MenuFactory::append_menu_item_change_filament(), apply_extruder_selector(), Slic3r::GUI::IMEXFilamentPickerPopover::build_row(), Slic3r::GUI::MenuFactory::create_filament_action_menu(), BitmapChoiceRenderer::CreateEditorCtrl(), Slic3r::GUI::ObjectTablePanel::init_bitmap(), Slic3r::GUI::DynamicFilamentList::update(), Slic3r::GUI::PlaterPresetComboBox::update(), Slic3r::GUI::Sidebar::update_mixed_filament_list(), and Slic3r::GUI::ObjectDataViewModelNode::UpdateExtruderAndColorIcon().

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

◆ msw_buttons_rescale()

void msw_buttons_rescale ( wxDialog * dlg,
const int em_unit,
const std::vector< int > & btn_ids )
407{
408 const wxSize& btn_size = wxSize(-1, int(2.5f * em_unit + 0.5f));
409
410 for (int btn_id : btn_ids) {
411 // There is a case [FirmwareDialog], when we have wxControl instead of wxButton
412 // so let casting everything to the wxControl
413 wxControl* btn = static_cast<wxControl*>(dlg->FindWindowById(btn_id, dlg));
414 if (btn)
415 btn->SetMinSize(btn_size);
416 }
417}

References em_unit().

Referenced by Slic3r::GUI::AboutDialog::on_dpi_changed(), Slic3r::GUI::ConfigWizard::on_dpi_changed(), Slic3r::GUI::CopyrightsDialog::on_dpi_changed(), Slic3r::GUI::OAuthDialog::on_dpi_changed(), Slic3r::GUI::PrintHostQueueDialog::on_dpi_changed(), and Slic3r::GUI::SendSystemInfoDialog::on_dpi_changed().

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

◆ msw_rescale_menu()

void msw_rescale_menu ( wxMenu * )
inline
33{}

Referenced by Slic3r::GUI::MenuFactory::msw_rescale(), Slic3r::GUI::MainFrame::on_dpi_changed(), Slic3r::GUI::MenuFactory::sys_color_changed(), and Slic3r::GUI::MenuFactory::sys_color_changed().

Here is the caller graph for this function:

◆ read_color_pack()

std::vector< std::vector< std::string > > read_color_pack ( std::vector< std::string > color_pack)
623 {
624 std::vector<std::vector<std::string>> color_info;
625 for (const std::string &color : color_pack) {
626 std::vector<std::string> colors;
627 colors = Slic3r::split_string(color, ' ');
628 color_info.push_back(colors);
629 }
630 return color_info;
631}
std::vector< std::string > split_string(const std::string &str, char delimiter)
Definition utils.cpp:1424

References Slic3r::split_string().

Referenced by get_extruder_color_icons().

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