63{
65
67
70 m_root_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, 6);
71
73
74 std::vector<int> lane_logicals;
75 for (
size_t L = 0;
L <
m_pem.values.size(); ++
L)
77 lane_logicals.push_back((
int)
L);
78
80
81 auto* choice = new BitmapComboBox(this, wxID_ANY, wxEmptyString,
82 wxDefaultPosition, wxSize(140, -1),
83 0, nullptr, wxCB_READONLY);
84 const int left_pad_px = 8;
85 auto pad_left = [&](const wxBitmap& src) -> wxBitmap {
86 if (!src.IsOk()) return src;
87 wxImage im(src.GetWidth() + left_pad_px, src.GetHeight());
88 im.InitAlpha();
89 unsigned char* a = im.GetAlpha();
90 std::fill(a, a + im.GetWidth() * im.GetHeight(), (unsigned char)0);
91 wxBitmap out(im);
92 wxMemoryDC dc(out);
93 dc.DrawBitmap(src, left_pad_px, 0, true);
94 dc.SelectObject(wxNullBitmap);
95 return out;
96 };
97
98 for (
int L : lane_logicals) {
99 const wxString label = wxString::Format(
_L(
"Filament %d"),
L + 1);
100 if (
L >= 0 &&
L < (
int)bmps.size() && bmps[
L] && bmps[
L]->IsOk())
101 choice->Append(label, pad_left(*bmps[
L]));
102 else
103 choice->Append(label, wxNullBitmap);
104 }
105
106 const auto map =
m_plate->get_imex_head_filament_map();
108 int selected_slot_1based = (it != map.end())
109 ? it->second
110 : (lane_logicals.empty() ? -1 : lane_logicals.front() + 1);
111
112 for (int i = 0; i < (int)lane_logicals.size(); ++i) {
113 if (lane_logicals[i] + 1 == selected_slot_1based) {
114 choice->SetSelection(i);
115 break;
116 }
117 }
118
119 choice->Bind(wxEVT_COMBOBOX, [this, lane_logicals, choice](wxCommandEvent&) {
120 int sel = choice->GetSelection();
121 if (sel < 0 || sel >= (int)lane_logicals.size()) return;
123
124
125
126 DismissAndNotify();
127 });
128
129 m_root_sizer->Add(choice, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6);
131}
#define L(s)
Definition ExtrusionEntity.cpp:25
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
void on_filament_selected(int slot_1_based)
Definition IMEXFilamentPickerPopover.cpp:133
std::vector< wxBitmap * > get_extruder_color_icons(bool thin_icon)
Definition wxExtensions.cpp:572