OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::AMSSettingTypePanel Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/AMSSetting.hpp>

Inheritance diagram for Slic3r::GUI::AMSSettingTypePanel:
Collaboration diagram for Slic3r::GUI::AMSSettingTypePanel:

Public Member Functions

 AMSSettingTypePanel (wxWindow *parent, AMSSetting *setting_dlg)
 ~AMSSettingTypePanel ()
void UpdateInfo (const MachineObject *obj)

Private Member Functions

void CreateGui ()
void OnAmsTypeChanged (wxCommandEvent &event)

Private Attributes

std::weak_ptr< DevAmsSystemFirmwareSwitch > m_ams_firmware_switch
int m_ams_firmware_current_idx { -1 }
std::unordered_map< int, DevAmsSystemFirmwareSwitch::DevAmsSystemFirmware > m_ams_firmwares
AMSSetting * m_setting_dlg
ComboBox * m_type_combobox
Label * m_switching_tips
AnimaIcon * m_switching_icon

Detailed Description

Constructor & Destructor Documentation

◆ AMSSettingTypePanel()

Slic3r::GUI::AMSSettingTypePanel::AMSSettingTypePanel ( wxWindow * parent,
AMSSetting * setting_dlg )
600 : wxPanel(parent), m_setting_dlg(setting_dlg)
601{
602 CreateGui();
603}
void CreateGui()
Definition AMSSetting.cpp:612
AMSSetting * m_setting_dlg
Definition AMSSetting.hpp:136

References CreateGui(), and m_setting_dlg.

Here is the call graph for this function:

◆ ~AMSSettingTypePanel()

Slic3r::GUI::AMSSettingTypePanel::~AMSSettingTypePanel ( )
606{
607 if (m_switching_icon->IsPlaying()) {
608 m_switching_icon->Stop();
609 }
610}
AnimaIcon * m_switching_icon
Definition AMSSetting.hpp:139

References m_switching_icon.

Member Function Documentation

◆ CreateGui()

void Slic3r::GUI::AMSSettingTypePanel::CreateGui ( )
private
613{
614 wxBoxSizer* h_sizer = new wxBoxSizer(wxHORIZONTAL);
615
616 Label* title = new Label(this, ::Label::Head_13, _L("AMS Type"));
617 title->SetBackgroundColour(*wxWHITE);
618
619 m_type_combobox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(240, -1), 0, nullptr, wxCB_READONLY);
620 m_type_combobox->SetMinSize(wxSize(240, -1));
621 m_type_combobox->Bind(wxEVT_COMBOBOX, &AMSSettingTypePanel::OnAmsTypeChanged, this);
622
623 m_switching_tips = new Label(this, ::Label::Body_14);
624 m_switching_tips->SetBackgroundColour(*wxWHITE);
625 m_switching_tips->Show(false);
626
627 std::vector<std::string> list{ "ams_rfid_1", "ams_rfid_2", "ams_rfid_3", "ams_rfid_4" };
628 m_switching_icon = new AnimaIcon(this, wxID_ANY, list, "refresh_printer", 100);
629 m_switching_icon->SetMinSize(wxSize(FromDIP(20), FromDIP(20)));
630
631 h_sizer->Add(title, 0);
632 h_sizer->AddStretchSpacer();
633 h_sizer->Add(m_type_combobox, 0, wxEXPAND);
634 h_sizer->Add(m_switching_icon, 0, wxALIGN_CENTER);
635 h_sizer->Add(m_switching_tips, 0, wxEXPAND | wxLEFT, FromDIP(8));
636 SetSizer(h_sizer);
637 Layout();
638 Fit();
639}
#define _L(s)
Definition OBJ.cpp:34
static wxFont Head_13
Definition Label.hpp:46
static wxFont Body_14
Definition Label.hpp:53
ComboBox * m_type_combobox
Definition AMSSetting.hpp:137
void OnAmsTypeChanged(wxCommandEvent &event)
Definition AMSSetting.cpp:702
Label * m_switching_tips
Definition AMSSetting.hpp:138

References _L, Label::Body_14, Label::Head_13, m_switching_icon, m_switching_tips, m_type_combobox, and OnAmsTypeChanged().

Referenced by AMSSettingTypePanel().

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

◆ OnAmsTypeChanged()

void Slic3r::GUI::AMSSettingTypePanel::OnAmsTypeChanged ( wxCommandEvent & event)
private
703{
704 auto part = m_ams_firmware_switch.lock();
705 if (!part) {
706 event.Skip();
707 return;
708 }
709
710 int new_selection_idx = m_type_combobox->GetSelection();
711 if (new_selection_idx == part->GetCurrentFirmwareIdxSel()) {
712 event.Skip();
713 return;
714 }
715
716 auto obj_ = part->GetFilaSystem()->GetOwner();
717 if (obj_) {
718 if (obj_->is_in_printing() || obj_->is_in_upgrading()) {
719 MessageDialog dlg(this, _L("The printer is busy and cannot switch AMS type."), SLIC3R_APP_NAME + _L("Info"), wxOK | wxICON_INFORMATION);
720 dlg.ShowModal();
721 m_type_combobox->SetSelection(part->GetCurrentFirmwareIdxSel());
722 return;
723 }
724
725 auto ext = obj_->GetExtderSystem()->GetCurrentExtder();
726 if (ext && ext->HasFilamentInExt()) {
727 MessageDialog dlg(this, _L("Please unload all filament before switching."), SLIC3R_APP_NAME + _L("Info"), wxOK | wxICON_INFORMATION);
728 dlg.SetButtonLabel(wxID_OK, _L("Confirm"));
729 dlg.ShowModal();
730 m_type_combobox->SetSelection(part->GetCurrentFirmwareIdxSel());
731 if (m_setting_dlg) {
732 m_setting_dlg->EndModal(wxID_OK);
733 }
734
735 return;
736 }
737
738 MessageDialog dlg(this, _L("AMS type switching needs firmware update, taking about 30s. Switch now?"), SLIC3R_APP_NAME + _L("Info"), wxOK | wxCANCEL | wxICON_INFORMATION);
739 dlg.SetButtonLabel(wxID_OK, _L("Confirm"));
740 int rtn = dlg.ShowModal();
741 if (rtn != wxID_OK) {
742 m_type_combobox->SetSelection(part->GetCurrentFirmwareIdxSel());
743 return;
744 }
745
746 part->CrtlSwitchFirmware(new_selection_idx);
747 }
748
749 event.Skip();
750}
std::weak_ptr< DevAmsSystemFirmwareSwitch > m_ams_firmware_switch
Definition AMSSetting.hpp:130

References _L, m_ams_firmware_switch, m_setting_dlg, m_type_combobox, Slic3r::GUI::MsgDialog::SetButtonLabel(), and Slic3r::GUI::DPIAware< P >::ShowModal().

Referenced by CreateGui().

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

◆ UpdateInfo()

void Slic3r::GUI::AMSSettingTypePanel::UpdateInfo ( const MachineObject * obj)
642{
643 if (!obj) {
644 Show(false);
645 return;
646 }
647
648 m_ams_firmware_switch = obj->GetFilaSystem()->GetAmsFirmwareSwitch();
649 auto ptr = m_ams_firmware_switch.lock();
650 if (!ptr) {
651 Show(false);
652 return;
653 }
654
655 if (!ptr->SupportSwitchFirmware()) {
656 Show(false);
657 return;
658 }
659
660 if (ptr->IsSwitching()) {
661 int display_percent = obj->get_upgrade_percent(); // Orca: read upgrade progress via the kept MachineObject accessor
662 if (display_percent == 100 || display_percent == 0) {
663 display_percent = 1;// special case, sometimes it's switching but percent is 0 or 100
664 }
665 const auto& tips = _L("Switching") + " " + wxString::Format("%d%%", display_percent);
666 m_switching_tips->SetLabel(tips);
667 m_switching_icon->Play();
668 m_switching_tips->Show(true);
669 m_switching_icon->Show(true);
670 m_type_combobox->Show(false);
671 } else {
672 int current_idx = ptr->GetCurrentFirmwareIdxSel();
673 auto ams_firmwares = ptr->GetSuppotedFirmwares();
674 if (m_ams_firmwares != ams_firmwares || m_ams_firmware_current_idx != current_idx) {
675 m_ams_firmware_current_idx = current_idx;
676 m_ams_firmwares = ams_firmwares;
677
678 m_type_combobox->Clear();
679 for (auto ams_firmware : m_ams_firmwares) {
680 if (m_ams_firmware_current_idx == ams_firmware.first) {
681 m_type_combobox->Append(_L(ams_firmware.second.m_name));
682 } else {
683 m_type_combobox->Append(_L(ams_firmware.second.m_name));
684 }
685 }
687 }
688
689 if(m_switching_icon->IsPlaying()) {
690 m_switching_icon->Stop();
691 }
692
693 m_switching_tips->Show(false);
694 m_switching_icon->Show(false);
695 m_type_combobox->Show(true);
696 }
697
698 Show(true);
699 Layout();
700}
int m_ams_firmware_current_idx
Definition AMSSetting.hpp:132
std::unordered_map< int, DevAmsSystemFirmwareSwitch::DevAmsSystemFirmware > m_ams_firmwares
Definition AMSSetting.hpp:133

References _L, Slic3r::MachineObject::get_upgrade_percent(), Slic3r::MachineObject::GetFilaSystem(), m_ams_firmware_current_idx, m_ams_firmware_switch, m_ams_firmwares, m_switching_icon, m_switching_tips, and m_type_combobox.

Here is the call graph for this function:

Member Data Documentation

◆ m_ams_firmware_current_idx

int Slic3r::GUI::AMSSettingTypePanel::m_ams_firmware_current_idx { -1 }
private
132{ -1 };

Referenced by UpdateInfo().

◆ m_ams_firmware_switch

std::weak_ptr<DevAmsSystemFirmwareSwitch> Slic3r::GUI::AMSSettingTypePanel::m_ams_firmware_switch
private

Referenced by OnAmsTypeChanged(), and UpdateInfo().

◆ m_ams_firmwares

std::unordered_map<int, DevAmsSystemFirmwareSwitch::DevAmsSystemFirmware> Slic3r::GUI::AMSSettingTypePanel::m_ams_firmwares
private

Referenced by UpdateInfo().

◆ m_setting_dlg

AMSSetting* Slic3r::GUI::AMSSettingTypePanel::m_setting_dlg
private

◆ m_switching_icon

AnimaIcon* Slic3r::GUI::AMSSettingTypePanel::m_switching_icon
private

◆ m_switching_tips

Label* Slic3r::GUI::AMSSettingTypePanel::m_switching_tips
private

Referenced by CreateGui(), and UpdateInfo().

◆ m_type_combobox

ComboBox* Slic3r::GUI::AMSSettingTypePanel::m_type_combobox
private

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