233 : wxPanel(parent)
236{
237 wxGetApp().UpdateDarkUI(this);
238 const auto &models = vendor.models;
239
240 auto *sizer = new wxBoxSizer(wxVERTICAL);
241
242 const auto font_title = GetFont().MakeBold().Scaled(1.3f);
243 const auto font_name = GetFont().MakeBold();
244 const auto font_alt_nozzle = GetFont().Scaled(0.9f);
245
246
247
248 std::vector<wxStaticText*> titles;
249 std::vector<wxStaticBitmap*> bitmaps;
250 std::vector<wxPanel*> variants_panels;
251
252 int max_row_width = 0;
253 int current_row_width = 0;
254
255 bool is_variants = false;
256
257 for (const auto &model : models) {
258 if (! filter(model)) { continue; }
259
260 wxBitmap bitmap;
261 int bitmap_width = 0;
262 auto load_bitmap = [](const wxString& bitmap_file, wxBitmap& bitmap, int& bitmap_width)->bool {
263 if (wxFileExists(bitmap_file)) {
264 bitmap.LoadFile(bitmap_file, wxBITMAP_TYPE_PNG);
265 bitmap_width = bitmap.GetWidth();
266 return true;
267 }
268 return false;
269 };
270 if (!load_bitmap(
GUI::from_u8(
Slic3r::data_dir() +
"/vendor/" + vendor.id +
"/" + model.id +
"_thumbnail.png"), bitmap, bitmap_width)) {
272 BOOST_LOG_TRIVIAL(warning) << boost::format("Can't find bitmap file `%1%` for vendor `%2%`, printer `%3%`, using placeholder icon instead")
274 % vendor.id
275 % model.id;
277 }
278 }
279 auto *title =
new wxStaticText(
this, wxID_ANY,
from_u8(model.name), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
280 title->SetFont(font_name);
281 const int wrap_width = std::max((
int)
MODEL_MIN_WRAP, bitmap_width);
282 title->Wrap(wrap_width);
283
284 current_row_width += wrap_width;
285 if (titles.size() % max_cols == max_cols - 1) {
286 max_row_width = std::max(max_row_width, current_row_width);
287 current_row_width = 0;
288 }
289
290 titles.push_back(title);
291
292 auto *bitmap_widget = new wxStaticBitmap(this, wxID_ANY, bitmap);
293 bitmaps.push_back(bitmap_widget);
294
295 auto *variants_panel = new wxPanel(this);
296 wxGetApp().UpdateDarkUI(variants_panel);
297 auto *variants_sizer = new wxBoxSizer(wxVERTICAL);
298 variants_panel->SetSizer(variants_sizer);
299 const auto model_id = model.id;
300
301 for (size_t i = 0; i < model.variants.size(); i++) {
302 const auto &variant = model.variants[i];
303
304 const auto label = model.technology ==
ptFFF
305 ?
from_u8((boost::format(
"%1% %2% %3%") % variant.name %
_utf8(
L(
"mm")) %
_utf8(
L(
"nozzle"))).str())
307
308 if (i == 1) {
309 auto *alt_label =
new wxStaticText(variants_panel, wxID_ANY,
_L(
"Alternate nozzles:"));
310 alt_label->SetFont(font_alt_nozzle);
311 variants_sizer->Add(alt_label, 0, wxBOTTOM, 3);
312 is_variants = true;
313 }
314
315 auto *cbox =
new Checkbox(variants_panel, label, model_id, variant.name);
317
318 const bool enabled = appconfig.get_variant(vendor.id, model_id, variant.name);
319 cbox->SetValue(enabled);
320
321 variants_sizer->Add(cbox, 0, wxBOTTOM, 3);
322
323 cbox->Bind(wxEVT_CHECKBOX, [this, cbox](wxCommandEvent &event) {
325 });
326 }
327
328 variants_panels.push_back(variants_panel);
329 }
330
331 width = std::max(max_row_width, current_row_width);
332
333 const size_t cols = std::min(max_cols, titles.size());
334
335 auto *printer_grid = new wxFlexGridSizer(cols, 0, 20);
336 printer_grid->SetFlexibleDirection(wxVERTICAL | wxHORIZONTAL);
337
338 if (titles.size() > 0) {
339 const size_t odd_items = titles.size() %
cols;
340
341 for (
size_t i = 0; i < titles.size() - odd_items; i +=
cols) {
342 for (
size_t j = i; j < i +
cols; j++) { printer_grid->Add(bitmaps[j], 0, wxBOTTOM, 20); }
343 for (
size_t j = i; j < i +
cols; j++) { printer_grid->Add(titles[j], 0, wxBOTTOM, 3); }
344 for (
size_t j = i; j < i +
cols; j++) { printer_grid->Add(variants_panels[j]); }
345
346
347 if (titles.size() > cols) {
348 for (
size_t j = i; j < i +
cols; j++) { printer_grid->Add(1, 30); }
349 }
350 }
351 if (odd_items > 0) {
352 const size_t rem = titles.size() - odd_items;
353
354 for (size_t i = rem; i < titles.size(); i++) { printer_grid->Add(bitmaps[i], 0, wxBOTTOM, 20); }
355 for (
size_t i = 0; i <
cols - odd_items; i++) { printer_grid->AddSpacer(1); }
356 for (size_t i = rem; i < titles.size(); i++) { printer_grid->Add(titles[i], 0, wxBOTTOM, 3); }
357 for (
size_t i = 0; i <
cols - odd_items; i++) { printer_grid->AddSpacer(1); }
358 for (size_t i = rem; i < titles.size(); i++) { printer_grid->Add(variants_panels[i]); }
359 }
360 }
361
362 auto *title_sizer = new wxBoxSizer(wxHORIZONTAL);
363 if (! title.IsEmpty()) {
364 auto *title_widget =
new wxStaticText(
this, wxID_ANY, title);
365 title_widget->SetFont(font_title);
366 title_sizer->Add(title_widget);
367 }
368 title_sizer->AddStretchSpacer();
369
370 if (titles.size() > 1 || is_variants) {
371
372
373 auto *sel_all_std =
new Button(
this, titles.size() > 1 ?
_L(
"All standard") :
_L(
"Standard"));
374 auto *sel_all =
new Button(
this,
_L(
"All"));
375 auto *sel_none =
new Button(
this,
_L(
"None"));
376
377 wxGetApp().UpdateDarkUI(sel_all_std);
378 wxGetApp().UpdateDarkUI(sel_all);
379 wxGetApp().UpdateDarkUI(sel_none);
380
381 if (is_variants)
382 sel_all_std->Bind(wxEVT_BUTTON, [
this](
const wxCommandEvent& event) { this->
select_all(
true,
false); });
383 sel_all->Bind(wxEVT_BUTTON, [
this](
const wxCommandEvent &event) { this->
select_all(
true,
true); });
384 sel_none->Bind(wxEVT_BUTTON, [
this](
const wxCommandEvent &event) { this->
select_all(
false); });
385 if (is_variants)
386 title_sizer->Add(sel_all_std, 0, wxRIGHT,
BTN_SPACING);
387 title_sizer->Add(sel_all, 0, wxRIGHT,
BTN_SPACING);
388 title_sizer->Add(sel_none);
389
390 wxGetApp().UpdateDarkUI(sel_all_std);
391 wxGetApp().UpdateDarkUI(sel_all);
392 wxGetApp().UpdateDarkUI(sel_none);
393
394
395 if (is_variants)
396 m_button_indexes = { sel_all_std->GetId(), sel_all->GetId(), sel_none->GetId() };
397 else {
398 sel_all_std->Destroy();
400 }
401 }
402
403 sizer->Add(title_sizer, 0, wxEXPAND | wxBOTTOM,
BTN_SPACING);
404 sizer->Add(printer_grid);
405
406 SetSizer(sizer);
407}
#define L(s)
Definition ExtrusionEntity.cpp:25
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
@ MODEL_MIN_WRAP
Definition ConfigWizard_private.hpp:51
@ BTN_SPACING
Definition ConfigWizard_private.hpp:55
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
std::string var(const std::string &file_name)
Definition utils.cpp:278
@ ptFFF
Definition Config.hpp:231
const std::string & data_dir()
Definition utils.cpp:365
const std::string & resources_dir()
Definition utils.cpp:296
size_t cols(const T &raster)
Definition MarchingSquares.hpp:173
#define _utf8(s)
Definition I18N.hpp:10
Definition ConfigWizard_private.hpp:182
int width
Definition ConfigWizard_private.hpp:210
void select_all(bool select, bool alternates=false)
Definition ConfigWizard.cpp:413
std::vector< Checkbox * > cboxes_alt
Definition ConfigWizard_private.hpp:195
void on_checkbox(const Checkbox *cbox, bool checked)
Definition ConfigWizard.cpp:468
std::vector< Checkbox * > cboxes
Definition ConfigWizard_private.hpp:194
std::vector< int > m_button_indexes
Definition ConfigWizard_private.hpp:211
static const std::string PRINTER_PLACEHOLDER
Definition ConfigWizard_private.hpp:208
const std::string vendor_id
Definition ConfigWizard_private.hpp:193