320{
321 wxSize size = GetSize();
325
326 if (mcolor.Alpha() == 0)
327 {
329 }
330
332 {
333 mcolor = wxColour(0x90, 0x90, 0x90);
334 acolor = wxColour(0x90, 0x90, 0x90);
335 }
336
337
338 dc.SetPen(*wxTRANSPARENT_PEN);
340 int top_h = FromDIP(20);
341 bool drawn = false;
342
343 wxGraphicsContext* gc = dc.GetGraphicsContext();
344 if (gc) {
345 double r = FromDIP(5);
346 auto make_path = [&](double x, double w, bool left_round, bool right_round) {
347 wxGraphicsPath p = gc->CreatePath();
348 double rl = left_round ? std::min<double>(r, std::min<double>(w, top_h)) : 0.0;
349 double rr = right_round ? std::min<double>(r, std::min<double>(w, top_h)) : 0.0;
350 p.MoveToPoint(x, top_h);
351 p.AddLineToPoint(x, rl);
352 if (rl > 0) p.AddArc(x + rl, rl, rl,
M_PI, -
M_PI / 2,
true);
353 p.AddLineToPoint(x + w - rr, 0);
354 if (rr > 0) p.AddArc(x + w - rr, rr, rr, -
M_PI / 2, 0,
true);
355 p.AddLineToPoint(x + w, top_h);
356 p.CloseSubpath();
357 return p;
358 };
359
361 wxGraphicsPath path = make_path(0, size.x, true, true);
366 }
367 gc->SetBrush(gc->CreateLinearGradientBrush(0, 0, size.x, 0, stops));
368 gc->FillPath(path);
369 } else {
371 for (int i = 0; i < cols_size; i++) {
372 double x0 = (double)size.x * i / cols_size;
373 double w = (i == cols_size - 1) ? (size.x - x0) : ((double)size.x / cols_size);
374 wxGraphicsPath seg = make_path(x0, w, i == 0, i == cols_size - 1);
376 gc->FillPath(seg);
377 }
378 }
379 drawn = true;
380 }
381
382 if (!drawn) {
385 int gw = std::round((double)size.x / seg);
386 for (int i = 0; i < seg; i++) {
387 int x0 = gw * i;
388 int w = (i == seg - 1) ? (size.x - x0) : gw;
390 }
391 } else {
393 int cw = std::round((double)size.x / cols_size);
394 for (int i = 0; i < cols_size; i++) {
396 int x0 = cw * i;
397 int w = (i == cols_size - 1) ? (size.x - x0) : cw;
398 dc.DrawRectangle(x0, 0, w, top_h);
399 }
400 }
401 }
402 } else {
403 dc.SetBrush(wxBrush(mcolor));
404 dc.DrawRoundedRectangle(0, 0, size.x, FromDIP(20), 5);
405
406 dc.SetPen(*wxTRANSPARENT_PEN);
407 dc.SetBrush(wxBrush(mcolor));
408 dc.DrawRectangle(0, FromDIP(10), size.x, FromDIP(10));
409 }
410
411
413 auto material_name_colour = mcolor.GetLuminance() < 0.6 ? *wxWHITE : wxColour(0x26, 0x2E, 0x30);
414 if (mcolor.Alpha() == 0) { material_name_colour = wxColour(0x26, 0x2E, 0x30); }
415 dc.SetTextForeground(material_name_colour);
416
419 {
421 }
422
424 dc.DrawText(
m_material_name, wxPoint((GetSize().x - material_txt_size.x) / 2, (FromDIP(20) - material_txt_size.y) / 2));
425
426 dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
427 dc.DrawLine(FromDIP(1), FromDIP(20), FromDIP(size.x), FromDIP(20));
430
431
435 dc.SetPen(*wxTRANSPARENT_PEN);
436
438 {
440
442 {
443 for (
int i = 0; i <
m_ams_cols.size() - 1; i++)
444 {
448 }
449 }
450 else
451 {
453 for (int i = 0; i < cols_size; i++)
454 {
457 if (i != cols_size - 1)
458 {
460 }
461 else
462 {
464 }
465 }
466 }
467 }
468 else
469 {
471 {
472 dc.SetPen(*wxTRANSPARENT_PEN);
473 dc.SetBrush(wxBrush(wxColour(acolor)));
476 }
477 }
478
480 {
481 dc.SetPen(wxPen(wxGetApp().dark_mode() ? wxColour(107, 107, 107) : wxColour(0xAC, 0xAC, 0xAC), FromDIP(1)));
482 }
483 else
484 {
485 dc.SetPen(wxPen(wxColour(234, 31, 48), FromDIP(1)));
486 }
487
488 dc.SetBrush(*wxTRANSPARENT_BRUSH);
489 dc.DrawRoundedRectangle(FromDIP(0), FromDIP(0), size.x - FromDIP(0), size.y, 5);
490
492 {
493 dc.SetPen(wxPen(wxColour("#009688"), FromDIP(2)));
494 dc.SetBrush(*wxTRANSPARENT_BRUSH);
495 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(1), size.y - FromDIP(1), 5);
497 dc.SetPen(wxPen(wxColour(0xFF, 0x6F, 0x00), FromDIP(2)));
498 dc.SetBrush(*wxTRANSPARENT_BRUSH);
499 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(1), size.y - FromDIP(1), 5);
500 }
501
502
505
507 {
510 }
511 else
512 {
513 if (acolor.Alpha() == 0)
514 {
516 }
517 else
518 {
520 }
521 }
522
523
525
526 int text_pos_x = 0;
527 int text_pos_y = 0;
528 auto mapping_txt_size = wxSize(0, 0);
530 {
535 text_pos_x = mapping_txt_size.x / 4;
536 }
537 else
538 {
542 text_pos_x = 0;
543 }
544
547 {
548 dc.DrawText(
m_mapping_text, wxPoint(GetSize().x / 2 + (GetSize().x / 2 - mapping_txt_size.x) / 2 - FromDIP(8) - FromDIP(
LEFT_OFFSET) + text_pos_x, text_pos_y));
549
551 if ((acolor.Red() > 160 && acolor.Green() > 160 && acolor.Blue() > 160) && (acolor.Red() < 180 && acolor.Green() < 180 && acolor.Blue() < 180))
552 {
554 }
555 else
556 {
558 }
559 }
560
562
563
565 wxPen dashed_pen(wxColour("#CECECE"), 1, wxPENSTYLE_SHORT_DASH);
566 dc.SetPen(dashed_pen);
568 dc.DrawLine(FromDIP(1), up, FromDIP(size.x), up);
569
573
576
577
578 const auto& text_size = dc.GetTextExtent(wrapped_nozzle_str);
580 int text_y =
up + (size.y -
up - text_size.y) / 2;
581 dc.DrawText(wrapped_nozzle_str, text_x, text_y);
582 }
583}
#define M_PI
Definition ExtrusionSimulator.cpp:31
static wxFont Head_12
Definition Label.hpp:47
static wxFont Body_12
Definition Label.hpp:55
static wxFont Body_10
Definition Label.hpp:56
bool m_warning
Definition AmsMappingPopup.hpp:170
std::vector< wxColour > m_ams_cols
Definition AmsMappingPopup.hpp:153
wxString m_mapping_text
Definition AmsMappingPopup.hpp:104
bool m_selected
Definition AmsMappingPopup.hpp:169
int m_material_ctype
Definition AmsMappingPopup.hpp:144
wxString m_mapped_nozzle_str
Definition AmsMappingPopup.hpp:147
int m_ams_ctype
Definition AmsMappingPopup.hpp:152
bool m_match
Definition AmsMappingPopup.hpp:171
std::vector< wxColour > m_material_cols
Definition AmsMappingPopup.hpp:145
static void get_suitable_font_size(int max_height, wxDC &dc)
Definition WxFontUtils.cpp:309
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
const int LEFT_OFFSET
Definition AmsMappingPopup.cpp:81
static wxString s_wrap_mapped_nozzle_str(const wxString &text)
Definition AmsMappingPopup.cpp:268
void fill_gradient_rect_east(wxDC &dc, const wxRect &rect, const wxColour &from, const wxColour &to)
Definition FilamentBitmapUtils.cpp:76
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16
void change_the_opacity(wxColour &colour)
Definition DeviceManager.cpp:6154
@ up
Definition MarchingSquares.hpp:192
@ right
Definition MarchingSquares.hpp:190
@ left
Definition MarchingSquares.hpp:188