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

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

Inheritance diagram for Slic3r::GUI::FilamentMapManualPanel:
Collaboration diagram for Slic3r::GUI::FilamentMapManualPanel:

Public Member Functions

 FilamentMapManualPanel (wxWindow *parent, const std::vector< std::string > &color, const std::vector< std::string > &type, const std::vector< int > &filament_list, const std::vector< int > &filament_map, const std::vector< int > &filament_volume_map)
 ~FilamentMapManualPanel ()
std::vector< int > GetFilamentMaps () const
std::vector< int > GetFilamentVolumeMaps () const
std::vector< int > GetLeftFilaments () const
std::vector< int > GetRightFilaments () const
std::vector< int > GetRightHighFlowFilaments () const
std::vector< int > GetRightStandardFilaments () const
std::vector< int > GetRightTPUHighFlowFilaments () const
void UpdateNozzleVolumeType ()
void UpdateNozzleCountDisplay ()
bool Show (bool show=true) override

Private Member Functions

void OnTimer (wxTimerEvent &evt)
void OnSwitchFilament (wxCommandEvent &)
void SyncPanelHeights ()
void OnDragDropCompleted (wxCommandEvent &evt)
void OnSuggestionClicked (wxCommandEvent &event)

Private Attributes

DragDropPanel * m_left_panel
SeparatedDragDropPanel * m_right_panel
Label * m_description
Label * m_tips
Label * m_errors
wxPanel * m_suggestion_panel
ScalableButton * m_switch_btn
std::vector< int > m_filament_map
std::vector< int > m_filament_volume_map
std::vector< int > m_filament_list
std::vector< std::string > m_filament_color
std::vector< std::string > m_filament_type
wxTimer * m_timer
int m_invalid_id {-1}
bool m_force_validation {false}

Detailed Description

Constructor & Destructor Documentation

◆ FilamentMapManualPanel()

Slic3r::GUI::FilamentMapManualPanel::FilamentMapManualPanel ( wxWindow * parent,
const std::vector< std::string > & color,
const std::vector< std::string > & type,
const std::vector< int > & filament_list,
const std::vector< int > & filament_map,
const std::vector< int > & filament_volume_map )
300 : wxPanel(parent)
302 , m_filament_volume_map(filament_volume_map)
303 , m_filament_list(filament_list)
304 , m_filament_color(color)
305 , m_filament_type(type)
306{
307 SetName(wxT("FilamentMapManualPanel"));
308 SetBackgroundColour(BgNormalColor);
309
310 auto top_sizer = new wxBoxSizer(wxVERTICAL);
311
312 m_description = new Label(this, _L("We will slice according to this grouping method:"));
313 top_sizer->Add(m_description, 0, wxALIGN_LEFT | wxLEFT, FromDIP(15));
314 m_description->Wrap(FromDIP(520));
315 top_sizer->AddSpacer(FromDIP(8));
316
317 auto drag_sizer = new wxBoxSizer(wxHORIZONTAL);
318
319 m_left_panel = new DragDropPanel(this, _L("Left Nozzle"), false);
320 m_right_panel = new SeparatedDragDropPanel(this, _L("Right Nozzle"), false);
321 m_switch_btn = new ScalableButton(this, wxID_ANY, "switch_filament_maps");
322
324
325 for (size_t idx = 0; idx < m_filament_map.size(); ++idx) {
326 auto iter = std::find(m_filament_list.begin(), m_filament_list.end(), idx + 1);
327 if (iter == m_filament_list.end()) continue;
328 wxColor color = Hex2Color(m_filament_color[idx]);
329 std::string type = m_filament_type[idx];
330 if (m_filament_map[idx] == 1) {
331 m_left_panel->AddColorBlock(color, type, idx + 1);
332 } else {
333 assert(m_filament_map[idx] == 2);
334 bool is_high_flow = (idx < m_filament_volume_map.size()) && (m_filament_volume_map[idx] == static_cast<int>(NozzleVolumeType::nvtHighFlow));
335 m_right_panel->AddColorBlock(color, type, idx + 1, is_high_flow);
336 }
337 }
338 m_left_panel->SetMinSize({FromDIP(260), FromDIP(110)});
339 m_right_panel->SetMinSize({FromDIP(260), FromDIP(110)});
340
341 drag_sizer->Add(m_left_panel, 1, wxEXPAND);
342 drag_sizer->Add(m_switch_btn, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(8));
343 drag_sizer->Add(m_right_panel, 1, wxEXPAND);
344
345 top_sizer->Add(drag_sizer, 0, wxEXPAND);
346
347 m_tips = new Label(this, _L("Tip: You can drag the filaments to reassign them to different nozzles."));
348 m_tips->SetFont(Label::Body_14);
349 m_tips->SetForegroundColour(TextNormalGreyColor);
350 m_tips->Wrap(FromDIP(520));
351 top_sizer->AddSpacer(FromDIP(20));
352 top_sizer->Add(m_tips, 0, wxALIGN_LEFT | wxLEFT, FromDIP(15));
353
354 m_errors = new Label(this, "");
355 m_errors->SetFont(Label::Body_13);
356 m_errors->SetForegroundColour(TextErrorColor);
357 m_errors->Wrap(FromDIP(520));
358 top_sizer->AddSpacer(FromDIP(10));
359 top_sizer->Add(m_errors, 0, wxALIGN_LEFT | wxLEFT, FromDIP(15));
360
361 m_errors->Hide();
362
363 m_suggestion_panel = new wxPanel(this, wxID_ANY);
364 m_suggestion_panel->SetBackgroundColour(*wxWHITE);
365 auto suggestion_sizer = new wxBoxSizer(wxHORIZONTAL);
366 auto suggestion_text = new Label(m_suggestion_panel, _L("Please adjust your grouping or click "));
367 suggestion_text->SetFont(Label::Body_13);
368 suggestion_text->SetForegroundColour(TextErrorColor);
369 suggestion_text->SetBackgroundColour(*wxWHITE);
370 auto suggestion_btn = new ScalableButton(m_suggestion_panel, wxID_ANY, "edit", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 14);
371 suggestion_btn->SetBackgroundColour(*wxWHITE);
372 auto suggestion_text2 = new Label(m_suggestion_panel, _L(" to set nozzle count"));
373 suggestion_text2->SetFont(Label::Body_13);
374 suggestion_text2->SetForegroundColour(TextErrorColor);
375 suggestion_text2->SetBackgroundColour(*wxWHITE);
376 suggestion_sizer->Add(suggestion_text, 0, wxALIGN_CENTER_VERTICAL);
377 suggestion_sizer->Add(suggestion_btn, 0, wxALIGN_CENTER_VERTICAL);
378 suggestion_sizer->Add(suggestion_text2, 0, wxALIGN_CENTER_VERTICAL);
379 m_suggestion_panel->SetSizer(suggestion_sizer);
380 top_sizer->Add(m_suggestion_panel, 0, wxALIGN_LEFT | wxLEFT, FromDIP(15));
381 m_suggestion_panel->Hide();
382 suggestion_btn->Bind(wxEVT_BUTTON, &FilamentMapManualPanel::OnSuggestionClicked, this);
383
384 // Multi-nozzle: give the user a reachable way to declare, per extruder, how many
385 // physical nozzles of each volume type a multi-nozzle extruder carries. This is the
386 // fallback "manual" producer of the extruder_nozzle_stats config (the full device nozzle-rack
387 // auto-sync is deferred). Gated on the edited printer preset having an extruder with
388 // extruder_max_nozzle_count > 1, so the trigger is not even created for any single-nozzle or
389 // dual-extruder ({1,1}, H2D) printer - zero UI change for every existing profile.
391 auto *max_nozzle_counts_opt = wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionIntsNullable>("extruder_max_nozzle_count");
392 auto *set_count_link = new Label(this, _L("Set the physical nozzle count..."));
393 set_count_link->SetFont(Label::Body_14);
394 set_count_link->SetForegroundColour(BorderSelectedColor);
395 set_count_link->SetCursor(wxCursor(wxCURSOR_HAND));
396 top_sizer->AddSpacer(FromDIP(8));
397 top_sizer->Add(set_count_link, 0, wxALIGN_LEFT | wxLEFT, FromDIP(15));
398 const std::vector<int> max_counts = max_nozzle_counts_opt->values;
399 set_count_link->Bind(wxEVT_LEFT_DOWN, [max_counts](wxMouseEvent &evt) {
400 for (int extruder_id = 0; extruder_id < (int) max_counts.size(); ++extruder_id) {
401 if (max_counts[extruder_id] > 1 && max_counts[extruder_id] != ConfigOptionIntsNullable::nil_value())
402 GUI::manuallySetNozzleCount(extruder_id);
403 }
404 evt.Skip();
405 });
406 }
407
408 m_timer = new wxTimer(this);
409 Bind(wxEVT_TIMER, &FilamentMapManualPanel::OnTimer, this);
410 Bind(wxEVT_DRAG_DROP_COMPLETED, &FilamentMapManualPanel::OnDragDropCompleted, this);
411
412 m_switch_btn->Bind(wxEVT_BUTTON, &FilamentMapManualPanel::OnSwitchFilament, this);
413
414 SetSizer(top_sizer);
415 SetMinSize(wxSize(FromDIP(580), -1));
416 Layout();
417 Fit();
418 GUI::wxGetApp().UpdateDarkUIWin(this);
419}
#define _L(s)
Definition OBJ.cpp:34
static wxFont Body_13
Definition Label.hpp:54
static wxFont Body_14
Definition Label.hpp:53
static int nil_value()
Definition Config.hpp:1083
std::vector< std::string > m_filament_type
Definition FilamentMapPanel.hpp:68
std::vector< int > m_filament_volume_map
Definition FilamentMapPanel.hpp:65
DragDropPanel * m_left_panel
Definition FilamentMapPanel.hpp:54
wxTimer * m_timer
Definition FilamentMapPanel.hpp:70
SeparatedDragDropPanel * m_right_panel
Definition FilamentMapPanel.hpp:55
std::vector< int > m_filament_list
Definition FilamentMapPanel.hpp:66
void OnTimer(wxTimerEvent &evt)
Definition FilamentMapPanel.cpp:58
Label * m_errors
Definition FilamentMapPanel.hpp:59
ScalableButton * m_switch_btn
Definition FilamentMapPanel.hpp:62
void OnDragDropCompleted(wxCommandEvent &evt)
Definition FilamentMapPanel.cpp:288
Label * m_description
Definition FilamentMapPanel.hpp:57
std::vector< int > m_filament_map
Definition FilamentMapPanel.hpp:64
void UpdateNozzleVolumeType()
Definition FilamentMapPanel.cpp:421
wxPanel * m_suggestion_panel
Definition FilamentMapPanel.hpp:60
void OnSuggestionClicked(wxCommandEvent &event)
Definition FilamentMapPanel.cpp:162
std::vector< std::string > m_filament_color
Definition FilamentMapPanel.hpp:67
void OnSwitchFilament(wxCommandEvent &)
Definition FilamentMapPanel.cpp:477
Label * m_tips
Definition FilamentMapPanel.hpp:58
wxMouseEvent
Definition CameraPopup.cpp:47
void manuallySetNozzleCount(int extruder_id)
Definition MultiNozzleSync.cpp:320
static bool printer_has_multi_nozzle_extruder()
Definition FilamentMapPanel.cpp:49
static const wxColour BgNormalColor
Definition CapsuleButton.cpp:18
static const wxColour TextNormalGreyColor
Definition FilamentMapPanel.cpp:41
static const wxColour BorderSelectedColor
Definition FilamentMapPanel.cpp:37
wxColor Hex2Color(const std::string &str)
Definition DragDropPanel.cpp:42
static const wxColour TextErrorColor
Definition FilamentMapPanel.cpp:43
@ nvtHighFlow
Definition PrintConfig.hpp:620
ConfigOptionIntsTempl< true > ConfigOptionIntsNullable
Definition Config.hpp:1155
zaa_minimize_perimeter_height filament_map((ConfigOptionInts, filament_volume_map))((ConfigOptionInts

References _L, Slic3r::GUI::BgNormalColor, Label::Body_13, Label::Body_14, Slic3r::GUI::BorderSelectedColor, Slic3r::filament_map(), Slic3r::GUI::Hex2Color(), m_description, m_errors, m_filament_color, m_filament_list, m_filament_map, m_filament_type, m_filament_volume_map, m_left_panel, m_right_panel, m_suggestion_panel, m_switch_btn, m_timer, m_tips, Slic3r::GUI::manuallySetNozzleCount(), Slic3r::ConfigOptionIntsTempl< true >::nil_value(), Slic3r::nvtHighFlow, OnDragDropCompleted(), OnSuggestionClicked(), OnSwitchFilament(), OnTimer(), Slic3r::GUI::printer_has_multi_nozzle_extruder(), Slic3r::GUI::TextErrorColor, Slic3r::GUI::TextNormalGreyColor, UpdateNozzleVolumeType(), Slic3r::ConfigOptionVector< int >::values, and Slic3r::GUI::wxMouseEvent.

Here is the call graph for this function:

◆ ~FilamentMapManualPanel()

Slic3r::GUI::FilamentMapManualPanel::~FilamentMapManualPanel ( )
472{
473 m_timer->Stop();
474 delete m_timer;
475}

References m_timer.

Member Function Documentation

◆ GetFilamentMaps()

std::vector< int > Slic3r::GUI::FilamentMapManualPanel::GetFilamentMaps ( ) const
184{
185 std::vector<int> new_filament_map = m_filament_map;
186 std::vector<int> left_filaments = this->GetLeftFilaments();
187 std::vector<int> right_filaments = this->GetRightFilaments();
188
189 for (int i = 0; i < (int) new_filament_map.size(); ++i) {
190 if (std::find(left_filaments.begin(), left_filaments.end(), i + 1) != left_filaments.end()) {
191 new_filament_map[i] = 1;
192 } else if (std::find(right_filaments.begin(), right_filaments.end(), i + 1) != right_filaments.end()) {
193 new_filament_map[i] = 2;
194 }
195 }
196 return new_filament_map;
197}
std::vector< int > GetLeftFilaments() const
Definition FilamentMapPanel.hpp:36
std::vector< int > GetRightFilaments() const
Definition FilamentMapPanel.hpp:37

References GetLeftFilaments(), GetRightFilaments(), and m_filament_map.

Referenced by OnTimer().

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

◆ GetFilamentVolumeMaps()

std::vector< int > Slic3r::GUI::FilamentMapManualPanel::GetFilamentVolumeMaps ( ) const
200{
201 std::vector<int> volume_map(m_filament_map.size(), 0);
202
203 std::vector<int> left_filaments = this->GetLeftFilaments();
204 std::vector<int> right_high_flow_filaments = this->GetRightHighFlowFilaments();
205 std::vector<int> right_standard_filaments = this->GetRightStandardFilaments();
206 std::vector<int> right_tpu_high_flow_filaments = this->GetRightTPUHighFlowFilaments();
207
208 auto preset_bundle = wxGetApp().preset_bundle;
209 auto proj_config = preset_bundle->project_config;
210 auto nozzle_volume_values = proj_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values;
211 // The high-flow panel of the right extruder also holds an E3D High Flow nozzle; keep that type
212 // instead of writing plain High Flow, which the extruder does not have.
213 const int right_extruder_id = 1;
214 const bool right_e3d_high_flow = nozzle_volume_values.size() > right_extruder_id &&
215 nozzle_volume_values[right_extruder_id] == static_cast<int>(NozzleVolumeType::nvtE3DHighFlow);
216 const int right_high_flow_volume = static_cast<int>(right_e3d_high_flow ? NozzleVolumeType::nvtE3DHighFlow : NozzleVolumeType::nvtHighFlow);
217
218 for (int i = 0; i < (int) volume_map.size(); ++i) {
219 int filament_id = i + 1;
220
221 if (std::find(left_filaments.begin(), left_filaments.end(), filament_id) != left_filaments.end()) {
222 if (nozzle_volume_values.size() > 0) {
223 // Orca: never emit the Hybrid marker as a per-filament value; on a Hybrid
224 // extruder each filament prints with a concrete flow, defaulting to Standard.
225 volume_map[i] = nozzle_volume_values[0] == static_cast<int>(NozzleVolumeType::nvtHybrid) ?
226 static_cast<int>(NozzleVolumeType::nvtStandard) :
227 nozzle_volume_values[0];
228 }
229 }
230 else if (std::find(right_high_flow_filaments.begin(), right_high_flow_filaments.end(), filament_id) != right_high_flow_filaments.end()) {
231 volume_map[i] = right_high_flow_volume;
232 }
233 else if (std::find(right_standard_filaments.begin(), right_standard_filaments.end(), filament_id) != right_standard_filaments.end()) {
234 volume_map[i] = static_cast<int>(NozzleVolumeType::nvtStandard);
235 }
236 else if (std::find(right_tpu_high_flow_filaments.begin(), right_tpu_high_flow_filaments.end(), filament_id) != right_tpu_high_flow_filaments.end()) {
237 volume_map[i] = static_cast<int>(NozzleVolumeType::nvtTPUHighFlow);
238 }
239 }
240
241 return volume_map;
242}
size_t size() const override
Definition Config.hpp:722
std::vector< int > GetRightStandardFilaments() const
Definition FilamentMapPanel.hpp:40
std::vector< int > GetRightTPUHighFlowFilaments() const
Definition FilamentMapPanel.hpp:41
std::vector< int > GetRightHighFlowFilaments() const
Definition FilamentMapPanel.hpp:39
@ nvtE3DHighFlow
Definition PrintConfig.hpp:626
@ nvtHybrid
Definition PrintConfig.hpp:621
@ nvtTPUHighFlow
Definition PrintConfig.hpp:624
@ nvtStandard
Definition PrintConfig.hpp:619
ConfigOptionEnumsGenericTempl< false > ConfigOptionEnumsGeneric
Definition Config.hpp:2311

References GetLeftFilaments(), GetRightHighFlowFilaments(), GetRightStandardFilaments(), GetRightTPUHighFlowFilaments(), m_filament_map, Slic3r::nvtE3DHighFlow, Slic3r::nvtHighFlow, Slic3r::nvtHybrid, Slic3r::nvtStandard, and Slic3r::nvtTPUHighFlow.

Referenced by OnTimer().

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

◆ GetLeftFilaments()

std::vector< int > Slic3r::GUI::FilamentMapManualPanel::GetLeftFilaments ( ) const
inline
36{ return m_left_panel->GetAllFilaments(); }

References m_left_panel.

Referenced by GetFilamentMaps(), and GetFilamentVolumeMaps().

Here is the caller graph for this function:

◆ GetRightFilaments()

std::vector< int > Slic3r::GUI::FilamentMapManualPanel::GetRightFilaments ( ) const
inline
37{ return m_right_panel->GetAllFilaments(); }

References m_right_panel.

Referenced by GetFilamentMaps().

Here is the caller graph for this function:

◆ GetRightHighFlowFilaments()

std::vector< int > Slic3r::GUI::FilamentMapManualPanel::GetRightHighFlowFilaments ( ) const
inline
39{ return m_right_panel->GetHighFlowFilaments(); }

References m_right_panel.

Referenced by GetFilamentVolumeMaps().

Here is the caller graph for this function:

◆ GetRightStandardFilaments()

std::vector< int > Slic3r::GUI::FilamentMapManualPanel::GetRightStandardFilaments ( ) const
inline
40{ return m_right_panel->GetStandardFilaments(); }

References m_right_panel.

Referenced by GetFilamentVolumeMaps().

Here is the caller graph for this function:

◆ GetRightTPUHighFlowFilaments()

std::vector< int > Slic3r::GUI::FilamentMapManualPanel::GetRightTPUHighFlowFilaments ( ) const
inline
41{ return m_right_panel->GetTPUHighFlowFilaments(); }

References m_right_panel.

Referenced by GetFilamentVolumeMaps().

Here is the caller graph for this function:

◆ OnDragDropCompleted()

void Slic3r::GUI::FilamentMapManualPanel::OnDragDropCompleted ( wxCommandEvent & evt)
private
289{
291 event.Skip();
292}
void SyncPanelHeights()
Definition FilamentMapPanel.cpp:244

References SyncPanelHeights().

Referenced by FilamentMapManualPanel().

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

◆ OnSuggestionClicked()

void Slic3r::GUI::FilamentMapManualPanel::OnSuggestionClicked ( wxCommandEvent & event)
private
163{
164 wxWindow *current = this;
165 while (current && !wxDynamicCast(current, wxDialog)) {
166 current = current->GetParent();
167 }
168
169 if (current) {
170 wxDialog *dlg = wxDynamicCast(current, wxDialog);
171 if (dlg) {
172 int invalid_eid = m_invalid_id;
173 dlg->EndModal(wxID_CANCEL);
174
175 if (invalid_eid >= 0) {
176 manuallySetNozzleCount(invalid_eid);
177 }
178 wxGetApp().plater()->update();
179 }
180 }
181}
int m_invalid_id
Definition FilamentMapPanel.hpp:71

References m_invalid_id, and Slic3r::GUI::manuallySetNozzleCount().

Referenced by FilamentMapManualPanel().

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

◆ OnSwitchFilament()

void Slic3r::GUI::FilamentMapManualPanel::OnSwitchFilament ( wxCommandEvent & )
private
478{
479 auto left_blocks = m_left_panel->get_filament_blocks();
480 auto right_blocks = m_right_panel->get_filament_blocks();
481
482 for (auto &block : left_blocks) {
483 m_right_panel->AddColorBlock(block->GetColor(), block->GetType(), block->GetFilamentId(), false, false);
484 m_left_panel->RemoveColorBlock(block, false);
485 }
486
487 for (auto &block : right_blocks) {
488 m_left_panel->AddColorBlock(block->GetColor(), block->GetType(), block->GetFilamentId(), false);
489 m_right_panel->RemoveColorBlock(block, false);
490 }
491 this->GetParent()->Layout();
492 this->GetParent()->Fit();
493
494 if (m_right_panel->IsUseSeparation()) {
495 m_left_panel->Layout();
496 m_left_panel->Fit();
497 m_right_panel->Layout();
498 m_right_panel->Fit();
500 }
501}

References m_left_panel, m_right_panel, and SyncPanelHeights().

Referenced by FilamentMapManualPanel().

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

◆ OnTimer()

void Slic3r::GUI::FilamentMapManualPanel::OnTimer ( wxTimerEvent & evt)
private
59{
60 bool valid = true;
61 int invalid_eid = -1;
63 auto preset_bundle = wxGetApp().preset_bundle;
64 auto proj_config = preset_bundle->project_config;
65 auto nozzle_volume_values = proj_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values;
66 std::vector<int> filament_map = GetFilamentMaps();
67 std::vector<int> filament_volume_map = GetFilamentVolumeMaps();
68 // Orca: only multi-nozzle extruders carry a meaningful nozzle inventory; validating a plain
69 // dual-extruder printer against it would flag every grouping whenever the stats are stale.
71 for (size_t eid = 0; eid < nozzle_volume_values.size(); ++eid) {
72 NozzleVolumeType extruder_volume_type = NozzleVolumeType(nozzle_volume_values[eid]);
73 bool extruder_used = std::find_if(m_filament_list.begin(), m_filament_list.end(),
74 [&filament_map, eid](int fid) {
75 return fid - 1 < (int) filament_map.size() && (filament_map[fid - 1] - 1) == (int) eid;
76 }) != m_filament_list.end();
77
78 if (!extruder_used) {
79 continue;
80 }
81
82 if (extruder_volume_type == nvtHybrid) {
83 int standard_count = getExtruderNozzleCount(preset_bundle, eid, NozzleVolumeType::nvtStandard);
84 int highflow_count = getExtruderNozzleCount(preset_bundle, eid, NozzleVolumeType::nvtHighFlow);
85
86 auto has_material_of_type = [this, eid, &filament_map, &filament_volume_map](NozzleVolumeType volume_type) {
87 return std::find_if(m_filament_list.begin(), m_filament_list.end(),
88 [eid, &filament_map, &filament_volume_map, volume_type](int fid) {
89 return fid - 1 < (int) filament_map.size() && (filament_map[fid - 1] - 1) == (int) eid &&
90 fid - 1 < (int) filament_volume_map.size() &&
91 filament_volume_map[fid - 1] == static_cast<int>(volume_type);
92 }) != m_filament_list.end();
93 };
94
95 bool has_standard = has_material_of_type(NozzleVolumeType::nvtStandard);
96 bool has_highflow = has_material_of_type(NozzleVolumeType::nvtHighFlow);
97
98 if ((has_standard && standard_count == 0) ||
99 (has_highflow && highflow_count == 0)) {
100 valid = false;
101 invalid_eid = eid;
102 invalid_nozzle = (has_standard && standard_count == 0) ? NozzleVolumeType::nvtStandard : NozzleVolumeType::nvtHighFlow;
103 break;
104 }
105 } else {
106 int count = getExtruderNozzleCount(preset_bundle, eid, extruder_volume_type);
107 if (count == 0) {
108 valid = false;
109 invalid_eid = eid;
110 invalid_nozzle = extruder_volume_type;
111 break;
112 }
113 }
114 }
115 }
116
117 bool update_ui = m_invalid_id != invalid_eid;
118 bool send_event = update_ui || m_force_validation;
119
120 m_invalid_id = invalid_eid;
121
122 if (update_ui) {
123 if (valid) {
124 m_errors->Hide();
125 m_suggestion_panel->Hide();
126 } else {
127 // [extruder][nozzle volume type]
128 static const char* const error_msgs[2][2] = {
129 {L("Error: Left extruder has no available Standard nozzle, current group result is invalid."),
130 L("Error: Left extruder has no available High Flow nozzle, current group result is invalid.")},
131 {L("Error: Right extruder has no available Standard nozzle, current group result is invalid."),
132 L("Error: Right extruder has no available High Flow nozzle, current group result is invalid.")}};
133 m_errors->SetLabel(_(error_msgs[invalid_eid == 0 ? 0 : 1][invalid_nozzle == NozzleVolumeType::nvtStandard ? 0 : 1]));
134 // Re-wrap: wrapping only applies to the label text present when Wrap is called,
135 // and the label was empty at construction time.
136 m_errors->Wrap(FromDIP(520));
137 m_errors->Show();
138 m_suggestion_panel->Show();
139 }
140 m_left_panel->Freeze();
141 m_right_panel->Freeze();
142 m_tips->Freeze();
143 m_description->Freeze();
144 Layout();
145 Fit();
146 this->GetParent()->Layout();
147 this->GetParent()->Fit();
148 m_left_panel->Thaw();
149 m_right_panel->Thaw();
150 m_tips->Thaw();
151 m_description->Thaw();
152 }
153
154 if (send_event) {
155 wxCommandEvent event(wxEVT_INVALID_MANUAL_MAP);
156 event.SetInt(valid);
157 ProcessEvent(event);
158 m_force_validation = false;
159 }
160}
#define _(s)
Definition 3mf.cpp:306
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246
#define L(s)
Definition ExtrusionEntity.cpp:25
static void update_ui(wxWindow *window)
Definition WipeTowerDialog.cpp:60
std::vector< int > GetFilamentVolumeMaps() const
Definition FilamentMapPanel.cpp:199
std::vector< int > GetFilamentMaps() const
Definition FilamentMapPanel.cpp:183
bool m_force_validation
Definition FilamentMapPanel.hpp:72
int getExtruderNozzleCount(PresetBundle *preset_bundle, int extruder_id, NozzleVolumeType volume_type)
Definition MultiNozzleSync.cpp:72
NozzleVolumeType
Definition PrintConfig.hpp:618

References _, count, Slic3r::filament_map(), Slic3r::GUI::getExtruderNozzleCount(), GetFilamentMaps(), GetFilamentVolumeMaps(), L, m_description, m_errors, m_filament_list, m_force_validation, m_invalid_id, m_left_panel, m_right_panel, m_suggestion_panel, m_tips, Slic3r::nvtHighFlow, Slic3r::nvtHybrid, Slic3r::nvtStandard, Slic3r::GUI::printer_has_multi_nozzle_extruder(), and update_ui().

Referenced by FilamentMapManualPanel().

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

◆ Show()

bool Slic3r::GUI::FilamentMapManualPanel::Show ( bool show = true)
override
504{
505 m_force_validation = show;
506 if (show) {
507 m_timer->Start(500);
509 } else {
510 m_timer->Stop();
511 }
512
513 return wxPanel::Show(show);
514}

References m_force_validation, m_timer, and SyncPanelHeights().

Here is the call graph for this function:

◆ SyncPanelHeights()

void Slic3r::GUI::FilamentMapManualPanel::SyncPanelHeights ( )
private
245{
246 if (!m_left_panel || !m_right_panel) return;
247
248 auto curr_left = m_left_panel->GetMinSize();
249 auto curr_right = m_right_panel->GetMinSize();
250
251 m_left_panel->SetMinSize(wxSize(FromDIP(260), FromDIP(110)));
252 m_right_panel->SetMinSize(wxSize(FromDIP(260), FromDIP(110)));
253
254 m_left_panel->Layout();
255 m_left_panel->Fit();
256 m_right_panel->Layout();
257 m_right_panel->Fit();
258
259 wxSize left_best_size = m_left_panel->GetBestSize();
260 wxSize right_best_size = m_right_panel->GetBestSize();
261
262 int max_height = std::max(left_best_size.GetHeight(), right_best_size.GetHeight());
263 bool height_changed = curr_left.GetHeight() != max_height || curr_right.GetHeight() != max_height;
264 if (!height_changed) {
265 if (curr_left.GetHeight() > 0)
266 m_left_panel->SetMinSize(curr_left);
267 if (curr_right.GetHeight() > 0)
268 m_right_panel->SetMinSize(curr_right);
269 if (GetParent()) {
270 GetParent()->Layout();
271 GetParent()->Fit();
272 }
273 return;
274 }
275
276 m_left_panel->SetMinSize(wxSize(FromDIP(260), max_height));
277 m_right_panel->SetMinSize(wxSize(FromDIP(260), max_height));
278
279 Layout();
280 Fit();
281
282 if (GetParent()) {
283 GetParent()->Layout();
284 GetParent()->Fit();
285 }
286}

References m_left_panel, and m_right_panel.

Referenced by OnDragDropCompleted(), OnSwitchFilament(), and Show().

Here is the caller graph for this function:

◆ UpdateNozzleCountDisplay()

void Slic3r::GUI::FilamentMapManualPanel::UpdateNozzleCountDisplay ( )
441{
442 auto preset_bundle = wxGetApp().preset_bundle;
443
444 // Orca: nozzle counts are only tracked (and only meaningful) for multi-nozzle extruders;
445 // plain dual-extruder printers keep their unadorned zone titles.
447 m_left_panel->UpdateLabel(_L("Left Nozzle"));
448 m_right_panel->UpdateLabel(_L("Right Nozzle"));
449 return;
450 }
451
452 // Format the count suffix separately so a translation containing '%' cannot
453 // corrupt the wxString::Format output.
454 int left_count = getExtruderNozzleCountTotal(preset_bundle, 0);
455 wxString left_title = _L("Left Nozzle") + wxString::Format("(%d)", left_count);
456 m_left_panel->UpdateLabel(left_title);
457
458 if (m_right_panel->IsUseSeparation()) {
459 int standard_count = getExtruderNozzleCount(preset_bundle, 1, NozzleVolumeType::nvtStandard);
460 int highflow_count = getExtruderNozzleCount(preset_bundle, 1, NozzleVolumeType::nvtHighFlow);
461 // TRN Nozzle counts: Std = standard flow, HF = high flow
462 wxString right_title = _L("Right Nozzle") + wxString::Format(_L("(Std: %d, HF: %d)"), standard_count, highflow_count);
463 m_right_panel->UpdateLabel(right_title);
464 } else {
465 int right_count = getExtruderNozzleCountTotal(preset_bundle, 1);
466 wxString right_title = _L("Right Nozzle") + wxString::Format("(%d)", right_count);
467 m_right_panel->UpdateLabel(right_title);
468 }
469}
int getExtruderNozzleCountTotal(PresetBundle *preset_bundle, int extruder_id)
Definition MultiNozzleSync.cpp:86

References _L, Slic3r::GUI::getExtruderNozzleCount(), Slic3r::GUI::getExtruderNozzleCountTotal(), m_left_panel, m_right_panel, Slic3r::nvtHighFlow, Slic3r::nvtStandard, and Slic3r::GUI::printer_has_multi_nozzle_extruder().

Referenced by UpdateNozzleVolumeType().

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

◆ UpdateNozzleVolumeType()

void Slic3r::GUI::FilamentMapManualPanel::UpdateNozzleVolumeType ( )
422{
423 auto check_separation = []() {
424 auto preset_bundle = wxGetApp().preset_bundle;
425 auto nozzle_volume_values = preset_bundle->project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values;
426 if (nozzle_volume_values.size() <= 1)
427 return false;
428
429 return nozzle_volume_values[1] == static_cast<int>(NozzleVolumeType::nvtHybrid);
430 };
431 bool should_separate = check_separation();
432 m_right_panel->SetUseSeparation(should_separate);
433
435
436 Layout();
437 Fit();
438}
void UpdateNozzleCountDisplay()
Definition FilamentMapPanel.cpp:440

References m_right_panel, Slic3r::nvtHybrid, and UpdateNozzleCountDisplay().

Referenced by FilamentMapManualPanel().

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

Member Data Documentation

◆ m_description

Label* Slic3r::GUI::FilamentMapManualPanel::m_description
private

Referenced by FilamentMapManualPanel(), and OnTimer().

◆ m_errors

Label* Slic3r::GUI::FilamentMapManualPanel::m_errors
private

Referenced by FilamentMapManualPanel(), and OnTimer().

◆ m_filament_color

std::vector<std::string> Slic3r::GUI::FilamentMapManualPanel::m_filament_color
private

Referenced by FilamentMapManualPanel().

◆ m_filament_list

std::vector<int> Slic3r::GUI::FilamentMapManualPanel::m_filament_list
private

Referenced by FilamentMapManualPanel(), and OnTimer().

◆ m_filament_map

std::vector<int> Slic3r::GUI::FilamentMapManualPanel::m_filament_map
private

◆ m_filament_type

std::vector<std::string> Slic3r::GUI::FilamentMapManualPanel::m_filament_type
private

Referenced by FilamentMapManualPanel().

◆ m_filament_volume_map

std::vector<int> Slic3r::GUI::FilamentMapManualPanel::m_filament_volume_map
private

Referenced by FilamentMapManualPanel().

◆ m_force_validation

bool Slic3r::GUI::FilamentMapManualPanel::m_force_validation {false}
private
72{false};

Referenced by OnTimer(), and Show().

◆ m_invalid_id

int Slic3r::GUI::FilamentMapManualPanel::m_invalid_id {-1}
private
71{-1};

Referenced by OnSuggestionClicked(), and OnTimer().

◆ m_left_panel

DragDropPanel* Slic3r::GUI::FilamentMapManualPanel::m_left_panel
private

◆ m_right_panel

◆ m_suggestion_panel

wxPanel* Slic3r::GUI::FilamentMapManualPanel::m_suggestion_panel
private

Referenced by FilamentMapManualPanel(), and OnTimer().

◆ m_switch_btn

ScalableButton* Slic3r::GUI::FilamentMapManualPanel::m_switch_btn
private

Referenced by FilamentMapManualPanel().

◆ m_timer

wxTimer* Slic3r::GUI::FilamentMapManualPanel::m_timer
private

◆ m_tips

Label* Slic3r::GUI::FilamentMapManualPanel::m_tips
private

Referenced by FilamentMapManualPanel(), and OnTimer().


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