OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::AMSCountPopupWindow Class Reference
Inheritance diagram for Slic3r::GUI::AMSCountPopupWindow:
Collaboration diagram for Slic3r::GUI::AMSCountPopupWindow:

Public Member Functions

 AMSCountPopupWindow (ExtruderGroup *extruder, int index)
bool Create (wxWindow *parent, int flags=wxBORDER_NONE)

Static Public Member Functions

static void SetAMSCount (int index, int ams4, int ams1)
static void GetAMSCount (int index, int &ams4, int &ams1)
static void UpdateAMSCount (int index, ExtruderGroup *extruder)

Protected Member Functions

virtual bool ShouldDismissOnTopWindowDeactivate ()

Detailed Description

Constructor & Destructor Documentation

◆ AMSCountPopupWindow()

Slic3r::GUI::AMSCountPopupWindow::AMSCountPopupWindow ( ExtruderGroup * extruder,
int index )
inline
1419 : PopupWindow(extruder, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS)
1420 {
1421 SetBackgroundColour(*wxWHITE);
1422 auto msg = new wxStaticText(this, wxID_ANY, _L("Set the number of AMS installed on the nozzle."));
1423 msg->SetFont(Label::Body_14);
1424 msg->SetForegroundColour("#262E30");
1425 msg->Wrap(FromDIP(280));
1426 auto box = new StaticBox(this, wxID_ANY);
1427 box->SetBackgroundColor(0xF8F8F8);
1428 box->SetBorderWidth(0);
1429 auto img4 = new ScalableButton(box, wxID_ANY, "ams_4_tray", {}, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 44);
1430 //img4->SetBackgroundColour(*wxWHITE);
1431 auto img1 = new ScalableButton(box, wxID_ANY, "ams_1_tray", {}, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 44);
1432 //img1->SetBackgroundColour(*wxWHITE);
1433 auto txt4 = new wxStaticText(box, wxID_ANY, _L("AMS(4 slots)"));
1434 txt4->SetFont(Label::Body_14);
1435 txt4->SetBackgroundColour(0xF8F8F8);
1436 txt4->SetForegroundColour("#262E30");
1437 auto txt1 = new wxStaticText(box, wxID_ANY, _L("AMS(1 slot)"));
1438 txt1->SetFont(Label::Body_14);
1439 txt1->SetBackgroundColour(0xF8F8F8);
1440 txt1->SetForegroundColour("#262E30");
1441 int ams4 = 0, ams1 = 0;
1442 int oth4 = 0, oth1 = 0;
1443 GetAMSCount(index, ams4, ams1);
1444 GetAMSCount(1 - index, oth4, oth1);
1445 auto val4 = new SpinInput(box, {}, {}, wxDefaultPosition, {FromDIP(60), -1}, 0, 0, 4 - oth4, ams4);
1446 auto val1 = new SpinInput(box, {}, {}, wxDefaultPosition, {FromDIP(60), -1}, 0, 0, 8 - oth1, ams1);
1447 auto event_handler = [index, val4, val1, extruder](auto &evt) {
1448 SetAMSCount(index, val4->GetValue(), val1->GetValue());
1449 UpdateAMSCount(index, extruder);
1450 };
1451 val4->Bind(wxEVT_SPINCTRL, event_handler);
1452 val1->Bind(wxEVT_SPINCTRL, event_handler);
1453
1454 wxSizer * sizer = new wxBoxSizer(wxVERTICAL);
1455 sizer->Add(msg, 0, wxTOP | wxLEFT | wxRIGHT, FromDIP(10));
1456 wxSizer *sizer2 = new wxBoxSizer(wxVERTICAL);
1457 wxSizer *sizer21 = new wxBoxSizer(wxHORIZONTAL);
1458 sizer21->Add(img4, 0, wxALIGN_CENTRE);
1459 sizer21->Add(txt4, 2, wxLEFT | wxALIGN_CENTRE, FromDIP(10));
1460 sizer21->Add(val4, 1, wxLEFT | wxALIGN_CENTRE, FromDIP(10));
1461 sizer2->Add(sizer21, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, FromDIP(14));
1462 sizer2->AddSpacer(FromDIP(6));
1463 wxSizer *sizer22 = new wxBoxSizer(wxHORIZONTAL);
1464 sizer22->Add(img1, 0, wxALIGN_CENTRE);
1465 sizer22->Add(txt1, 2, wxLEFT | wxALIGN_CENTRE, FromDIP(10));
1466 sizer22->Add(val1, 1, wxLEFT | wxALIGN_CENTRE, FromDIP(10));
1467 sizer2->Add(sizer22, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, FromDIP(14));
1468 box->SetSizer(sizer2);
1469 sizer->Add(box, 0, wxTOP | wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, FromDIP(14));
1470 SetSizer(sizer);
1471
1472 Layout();
1473 Fit();
1474
1475 Bind(wxEVT_PAINT, [this](wxPaintEvent& evt) {
1476 wxPaintDC dc(this);
1477 dc.SetPen(StateColor::darkModeColorFor(wxColour("#009688"))); // ORCA match popup border color
1478 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1479 dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
1480 });
1481
1482 SetBackgroundColour(*wxWHITE);
1483 wxGetApp().UpdateDarkUIWin(this);
1484 }
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Body_14
Definition Label.hpp:53
PopupWindow()
Definition PopupWindow.hpp:10
static void UpdateAMSCount(int index, ExtruderGroup *extruder)
Definition Plater.cpp:1514
static void GetAMSCount(int index, int &ams4, int &ams1)
Definition Plater.cpp:1500
static void SetAMSCount(int index, int ams4, int ams1)
Definition Plater.cpp:1486
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References PopupWindow::PopupWindow(), _L, Label::Body_14, StateColor::darkModeColorFor(), GetAMSCount(), SpinInput::GetValue(), SetAMSCount(), UpdateAMSCount(), and wxStaticText.

Here is the call graph for this function:

Member Function Documentation

◆ Create()

bool PopupWindow::Create ( wxWindow * parent,
int flags = wxBORDER_NONE )
inherited
22{
23 if (!wxPopupTransientWindow::Create(parent, style))
24 return false;
25#ifdef __WXGTK__
26 GetTopParent(parent)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
27#endif
28#ifdef __WXOSX__
29 if (style & wxPU_CONTAINS_CONTROLS)
30 for (auto evt : {wxEVT_LEFT_DOWN, wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK, wxEVT_MOTION, wxEVT_MOUSEWHEEL})
31 Bind(evt, &PopupWindow::OnMouseEvent2, this);
32#endif
33 return true;
34}
static wxWindow * GetTopParent(wxWindow *pWindow)
Definition PopupWindow.cpp:10
#define style
Definition WipeTowerDialog.cpp:101

References GetTopParent(), and style.

Referenced by PopupWindow(), and DropDown::Create().

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

◆ GetAMSCount()

void Slic3r::GUI::AMSCountPopupWindow::GetAMSCount ( int index,
int & ams4,
int & ams1 )
inlinestatic
1501 {
1502 PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
1503 if (preset_bundle.extruder_ams_counts.empty()) {
1504 ams4 = 0;
1505 ams1 = 0;
1506 }
1507 else {
1508 assert(preset_bundle.extruder_ams_counts.size() == 2);
1509 ams4 = preset_bundle.extruder_ams_counts[index][4];
1510 ams1 = preset_bundle.extruder_ams_counts[index][1];
1511 }
1512 }

References Slic3r::PresetBundle::extruder_ams_counts.

Referenced by AMSCountPopupWindow().

Here is the caller graph for this function:

◆ SetAMSCount()

void Slic3r::GUI::AMSCountPopupWindow::SetAMSCount ( int index,
int ams4,
int ams1 )
inlinestatic
1487 {
1488 PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
1489 preset_bundle.extruder_ams_counts.resize(2);
1490 auto &ams_map = preset_bundle.extruder_ams_counts[index];
1491 ams_map[4] = ams4;
1492 ams_map[1] = ams1;
1493
1494 std::vector<std::string> extruder_ams_count = save_extruder_ams_count_to_string(preset_bundle.extruder_ams_counts);
1495 std::string extruder_ams_count_str = boost::algorithm::join(extruder_ams_count, ",");
1496 wxGetApp().app_config->set("presets", "extruder_ams_count", extruder_ams_count_str);
1497 wxGetApp().plater()->update(); // update slice status
1498 }
std::vector< std::string > save_extruder_ams_count_to_string(const std::vector< std::map< int, int > > &extruder_ams_count)
Definition PrintConfig.cpp:891

References Slic3r::PresetBundle::extruder_ams_counts, and Slic3r::save_extruder_ams_count_to_string().

Referenced by AMSCountPopupWindow(), and Slic3r::GUI::Sidebar::priv::sync_extruder_list().

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

◆ ShouldDismissOnTopWindowDeactivate()

virtual bool PopupWindow::ShouldDismissOnTopWindowDeactivate ( )
inlineprotectedvirtualinherited

Reimplemented in DropDown.

28{ return true; }

◆ UpdateAMSCount()

void Slic3r::GUI::AMSCountPopupWindow::UpdateAMSCount ( int index,
ExtruderGroup * extruder )
inlinestatic
1515 {
1516 std::vector<std::map<int, int>> &ams_counts = wxGetApp().preset_bundle->extruder_ams_counts;
1517 ams_counts.resize(2);
1518 std::map<int, int>& ams_map = ams_counts[index];
1519 if (ams_map.find(4) == ams_map.end()) {
1520 ams_map[4] = 0;
1521 }
1522 if (ams_map.find(1) == ams_map.end()) {
1523 ams_map[1] = 0;
1524 }
1525
1526 extruder->set_ams_count(ams_map[4], ams_map[1]);
1527 }

References Slic3r::GUI::ExtruderGroup::set_ams_count().

Referenced by AMSCountPopupWindow(), Slic3r::GUI::ExtruderGroup::ExtruderGroup(), Slic3r::GUI::Sidebar::priv::sync_extruder_list(), and Slic3r::GUI::Sidebar::update_presets().

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

The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Plater.cpp