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

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DeviceTab/wgtDeviceNozzleSelect.h>

Inheritance diagram for Slic3r::GUI::wgtDeviceNozzleRackSelect:
Collaboration diagram for Slic3r::GUI::wgtDeviceNozzleRackSelect:

Public Member Functions

 wgtDeviceNozzleRackSelect (wxWindow *parent)
 ~wgtDeviceNozzleRackSelect ()=default
int GetSelectedNozzlePosID () const
void UpdatSelectedNozzles (std::shared_ptr< DevNozzleRack > rack, std::vector< int > selected_nozzle_pos_vec, bool use_dynamic_switch, std::optional< PrintFromType > print_from_type)
void Rescale ()

Private Member Functions

void CreateGui ()
void ClearSelection ()
void SetSelectedNozzle (const DevNozzle &nozzle)
void UpdatSelectedNozzle (std::shared_ptr< DevNozzleRack > rack, int selected_nozzle_pos_id=-1)
void UpdateNozzleInfos (std::shared_ptr< DevNozzleRack > rack)
void OnNozzleItemSelected (wxCommandEvent &evt)

Private Attributes

DevNozzle m_selected_nozzle
std::weak_ptr< DevNozzleRack > m_nozzle_rack
bool m_enable_manual_nozzle_pick = true
wgtMsgBox * m_title_tips_dynamic
wgtDeviceNozzleRackNozzleItem * m_toolhead_nozzle_l {nullptr}
wgtDeviceNozzleRackNozzleItem * m_toolhead_nozzle_r {nullptr}
std::unordered_map< int, wgtDeviceNozzleRackNozzleItem * > m_nozzle_items

Detailed Description

Constructor & Destructor Documentation

◆ wgtDeviceNozzleRackSelect()

Slic3r::GUI::wgtDeviceNozzleRackSelect::wgtDeviceNozzleRackSelect ( wxWindow * parent)
37: wxPanel(parent, wxID_ANY) { CreateGui(); }
void CreateGui()
Definition wgtDeviceNozzleSelect.cpp:63

References CreateGui().

Here is the call graph for this function:

◆ ~wgtDeviceNozzleRackSelect()

Slic3r::GUI::wgtDeviceNozzleRackSelect::~wgtDeviceNozzleRackSelect ( )
default

Member Function Documentation

◆ ClearSelection()

void Slic3r::GUI::wgtDeviceNozzleRackSelect::ClearSelection ( )
private
232{
233 m_selected_nozzle = DevNozzle();
234 m_toolhead_nozzle_l->SetSelected(false);
235 m_toolhead_nozzle_r->SetSelected(false);
236 for (auto &item : m_nozzle_items) { item.second->SetSelected(false); }
237}
wgtDeviceNozzleRackNozzleItem * m_toolhead_nozzle_r
Definition wgtDeviceNozzleSelect.h:72
wgtDeviceNozzleRackNozzleItem * m_toolhead_nozzle_l
Definition wgtDeviceNozzleSelect.h:71
std::unordered_map< int, wgtDeviceNozzleRackNozzleItem * > m_nozzle_items
Definition wgtDeviceNozzleSelect.h:73
DevNozzle m_selected_nozzle
Definition wgtDeviceNozzleSelect.h:61

References m_nozzle_items, m_selected_nozzle, m_toolhead_nozzle_l, and m_toolhead_nozzle_r.

Referenced by SetSelectedNozzle(), and UpdatSelectedNozzles().

Here is the caller graph for this function:

◆ CreateGui()

void Slic3r::GUI::wgtDeviceNozzleRackSelect::CreateGui ( )
private
64{
65 wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
66
67 wxColour tip_bg_clr("#FFF0E0");
68 m_title_tips_dynamic = new wgtMsgBox(this);
69 m_title_tips_dynamic->SetBackgroundColour(tip_bg_clr);
70 m_title_tips_dynamic->SetBorderColor(wxColour("#FF6F00"));
71 m_title_tips_dynamic->SetCornerRadius(1);
72 m_title_tips_dynamic->SetBorderWidth(1);
73 auto text_label = m_title_tips_dynamic->GetTextLabel();
74 text_label->SetFont(::Label::Body_12);
75 text_label->SetForegroundColour("#FF6F00");
76 text_label->SetBackgroundColour(tip_bg_clr);
77 text_label->SetLabel(_L("Dynamic nozzles are allocated on the current plate. Picking hotend is not supported."));
78 text_label->Wrap(FromDIP(300));
79 text_label->Fit();
80 m_title_tips_dynamic->Layout();
81 m_title_tips_dynamic->Refresh();
82
83 // nozzles
84 wxGridSizer *nozzle_sizer = new wxGridSizer(2, 3, FromDIP(10), FromDIP(10));
85 for (auto idx : a_nozzle_seq) {
86 wgtDeviceNozzleRackNozzleItem *nozzle_item = new wgtDeviceNozzleRackNozzleItem(this, idx - 16);
87 nozzle_item->EnableSelect();
88 nozzle_item->Bind(EVT_NOZZLE_RACK_NOZZLE_ITEM_SELECTED, &wgtDeviceNozzleRackSelect::OnNozzleItemSelected, this);
89 m_nozzle_items[idx] = nozzle_item;
90 nozzle_sizer->Add(nozzle_item, 0);
91 }
92
93 // toolhead area
94 m_toolhead_nozzle_l = new wgtDeviceNozzleRackNozzleItem(this, 1);
95 m_toolhead_nozzle_l->EnableSelect();
96 m_toolhead_nozzle_l->SetDisplayIdText("L");
97 m_toolhead_nozzle_l->Bind(EVT_NOZZLE_RACK_NOZZLE_ITEM_SELECTED, &wgtDeviceNozzleRackSelect::OnNozzleItemSelected, this);
98
99 m_toolhead_nozzle_r = new wgtDeviceNozzleRackNozzleItem(this, 0);
100 m_toolhead_nozzle_r->EnableSelect();
101 m_toolhead_nozzle_r->SetDisplayIdText("R");
102 m_toolhead_nozzle_r->Bind(EVT_NOZZLE_RACK_NOZZLE_ITEM_SELECTED, &wgtDeviceNozzleRackSelect::OnNozzleItemSelected, this);
103
104 wxSizer* toolhead_sizer = new wxBoxSizer(wxHORIZONTAL);
105 toolhead_sizer->Add(m_toolhead_nozzle_l, 0, wxRIGHT, FromDIP(5));
106 toolhead_sizer->Add(m_toolhead_nozzle_r, 0, wxLEFT, FromDIP(5));
107
108 main_sizer->Add(m_title_tips_dynamic, 0, wxALIGN_CENTRE_VERTICAL | wxBOTTOM, FromDIP(10));
109 main_sizer->Add(s_create_title(this, _L("Hotend Rack")), 0, wxEXPAND);
110 main_sizer->Add(nozzle_sizer, 0, wxTOP | wxBOTTOM | wxALIGN_LEFT, FromDIP(10));
111 main_sizer->Add(s_create_title(this, _L("ToolHead")), 0, wxEXPAND);
112 main_sizer->AddSpacer(FromDIP(10));
113 main_sizer->Add(toolhead_sizer, 0, wxALIGN_LEFT);
114
115 SetBackgroundColour(*wxWHITE);
116 SetSizer(main_sizer);
117 Layout();
118 Fit();
119
120 wxGetApp().UpdateDarkUIWin(this);
121}
#define _L(s)
Definition OBJ.cpp:34
static wxFont Body_12
Definition Label.hpp:55
wgtMsgBox * m_title_tips_dynamic
Definition wgtDeviceNozzleSelect.h:68
void OnNozzleItemSelected(wxCommandEvent &evt)
Definition wgtDeviceNozzleSelect.cpp:272
static wxPanel * s_create_title(wxWindow *parent, const wxString &text)
Definition wgtDeviceNozzleSelect.cpp:39
static std::vector< int > a_nozzle_seq
Definition wgtDeviceNozzleRack.cpp:64

References _L, a_nozzle_seq, Label::Body_12, Slic3r::GUI::wgtDeviceNozzleRackNozzleItem::EnableSelect(), m_nozzle_items, m_title_tips_dynamic, m_toolhead_nozzle_l, m_toolhead_nozzle_r, OnNozzleItemSelected(), and Slic3r::GUI::s_create_title().

Referenced by wgtDeviceNozzleRackSelect().

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

◆ GetSelectedNozzlePosID()

int Slic3r::GUI::wgtDeviceNozzleRackSelect::GetSelectedNozzlePosID ( ) const
inline
45{ return m_selected_nozzle.GetNozzlePosId();}

References m_selected_nozzle.

Referenced by OnNozzleItemSelected().

Here is the caller graph for this function:

◆ OnNozzleItemSelected()

void Slic3r::GUI::wgtDeviceNozzleRackSelect::OnNozzleItemSelected ( wxCommandEvent & evt)
private
273{
275 return;
276 }
277
278 auto *item = dynamic_cast<wgtDeviceNozzleRackNozzleItem *>(evt.GetEventObject());
279 if (auto ptr = m_nozzle_rack.lock(); item && ptr) {
280 int to_select_pos_id = sGetNozzlePosId(item, m_toolhead_nozzle_l, m_toolhead_nozzle_r);
281 if (to_select_pos_id > -1 && to_select_pos_id != GetSelectedNozzlePosID()) {
282 SetSelectedNozzle(ptr->GetNozzleSystem()->GetNozzleByPosId(to_select_pos_id));
283 wxCommandEvent change_evt(EVT_NOZZLE_SELECT_CHANGED, GetId());
284 change_evt.SetEventObject(this);
285 ProcessEvent(change_evt);
286 evt.Skip();
287 } else {
288 wxCommandEvent change_evt(EVT_NOZZLE_SELECT_CLICKED, GetId());
289 change_evt.SetEventObject(this);
290 ProcessEvent(change_evt);
291 evt.Skip();
292 }
293 }
294}
void SetSelectedNozzle(const DevNozzle &nozzle)
Definition wgtDeviceNozzleSelect.cpp:239
std::weak_ptr< DevNozzleRack > m_nozzle_rack
Definition wgtDeviceNozzleSelect.h:62
int GetSelectedNozzlePosID() const
Definition wgtDeviceNozzleSelect.h:45
bool m_enable_manual_nozzle_pick
Definition wgtDeviceNozzleSelect.h:65
volatile int sGetNozzlePosId(wgtDeviceNozzleRackNozzleItem *item, wgtDeviceNozzleRackNozzleItem *l_item, wgtDeviceNozzleRackNozzleItem *r_item)
Definition wgtDeviceNozzleSelect.cpp:256

References GetSelectedNozzlePosID(), m_enable_manual_nozzle_pick, m_nozzle_rack, m_toolhead_nozzle_l, m_toolhead_nozzle_r, SetSelectedNozzle(), and Slic3r::GUI::sGetNozzlePosId().

Referenced by CreateGui().

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

◆ Rescale()

void Slic3r::GUI::wgtDeviceNozzleRackSelect::Rescale ( )
297{
298 m_toolhead_nozzle_l->Rescale();
299 m_toolhead_nozzle_r->Rescale();
300 for (auto &item : m_nozzle_items) { item.second->Rescale(); }
301}

References m_nozzle_items, m_toolhead_nozzle_l, and m_toolhead_nozzle_r.

◆ SetSelectedNozzle()

void Slic3r::GUI::wgtDeviceNozzleRackSelect::SetSelectedNozzle ( const DevNozzle & nozzle)
private
240{
241 int new_selected_pos_id = nozzle.GetNozzlePosId();
242 if (m_selected_nozzle.GetNozzlePosId() != new_selected_pos_id) {
244
245 m_selected_nozzle = nozzle;
246 if (new_selected_pos_id == MAIN_EXTRUDER_ID) {
247 m_toolhead_nozzle_r->SetSelected(true);
248 } else if (new_selected_pos_id == DEPUTY_EXTRUDER_ID) {
249 m_toolhead_nozzle_l->SetSelected(true);
250 } else if (auto it = m_nozzle_items.find(m_selected_nozzle.GetNozzlePosId()); it != m_nozzle_items.end()) {
251 it->second->SetSelected(true);
252 }
253 }
254}
#define DEPUTY_EXTRUDER_ID
Definition DevDefs.h:102
#define MAIN_EXTRUDER_ID
Definition DevDefs.h:101
void ClearSelection()
Definition wgtDeviceNozzleSelect.cpp:231

References ClearSelection(), DEPUTY_EXTRUDER_ID, Slic3r::DevNozzle::GetNozzlePosId(), m_nozzle_items, m_selected_nozzle, m_toolhead_nozzle_l, m_toolhead_nozzle_r, and MAIN_EXTRUDER_ID.

Referenced by OnNozzleItemSelected(), and UpdatSelectedNozzle().

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

◆ UpdateNozzleInfos()

void Slic3r::GUI::wgtDeviceNozzleRackSelect::UpdateNozzleInfos ( std::shared_ptr< DevNozzleRack > rack)
private
138{
139 m_nozzle_rack = rack;
140 if (rack) {
141 s_update_nozzle_info(m_toolhead_nozzle_l, rack, rack->GetNozzleSystem()->GetNozzleByPosId(DEPUTY_EXTRUDER_ID));
142 s_update_nozzle_info(m_toolhead_nozzle_r, rack, rack->GetNozzleSystem()->GetNozzleByPosId(MAIN_EXTRUDER_ID));
143 for (const auto& item : m_nozzle_items) {
144 s_update_nozzle_info(item.second, rack, rack->GetNozzleSystem()->GetNozzleByPosId(item.first));
145 }
146 }
147}
static void s_update_nozzle_info(wgtDeviceNozzleRackNozzleItem *item, std::shared_ptr< DevNozzleRack > rack, const DevNozzle &nozzle_info)
Definition wgtDeviceNozzleSelect.cpp:123

References DEPUTY_EXTRUDER_ID, m_nozzle_items, m_nozzle_rack, m_toolhead_nozzle_l, m_toolhead_nozzle_r, MAIN_EXTRUDER_ID, and Slic3r::GUI::s_update_nozzle_info().

Referenced by UpdatSelectedNozzles().

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

◆ UpdatSelectedNozzle()

void Slic3r::GUI::wgtDeviceNozzleRackSelect::UpdatSelectedNozzle ( std::shared_ptr< DevNozzleRack > rack,
int selected_nozzle_pos_id = -1 )
private
171{
172 m_nozzle_rack = rack;
173 if (rack) {
174 SetSelectedNozzle(rack->GetNozzleSystem()->GetNozzleByPosId(selected_nozzle_pos_id));
176 s_enable_item_if_match(m_toolhead_nozzle_r, rack->GetNozzleSystem()->GetNozzleByPosId(MAIN_EXTRUDER_ID), m_selected_nozzle);
177 s_enable_item_if_match(m_toolhead_nozzle_l, rack->GetNozzleSystem()->GetNozzleByPosId(DEPUTY_EXTRUDER_ID), m_selected_nozzle);
178 for (auto& item : m_nozzle_items) {
179 s_enable_item_if_match(item.second, rack->GetNozzleSystem()->GetNozzleByPosId(item.first), m_selected_nozzle);
180 }
181 }
182 }
183}
static void s_enable_item_if_match(wgtDeviceNozzleRackNozzleItem *item, const DevNozzle &nozzle_info, const DevNozzle &selected_nozzle)
Definition wgtDeviceNozzleSelect.cpp:149

References DEPUTY_EXTRUDER_ID, m_enable_manual_nozzle_pick, m_nozzle_items, m_nozzle_rack, m_selected_nozzle, m_toolhead_nozzle_l, m_toolhead_nozzle_r, MAIN_EXTRUDER_ID, Slic3r::GUI::s_enable_item_if_match(), and SetSelectedNozzle().

Referenced by UpdatSelectedNozzles().

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

◆ UpdatSelectedNozzles()

void Slic3r::GUI::wgtDeviceNozzleRackSelect::UpdatSelectedNozzles ( std::shared_ptr< DevNozzleRack > rack,
std::vector< int > selected_nozzle_pos_vec,
bool use_dynamic_switch,
std::optional< PrintFromType > print_from_type )
189{
190 m_nozzle_rack = rack;
191 m_enable_manual_nozzle_pick = !use_dynamic_switch;
192 m_title_tips_dynamic->Show(use_dynamic_switch);
193
194 UpdateNozzleInfos(rack);
195 if (!use_dynamic_switch) {
196 if (selected_nozzle_pos_vec.size() > 0) {
197 return UpdatSelectedNozzle(rack, selected_nozzle_pos_vec.at(0));
198 } else {
199 return ClearSelection();
200 }
201 }
202
203 if (rack) {
205 for (const auto& pos_id : selected_nozzle_pos_vec) {
206 if (pos_id == MAIN_EXTRUDER_ID) {
207 m_toolhead_nozzle_r->SetSelected(true);
208 } else if (pos_id == DEPUTY_EXTRUDER_ID) {
209 m_toolhead_nozzle_l->SetSelected(true);
210 } else if (auto it = m_nozzle_items.find(pos_id); it != m_nozzle_items.end()) {
211 it->second->SetSelected(true);
212 }
213 }
214
215 if (!m_toolhead_nozzle_l->IsSelected()) {
216 m_toolhead_nozzle_l->SetDisable(true);
217 }
218
219 if (!m_toolhead_nozzle_r->IsSelected()) {
220 m_toolhead_nozzle_r->SetDisable(true);
221 }
222
223 for (const auto& item : m_nozzle_items) {
224 if (!item.second->IsSelected()) {
225 item.second->SetDisable(true);
226 }
227 }
228 }
229}
void UpdatSelectedNozzle(std::shared_ptr< DevNozzleRack > rack, int selected_nozzle_pos_id=-1)
Definition wgtDeviceNozzleSelect.cpp:170
void UpdateNozzleInfos(std::shared_ptr< DevNozzleRack > rack)
Definition wgtDeviceNozzleSelect.cpp:137

References ClearSelection(), DEPUTY_EXTRUDER_ID, m_enable_manual_nozzle_pick, m_nozzle_items, m_nozzle_rack, m_title_tips_dynamic, m_toolhead_nozzle_l, m_toolhead_nozzle_r, MAIN_EXTRUDER_ID, UpdateNozzleInfos(), and UpdatSelectedNozzle().

Here is the call graph for this function:

Member Data Documentation

◆ m_enable_manual_nozzle_pick

bool Slic3r::GUI::wgtDeviceNozzleRackSelect::m_enable_manual_nozzle_pick = true
private

◆ m_nozzle_items

std::unordered_map<int, wgtDeviceNozzleRackNozzleItem *> Slic3r::GUI::wgtDeviceNozzleRackSelect::m_nozzle_items
private

◆ m_nozzle_rack

std::weak_ptr<DevNozzleRack> Slic3r::GUI::wgtDeviceNozzleRackSelect::m_nozzle_rack
private

◆ m_selected_nozzle

DevNozzle Slic3r::GUI::wgtDeviceNozzleRackSelect::m_selected_nozzle
private

◆ m_title_tips_dynamic

wgtMsgBox* Slic3r::GUI::wgtDeviceNozzleRackSelect::m_title_tips_dynamic
private

Referenced by CreateGui(), and UpdatSelectedNozzles().

◆ m_toolhead_nozzle_l

wgtDeviceNozzleRackNozzleItem* Slic3r::GUI::wgtDeviceNozzleRackSelect::m_toolhead_nozzle_l {nullptr}
private

◆ m_toolhead_nozzle_r

wgtDeviceNozzleRackNozzleItem* Slic3r::GUI::wgtDeviceNozzleRackSelect::m_toolhead_nozzle_r {nullptr}
private

The documentation for this class was generated from the following files: