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

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

Inheritance diagram for Slic3r::GUI::SeparatedDragDropPanel:
Collaboration diagram for Slic3r::GUI::SeparatedDragDropPanel:

Public Member Functions

 SeparatedDragDropPanel (wxWindow *parent, const wxString &label, bool use_separation=false)
void AddColorBlock (const wxColour &color, const std::string &type, int filament_id, bool is_high_flow=false, bool update_ui=true)
void RemoveColorBlock (ColorPanel *panel, bool update_ui=true)
std::vector< int > GetAllFilaments () const
std::vector< int > GetHighFlowFilaments () const
std::vector< int > GetStandardFilaments () const
std::vector< int > GetTPUHighFlowFilaments () const
std::vector< ColorPanel * > get_filament_blocks () const
std::vector< ColorPanel * > get_high_flow_blocks () const
std::vector< ColorPanel * > get_standard_blocks () const
void SetUseSeparation (bool use_separation)
bool IsUseSeparation () const
void ClearAllBlocks ()
void UpdateLabel (const wxString &label)

Private Member Functions

void UpdateLayout ()

Private Attributes

wxBoxSizer * m_main_sizer
wxPanel * m_content_panel
wxBoxSizer * m_content_sizer
wxPanel * m_separator = nullptr
Label * m_label
DragDropPanel * m_high_flow_panel
DragDropPanel * m_standard_panel
DragDropPanel * m_unified_panel
bool m_use_separation

Detailed Description

Constructor & Destructor Documentation

◆ SeparatedDragDropPanel()

Slic3r::GUI::SeparatedDragDropPanel::SeparatedDragDropPanel ( wxWindow * parent,
const wxString & label,
bool use_separation = false )
391 : wxPanel(parent), m_use_separation(use_separation)
392{
393 SetBackgroundColour(0xF8F8F8);
394
395 m_main_sizer = new wxBoxSizer(wxVERTICAL);
396
397 auto title_panel = new wxPanel(this);
398 title_panel->SetBackgroundColour(0xEEEEEE);
399 auto title_sizer = new wxBoxSizer(wxHORIZONTAL);
400 title_panel->SetSizer(title_sizer);
401
402 m_label = new Label(title_panel, label);
403 m_label->SetFont(Label::Head_13);
404 m_label->SetBackgroundColour(0xEEEEEE);
405
406 title_sizer->Add(m_label, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
407
408 m_main_sizer->Add(title_panel, 0, wxEXPAND);
409 m_main_sizer->AddSpacer(10);
410
411 m_content_panel = new wxPanel(this);
412 m_content_panel->SetBackgroundColour(0xF8F8F8);
413 m_content_sizer = new wxBoxSizer(wxHORIZONTAL);
415
416 m_high_flow_panel = new DragDropPanel(m_content_panel, _L("High Flow"), false, true, true);
417 m_standard_panel = new DragDropPanel(m_content_panel, _L("Standard"), false, true, true);
418 m_unified_panel = new DragDropPanel(m_content_panel, wxEmptyString, false, false);
419
420 m_high_flow_panel->SetBackgroundColour(0xF8F8F8);
421 m_standard_panel->SetBackgroundColour(0xF8F8F8);
422 m_unified_panel->SetBackgroundColour(0xF8F8F8);
423 m_unified_panel->SetMinSize({FromDIP(260), -1});
424
425 m_main_sizer->Add(m_content_panel, 1, wxEXPAND);
426
427 UpdateLayout();
428
429 auto drop_target = new SeparatedColorDropTarget(this);
430 SetDropTarget(drop_target);
431
432 SetSizer(m_main_sizer);
433 Layout();
434 wxGetApp().UpdateDarkUIWin(this);
435}
#define _L(s)
Definition OBJ.cpp:34
static wxFont Head_13
Definition Label.hpp:46
DragDropPanel * m_high_flow_panel
Definition DragDropPanel.hpp:114
wxBoxSizer * m_main_sizer
Definition DragDropPanel.hpp:108
bool m_use_separation
Definition DragDropPanel.hpp:119
void UpdateLayout()
Definition DragDropPanel.cpp:437
Label * m_label
Definition DragDropPanel.hpp:112
DragDropPanel * m_unified_panel
Definition DragDropPanel.hpp:117
DragDropPanel * m_standard_panel
Definition DragDropPanel.hpp:115
wxPanel * m_content_panel
Definition DragDropPanel.hpp:109
wxBoxSizer * m_content_sizer
Definition DragDropPanel.hpp:110

References _L, Label::Head_13, m_content_panel, m_content_sizer, m_high_flow_panel, m_label, m_main_sizer, m_standard_panel, m_unified_panel, m_use_separation, and UpdateLayout().

Here is the call graph for this function:

Member Function Documentation

◆ AddColorBlock()

void Slic3r::GUI::SeparatedDragDropPanel::AddColorBlock ( const wxColour & color,
const std::string & type,
int filament_id,
bool is_high_flow = false,
bool update_ui = true )
526{
527 if (m_use_separation) {
528 if (is_high_flow) {
529 m_high_flow_panel->AddColorBlock(color, type, filament_id, update_ui);
530 } else {
531 m_standard_panel->AddColorBlock(color, type, filament_id, update_ui);
532 }
533
534 if (update_ui) {
535 CallAfter([this]() {
536 Layout();
537 GetParent()->Layout();
538 });
539 }
540 } else {
541 m_unified_panel->AddColorBlock(color, type, filament_id, update_ui);
542 }
543}
static void update_ui(wxWindow *window)
Definition WipeTowerDialog.cpp:60

References m_high_flow_panel, m_standard_panel, m_unified_panel, m_use_separation, and update_ui().

Here is the call graph for this function:

◆ ClearAllBlocks()

void Slic3r::GUI::SeparatedDragDropPanel::ClearAllBlocks ( )
657{
658 auto high_flow_blocks = m_high_flow_panel->get_filament_blocks();
659 for (auto &block : high_flow_blocks) {
660 m_high_flow_panel->RemoveColorBlock(block, false);
661 }
662
663 auto standard_blocks = m_standard_panel->get_filament_blocks();
664 for (auto &block : standard_blocks) {
665 m_standard_panel->RemoveColorBlock(block, false);
666 }
667
668 auto unified_blocks = m_unified_panel->get_filament_blocks();
669 for (auto &block : unified_blocks) {
670 m_unified_panel->RemoveColorBlock(block, false);
671 }
672}

References m_high_flow_panel, m_standard_panel, and m_unified_panel.

◆ get_filament_blocks()

std::vector< ColorPanel * > Slic3r::GUI::SeparatedDragDropPanel::get_filament_blocks ( ) const
632{
633 if (m_use_separation) {
634 auto high_flow = m_high_flow_panel->get_filament_blocks();
635 auto standard = m_standard_panel->get_filament_blocks();
636
637 std::vector<ColorPanel *> result;
638 result.insert(result.end(), high_flow.begin(), high_flow.end());
639 result.insert(result.end(), standard.begin(), standard.end());
640 return result;
641 } else {
642 return m_unified_panel->get_filament_blocks();
643 }
644}

References m_high_flow_panel, m_standard_panel, m_unified_panel, and m_use_separation.

◆ get_high_flow_blocks()

std::vector< ColorPanel * > Slic3r::GUI::SeparatedDragDropPanel::get_high_flow_blocks ( ) const
647{
648 return m_high_flow_panel->get_filament_blocks();
649}

References m_high_flow_panel.

◆ get_standard_blocks()

std::vector< ColorPanel * > Slic3r::GUI::SeparatedDragDropPanel::get_standard_blocks ( ) const
652{
653 return m_standard_panel->get_filament_blocks();
654}

References m_standard_panel.

◆ GetAllFilaments()

std::vector< int > Slic3r::GUI::SeparatedDragDropPanel::GetAllFilaments ( ) const
568{
569 if (m_use_separation) {
570 auto high_flow = m_high_flow_panel->GetAllFilaments();
571 auto standard = m_standard_panel->GetAllFilaments();
572
573 std::vector<int> result;
574 result.insert(result.end(), high_flow.begin(), high_flow.end());
575 result.insert(result.end(), standard.begin(), standard.end());
576 return result;
577 } else {
578 return m_unified_panel->GetAllFilaments();
579 }
580}

References m_high_flow_panel, m_standard_panel, m_unified_panel, and m_use_separation.

◆ GetHighFlowFilaments()

std::vector< int > Slic3r::GUI::SeparatedDragDropPanel::GetHighFlowFilaments ( ) const
583{
584 if (m_use_separation) {
585 return m_high_flow_panel->GetAllFilaments();
586 }
587 auto nozzle_volumes = wxGetApp().preset_bundle->project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
588 const int right_eid = 1;
589 if (nozzle_volumes->values.size() > right_eid) {
590 int volume_type = nozzle_volumes->values[right_eid];
591 if (volume_type == static_cast<int>(NozzleVolumeType::nvtHighFlow) ||
592 volume_type == static_cast<int>(NozzleVolumeType::nvtE3DHighFlow)) {
593 return m_unified_panel->GetAllFilaments();
594 }
595 }
596 return {};
597}
@ nvtE3DHighFlow
Definition PrintConfig.hpp:626
@ nvtHighFlow
Definition PrintConfig.hpp:620
ConfigOptionEnumsGenericTempl< false > ConfigOptionEnumsGeneric
Definition Config.hpp:2311

References m_high_flow_panel, m_unified_panel, m_use_separation, Slic3r::nvtE3DHighFlow, and Slic3r::nvtHighFlow.

◆ GetStandardFilaments()

std::vector< int > Slic3r::GUI::SeparatedDragDropPanel::GetStandardFilaments ( ) const
600{
601 if (m_use_separation) {
602 return m_standard_panel->GetAllFilaments();
603 }
604 auto nozzle_volumes = wxGetApp().preset_bundle->project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
605 const int right_eid = 1;
606 if (nozzle_volumes->values.size() > right_eid) {
607 int volume_type = nozzle_volumes->values[right_eid];
608 if (volume_type == static_cast<int>(NozzleVolumeType::nvtStandard)) {
609 return m_unified_panel->GetAllFilaments();
610 }
611 }
612 return {};
613}
@ nvtStandard
Definition PrintConfig.hpp:619

References m_standard_panel, m_unified_panel, m_use_separation, and Slic3r::nvtStandard.

◆ GetTPUHighFlowFilaments()

std::vector< int > Slic3r::GUI::SeparatedDragDropPanel::GetTPUHighFlowFilaments ( ) const
616{
617 if (m_use_separation) {
618 return {};
619 }
620 auto nozzle_volumes = wxGetApp().preset_bundle->project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
621 const int right_eid = 1;
622 if (nozzle_volumes->values.size() > right_eid) {
623 int volume_type = nozzle_volumes->values[right_eid];
624 if (volume_type == static_cast<int>(NozzleVolumeType::nvtTPUHighFlow)) {
625 return m_unified_panel->GetAllFilaments();
626 }
627 }
628 return {};
629}
@ nvtTPUHighFlow
Definition PrintConfig.hpp:624

References m_unified_panel, m_use_separation, and Slic3r::nvtTPUHighFlow.

◆ IsUseSeparation()

bool Slic3r::GUI::SeparatedDragDropPanel::IsUseSeparation ( ) const
inline
101{ return m_use_separation; }

References m_use_separation.

◆ RemoveColorBlock()

void Slic3r::GUI::SeparatedDragDropPanel::RemoveColorBlock ( ColorPanel * panel,
bool update_ui = true )
546{
547 auto high_flow_blocks = m_high_flow_panel->get_filament_blocks();
548 auto standard_blocks = m_standard_panel->get_filament_blocks();
549 auto unified_blocks = m_unified_panel->get_filament_blocks();
550
551 if (std::find(high_flow_blocks.begin(), high_flow_blocks.end(), panel) != high_flow_blocks.end()) {
552 m_high_flow_panel->RemoveColorBlock(panel, update_ui);
553 } else if (std::find(standard_blocks.begin(), standard_blocks.end(), panel) != standard_blocks.end()) {
554 m_standard_panel->RemoveColorBlock(panel, update_ui);
555 } else if (std::find(unified_blocks.begin(), unified_blocks.end(), panel) != unified_blocks.end()) {
556 m_unified_panel->RemoveColorBlock(panel, update_ui);
557 }
558
560 CallAfter([this]() {
561 Layout();
562 GetParent()->Layout();
563 });
564 }
565}

References m_high_flow_panel, m_standard_panel, m_unified_panel, m_use_separation, and update_ui().

Here is the call graph for this function:

◆ SetUseSeparation()

void Slic3r::GUI::SeparatedDragDropPanel::SetUseSeparation ( bool use_separation)
496{
497 if (m_use_separation != use_separation) {
498 m_use_separation = use_separation;
499
500 if (use_separation) {
501 auto blocks = m_unified_panel->get_filament_blocks();
502 for (auto &block : blocks) {
503 m_standard_panel->AddColorBlock(block->GetColor(), block->GetType(), block->GetFilamentId(), false);
504 m_unified_panel->RemoveColorBlock(block, false);
505 }
506 } else {
507 auto high_flow_blocks = m_high_flow_panel->get_filament_blocks();
508 auto standard_blocks = m_standard_panel->get_filament_blocks();
509
510 for (auto &block : high_flow_blocks) {
511 m_unified_panel->AddColorBlock(block->GetColor(), block->GetType(), block->GetFilamentId(), false);
512 m_high_flow_panel->RemoveColorBlock(block, false);
513 }
514
515 for (auto &block : standard_blocks) {
516 m_unified_panel->AddColorBlock(block->GetColor(), block->GetType(), block->GetFilamentId(), false);
517 m_standard_panel->RemoveColorBlock(block, false);
518 }
519 }
520
521 UpdateLayout();
522 }
523}

References m_high_flow_panel, m_standard_panel, m_unified_panel, m_use_separation, and UpdateLayout().

Here is the call graph for this function:

◆ UpdateLabel()

void Slic3r::GUI::SeparatedDragDropPanel::UpdateLabel ( const wxString & label)
487{
488 if (m_label) {
489 m_label->SetLabel(label);
490 m_label->Refresh();
491 Layout();
492 }
493}

References m_label.

◆ UpdateLayout()

void Slic3r::GUI::SeparatedDragDropPanel::UpdateLayout ( )
private
438{
439 m_content_sizer->Clear(false);
440
441 if (m_use_separation) {
442 m_unified_panel->Hide();
443 m_high_flow_panel->Show();
444 m_standard_panel->Show();
445
446 wxSize content_size = m_content_panel->GetSize();
447 int panel_width = (content_size.GetWidth() - FromDIP(1) - FromDIP(8)) / 2;
448 if (panel_width > 0) {
449 m_high_flow_panel->SetMinSize(wxSize(panel_width, -1));
450 m_standard_panel->SetMinSize(wxSize(panel_width, -1));
451 }
452
453 m_content_sizer->Add(m_high_flow_panel, 1, wxEXPAND | wxLEFT, FromDIP(8));
454
455 // Create the separator once and re-attach it on relayout; Clear(false) above only
456 // detaches, so allocating here would leak a window per relayout.
457 if (!m_separator) {
458 m_separator = new wxPanel(m_content_panel, wxID_ANY);
459 m_separator->SetBackgroundColour(StateColor::darkModeColorFor(wxColour(0xCE, 0xCE, 0xCE)));
460 m_separator->SetMinSize(wxSize(FromDIP(1), -1));
461 }
462 m_separator->Show();
463 m_content_sizer->Add(m_separator, 0, wxEXPAND | wxALL, FromDIP(4));
464
465 m_content_sizer->Add(m_standard_panel, 1, wxEXPAND | wxRIGHT, FromDIP(8));
466 } else {
467 m_high_flow_panel->Hide();
468 m_standard_panel->Hide();
469 if (m_separator)
470 m_separator->Hide();
471 m_unified_panel->Show();
472
473 m_content_sizer->Add(m_unified_panel, 1, wxEXPAND);
474 }
475 m_content_sizer->Layout();
476 Layout();
477 Fit();
478 if (GetParent()) {
479 GetParent()->Layout();
480 if (GetParent()->GetParent()) {
481 GetParent()->GetParent()->Layout();
482 }
483 }
484}
wxPanel * m_separator
Definition DragDropPanel.hpp:111
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References StateColor::darkModeColorFor(), m_content_panel, m_content_sizer, m_high_flow_panel, m_separator, m_standard_panel, m_unified_panel, and m_use_separation.

Referenced by SeparatedDragDropPanel(), and SetUseSeparation().

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

Member Data Documentation

◆ m_content_panel

wxPanel* Slic3r::GUI::SeparatedDragDropPanel::m_content_panel
private

◆ m_content_sizer

wxBoxSizer* Slic3r::GUI::SeparatedDragDropPanel::m_content_sizer
private

◆ m_high_flow_panel

◆ m_label

Label* Slic3r::GUI::SeparatedDragDropPanel::m_label
private

◆ m_main_sizer

wxBoxSizer* Slic3r::GUI::SeparatedDragDropPanel::m_main_sizer
private

Referenced by SeparatedDragDropPanel().

◆ m_separator

wxPanel* Slic3r::GUI::SeparatedDragDropPanel::m_separator = nullptr
private

Referenced by UpdateLayout().

◆ m_standard_panel

◆ m_unified_panel

◆ m_use_separation


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