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

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

Inheritance diagram for Slic3r::GUI::CaliPASaveAutoPanel:
Collaboration diagram for Slic3r::GUI::CaliPASaveAutoPanel:

Public Member Functions

 CaliPASaveAutoPanel (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
void create_panel (wxWindow *parent)
void set_machine_obj (MachineObject *obj)
std::vector< std::pair< int, std::string > > default_naming (std::vector< std::pair< int, std::string > > preset_names)
void sync_cali_result (const std::vector< PACalibResult > &cali_result, const std::vector< PACalibResult > &history_result)
void save_to_result_from_widgets (wxWindow *window, bool *out_is_valid, wxString *out_msg)
bool get_result (std::vector< PACalibResult > &out_result)
bool is_all_failed ()

Protected Member Functions

void sync_cali_result_for_multi_extruder (const std::vector< PACalibResult > &cali_result, const std::vector< PACalibResult > &history_result)

Protected Attributes

wxBoxSizer * m_top_sizer
wxPanel * m_complete_text_panel
wxPanel * m_part_failed_panel
wxPanel * m_grid_panel { nullptr }
wxPanel * m_multi_extruder_grid_panel { nullptr }
std::vector< PACalibResult > m_calib_results
std::vector< PACalibResult > m_history_results
bool m_is_all_failed { true }
MachineObject * m_obj { nullptr }

Detailed Description

Constructor & Destructor Documentation

◆ CaliPASaveAutoPanel()

Slic3r::GUI::CaliPASaveAutoPanel::CaliPASaveAutoPanel ( wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxTAB_TRAVERSAL )
179 : wxPanel(parent, id, pos, size, style)
180{
181 SetBackgroundColour(*wxWHITE);
182
183 m_top_sizer = new wxBoxSizer(wxVERTICAL);
184
185 create_panel(this);
186
187 this->SetSizer(m_top_sizer);
188 m_top_sizer->Fit(this);
189}
#define style
Definition WipeTowerDialog.cpp:101
void create_panel(wxWindow *parent)
Definition CalibrationWizardSavePage.cpp:192
wxBoxSizer * m_top_sizer
Definition CalibrationWizardSavePage.hpp:123

References create_panel(), m_top_sizer, and style.

Here is the call graph for this function:

Member Function Documentation

◆ create_panel()

void Slic3r::GUI::CaliPASaveAutoPanel::create_panel ( wxWindow * parent)
193{
194 m_complete_text_panel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
195 m_complete_text_panel->SetBackgroundColour(*wxWHITE);
196 m_complete_text_panel->Hide();
197 wxBoxSizer* complete_text_sizer = new wxBoxSizer(wxVERTICAL);
198 auto complete_text = new Label(m_complete_text_panel, _L("We found the best Flow Dynamics Calibration Factor"));
199 complete_text->SetFont(Label::Head_14);
200 complete_text_sizer->Add(complete_text, 0, wxEXPAND);
201 m_complete_text_panel->SetSizer(complete_text_sizer);
202
203 m_part_failed_panel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
204 m_part_failed_panel->SetBackgroundColour(wxColour(238, 238, 238));
205 wxBoxSizer* part_failed_sizer = new wxBoxSizer(wxVERTICAL);
206 m_part_failed_panel->SetSizer(part_failed_sizer);
207 part_failed_sizer->AddSpacer(FromDIP(10));
208 auto part_failed_text = new Label(m_part_failed_panel, _L("Part of the calibration failed! You may clean the plate and retry. The failed test result would be dropped."));
209 part_failed_text->SetFont(Label::Body_14);
210 part_failed_sizer->Add(part_failed_text, 0, wxLEFT | wxRIGHT, FromDIP(20));
211 part_failed_sizer->AddSpacer(FromDIP(10));
212
213 m_top_sizer->Add(m_part_failed_panel, 0, wxEXPAND, 0);
214
215 m_top_sizer->AddSpacer(FromDIP(20));
216
217 m_top_sizer->Add(m_complete_text_panel, 0, wxEXPAND, 0);
218
219 m_top_sizer->AddSpacer(FromDIP(20));
220
221 m_grid_panel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
222 m_grid_panel->SetBackgroundColour(*wxWHITE);
223 m_top_sizer->Add(m_grid_panel, 0, wxALIGN_CENTER);
224
225 m_multi_extruder_grid_panel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
226 m_multi_extruder_grid_panel->SetBackgroundColour(*wxWHITE);
227 m_top_sizer->Add(m_multi_extruder_grid_panel, 0, wxALIGN_CENTER);
228
229 m_top_sizer->AddSpacer(FromDIP(10));
230
231 auto naming_hints = new Label(parent, _L("*We recommend you to add brand, materia, type, and even humidity level in the Name"));
232 naming_hints->SetFont(Label::Body_14);
233 naming_hints->SetForegroundColour(wxColour(157, 157, 157));
234 m_top_sizer->Add(naming_hints, 0, wxEXPAND, 0);
235
236 m_top_sizer->AddSpacer(FromDIP(20));
237}
#define _L(s)
Definition OBJ.cpp:34
static wxFont Head_14
Definition Label.hpp:45
static wxFont Body_14
Definition Label.hpp:53
wxPanel * m_multi_extruder_grid_panel
Definition CalibrationWizardSavePage.hpp:127
wxPanel * m_part_failed_panel
Definition CalibrationWizardSavePage.hpp:125
wxPanel * m_grid_panel
Definition CalibrationWizardSavePage.hpp:126
wxPanel * m_complete_text_panel
Definition CalibrationWizardSavePage.hpp:124

References _L, Label::Body_14, Label::Head_14, m_complete_text_panel, m_grid_panel, m_multi_extruder_grid_panel, m_part_failed_panel, and m_top_sizer.

Referenced by CaliPASaveAutoPanel().

Here is the caller graph for this function:

◆ default_naming()

std::vector< std::pair< int, std::string > > Slic3r::GUI::CaliPASaveAutoPanel::default_naming ( std::vector< std::pair< int, std::string > > preset_names)
240{
241 std::unordered_set<std::string> set;
242 int i = 1;
243 for (auto& item : preset_names) {
244 if (!set.insert(item.second).second) {
245 item.second = get_default_name(item.second, CalibMode::Calib_PA_Line).ToUTF8().data();
246 item.second += "_" + std::to_string(i);
247 i++;
248 }
249 else {
250 item.second = get_default_name(item.second, CalibMode::Calib_PA_Line).ToUTF8().data();
251 }
252 }
253 return preset_names;
254}
static wxString get_default_name(wxString filament_name, CalibMode mode)
Definition CalibrationWizardSavePage.cpp:48
@ Calib_PA_Line
Definition calib.hpp:25
void set(id object, const void *key, id value)
Definition MacIME.mm:24

References Slic3r::Calib_PA_Line, and Slic3r::GUI::get_default_name().

Referenced by sync_cali_result().

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

◆ get_result()

bool Slic3r::GUI::CaliPASaveAutoPanel::get_result ( std::vector< PACalibResult > & out_result)
488 {
489 bool is_valid = true;
490 wxString err_msg;
491 // Check if the input value is valid and save to m_calib_results
492 if (m_obj && m_obj->is_multi_extruders())
494 else
495 save_to_result_from_widgets(m_grid_panel, &is_valid, &err_msg);
496 if (is_valid) {
497 out_result = m_calib_results;
498 return true;
499 }
500 else {
501 MessageDialog msg_dlg(nullptr, err_msg, wxEmptyString, wxICON_WARNING | wxOK);
502 msg_dlg.ShowModal();
503 return false;
504 }
505}
std::vector< PACalibResult > m_calib_results
Definition CalibrationWizardSavePage.hpp:131
void save_to_result_from_widgets(wxWindow *window, bool *out_is_valid, wxString *out_msg)
Definition CalibrationWizardSavePage.cpp:435
MachineObject * m_obj
Definition CalibrationWizardSavePage.hpp:134
bool is_valid(const FontFile &font, unsigned int index)
Definition Emboss.cpp:284

References m_calib_results, m_grid_panel, m_multi_extruder_grid_panel, m_obj, save_to_result_from_widgets(), and Slic3r::GUI::DPIAware< P >::ShowModal().

Here is the call graph for this function:

◆ is_all_failed()

bool Slic3r::GUI::CaliPASaveAutoPanel::is_all_failed ( )
inline
117{ return m_is_all_failed; }
bool m_is_all_failed
Definition CalibrationWizardSavePage.hpp:133

References m_is_all_failed.

◆ save_to_result_from_widgets()

void Slic3r::GUI::CaliPASaveAutoPanel::save_to_result_from_widgets ( wxWindow * window,
bool * out_is_valid,
wxString * out_msg )
435 {
436 if (!window)
437 return;
438
439 //operate
440 // The grid can hold two rows with the same tray_id under different extruders
441 // (rack / dual-address configs), so results must be keyed by (tray_id, extruder_id).
442 auto find_result = [this](int tray_id, int extruder_id) -> PACalibResult* {
443 auto it = std::find_if(m_calib_results.begin(), m_calib_results.end(), [tray_id, extruder_id](const PACalibResult& r) {
444 return r.tray_id == tray_id && r.extruder_id == extruder_id;
445 });
446 return it != m_calib_results.end() ? &(*it) : nullptr;
447 };
448 auto input = dynamic_cast<GridTextInput*>(window);
449 if (input && input->IsShown()) {
450 int tray_id = input->get_col_idx();
451 int extruder_id = input->get_extruder_id();
452 if (input->get_type() == GridTextInputType::K) {
453 float k = 0.0f;
454 if (!CalibUtils::validate_input_k_value(input->GetTextCtrl()->GetValue(), &k)) {
455 *out_msg = wxString::Format(_L("Please input a valid value (K in %.1f~%.1f)"), MIN_PA_K_VALUE, MAX_PA_K_VALUE);
456 *out_is_valid = false;
457 }
458 else if (auto* result = find_result(tray_id, extruder_id))
459 result->k_value = k;
460 }
461 else if (input->get_type() == GridTextInputType::N) {
462 }
463 }
464
465 auto comboBox = dynamic_cast<GridComboBox*>(window);
466 if (comboBox && comboBox->IsShown()) {
467 int tray_id = comboBox->get_col_idx();
468 int extruder_id = comboBox->get_extruder_id();
469 wxString name = comboBox->GetTextCtrl()->GetValue().ToStdString();
470 if (name.IsEmpty()) {
471 *out_msg = _L("Please enter the name you want to save to printer.");
472 *out_is_valid = false;
473 }
474 else if (name.Length() > 40) {
475 *out_msg = _L("The name cannot exceed 40 characters.");
476 *out_is_valid = false;
477 }
478 if (auto* result = find_result(tray_id, extruder_id))
479 result->name = into_u8(name);
480 }
481
482 auto childern = window->GetChildren();
483 for (auto child : childern) {
484 save_to_result_from_widgets(child, out_is_valid, out_msg);
485 }
486};
static bool validate_input_k_value(wxString k_text, float *output_value)
Definition CalibUtils.cpp:452
const double MAX_PA_K_VALUE
Definition CalibUtils.cpp:68
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
const double MIN_PA_K_VALUE
Definition CalibUtils.cpp:67
@ N
Definition CalibrationWizardSavePage.cpp:124
@ K
Definition CalibrationWizardSavePage.cpp:123

References _L, Slic3r::GUI::into_u8(), Slic3r::GUI::K, m_calib_results, Slic3r::GUI::MAX_PA_K_VALUE, Slic3r::GUI::MIN_PA_K_VALUE, Slic3r::GUI::N, save_to_result_from_widgets(), and Slic3r::GUI::CalibUtils::validate_input_k_value().

Referenced by get_result(), and save_to_result_from_widgets().

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

◆ set_machine_obj()

void Slic3r::GUI::CaliPASaveAutoPanel::set_machine_obj ( MachineObject * obj)
inline
111{ m_obj = obj; }

References m_obj.

◆ sync_cali_result()

void Slic3r::GUI::CaliPASaveAutoPanel::sync_cali_result ( const std::vector< PACalibResult > & cali_result,
const std::vector< PACalibResult > & history_result )
257{
258 if (m_obj && m_obj->is_multi_extruders()) {
259 m_grid_panel->Hide();
261 sync_cali_result_for_multi_extruder(cali_result, history_result);
262 return;
263 }
264
265 m_grid_panel->Show();
267
268 m_history_results = history_result;
269 m_calib_results.clear();
270 for (auto& item : cali_result) {
271 if (item.confidence == 0)
272 m_calib_results.push_back(item);
273 }
274 m_grid_panel->DestroyChildren();
275 auto grid_sizer = new wxBoxSizer(wxHORIZONTAL);
276 const int COLUMN_GAP = FromDIP(20);
277 const int ROW_GAP = FromDIP(30);
278 wxBoxSizer* left_title_sizer = new wxBoxSizer(wxVERTICAL);
279 left_title_sizer->AddSpacer(FromDIP(52));
280 auto k_title = new Label(m_grid_panel, _L("Factor K"));
281 k_title->SetFont(Label::Head_14);
282 left_title_sizer->Add(k_title, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
283 auto n_title = new Label(m_grid_panel, _L("Factor N"));
284 n_title->SetFont(Label::Head_14);
285 // hide n value
286 n_title->Hide();
287 left_title_sizer->Add(n_title, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
288 auto brand_title = new Label(m_grid_panel, _L("Name"));
289 brand_title->SetFont(Label::Head_14);
290 left_title_sizer->Add(brand_title, 0, wxALIGN_CENTER);
291 grid_sizer->Add(left_title_sizer);
292 grid_sizer->AddSpacer(COLUMN_GAP);
293
294 m_is_all_failed = true;
295 bool part_failed = false;
296 if (cali_result.empty())
297 part_failed = true;
298
299 std::vector<std::pair<int, std::string>> preset_names;
300 for (auto& info : m_obj->selected_cali_preset) {
301 preset_names.push_back({ info.tray_id, info.name });
302 }
303 preset_names = default_naming(preset_names);
304
305 std::vector<PACalibResult> sorted_cali_result = cali_result;
306 std::sort(sorted_cali_result.begin(), sorted_cali_result.end(), [](const PACalibResult &left, const PACalibResult& right) {
307 return left.tray_id < right.tray_id;
308 });
309
310 for (auto &item : sorted_cali_result) {
311 bool result_failed = false;
312 if (item.confidence != 0) {
313 result_failed = true;
314 part_failed = true;
315 }
316 else {
317 m_is_all_failed = false;
318 }
319
320 wxBoxSizer* column_data_sizer = new wxBoxSizer(wxVERTICAL);
321 auto tray_title = new Label(m_grid_panel, "");
322 tray_title->SetFont(Label::Head_14);
323 wxString tray_name = get_tray_name_by_tray_id(item.tray_id);
324 tray_title->SetLabel(tray_name);
325
326 auto k_value = new GridTextInput(m_grid_panel, "", "", CALIBRATION_SAVE_INPUT_SIZE, item.tray_id, GridTextInputType::K, item.extruder_id);
327 auto n_value = new GridTextInput(m_grid_panel, "", "", CALIBRATION_SAVE_INPUT_SIZE, item.tray_id, GridTextInputType::N, item.extruder_id);
328 k_value->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
329 n_value->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
330 auto k_value_failed = new Label(m_grid_panel, _L("Failed"));
331 auto n_value_failed = new Label(m_grid_panel, _L("Failed"));
332
333 auto comboBox_tray_name = new GridComboBox(m_grid_panel, CALIBRATION_SAVE_INPUT_SIZE, item.tray_id, item.extruder_id);
334 auto tray_name_failed = new Label(m_grid_panel, " - ");
335 wxArrayString selections;
336 static std::vector<PACalibResult> filtered_results;
337 filtered_results.clear();
338 for (auto history : history_result) {
339 if (history.filament_id == item.filament_id) {
340 filtered_results.push_back(history);
341 selections.push_back(from_u8(history.name));
342 }
343 }
344 comboBox_tray_name->Set(selections);
345
346 column_data_sizer->Add(tray_title, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
347 column_data_sizer->Add(k_value, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
348 column_data_sizer->Add(n_value, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
349 column_data_sizer->Add(k_value_failed, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
350 column_data_sizer->Add(n_value_failed, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
351 column_data_sizer->Add(comboBox_tray_name, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
352 column_data_sizer->Add(tray_name_failed, 0, wxALIGN_CENTER | wxBOTTOM, ROW_GAP);
353
354 auto set_edit_mode = [this, k_value, n_value, k_value_failed, n_value_failed, comboBox_tray_name, tray_name_failed](std::string str) {
355 if (str == "normal") {
356 comboBox_tray_name->Show();
357 tray_name_failed->Show(false);
358 k_value->Show();
359 n_value->Show();
360 k_value_failed->Show(false);
361 n_value_failed->Show(false);
362 }
363 if (str == "failed") {
364 comboBox_tray_name->Show(false);
365 tray_name_failed->Show();
366 k_value->Show(false);
367 n_value->Show(false);
368 k_value_failed->Show();
369 n_value_failed->Show();
370 }
371
372 // hide n value
373 n_value->Hide();
374 n_value_failed->Hide();
375
376 m_grid_panel->Layout();
377 m_grid_panel->Update();
378 };
379
380 if (!result_failed) {
381 set_edit_mode("normal");
382
383 auto k_str = wxString::Format("%.3f", item.k_value);
384 auto n_str = wxString::Format("%.3f", item.n_coef);
385 k_value->GetTextCtrl()->SetValue(k_str);
386 n_value->GetTextCtrl()->SetValue(n_str);
387
388 for (auto& name : preset_names) {
389 int tray_id = item.tray_id;
390 /* upgrade single extruder printer tray_id from 254 to 255 */
391 if (!m_obj->is_multi_extruders() && tray_id == VIRTUAL_TRAY_DEPUTY_ID) {
392 tray_id = VIRTUAL_TRAY_MAIN_ID;
393 }
394
395 if (tray_id == name.first) {
396 comboBox_tray_name->SetValue(from_u8(name.second));
397 }
398 }
399
400 comboBox_tray_name->Bind(wxEVT_COMBOBOX, [comboBox_tray_name](auto& e) {
401 int selection = comboBox_tray_name->GetSelection();
402 auto history = filtered_results[selection];
403 });
404 }
405 else {
406 set_edit_mode("failed");
407 }
408
409 grid_sizer->Add(column_data_sizer);
410 grid_sizer->AddSpacer(COLUMN_GAP);
411 }
412
413 m_grid_panel->SetSizer(grid_sizer, true);
414 m_grid_panel->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
415 SetFocusIgnoringChildren();
416 });
417
418 if (part_failed) {
419 m_part_failed_panel->Show();
420 m_complete_text_panel->Show();
421 if (m_is_all_failed) {
422 m_complete_text_panel->Hide();
423 }
424 }
425 else {
426 m_complete_text_panel->Show();
427 m_part_failed_panel->Hide();
428 }
429
430 wxGetApp().UpdateDarkUIWin(this);
431
432 Layout();
433}
#define CALIBRATION_SAVE_INPUT_SIZE
Definition CalibrationWizardSavePage.cpp:45
#define VIRTUAL_TRAY_DEPUTY_ID
Definition DevDefs.h:90
#define VIRTUAL_TRAY_MAIN_ID
Definition DevDefs.h:89
void sync_cali_result_for_multi_extruder(const std::vector< PACalibResult > &cali_result, const std::vector< PACalibResult > &history_result)
Definition CalibrationWizardSavePage.cpp:507
std::vector< std::pair< int, std::string > > default_naming(std::vector< std::pair< int, std::string > > preset_names)
Definition CalibrationWizardSavePage.cpp:239
std::vector< PACalibResult > m_history_results
Definition CalibrationWizardSavePage.hpp:132
constexpr int ROW_GAP
Definition KBShortcutsDialog.cpp:68
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
static wxString get_tray_name_by_tray_id(int tray_id)
Definition CalibrationWizardSavePage.cpp:95

References _L, CALIBRATION_SAVE_INPUT_SIZE, default_naming(), Slic3r::GUI::from_u8(), Slic3r::GUI::get_tray_name_by_tray_id(), Label::Head_14, Slic3r::GUI::K, m_calib_results, m_complete_text_panel, m_grid_panel, m_history_results, m_is_all_failed, m_multi_extruder_grid_panel, m_obj, m_part_failed_panel, Slic3r::GUI::N, sync_cali_result_for_multi_extruder(), VIRTUAL_TRAY_DEPUTY_ID, and VIRTUAL_TRAY_MAIN_ID.

Here is the call graph for this function:

◆ sync_cali_result_for_multi_extruder()

void Slic3r::GUI::CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder ( const std::vector< PACalibResult > & cali_result,
const std::vector< PACalibResult > & history_result )
protected
508{
509 if (!m_obj)
510 return;
511
512 std::map<int, DynamicPrintConfig> old_full_filament_ams_list = wxGetApp().sidebar().build_filament_ams_list(m_obj);
513 std::map<int, DynamicPrintConfig> full_filament_ams_list;
514 for (auto ams_item : old_full_filament_ams_list) {
515 int key = ams_item.first & 0x0FFFF;
516 full_filament_ams_list[key] = std::move(ams_item.second);
517 }
518
519 m_is_all_failed = true;
520 bool part_failed = false;
521 if (cali_result.empty())
522 part_failed = true;
523
524 m_history_results = history_result;
525 m_calib_results.clear();
526 for (auto &item : cali_result) {
527 if (item.confidence == 0) {
528 PACalibResult result = item;
529 result.tray_id = 4 * item.ams_id + item.slot_id;
530 if (item.ams_id == VIRTUAL_TRAY_MAIN_ID || item.ams_id == VIRTUAL_TRAY_DEPUTY_ID) {
531 result.tray_id = item.ams_id;
532 }
533 m_calib_results.push_back(result);
534 }
535 }
536 m_multi_extruder_grid_panel->DestroyChildren();
537 auto grid_sizer = new wxBoxSizer(wxHORIZONTAL);
538 const int COLUMN_GAP = FromDIP(10);
539 const int ROW_GAP = FromDIP(10);
540
541 m_multi_extruder_grid_panel->SetSizer(grid_sizer, true);
542 m_multi_extruder_grid_panel->Bind(wxEVT_LEFT_DOWN, [this](auto &e) { SetFocusIgnoringChildren(); });
543
544 const std::string& cwsp_pt = m_obj->printer_type;
547 grid_sizer->Add(left_sizer);
548 grid_sizer->AddSpacer(COLUMN_GAP);
549 grid_sizer->Add(right_sizer);
550
551 wxFlexGridSizer *left_grid_sizer = new wxFlexGridSizer(3, COLUMN_GAP, ROW_GAP);
552
553 // The main extruder can carry a nozzle rack (H2C); non-rack printers keep the 3-column layout.
554 auto ns = m_obj->GetNozzleSystem();
555 auto rack = ns ? ns->GetNozzleRack() : nullptr;
556 bool has_rack = rack && rack->IsSupported();
557
558 wxFlexGridSizer *right_grid_sizer = new wxFlexGridSizer(has_rack ? 4 : 3, COLUMN_GAP, ROW_GAP);
559 left_sizer->Add(left_grid_sizer);
560 right_sizer->Add(right_grid_sizer);
561
562 // main extruder
563 {
564 left_grid_sizer->Add(new wxStaticText(m_multi_extruder_grid_panel, wxID_ANY, ""), 1, wxEXPAND); // fill empty space
565
566 auto brand_title = new Label(m_multi_extruder_grid_panel, _L("Name"), 0, CALIBRATION_SAVE_INPUT_SIZE);
567 brand_title->SetFont(Label::Head_14);
568 left_grid_sizer->Add(brand_title, 1, wxALIGN_CENTER);
569
570 auto k_title = new Label(m_multi_extruder_grid_panel, _L("Factor K"), 0, CALIBRATION_SAVE_NUMBER_INPUT_SIZE);
571 k_title->SetFont(Label::Head_14);
572 left_grid_sizer->Add(k_title, 1, wxALIGN_CENTER);
573 }
574
575 // deputy extruder
576 {
577 right_grid_sizer->Add(new wxStaticText(m_multi_extruder_grid_panel, wxID_ANY, ""), 1, wxEXPAND); // fill empty space
578
579 auto brand_title = new Label(m_multi_extruder_grid_panel, _L("Name"), 0, CALIBRATION_SAVE_INPUT_SIZE);
580 brand_title->SetFont(Label::Head_14);
581 right_grid_sizer->Add(brand_title, 1, wxALIGN_CENTER);
582
583 auto k_title = new Label(m_multi_extruder_grid_panel, _L("Factor K"), 0, CALIBRATION_SAVE_NUMBER_INPUT_SIZE);
584 k_title->SetFont(Label::Head_14);
585 right_grid_sizer->Add(k_title, 1, wxALIGN_CENTER);
586
587 if (has_rack) {
588 auto nozzle_title = new Label(m_multi_extruder_grid_panel, _L("Nozzle ID"), 0, CALIBRATION_SAVE_NUMBER_INPUT_SIZE);
589 nozzle_title->SetFont(Label::Head_14);
590 right_grid_sizer->Add(nozzle_title, 1, wxALIGN_CENTER);
591 }
592 }
593
594 // key: (extruder_id, tray_id)
595 std::vector<std::pair<std::pair<int, int>, std::string>> preset_names;
596 int i = 1;
597 std::unordered_set<std::string> set;
598 for (auto &info : m_obj->selected_cali_preset) {
599 std::string default_name;
600 // Derive extruder_id from the tray so the extruder/tray key stays consistent
601 // with the calibration result's extruder_id.
602 int extruder_id = 0;
603 if (info.tray_id == VIRTUAL_TRAY_MAIN_ID) {
604 extruder_id = 0;
605 } else if (info.tray_id == VIRTUAL_TRAY_DEPUTY_ID) {
606 extruder_id = 1;
607 } else {
608 int ams_id = info.tray_id / 4;
609 extruder_id = m_obj->get_extruder_id_by_ams_id(std::to_string(ams_id));
610 }
611 {
612 if (extruder_id == MAIN_EXTRUDER_ID) {
614 if (has_rack) {
615 default_name += "_";
616 if (info.nozzle_pos_id == 0) {
617 default_name += "R";
618 } else if (info.nozzle_pos_id >= 0x10) {
619 default_name += std::to_string((info.nozzle_pos_id & 0x0f) + 1);
620 } else {
621 default_name += "N/A";
622 }
623 }
624 } else if (extruder_id == DEPUTY_EXTRUDER_ID) {
626 }
627 }
628
629 // nozzle_volume_type
630 {
631 default_name += "_";
632 if (info.nozzle_volume_type == NozzleVolumeType::nvtStandard) {
633 default_name += L("Standard");
634 }
635 else if (info.nozzle_volume_type == NozzleVolumeType::nvtHighFlow) {
636 default_name += L("High Flow");
637 }
638 }
639
640 // filament_id
641 {
642 default_name += "_";
643 default_name += get_default_name(info.name, CalibMode::Calib_PA_Line).ToUTF8().data();
644 if (!set.insert(default_name).second) {
645 default_name += "_" + std::to_string(i);
646 i++;
647 }
648 }
649
650 preset_names.push_back({{extruder_id, info.tray_id}, default_name});
651 }
652
653 bool left_first_add_item = true;
654 bool right_first_add_item = true;
655 std::vector<PACalibResult> sorted_cali_result = cali_result;
656 if (m_obj && m_obj->is_support_new_auto_cali_method) {
657 for (auto &res : sorted_cali_result) {
658 if (res.ams_id == VIRTUAL_TRAY_MAIN_ID || res.ams_id == VIRTUAL_TRAY_DEPUTY_ID) {
659 res.tray_id = res.ams_id;
660 } else {
661 res.tray_id = res.ams_id * 4 + res.slot_id;
662 }
663 }
664 }
665
666 std::sort(sorted_cali_result.begin(), sorted_cali_result.end(), [](const PACalibResult &left, const PACalibResult &right) {
667 return left.tray_id < right.tray_id;
668 });
669 for (auto &item : sorted_cali_result) {
670 bool result_failed = false;
671 if (item.confidence != 0) {
672 result_failed = true;
673 part_failed = true;
674 } else {
675 m_is_all_failed = false;
676 }
677
678 wxString tray_name = get_tray_name_by_tray_id(item.tray_id);
679 wxButton *tray_title = new wxButton(m_multi_extruder_grid_panel, wxID_ANY, {}, wxDefaultPosition, wxSize(FromDIP(20), FromDIP(20)), wxBU_EXACTFIT | wxBU_AUTODRAW | wxBORDER_NONE);
680 tray_title->SetBackgroundColour(*wxWHITE);
681 tray_title->SetBitmap(*get_extruder_color_icon(full_filament_ams_list[item.tray_id].opt_string("filament_colour", 0u), tray_name.ToStdString(), FromDIP(20), FromDIP(20)));
682 tray_title->SetToolTip("");
683
684 auto k_value = new GridTextInput(m_multi_extruder_grid_panel, "", "", CALIBRATION_SAVE_NUMBER_INPUT_SIZE, item.tray_id, GridTextInputType::K, item.extruder_id);
685 auto n_value = new GridTextInput(m_multi_extruder_grid_panel, "", "", CALIBRATION_SAVE_NUMBER_INPUT_SIZE, item.tray_id, GridTextInputType::N, item.extruder_id);
686 k_value->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
687 n_value->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
688 auto k_value_failed = new Label(m_multi_extruder_grid_panel, _L("Failed"));
689 auto n_value_failed = new Label(m_multi_extruder_grid_panel, _L("Failed"));
690
691 auto nozzle_id_value = new Label(m_multi_extruder_grid_panel, wxEmptyString);
692 nozzle_id_value->SetMinSize(wxSize(FromDIP(180), FromDIP(24)));
693 nozzle_id_value->Wrap(-1);
694 auto nozzle_id_failed = new Label(m_multi_extruder_grid_panel, _L("Failed"));
695
696 auto comboBox_tray_name = new GridComboBox(m_multi_extruder_grid_panel, CALIBRATION_SAVE_INPUT_SIZE, item.tray_id, item.extruder_id);
697 auto tray_name_failed = new Label(m_multi_extruder_grid_panel, " - ");
698 wxArrayString selections;
699 static std::vector<PACalibResult> filtered_results;
700 filtered_results.clear();
701 for (auto history : history_result) {
702 if (history.filament_id == item.filament_id
703 && history.extruder_id == item.extruder_id
704 && history.nozzle_volume_type == item.nozzle_volume_type
705 && history.nozzle_diameter == item.nozzle_diameter) {
706 filtered_results.push_back(history);
707 selections.push_back(from_u8(history.name));
708 }
709 }
710 comboBox_tray_name->Set(selections);
711
712 auto set_edit_mode = [this, k_value, n_value, k_value_failed, n_value_failed, nozzle_id_value, nozzle_id_failed, comboBox_tray_name, tray_name_failed](std::string str, bool display_nozzle) {
713 if (str == "normal") {
714 comboBox_tray_name->Show();
715 tray_name_failed->Show(false);
716 k_value->Show();
717 n_value->Show();
718 nozzle_id_value->Show(display_nozzle);
719 k_value_failed->Show(false);
720 n_value_failed->Show(false);
721 nozzle_id_failed->Show(false);
722 }
723 if (str == "failed") {
724 comboBox_tray_name->Show(false);
725 tray_name_failed->Show();
726 k_value->Show(false);
727 n_value->Show(false);
728 nozzle_id_value->Show(false);
729 k_value_failed->Show();
730 n_value_failed->Show();
731 nozzle_id_failed->Show(display_nozzle);
732 }
733
734 // hide n value
735 n_value->Hide();
736 n_value_failed->Hide();
737
740 };
741
742 if (!result_failed) {
743 set_edit_mode("normal", has_rack && item.extruder_id == MAIN_EXTRUDER_ID);
744
745 auto k_str = wxString::Format("%.3f", item.k_value);
746 auto n_str = wxString::Format("%.3f", item.n_coef);
747 k_value->GetTextCtrl()->SetValue(k_str);
748 n_value->GetTextCtrl()->SetValue(n_str);
749
750 if (has_rack && item.extruder_id == MAIN_EXTRUDER_ID) {
751 wxString nozzle_id_str;
752 if (item.nozzle_pos_id == 0) {
753 nozzle_id_str += "R | ";
754 } else if (item.nozzle_pos_id >= 0x10) {
755 nozzle_id_str += wxString::Format("%d | ", (item.nozzle_pos_id & 0x0f) + 1);
756 } else {
757 nozzle_id_str += "N/A | ";
758 BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << "Nozzle position id is -1 or invalid.";
759 }
760 nozzle_id_str += wxString::Format("%.1f mm ", item.nozzle_diameter);
761 switch (item.nozzle_volume_type) {
762 case NozzleVolumeType::nvtStandard: nozzle_id_str += _L("Standard Flow"); break;
763 case NozzleVolumeType::nvtHighFlow: nozzle_id_str += _L("High Flow"); break;
764 case NozzleVolumeType::nvtTPUHighFlow: nozzle_id_str += _L("TPU High Flow"); break;
765 case NozzleVolumeType::nvtE3DHighFlow: nozzle_id_str += _L("E3D High Flow"); break;
766 default: break;
767 }
768 nozzle_id_value->SetLabel(nozzle_id_str);
769 }
770
771 for (auto &name : preset_names) {
772 int extruder_id = name.first.first;
773 int tray_id = name.first.second;
774 if (item.tray_id == tray_id && item.extruder_id == extruder_id) {
775 comboBox_tray_name->SetValue(from_u8(name.second));
776 }
777 }
778
779 comboBox_tray_name->Bind(wxEVT_COMBOBOX, [comboBox_tray_name](auto &e) {
780 int selection = comboBox_tray_name->GetSelection();
781 auto history = filtered_results[selection];
782 });
783 } else {
784 set_edit_mode("failed", has_rack && item.extruder_id == MAIN_EXTRUDER_ID);
785 }
786
787 if ((m_obj->is_main_extruder_on_left() && item.extruder_id == 0)
788 || (!m_obj->is_main_extruder_on_left() && item.extruder_id == 1)) {
789 if (left_first_add_item) {
790 wxString title_name = left_sizer->GetStaticBox()->GetLabel();
791 title_name += " - ";
792 title_name += get_nozzle_volume_type_name(item.nozzle_volume_type);
793 left_sizer->GetStaticBox()->SetLabel(title_name);
794 left_first_add_item = false;
795 }
796
797 left_grid_sizer->Add(tray_title, 1, wxEXPAND);
798
799 if (comboBox_tray_name->IsShown()) {
800 left_grid_sizer->Add(comboBox_tray_name, 1, wxEXPAND);
801 } else {
802 left_grid_sizer->Add(tray_name_failed, 1, wxEXPAND);
803 }
804
805 if (k_value->IsShown()) {
806 left_grid_sizer->Add(k_value, 1, wxEXPAND);
807 } else {
808 left_grid_sizer->Add(k_value_failed, 1, wxEXPAND);
809 }
810 }
811 else {
812 if (right_first_add_item) {
813 wxString title_name = right_sizer->GetStaticBox()->GetLabel();
814 title_name += " - ";
815 title_name += get_nozzle_volume_type_name(item.nozzle_volume_type);
816 right_sizer->GetStaticBox()->SetLabel(title_name);
817 right_first_add_item = false;
818 }
819 right_grid_sizer->Add(tray_title, 1, wxEXPAND);
820
821 if (comboBox_tray_name->IsShown()) {
822 right_grid_sizer->Add(comboBox_tray_name, 1, wxEXPAND);
823 } else {
824 right_grid_sizer->Add(tray_name_failed, 1, wxEXPAND);
825 }
826
827 if (k_value->IsShown()) {
828 right_grid_sizer->Add(k_value, 1, wxEXPAND);
829 } else {
830 right_grid_sizer->Add(k_value_failed, 1, wxEXPAND);
831 }
832
833 if (has_rack) {
834 if (nozzle_id_value->IsShown()) {
835 right_grid_sizer->Add(nozzle_id_value, 1, wxEXPAND);
836 } else {
837 right_grid_sizer->Add(nozzle_id_failed, 1, wxEXPAND);
838 }
839 }
840 }
841 }
842
843 if (left_first_add_item)
844 left_sizer->Show(false);
845 if (right_first_add_item)
846 right_sizer->Show(false);
847
848 if (part_failed) {
849 m_part_failed_panel->Show();
850 m_complete_text_panel->Show();
851 if (m_is_all_failed) {
852 m_complete_text_panel->Hide();
853 }
854 } else {
855 m_complete_text_panel->Show();
856 m_part_failed_panel->Hide();
857 }
858
859 wxGetApp().UpdateDarkUIWin(this);
860
861 Layout();
862}
#define CALIBRATION_SAVE_NUMBER_INPUT_SIZE
Definition CalibrationWizardSavePage.cpp:44
#define DEPUTY_EXTRUDER_ID
Definition DevDefs.h:102
#define MAIN_EXTRUDER_ID
Definition DevDefs.h:101
#define L(s)
Definition ExtrusionEntity.cpp:25
class WXDLLIMPEXP_FWD_CORE wxButton
Definition ProgressDialog.hpp:27
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static std::string get_toolhead_display_name(const std::string &type_str, int ext_id, ToolHeadComponent component, ToolHeadNameCase name_case=ToolHeadNameCase::TitleCase, bool short_name=false)
Definition DevConfigUtil.cpp:379
wxString get_nozzle_volume_type_name(NozzleVolumeType type)
Definition CalibUtils.cpp:138
@ nvtE3DHighFlow
Definition PrintConfig.hpp:626
@ nvtHighFlow
Definition PrintConfig.hpp:620
@ nvtTPUHighFlow
Definition PrintConfig.hpp:624
@ nvtStandard
Definition PrintConfig.hpp:619
@ Extruder
Definition DevConfigUtil.h:34
@ Nozzle
Definition DevConfigUtil.h:35
@ SentenceCase
Definition DevConfigUtil.h:42
@ TitleCase
Definition DevConfigUtil.h:41
wxBitmap * get_extruder_color_icon(std::vector< std::string > colors, bool is_gradient, std::string label, int icon_width, int icon_height, const std::vector< wxColour > *ramp)
Definition wxExtensions.cpp:633

References _L, Slic3r::Calib_PA_Line, CALIBRATION_SAVE_INPUT_SIZE, CALIBRATION_SAVE_NUMBER_INPUT_SIZE, DEPUTY_EXTRUDER_ID, Slic3r::Extruder, Slic3r::GUI::from_u8(), Slic3r::GUI::get_default_name(), get_extruder_color_icon(), Slic3r::GUI::get_nozzle_volume_type_name(), Slic3r::DevPrinterConfigUtil::get_toolhead_display_name(), Slic3r::GUI::get_tray_name_by_tray_id(), Label::Head_14, Slic3r::GUI::K, L, m_calib_results, m_complete_text_panel, m_history_results, m_is_all_failed, m_multi_extruder_grid_panel, m_obj, m_part_failed_panel, MAIN_EXTRUDER_ID, Slic3r::GUI::N, Slic3r::Nozzle, Slic3r::nvtE3DHighFlow, Slic3r::nvtHighFlow, Slic3r::nvtStandard, Slic3r::nvtTPUHighFlow, Slic3r::SentenceCase, Slic3r::TitleCase, Slic3r::PACalibResult::tray_id, VIRTUAL_TRAY_DEPUTY_ID, VIRTUAL_TRAY_MAIN_ID, wxButton, and wxStaticText.

Referenced by sync_cali_result().

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

Member Data Documentation

◆ m_calib_results

std::vector<PACalibResult> Slic3r::GUI::CaliPASaveAutoPanel::m_calib_results
protected

◆ m_complete_text_panel

wxPanel* Slic3r::GUI::CaliPASaveAutoPanel::m_complete_text_panel
protected

◆ m_grid_panel

wxPanel* Slic3r::GUI::CaliPASaveAutoPanel::m_grid_panel { nullptr }
protected
126{ nullptr };

Referenced by create_panel(), get_result(), and sync_cali_result().

◆ m_history_results

std::vector<PACalibResult> Slic3r::GUI::CaliPASaveAutoPanel::m_history_results
protected

◆ m_is_all_failed

bool Slic3r::GUI::CaliPASaveAutoPanel::m_is_all_failed { true }
protected

◆ m_multi_extruder_grid_panel

wxPanel* Slic3r::GUI::CaliPASaveAutoPanel::m_multi_extruder_grid_panel { nullptr }
protected

◆ m_obj

MachineObject* Slic3r::GUI::CaliPASaveAutoPanel::m_obj { nullptr }
protected

◆ m_part_failed_panel

wxPanel* Slic3r::GUI::CaliPASaveAutoPanel::m_part_failed_panel
protected

◆ m_top_sizer

wxBoxSizer* Slic3r::GUI::CaliPASaveAutoPanel::m_top_sizer
protected

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