OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
WipingDialog Class Reference

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

Inheritance diagram for WipingDialog:
Collaboration diagram for WipingDialog:

Public Types

using VolumeMatrix = std::vector<std::vector<double>>

Public Member Functions

 WipingDialog (wxWindow *parent, const int max_flush_volume=Slic3r::g_max_flush_volume)
std::vector< double > GetFlattenMatrix () const
std::vector< double > GetMultipliers () const
bool GetSubmitFlag () const

Static Public Member Functions

static VolumeMatrix CalcFlushingVolumes (int extruder_id)

Private Member Functions

wxString BuildTableObjStr ()
wxString BuildTextObjStr (bool multi_language=true)
void StoreFlushData (int extruder_num, const std::vector< std::vector< double > > &flush_volume_vecs, const std::vector< double > &flush_multipliers)
std::vector< double > ExpandToFullMatrix (const std::vector< double > &sub_matrix, int nozzle_idx) const

Static Private Member Functions

static int CalcFlushingVolume (const wxColour &from_, const wxColour &to_, int min_flush_volume, int nozzle_flush_dataset)

Private Attributes

wxWebView * m_webview
int m_max_flush_volume
VolumeMatrix m_raw_matrixs
std::vector< double > m_flush_multipliers
std::vector< size_t > m_physical_indices
bool m_submit_flag { false }

Detailed Description

Member Typedef Documentation

◆ VolumeMatrix

using WipingDialog::VolumeMatrix = std::vector<std::vector<double>>

Constructor & Destructor Documentation

◆ WipingDialog()

WipingDialog::WipingDialog ( wxWindow * parent,
const int max_flush_volume = Slic3r::g_max_flush_volume )
459 :
460 wxDialog(parent, wxID_ANY, _(L("Flushing volumes for filament change")),
461 wxDefaultPosition, wxDefaultSize,
462 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
463 m_max_flush_volume(max_flush_volume)
464{
465 wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
466 this->SetSizer(main_sizer);
467 this->SetBackgroundColour(*wxWHITE);
468 auto filament_count = wxGetApp().preset_bundle->physical_filament_config_indices().size();
469
470 // Estimate table scroll area size based on filament count
471 // Each table cell is ~60x25 DIP, plus headers and borders
472 wxSize max_scroll_size = { FromDIP(1000), FromDIP(500) };
473 wxSize table_size = { (int)(filament_count + 1) * FromDIP(60), (int)(filament_count + 1) * FromDIP(25) + FromDIP(2) };
474 wxSize scroll_size = { std::min(max_scroll_size.x, table_size.x), std::min(max_scroll_size.y, table_size.y) };
475
476 // Fixed overhead: padding (~30), tip panel (~70), controls row (~50),
477 // description/multiplier section (~130), button row (~45) = ~325 DIP
478 wxSize fixed_overhead = { FromDIP(100), FromDIP(325) };
479 wxSize applied_size = scroll_size + fixed_overhead;
480
481 // Clamp to screen size (leave some margin for window decorations)
482 wxSize scaled_screen_size = wxGetDisplaySize();
483 double scale_factor = wxDisplay().GetScaleFactor();
484 scaled_screen_size = { (int)(scaled_screen_size.x / scale_factor), (int)(scaled_screen_size.y / scale_factor) };
485 wxSize screen_margin = { FromDIP(40), FromDIP(60) };
486 scaled_screen_size -= screen_margin;
487
488 applied_size = { std::min(applied_size.x, scaled_screen_size.x), std::min(applied_size.y, scaled_screen_size.y) };
489
490 // Ensure a reasonable minimum size so the dialog is usable even when clamped
491 applied_size.x = std::max(applied_size.x, FromDIP(350));
492 applied_size.y = std::max(applied_size.y, FromDIP(450));
493 m_webview = wxWebView::New(this, wxID_ANY,
494 wxEmptyString,
495 wxDefaultPosition,
496 applied_size,
497 wxWebViewBackendDefault,
498 wxNO_BORDER);
499
500 m_webview->AddScriptMessageHandler("wipingDialog");
501 // The page's strings (resources/web/flush/WipingDialog.html), keyed by their T() ids.
502 const nlohmann::json page_strings = {
503 // TRN Corner header of the flushing volume table: rows are the filament flushed from, columns the filament changed to.
504 {"from_to", _u8L("from/to")},
505 };
506 m_webview->AddUserScript(wxString::FromUTF8(WebViewHostDialog::localized_strings_script(page_strings)));
507 main_sizer->Add(m_webview, 1, wxEXPAND);
508
509 fs::path filepath = fs::path(resources_dir()) / "web/flush/WipingDialog.html";
510 wxString filepath_str = from_path(filepath);
511 wxFileName fn(filepath_str);
512 if(fn.FileExists()) {
513 wxString url = file_url_from_path(filepath);
514 BOOST_LOG_TRIVIAL(debug) << __FUNCTION__<< "File exists and load url " << url.ToStdString();
515 m_webview->LoadURL(url);
516 BOOST_LOG_TRIVIAL(debug) << __FUNCTION__<< "Successfully loaded url: " << url.ToStdString();
517 } else {
518 BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< "WipingDialog.html not exist at path: " << filepath.string();
519 }
520
521 main_sizer->SetSizeHints(this);
522 main_sizer->Fit(this);
523 CenterOnParent();
524 wxGetApp().UpdateDlgDarkUI(this);
525
526 //m_webview->Bind(wxEVT_WEBVIEW_NAVIGATED, [this](auto& evt) {
527 // auto table_obj_str = BuildTableObjStr();
528 // auto text_obj_str = BuildTextObjStr();
529 // CallAfter([table_obj_str, text_obj_str, this] {
530 // wxString script = wxString::Format("buildTable(%s);buildText(%s)", table_obj_str, text_obj_str);
531 // m_webview->RunScript(script);
532 // });
533 // });
534
535 m_webview->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, [this](wxWebViewEvent& evt) {
536 std::string message = evt.GetString().ToStdString();
537 BOOST_LOG_TRIVIAL(debug) << __FUNCTION__<< "Received message: " << message;
538 try {
539 json j = json::parse(message);
540 if (j["msg"].get<std::string>() == "init") {
541 auto table_obj_str = BuildTableObjStr();
542 auto text_obj_str = BuildTextObjStr(true);
543 CallAfter([table_obj_str, text_obj_str, this] {
544 wxString script1 = wxString::Format("buildTable(%s)", table_obj_str);
545 m_webview->RunScript(script1);
546 wxString script2 = wxString::Format("buildText(%s)", text_obj_str);
547 bool result = m_webview->RunScript(script2);
548 if (!result) {
549 BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< "Failed to run buildText, retry without multi language";
550 wxString script3 = wxString::Format("buildText(%s)", BuildTextObjStr(false));
551 m_webview->RunScript(script3);
552 }
553 });
554 }
555 else if (j["msg"].get<std::string>() == "updateMatrix") {
556 int extruder_id = j["extruder_id"].get<int>();
557 auto new_matrix = CalcFlushingVolumes(extruder_id);
558 json obj;
559 obj["flush_volume_matrix"] = MatrixFlatten(new_matrix);
560 obj["extruder_id"] = extruder_id;
561 CallAfter([obj, this] {
562 std::string flush_volume_matrix_str = obj["flush_volume_matrix"].dump();
563 std::string extruder_id_str = std::to_string(obj["extruder_id"].get<int>());
564 wxString script = wxString::Format("updateTable(%s,%s)", flush_volume_matrix_str, extruder_id_str);
565 m_webview->RunScript(script);
566 });
567 }
568 else if (j["msg"].get<std::string>() == "storeData") {
569 int extruder_num = j["number_of_extruders"].get<int>();
570 std::vector<std::vector<double>> store_matrixs;
571 for (auto iter = j["raw_matrix"].begin(); iter != j["raw_matrix"].end(); ++iter) {
572 store_matrixs.emplace_back((*iter).get<std::vector<double>>());
573 }
574 std::vector<double>store_multipliers = j["flush_multiplier"].get<std::vector<double>>();
575 {// limit all matrix value before write to gcode, the limitation is depends on the multipliers
576 size_t cols_temp_matrix = 0;
577 if (!store_matrixs.empty()) { cols_temp_matrix = store_matrixs[0].size(); }
578 if (store_multipliers.size() == store_matrixs.size() && cols_temp_matrix>0) // nuzzles==nuzzles
579 {
580 for (size_t idx = 0; idx < store_multipliers.size(); ++idx) {
581 double m_max_flush_volume_t = (double)m_max_flush_volume, m_store_multipliers=store_multipliers[idx];
582 std::transform(store_matrixs[idx].begin(), store_matrixs[idx].end(),
583 store_matrixs[idx].begin(),
584 [m_max_flush_volume_t, m_store_multipliers](double inputx) {
585 return std::clamp(inputx, 0.0, m_max_flush_volume_t / m_store_multipliers);
586 });
587 }
588 }
589 }
590 this->StoreFlushData(extruder_num, store_matrixs, store_multipliers);
591 m_submit_flag = true;
592 this->Close();
593 }
594 else if (j["msg"].get<std::string>() == "quit") {
595 this->Close();
596 }
597 }
598 catch (...) {
599 BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< "Failed to parse json message: " << message;
600 }
601 });
602
603 m_webview->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
604 if (e.GetKeyCode() == WXK_ESCAPE) {
605 if (IsModal()) EndModal(wxID_CANCEL);
606 else Close();
607 return;
608 }
609 e.Skip();
610 });
611}
#define _(s)
Definition 3mf.cpp:306
#define L(s)
Definition ExtrusionEntity.cpp:25
static std::vector< float > MatrixFlatten(const WipingDialog::VolumeMatrix &matrix)
Definition WipeTowerDialog.cpp:292
static std::string localized_strings_script(const nlohmann::json &strings)
Definition WebViewHostDialog.cpp:156
wxString BuildTextObjStr(bool multi_language=true)
Definition WipeTowerDialog.cpp:403
wxString BuildTableObjStr()
Definition WipeTowerDialog.cpp:335
bool m_submit_flag
Definition WipeTowerDialog.hpp:79
static VolumeMatrix CalcFlushingVolumes(int extruder_id)
Definition WipeTowerDialog.cpp:620
wxWebView * m_webview
Definition WipeTowerDialog.hpp:72
int m_max_flush_volume
Definition WipeTowerDialog.hpp:73
void StoreFlushData(int extruder_num, const std::vector< std::vector< double > > &flush_volume_vecs, const std::vector< double > &flush_multipliers)
Definition WipeTowerDialog.cpp:684
T * begin(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:838
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
wxString from_path(const boost::filesystem::path &path)
Definition GUI.cpp:555
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
nlohmann::json json
Definition AssembleList.cpp:42
const std::string & resources_dir()
Definition utils.cpp:296
#define _u8L(s)
Definition I18N.hpp:11

References _, _u8L, BuildTableObjStr(), BuildTextObjStr(), CalcFlushingVolumes(), Slic3r::GUI::file_url_from_path(), Slic3r::GUI::from_path(), L, Slic3r::GUI::WebViewHostDialog::localized_strings_script(), m_max_flush_volume, m_submit_flag, m_webview, MatrixFlatten(), Slic3r::resources_dir(), and StoreFlushData().

Here is the call graph for this function:

Member Function Documentation

◆ BuildTableObjStr()

wxString WipingDialog::BuildTableObjStr ( )
private
336{
337 auto full_config = wxGetApp().preset_bundle->full_config();
338 auto filament_colors = full_config.option<ConfigOptionStrings>("filament_colour")->values;
339 auto flush_multiplier = full_config.option<ConfigOptionFloats>("flush_multiplier")->values;
340 int nozzle_num = full_config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
341 auto raw_matrix_data = full_config.option<ConfigOptionFloats>("flush_volumes_matrix")->values;
342 auto nozzle_flush_dataset = full_config.option<ConfigOptionIntsNullable>("nozzle_flush_dataset")->values;
343
344 // Restrict the table to physical filaments; mixed slots have no flushing volumes.
345 m_physical_indices = wxGetApp().preset_bundle->physical_filament_config_indices();
346 const size_t full_n = filament_colors.size();
347 {
348 std::vector<std::string> physical_colors;
349 physical_colors.reserve(m_physical_indices.size());
350 for (size_t i : m_physical_indices)
351 if (i < filament_colors.size())
352 physical_colors.push_back(filament_colors[i]);
353 filament_colors = std::move(physical_colors);
354 }
355
356 std::vector<std::vector<double>> flush_matrixs;
357 for (int idx = 0; idx < nozzle_num; ++idx) {
358 auto fm = get_flush_volumes_matrix(raw_matrix_data, idx, nozzle_num);
359 flush_matrixs.emplace_back(extract_physical_sub_matrix(fm, full_n, m_physical_indices));
360 }
361 flush_multiplier.resize(nozzle_num, 1);
362
363 std::vector<std::vector<float>> default_matrixs;
364 for (int idx = 0; idx < nozzle_num; ++idx) {
365 default_matrixs.emplace_back(MatrixFlatten(CalcFlushingVolumes(idx)));
366 }
367
368 m_raw_matrixs = flush_matrixs;
370
371 json obj;
372 obj["flush_multiplier"] = flush_multiplier;
373 obj["extruder_num"] = nozzle_num;
374 obj["filament_colors"] = filament_colors;
375 obj["flush_volume_matrixs"] = json::array();
376 obj["min_flush_volumes"] = json::array();
377 obj["max_flush_volumes"] = json::array();
378 obj["min_flush_multiplier"] = g_min_flush_multiplier;
379 obj["max_flush_multiplier"] = g_max_flush_multiplier;
380 obj["is_dark_mode"] = wxGetApp().dark_mode();
381 obj["default_matrixs"] = json::array();
382
383 for (const auto& vec : flush_matrixs) {
384 obj["flush_volume_matrixs"].push_back(vec);
385 }
386 for (const auto &vec : default_matrixs) {
387 obj["default_matrixs"].push_back(vec);
388 }
389
390 for (int idx = 0; idx < nozzle_num; ++idx) {
391 const std::vector<int> &min_flush_volumes = get_min_flush_volumes(full_config, idx);
392 int min_flush_from_nozzle_volume = *min_element(min_flush_volumes.begin(), min_flush_volumes.end());
393 GenericFlushPredictor pd(nozzle_flush_dataset[idx]);
394 int min_flush_from_flush_data = pd.get_min_flush_volume();
395 obj["min_flush_volumes"].push_back(std::min(min_flush_from_flush_data,min_flush_from_nozzle_volume));
396 obj["max_flush_volumes"].push_back(m_max_flush_volume);
397 }
398
399 auto obj_str = obj.dump();
400 return obj_str;
401}
static const float g_min_flush_multiplier
Definition WipeTowerDialog.cpp:236
static const float g_max_flush_multiplier
Definition WipeTowerDialog.cpp:237
static std::vector< double > extract_physical_sub_matrix(const std::vector< double > &full_matrix, size_t full_n, const std::vector< size_t > &indices)
Definition WipeTowerDialog.cpp:304
size_t size() const override
Definition Config.hpp:722
std::vector< size_t > m_physical_indices
Definition WipeTowerDialog.hpp:78
std::vector< double > m_flush_multipliers
Definition WipeTowerDialog.hpp:76
VolumeMatrix m_raw_matrixs
Definition WipeTowerDialog.hpp:75
std::vector< int > get_min_flush_volumes(const DynamicPrintConfig &full_config, size_t nozzle_id)
Definition Plater.cpp:1246
ConfigOptionIntsTempl< true > ConfigOptionIntsNullable
Definition Config.hpp:1155
static std::vector< T > get_flush_volumes_matrix(const std::vector< T > &fv_matrix, size_t extruder_id=-1, size_t nozzle_nums=1)
Definition PrintConfig.hpp:2685
zaa_minimize_perimeter_height flush_multiplier((ConfigOptionEnum< PrimeVolumeMode >, prime_volume_mode))((ConfigOptionFloats
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:1015

References CalcFlushingVolumes(), extract_physical_sub_matrix(), Slic3r::flush_multiplier(), g_max_flush_multiplier, g_min_flush_multiplier, Slic3r::get_flush_volumes_matrix(), GenericFlushPredictor::get_min_flush_volume(), Slic3r::GUI::get_min_flush_volumes(), m_flush_multipliers, m_max_flush_volume, m_physical_indices, m_raw_matrixs, and MatrixFlatten().

Referenced by WipingDialog().

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

◆ BuildTextObjStr()

wxString WipingDialog::BuildTextObjStr ( bool multi_language = true)
private
404{
405 wxString auto_flush_tip;
406 wxString volume_desp_panel;
407 wxString volume_range_panel;
408 wxString multiplier_range_panel;
409 wxString calc_btn_panel;
410 wxString extruder_label_0;
411 wxString extruder_label_1;
412 wxString multiplier_label;
413 wxString ok_btn_label;
414 wxString cancel_btn_label;
415
416 const std::string pt = wxGetApp().preset_bundle->printers.get_edited_preset().get_printer_type(wxGetApp().preset_bundle);
417 const std::string extruder_name_0 = DevPrinterConfigUtil::get_toolhead_display_name(pt, DEPUTY_EXTRUDER_ID, ToolHeadComponent::Extruder, ToolHeadNameCase::SentenceCase);
418 const std::string extruder_name_1 = DevPrinterConfigUtil::get_toolhead_display_name(pt, MAIN_EXTRUDER_ID, ToolHeadComponent::Extruder, ToolHeadNameCase::SentenceCase);
419
420 if (multi_language) {
421 auto_flush_tip = _L("Orca would re-calculate your flushing volumes everytime the filaments color changed or filaments changed. You could disable the auto-calculate in Orca Slicer > Preferences");
422 volume_desp_panel = _L("Flushing volume (mm³) for each filament pair.");
423 volume_range_panel = wxString::Format(_L("Suggestion: Flushing Volume in range [%d, %d]"), 0, 700);
424 multiplier_range_panel = wxString::Format(_L("The multiplier should be in range [%.2f, %.2f]."), 0., 3.);
425 calc_btn_panel = _L("Re-calculate");
426 extruder_label_0 = _L(extruder_name_0);
427 extruder_label_1 = _L(extruder_name_1);
428 multiplier_label = _L("Multiplier");
429 ok_btn_label = _L("OK");
430 cancel_btn_label = _L("Cancel");
431 } else {
432 auto_flush_tip = "Orca would re-calculate your flushing volumes everytime the filaments color changed or filaments changed. You could disable the auto-calculate in Orca Slicer > Preferences";
433 volume_desp_panel = wxString::FromUTF8("Flushing volume (mm³) for each filament pair.");
434 volume_range_panel = wxString::Format("Suggestion: Flushing Volume in range [%d, %d]", 0, 700);
435 multiplier_range_panel = wxString::Format("The multiplier should be in range [%.2f, %.2f].", 0., 3.);
436 calc_btn_panel = "Re-calculate";
437 extruder_label_0 = wxString::FromUTF8(extruder_name_0);
438 extruder_label_1 = wxString::FromUTF8(extruder_name_1);
439 multiplier_label = "Multiplier";
440 ok_btn_label = "OK";
441 cancel_btn_label = "Cancel";
442 }
443
444 wxString text_obj = "{";
445 text_obj += wxString::Format("\"volume_desp_panel\":\"%s\",", volume_desp_panel);
446 text_obj += wxString::Format("\"volume_range_panel\":\"%s\",", volume_range_panel);
447 text_obj += wxString::Format("\"multiplier_range_panel\":\"%s\",", multiplier_range_panel);
448 text_obj += wxString::Format("\"calc_btn_panel\":\"%s\",", calc_btn_panel);
449 text_obj += wxString::Format("\"extruder_label_0\":\"%s\",", extruder_label_0);
450 text_obj += wxString::Format("\"extruder_label_1\":\"%s\",", extruder_label_1);
451 text_obj += wxString::Format("\"multiplier_label\":\"%s\",", multiplier_label);
452 text_obj += wxString::Format("\"ok_btn_label\":\"%s\",", ok_btn_label);
453 text_obj += wxString::Format("\"cancel_btn_label\":\"%s\",", cancel_btn_label);
454 text_obj += wxString::Format("\"auto_flush_tip\":\"%s\"", auto_flush_tip);
455 text_obj += "}";
456 return text_obj;
457}
#define DEPUTY_EXTRUDER_ID
Definition DevDefs.h:102
#define MAIN_EXTRUDER_ID
Definition DevDefs.h:101
#define _L(s)
Definition OBJ.cpp:34
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

References _L, DEPUTY_EXTRUDER_ID, Slic3r::Extruder, Slic3r::DevPrinterConfigUtil::get_toolhead_display_name(), MAIN_EXTRUDER_ID, and Slic3r::SentenceCase.

Referenced by WipingDialog().

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

◆ CalcFlushingVolume()

int WipingDialog::CalcFlushingVolume ( const wxColour & from_,
const wxColour & to_,
int min_flush_volume,
int nozzle_flush_dataset )
staticprivate
615{
616 Slic3r::FlushVolCalculator calculator(min_flush_volume, Slic3r::g_max_flush_volume, nozzle_flush_dataset);
617 return calculator.calc_flush_vol(from.Alpha(), from.Red(), from.Green(), from.Blue(), to.Alpha(), to.Red(), to.Green(), to.Blue());
618}
const int g_max_flush_volume
Definition FlushVolCalc.cpp:15

References Slic3r::FlushVolCalculator::calc_flush_vol(), and Slic3r::g_max_flush_volume.

Referenced by CalcFlushingVolumes().

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

◆ CalcFlushingVolumes()

WipingDialog::VolumeMatrix WipingDialog::CalcFlushingVolumes ( int extruder_id)
static
621{
622 auto& preset_bundle = wxGetApp().preset_bundle;
623 auto full_config = preset_bundle->full_config();
624 auto& ams_multi_color_filament = preset_bundle->ams_multi_color_filment;
625 // Mixed-colour slots are virtual and never flushed: compute a p x p matrix over the physical
626 // slots only, laid out like the table; row/column k belongs to config slot physical_indices[k].
627 auto physical_indices = preset_bundle->physical_filament_config_indices();
628
629 std::vector<std::string> all_color_strs = full_config.option<ConfigOptionStrings>("filament_colour")->values;
630 int flush_dataset_value = full_config.option<ConfigOptionIntsNullable>("nozzle_flush_dataset")->values[extruder_id];
631 const std::vector<int> min_flush_volumes = get_min_flush_volumes(full_config, extruder_id);
632
633 // Support for multi-color filament
634 std::vector<std::vector<wxColour>> multi_colors;
635 for (size_t cfg_idx : physical_indices) {
636 std::vector<wxColour> single_filament;
637 if (cfg_idx < ams_multi_color_filament.size() && !ams_multi_color_filament[cfg_idx].empty()) {
638 for (const auto& c : ams_multi_color_filament[cfg_idx])
639 single_filament.push_back(wxColour(c));
640 } else if (cfg_idx < all_color_strs.size()) {
641 single_filament.push_back(wxColour(all_color_strs[cfg_idx]));
642 }
643 multi_colors.push_back(single_filament);
644 }
645
646 VolumeMatrix matrix;
647 for (size_t pi = 0; pi < physical_indices.size(); ++pi) {
648 int from_cfg = (int)physical_indices[pi];
649 bool is_from_support = is_support_filament(from_cfg);
650 matrix.emplace_back();
651 for (size_t pj = 0; pj < physical_indices.size(); ++pj) {
652 int to_cfg = (int)physical_indices[pj];
653 if (from_cfg == to_cfg) {
654 matrix.back().emplace_back(0);
655 continue;
656 }
657
658 bool is_to_support = is_support_filament(to_cfg);
659 int flushing_volume = 0;
660 if (is_to_support) {
661 flushing_volume = Slic3r::g_flush_volume_to_support;
662 }
663 else {
664 int min_flush_from = (from_cfg < (int)min_flush_volumes.size()) ? min_flush_volumes[from_cfg] : 0;
665 for (size_t i = 0; i < multi_colors[pi].size(); ++i) {
666 const wxColour& from = multi_colors[pi][i];
667 for (size_t j = 0; j < multi_colors[pj].size(); ++j) {
668 const wxColour& to = multi_colors[pj][j];
669 int volume = CalcFlushingVolume(from, to, min_flush_from, flush_dataset_value);
670 flushing_volume = std::max(flushing_volume, volume);
671 }
672 }
673
674 if (is_from_support) {
675 flushing_volume = std::max(Slic3r::g_min_flush_volume_from_support, flushing_volume);
676 }
677 }
678 matrix.back().emplace_back(flushing_volume);
679 }
680 }
681 return matrix;
682}
static int CalcFlushingVolume(const wxColour &from_, const wxColour &to_, int min_flush_volume, int nozzle_flush_dataset)
Definition WipeTowerDialog.cpp:614
std::vector< std::vector< double > > VolumeMatrix
Definition WipeTowerDialog.hpp:56
bool is_support_filament(int extruder_id, bool strict_check)
Definition GUI_App.cpp:10492
const int g_min_flush_volume_from_support
Definition FlushVolCalc.cpp:12
const int g_flush_volume_to_support
Definition FlushVolCalc.cpp:13

References CalcFlushingVolume(), Slic3r::g_flush_volume_to_support, Slic3r::g_min_flush_volume_from_support, Slic3r::GUI::get_min_flush_volumes(), and Slic3r::GUI::is_support_filament().

Referenced by WipingDialog(), BuildTableObjStr(), and is_flush_config_modified().

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

◆ ExpandToFullMatrix()

std::vector< double > WipingDialog::ExpandToFullMatrix ( const std::vector< double > & sub_matrix,
int nozzle_idx ) const
private
694{
695 const auto& project_config = wxGetApp().preset_bundle->project_config;
696 const size_t full_n = project_config.option<ConfigOptionStrings>("filament_colour")->values.size();
697 if (m_physical_indices.size() == full_n)
698 return sub_matrix; // no mixed slots: sub-matrix already is the full matrix
699
700 auto raw = project_config.option<ConfigOptionFloats>("flush_volumes_matrix")->values;
701 int nozzle_num = (int)wxGetApp().preset_bundle->project_config.option<ConfigOptionFloats>("flush_multiplier")->values.size();
702 if (nozzle_num < 1) nozzle_num = 1;
703 auto original = get_flush_volumes_matrix(raw, nozzle_idx, nozzle_num);
704 return expand_physical_to_full_matrix(sub_matrix, m_physical_indices, full_n, original);
705}
static std::vector< double > expand_physical_to_full_matrix(const std::vector< double > &sub_matrix, const std::vector< size_t > &indices, size_t full_n, const std::vector< double > &original_matrix)
Definition WipeTowerDialog.cpp:320

References expand_physical_to_full_matrix(), Slic3r::get_flush_volumes_matrix(), m_physical_indices, and Slic3r::ConfigOptionVector< T >::size().

Referenced by GetFlattenMatrix().

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

◆ GetFlattenMatrix()

std::vector< double > WipingDialog::GetFlattenMatrix ( ) const
708{
709 std::vector<double> ret;
710 for (size_t idx = 0; idx < m_raw_matrixs.size(); ++idx) {
711 auto full = ExpandToFullMatrix(m_raw_matrixs[idx], (int)idx);
712 ret.insert(ret.end(), full.begin(), full.end());
713 }
714 return ret;
715}
std::vector< double > ExpandToFullMatrix(const std::vector< double > &sub_matrix, int nozzle_idx) const
Definition WipeTowerDialog.cpp:693

References ExpandToFullMatrix(), and m_raw_matrixs.

Referenced by open_flushing_dialog().

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

◆ GetMultipliers()

std::vector< double > WipingDialog::GetMultipliers ( ) const
719{
720 return m_flush_multipliers;
721}

References m_flush_multipliers.

Referenced by open_flushing_dialog().

Here is the caller graph for this function:

◆ GetSubmitFlag()

bool WipingDialog::GetSubmitFlag ( ) const
inline
62{ return m_submit_flag; }

References m_submit_flag.

Referenced by open_flushing_dialog().

Here is the caller graph for this function:

◆ StoreFlushData()

void WipingDialog::StoreFlushData ( int extruder_num,
const std::vector< std::vector< double > > & flush_volume_vecs,
const std::vector< double > & flush_multipliers )
private
685{
686 m_flush_multipliers = flush_multipliers;
687 m_raw_matrixs = flush_volume_vecs;
688}

References m_flush_multipliers, and m_raw_matrixs.

Referenced by WipingDialog().

Here is the caller graph for this function:

Member Data Documentation

◆ m_flush_multipliers

std::vector<double> WipingDialog::m_flush_multipliers
private

◆ m_max_flush_volume

int WipingDialog::m_max_flush_volume
private

Referenced by WipingDialog(), and BuildTableObjStr().

◆ m_physical_indices

std::vector<size_t> WipingDialog::m_physical_indices
private

◆ m_raw_matrixs

VolumeMatrix WipingDialog::m_raw_matrixs
private

◆ m_submit_flag

bool WipingDialog::m_submit_flag { false }
private
79{ false };

Referenced by WipingDialog(), and GetSubmitFlag().

◆ m_webview

wxWebView* WipingDialog::m_webview
private

Referenced by WipingDialog().


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