OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::PageMaterials Struct Reference

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

Inheritance diagram for Slic3r::GUI::PageMaterials:
Collaboration diagram for Slic3r::GUI::PageMaterials:

Public Member Functions

 PageMaterials (ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name)
void reload_presets ()
void update_lists (int sel_type, int sel_vendor, int last_selected_printer=-1)
void on_material_highlighted (int sel_material)
void on_material_hovered (int sel_material)
void select_material (int i)
void select_all (bool select)
void clear ()
void set_compatible_printers_html_window (const std::vector< std::string > &printer_names, bool all_printers=false)
void clear_compatible_printers_label ()
void sort_list_data (StringList *list, bool add_All_item, bool material_type_ordering)
void sort_list_data (PresetList *list, const std::vector< ProfilePrintData > &data)
void on_paint ()
void on_mouse_move_on_profiles (wxMouseEvent &evt)
void on_mouse_enter_profiles (wxMouseEvent &evt)
void on_mouse_leave_profiles (wxMouseEvent &evt)
virtual void on_activate () override
template<class T>
T * append (T *thing, int proportion=0, int flag=wxEXPAND|wxTOP|wxBOTTOM, int border=10)
wxStaticText * append_text (wxString text)
void append_spacer (int space)
ConfigWizard::priv * wizard_p () const
virtual void apply_custom_config (DynamicPrintConfig &config)
virtual void set_run_reason (ConfigWizard::RunReason run_reason)

Public Attributes

Materials * materials
StringList * list_printer
StringList * list_type
StringList * list_vendor
PresetList * list_profile
wxArrayInt sel_printers_prev
int sel_type_prev
int sel_vendor_prev
bool presets_loaded
wxFlexGridSizer * grid
wxHtmlWindow * html_window
int compatible_printers_width = { 100 }
std::string empty_printers_label
bool first_paint = { false }
int last_hovered_item = { -1 }
ConfigWizard * parent
const wxString shortname
wxBoxSizer * content
const unsigned indent

Static Public Attributes

static const std::string EMPTY

Detailed Description

Constructor & Destructor Documentation

◆ PageMaterials()

Slic3r::GUI::PageMaterials::PageMaterials ( ConfigWizard * parent,
Materials * materials,
wxString title,
wxString shortname,
wxString list1name )
666 : ConfigWizardPage(parent, std::move(title), std::move(shortname))
668 , list_printer(new StringList(this, wxLB_MULTIPLE))
669 , list_type(new StringList(this))
670 , list_vendor(new StringList(this))
671 , list_profile(new PresetList(this))
672{
673 SetBackgroundColour(*wxWHITE);
675
676 const int em = parent->em_unit();
677 const int list_h = 30*em;
678
679
680 list_printer->SetMinSize(wxSize(23*em, list_h));
681 list_type->SetMinSize(wxSize(13*em, list_h));
682 list_vendor->SetMinSize(wxSize(13*em, list_h));
683 list_profile->SetMinSize(wxSize(23*em, list_h));
684
685 grid = new wxFlexGridSizer(4, em/2, em);
686 grid->AddGrowableCol(3, 1);
687 grid->AddGrowableRow(1, 1);
688
689 grid->Add(new wxStaticText(this, wxID_ANY, _L("Printer:")));
690 grid->Add(new wxStaticText(this, wxID_ANY, list1name));
691 grid->Add(new wxStaticText(this, wxID_ANY, _L("Vendor:")));
692 grid->Add(new wxStaticText(this, wxID_ANY, _L("Profile:")));
693
694 grid->Add(list_printer, 0, wxEXPAND);
695 grid->Add(list_type, 0, wxEXPAND);
696 grid->Add(list_vendor, 0, wxEXPAND);
697 grid->Add(list_profile, 1, wxEXPAND);
698
699 auto *btn_sizer = new wxBoxSizer(wxHORIZONTAL);
700 auto *sel_all = new Button(this, _L("All"));
701 auto *sel_none = new Button(this, _L("None"));
702
703 wxGetApp().UpdateDarkUI(sel_all);
704 wxGetApp().UpdateDarkUI(sel_none);
705
706
707 btn_sizer->Add(sel_all, 0, wxRIGHT, em / 2);
708 btn_sizer->Add(sel_none);
709
710 wxGetApp().UpdateDarkUI(list_printer);
711 wxGetApp().UpdateDarkUI(list_type);
712 wxGetApp().UpdateDarkUI(list_vendor);
713 wxGetApp().UpdateDarkUI(sel_all);
714 wxGetApp().UpdateDarkUI(sel_none);
715 wxGetApp().UpdateDarkUI(list_profile);
716
717 grid->Add(new wxBoxSizer(wxHORIZONTAL));
718 grid->Add(new wxBoxSizer(wxHORIZONTAL));
719 grid->Add(new wxBoxSizer(wxHORIZONTAL));
720 grid->Add(btn_sizer, 0, wxALIGN_RIGHT);
721
722 append(grid, 1, wxEXPAND);
723
725
726 html_window = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition,
727 wxSize(60 * em, 20 * em), wxHW_SCROLLBAR_AUTO);
728 append(html_window, 0, wxEXPAND);
729
730 list_printer->Bind(wxEVT_LISTBOX, [this](wxCommandEvent& evt) {
731 update_lists(list_type->GetSelection(), list_vendor->GetSelection(), evt.GetInt());
732 });
733 list_type->Bind(wxEVT_LISTBOX, [this](wxCommandEvent &) {
734 update_lists(list_type->GetSelection(), list_vendor->GetSelection());
735 });
736 list_vendor->Bind(wxEVT_LISTBOX, [this](wxCommandEvent &) {
737 update_lists(list_type->GetSelection(), list_vendor->GetSelection());
738 });
739
740 list_profile->Bind(wxEVT_CHECKLISTBOX, [this](wxCommandEvent &evt) { select_material(evt.GetInt()); });
741 list_profile->Bind(wxEVT_LISTBOX, [this](wxCommandEvent& evt) { on_material_highlighted(evt.GetInt()); });
742
743 sel_all->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { select_all(true); });
744 sel_none->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { select_all(false); });
745 /*
746 Bind(wxEVT_PAINT, [this](wxPaintEvent& evt) {on_paint();});
747
748 list_profile->Bind(wxEVT_MOTION, [this](wxMouseEvent& evt) { on_mouse_move_on_profiles(evt); });
749 list_profile->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent& evt) { on_mouse_enter_profiles(evt); });
750 list_profile->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& evt) { on_mouse_leave_profiles(evt); });
751 */
753 set_compatible_printers_html_window(std::vector<std::string>(), false);
754}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
DataList< wxCheckListBox, std::string > PresetList
Definition ConfigWizard_private.hpp:337
@ VERTICAL_SPACING
Definition ConfigWizard_private.hpp:57
DataList< wxListBox, std::string > StringList
Definition ConfigWizard_private.hpp:336
T * append(T *thing, int proportion=0, int flag=wxEXPAND|wxTOP|wxBOTTOM, int border=10)
Definition ConfigWizard_private.hpp:227
ConfigWizard * parent
Definition ConfigWizard_private.hpp:218
void append_spacer(int space)
Definition ConfigWizard.cpp:521
ConfigWizardPage(ConfigWizard *parent, wxString title, wxString shortname, unsigned indent=0)
Definition ConfigWizard.cpp:477
const wxString shortname
Definition ConfigWizard_private.hpp:219
void select_material(int i)
Definition ConfigWizard.cpp:1169
Materials * materials
Definition ConfigWizard_private.hpp:349
StringList * list_type
Definition ConfigWizard_private.hpp:350
void on_material_highlighted(int sel_material)
Definition ConfigWizard.cpp:886
void set_compatible_printers_html_window(const std::vector< std::string > &printer_names, bool all_printers=false)
Definition ConfigWizard.cpp:792
void reload_presets()
Definition ConfigWizard.cpp:771
StringList * list_printer
Definition ConfigWizard_private.hpp:350
StringList * list_vendor
Definition ConfigWizard_private.hpp:350
void update_lists(int sel_type, int sel_vendor, int last_selected_printer=-1)
Definition ConfigWizard.cpp:921
wxFlexGridSizer * grid
Definition ConfigWizard_private.hpp:356
PresetList * list_profile
Definition ConfigWizard_private.hpp:351
wxHtmlWindow * html_window
Definition ConfigWizard_private.hpp:357
void select_all(bool select)
Definition ConfigWizard.cpp:1177

References Slic3r::GUI::ConfigWizardPage::ConfigWizardPage(), _L, Slic3r::GUI::ConfigWizardPage::append(), Slic3r::GUI::ConfigWizardPage::append_spacer(), grid, html_window, list_printer, list_profile, list_type, list_vendor, materials, on_material_highlighted(), Slic3r::GUI::ConfigWizardPage::parent, reload_presets(), select_all(), select_material(), set_compatible_printers_html_window(), Slic3r::GUI::ConfigWizardPage::shortname, update_lists(), Slic3r::GUI::VERTICAL_SPACING, and wxStaticText.

Here is the call graph for this function:

Member Function Documentation

◆ append()

template<class T>
T * Slic3r::GUI::ConfigWizardPage::append ( T * thing,
int proportion = 0,
int flag = wxEXPAND|wxTOP|wxBOTTOM,
int border = 10 )
inlineinherited
228 {
229 content->Add(thing, proportion, flag, border);
230 return thing;
231 }
wxBoxSizer * content
Definition ConfigWizard_private.hpp:220

References content.

Referenced by Slic3r::GUI::PageBedShape::PageBedShape(), Slic3r::GUI::PageCustom::PageCustom(), Slic3r::GUI::PageDiameters::PageDiameters(), Slic3r::GUI::PageFirmware::PageFirmware(), Slic3r::GUI::PageMaterials::PageMaterials(), Slic3r::GUI::PagePrinters::PagePrinters(), Slic3r::GUI::PageTemperatures::PageTemperatures(), Slic3r::GUI::PageWelcome::PageWelcome(), and append_text().

Here is the caller graph for this function:

◆ append_spacer()

void Slic3r::GUI::ConfigWizardPage::append_spacer ( int space)
inherited
522{
523 // FIXME: scaling
524 content->AddSpacer(space);
525}

References content.

Referenced by Slic3r::GUI::PageDiameters::PageDiameters(), Slic3r::GUI::PageMaterials::PageMaterials(), and Slic3r::GUI::PageTemperatures::PageTemperatures().

Here is the caller graph for this function:

◆ append_text()

wxStaticText * Slic3r::GUI::ConfigWizardPage::append_text ( wxString text)
inherited
513{
514 auto *widget = new wxStaticText(this, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
515 widget->Wrap(WRAP_WIDTH);
516 widget->SetMinSize(wxSize(WRAP_WIDTH, -1));
517 append(widget);
518 return widget;
519}
@ WRAP_WIDTH
Definition ConfigWizard_private.hpp:50

References append(), Slic3r::GUI::WRAP_WIDTH, and wxStaticText.

Referenced by Slic3r::GUI::PageBedShape::PageBedShape(), Slic3r::GUI::PageDiameters::PageDiameters(), Slic3r::GUI::PageFirmware::PageFirmware(), Slic3r::GUI::PageTemperatures::PageTemperatures(), and Slic3r::GUI::PageWelcome::PageWelcome().

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

◆ apply_custom_config()

virtual void Slic3r::GUI::ConfigWizardPage::apply_custom_config ( DynamicPrintConfig & config)
inlinevirtualinherited

◆ clear()

void Slic3r::GUI::PageMaterials::clear ( )
1192{
1193 list_printer->Clear();
1194 list_type->Clear();
1195 list_vendor->Clear();
1196 list_profile->Clear();
1197 sel_printers_prev.Clear();
1198 sel_type_prev = wxNOT_FOUND;
1199 sel_vendor_prev = wxNOT_FOUND;
1200 presets_loaded = false;
1201}
bool presets_loaded
Definition ConfigWizard_private.hpp:354
int sel_vendor_prev
Definition ConfigWizard_private.hpp:353
wxArrayInt sel_printers_prev
Definition ConfigWizard_private.hpp:352
int sel_type_prev
Definition ConfigWizard_private.hpp:353

References list_printer, list_profile, list_type, list_vendor, presets_loaded, sel_printers_prev, sel_type_prev, and sel_vendor_prev.

Referenced by reload_presets().

Here is the caller graph for this function:

◆ clear_compatible_printers_label()

void Slic3r::GUI::PageMaterials::clear_compatible_printers_label ( )
877{
878 set_compatible_printers_html_window(std::vector<std::string>(), false);
879}

References set_compatible_printers_html_window().

Referenced by on_material_highlighted(), and update_lists().

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

◆ on_activate()

void Slic3r::GUI::PageMaterials::on_activate ( )
overridevirtual

Reimplemented from Slic3r::GUI::ConfigWizardPage.

1204{
1205 if (! presets_loaded) {
1206 wizard_p()->update_materials(materials->technology);
1208 }
1209 first_paint = true;
1210}
ConfigWizard::priv * wizard_p() const
Definition ConfigWizard_private.hpp:236
void update_materials(Technology technology)
Definition ConfigWizard.cpp:1997
bool first_paint
Definition ConfigWizard_private.hpp:361

References first_paint, materials, presets_loaded, reload_presets(), Slic3r::GUI::ConfigWizard::priv::update_materials(), and Slic3r::GUI::ConfigWizardPage::wizard_p().

Here is the call graph for this function:

◆ on_material_highlighted()

void Slic3r::GUI::PageMaterials::on_material_highlighted ( int sel_material)
887{
888 if (sel_material == last_hovered_item)
889 return;
890 if (sel_material == -1) {
892 return;
893 }
894 last_hovered_item = sel_material;
895 std::vector<std::string> tabs;
896 tabs.push_back(std::string());
897 tabs.push_back(std::string());
898 tabs.push_back(std::string());
899 //selected material string
900 std::string material_name = list_profile->get_data(sel_material);
901 // get material preset
902 const std::vector<const Preset*> matching_materials = materials->get_presets_by_alias(material_name);
903 if (matching_materials.empty())
904 {
906 return;
907 }
908 //find matching printers
909 std::vector<std::string> names;
910 for (const Preset* printer : materials->printers) {
911 for (const Preset* material : matching_materials) {
912 if (is_compatible_with_printer(PresetWithVendorProfile(*material, material->vendor), PresetWithVendorProfile(*printer, printer->vendor))) {
913 names.push_back(printer->name);
914 break;
915 }
916 }
917 }
918 set_compatible_printers_html_window(names, names.size() == materials->printers.size());
919}
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer, const DynamicPrintConfig *extra_config)
Definition Preset.cpp:909
@ Preset
Definition calib.hpp:39
int last_hovered_item
Definition ConfigWizard_private.hpp:363
void clear_compatible_printers_label()
Definition ConfigWizard.cpp:876

References clear_compatible_printers_label(), Slic3r::is_compatible_with_printer(), last_hovered_item, list_profile, materials, Slic3r::Preset::name, set_compatible_printers_html_window(), and Slic3r::Preset::vendor.

Referenced by PageMaterials().

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

◆ on_material_hovered()

void Slic3r::GUI::PageMaterials::on_material_hovered ( int sel_material)
882{
883
884}

Referenced by on_mouse_leave_profiles(), and on_mouse_move_on_profiles().

Here is the caller graph for this function:

◆ on_mouse_enter_profiles()

void Slic3r::GUI::PageMaterials::on_mouse_enter_profiles ( wxMouseEvent & evt)
766{}

References Slic3r::GUI::wxMouseEvent.

◆ on_mouse_leave_profiles()

void Slic3r::GUI::PageMaterials::on_mouse_leave_profiles ( wxMouseEvent & evt)
768{
770}
void on_material_hovered(int sel_material)
Definition ConfigWizard.cpp:881

References on_material_hovered(), and Slic3r::GUI::wxMouseEvent.

Here is the call graph for this function:

◆ on_mouse_move_on_profiles()

void Slic3r::GUI::PageMaterials::on_mouse_move_on_profiles ( wxMouseEvent & evt)
759{
760 const wxClientDC dc(list_profile);
761 const wxPoint pos = evt.GetLogicalPosition(dc);
762 int item = list_profile->HitTest(pos);
764}
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References list_profile, on_material_hovered(), and Slic3r::GUI::wxMouseEvent.

Here is the call graph for this function:

◆ on_paint()

void Slic3r::GUI::PageMaterials::on_paint ( )
756{
757}

◆ reload_presets()

void Slic3r::GUI::PageMaterials::reload_presets ( )
772{
773 clear();
774
775 list_printer->append(_L("(All)"), &EMPTY);
776 //list_printer->SetLabelMarkup("<b>bald</b>");
777 for (const Preset* printer : materials->printers) {
778 list_printer->append(printer->name, &printer->name);
779 }
780 sort_list_data(list_printer, true, false);
781 if (list_printer->GetCount() > 0) {
782 list_printer->SetSelection(0);
783 sel_printers_prev.Clear();
784 sel_type_prev = wxNOT_FOUND;
785 sel_vendor_prev = wxNOT_FOUND;
786 update_lists(0, 0, 0);
787 }
788
789 presets_loaded = true;
790}
static const std::string EMPTY
Definition ConfigWizard_private.hpp:362
void sort_list_data(StringList *list, bool add_All_item, bool material_type_ordering)
Definition ConfigWizard.cpp:1077
void clear()
Definition ConfigWizard.cpp:1191

References _L, clear(), EMPTY, list_printer, materials, Slic3r::Preset::name, presets_loaded, sel_printers_prev, sel_type_prev, sel_vendor_prev, sort_list_data(), and update_lists().

Referenced by PageMaterials(), and on_activate().

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

◆ select_all()

void Slic3r::GUI::PageMaterials::select_all ( bool select)
1178{
1179 wxWindowUpdateLocker freeze_guard(this);
1180 (void)freeze_guard;
1181
1182 for (unsigned i = 0; i < list_profile->GetCount(); i++) {
1183 const bool current = list_profile->IsChecked(i);
1184 if (current != select) {
1185 list_profile->Check(i, select);
1186 select_material(i);
1187 }
1188 }
1189}

References list_profile, and select_material().

Referenced by PageMaterials().

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

◆ select_material()

void Slic3r::GUI::PageMaterials::select_material ( int i)
1170{
1171 const bool checked = list_profile->IsChecked(i);
1172
1173 const std::string& alias_key = list_profile->get_data(i);
1174 wizard_p()->update_presets_in_config(materials->appconfig_section(), alias_key, checked);
1175}
void update_presets_in_config(const std::string &section, const std::string &alias_key, bool add)
Definition ConfigWizard.cpp:2633

References list_profile, materials, Slic3r::GUI::ConfigWizard::priv::update_presets_in_config(), and Slic3r::GUI::ConfigWizardPage::wizard_p().

Referenced by PageMaterials(), and select_all().

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

◆ set_compatible_printers_html_window()

void Slic3r::GUI::PageMaterials::set_compatible_printers_html_window ( const std::vector< std::string > & printer_names,
bool all_printers = false )
793{
794 const auto bgr_clr = html_window->GetParent()->GetBackgroundColour();
795//#if defined(__APPLE__)
796// html_window->GetParent()->GetBackgroundColour();
797//#else
798//#if defined(_WIN32)
799// html_window->GetParent()->GetBackgroundColour();
800//#else
801// wxSystemSettings::GetColour(wxSYS_COLOUR_MENU);
802//#endif
803//#endif
804 const auto text_clr = wxGetApp().get_label_clr_default();
805 const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
806 const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
807 wxString first_line = format_wxstr(_L("%1% marked with <b>*</b> are <b>not</b> compatible with some installed printers."), materials->technology == T_FFF ? _L("Filaments") : _L("SLA materials"));
808 wxString text;
809 if (all_printers) {
810 wxString second_line = format_wxstr(_L("All installed printers are compatible with the selected %1%."), materials->technology == T_FFF ? _L("filament") : _L("SLA material"));
811 text = wxString::Format(
812 "<html>"
813 "<style>"
814 "table{border-spacing: 1px;}"
815 "</style>"
816 "<body bgcolor= %s>"
817 "<font color=%s>"
818 "<font size=\"3\">"
819 "%s<br /><br />%s"
820 "</font>"
821 "</font>"
822 "</body>"
823 "</html>"
824 , bgr_clr_str
825 , text_clr_str
826 , first_line
827 , second_line
828 );
829 } else {
830 wxString second_line;
831 if (!printer_names.empty())
832 second_line = (materials->technology == T_FFF ?
833 _L("Only the following installed printers are compatible with the selected filaments") :
834 _L("Only the following installed printers are compatible with the selected SLA materials")) + ":";
835 text = wxString::Format(
836 "<html>"
837 "<style>"
838 "table{border-spacing: 1px;}"
839 "</style>"
840 "<body bgcolor= %s>"
841 "<font color=%s>"
842 "<font size=\"3\">"
843 "%s<br /><br />%s"
844 "<table>"
845 "<tr>"
846 , bgr_clr_str
847 , text_clr_str
848 , first_line
849 , second_line);
850 for (size_t i = 0; i < printer_names.size(); ++i)
851 {
852 text += wxString::Format("<td>%s</td>", boost::nowide::widen(printer_names[i]));
853 if (i % 3 == 2) {
854 text += wxString::Format(
855 "</tr>"
856 "<tr>");
857 }
858 }
859 text += wxString::Format(
860 "</tr>"
861 "</table>"
862 "</font>"
863 "</font>"
864 "</body>"
865 "</html>"
866 );
867 }
868
869 wxFont font = get_default_font_for_dpi(this, get_dpi_for_window(this));
870 const int fs = font.GetPointSize();
871 int size[] = { fs,fs,fs,fs,fs,fs,fs };
872 html_window->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
873 html_window->SetPage(text);
874}
wxString format_wxstr(const char *fmt, TArgs &&... args)
Definition format.hpp:22
int get_dpi_for_window(const wxWindow *window)
Definition GUI_Utils.cpp:234
@ T_FFF
Definition ConfigWizard_private.hpp:69
wxFont get_default_font_for_dpi(const wxWindow *window, int dpi)
Definition GUI_Utils.cpp:287
std::string encode_color(const ColorRGB &color)
Definition Color.cpp:397

References _L, Slic3r::encode_color(), Slic3r::GUI::format_wxstr(), Slic3r::GUI::get_default_font_for_dpi(), Slic3r::GUI::get_dpi_for_window(), html_window, materials, and Slic3r::GUI::T_FFF.

Referenced by PageMaterials(), clear_compatible_printers_label(), and on_material_highlighted().

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

◆ set_run_reason()

virtual void Slic3r::GUI::ConfigWizardPage::set_run_reason ( ConfigWizard::RunReason run_reason)
inlinevirtualinherited

◆ sort_list_data() [1/2]

void Slic3r::GUI::PageMaterials::sort_list_data ( PresetList * list,
const std::vector< ProfilePrintData > & data )
1137{
1138 // sort data
1139 // then prusa profiles
1140 // then the rest
1141 // in alphabetical order
1142 std::vector<ProfilePrintData> prusa_profiles;
1143 std::vector<ProfilePrintData> other_profiles;
1144 //for (int i = 0; i < data.size(); ++i) {
1145 for (const auto& item : data) {
1146 const std::string& name = item.name;
1147 if (name.find("Bambu") != std::string::npos)
1148 prusa_profiles.emplace_back(item);
1149 else
1150 other_profiles.emplace_back(item);
1151 }
1152 std::sort(prusa_profiles.begin(), prusa_profiles.end(), [](ProfilePrintData a, ProfilePrintData b) {
1153 return a.name.get() < b.name.get();
1154 });
1155 std::sort(other_profiles.begin(), other_profiles.end(), [](ProfilePrintData a, ProfilePrintData b) {
1156 return a.name.get() < b.name.get();
1157 });
1158 list->Clear();
1159 for (size_t i = 0; i < prusa_profiles.size(); ++i) {
1160 list->append(std::string(prusa_profiles[i].name) + (prusa_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(prusa_profiles[i].name.get()));
1161 list->Check(i, prusa_profiles[i].checked);
1162 }
1163 for (size_t i = 0; i < other_profiles.size(); ++i) {
1164 list->append(std::string(other_profiles[i].name) + (other_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(other_profiles[i].name.get()));
1165 list->Check(i + prusa_profiles.size(), other_profiles[i].checked);
1166 }
1167}

References Slic3r::GUI::DataList< T, D >::append().

Here is the call graph for this function:

◆ sort_list_data() [2/2]

void Slic3r::GUI::PageMaterials::sort_list_data ( StringList * list,
bool add_All_item,
bool material_type_ordering )
1078{
1079// get data from list
1080// sort data
1081// first should be <all>
1082// then prusa profiles
1083// then the rest
1084// in alphabetical order
1085
1086 std::vector<std::reference_wrapper<const std::string>> prusa_profiles;
1087 std::vector<std::reference_wrapper<const std::string>> other_profiles;
1088 for (int i = 0 ; i < list->size(); ++i) {
1089 const std::string& data = list->get_data(i);
1090 if (data == EMPTY) // do not sort <all> item
1091 continue;
1092 if (!material_type_ordering && data.find("Bambu") != std::string::npos)
1093 prusa_profiles.push_back(data);
1094 else
1095 other_profiles.push_back(data);
1096 }
1097 if(material_type_ordering) {
1098
1099 const ConfigOptionDef* def = print_config_def.get("filament_type");
1100 std::vector<std::string>enum_values = def->enum_values;
1101 size_t end_of_sorted = 0;
1102 for (size_t vals = 0; vals < enum_values.size(); vals++) {
1103 for (size_t profs = end_of_sorted; profs < other_profiles.size(); profs++)
1104 {
1105 // find instead compare because PET vs PETG
1106 if (other_profiles[profs].get().find(enum_values[vals]) != std::string::npos) {
1107 //swap
1108 if(profs != end_of_sorted) {
1109 std::reference_wrapper<const std::string> aux = other_profiles[end_of_sorted];
1110 other_profiles[end_of_sorted] = other_profiles[profs];
1111 other_profiles[profs] = aux;
1112 }
1113 end_of_sorted++;
1114 break;
1115 }
1116 }
1117 }
1118 } else {
1119 std::sort(prusa_profiles.begin(), prusa_profiles.end(), [](std::reference_wrapper<const std::string> a, std::reference_wrapper<const std::string> b) {
1120 return a.get() < b.get();
1121 });
1122 std::sort(other_profiles.begin(), other_profiles.end(), [](std::reference_wrapper<const std::string> a, std::reference_wrapper<const std::string> b) {
1123 return a.get() < b.get();
1124 });
1125 }
1126
1127 list->Clear();
1128 if (add_All_item)
1129 list->append(_L("(All)"), &EMPTY);
1130 for (const auto& item : prusa_profiles)
1131 list->append(item, &const_cast<std::string&>(item.get()));
1132 for (const auto& item : other_profiles)
1133 list->append(item.get() == Materials::UNKNOWN ? _L(item.get()) : from_u8(item.get()), &const_cast<std::string&>(item.get()));
1134}
const ConfigOptionDef * get(const t_config_option_key &opt_key) const
Definition Config.hpp:2662
std::vector< std::string > enum_values
Definition Config.hpp:2615
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
const PrintConfigDef print_config_def
Definition PrintConfig.cpp:10099
id get(id object, const void *key)
Definition MacIME.mm:22
RaycastManager::TrItems::iterator find(RaycastManager::TrItems &items, const RaycastManager::TrKey &key)
Definition RaycastManager.cpp:298
static const std::string UNKNOWN
Definition ConfigWizard_private.hpp:165

References _L, Slic3r::GUI::DataList< T, D >::append(), EMPTY, Slic3r::ConfigOptionDef::enum_values, Slic3r::GUI::from_u8(), Slic3r::GUI::DataList< T, D >::get_data(), Slic3r::print_config_def, Slic3r::GUI::DataList< T, D >::size(), and Slic3r::GUI::Materials::UNKNOWN.

Referenced by reload_presets(), and update_lists().

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

◆ update_lists()

void Slic3r::GUI::PageMaterials::update_lists ( int sel_type,
int sel_vendor,
int last_selected_printer = -1 )
922{
923 wxWindowUpdateLocker freeze_guard(this);
924 (void)freeze_guard;
925
926 wxArrayInt sel_printers;
927 int sel_printers_count = list_printer->GetSelections(sel_printers);
928
929 if (sel_printers != sel_printers_prev) {
930
931 // Refresh type list
932 list_type->Clear();
933 list_type->append(_L("(All)"), &EMPTY);
934 if (sel_printers_count > 0) {
935 // If all is selected with other printers
936 // unselect "all" or all printers depending on last value
937 if (sel_printers[0] == 0 && sel_printers_count > 1) {
938 if (last_selected_printer == 0) {
939 list_printer->SetSelection(wxNOT_FOUND);
940 list_printer->SetSelection(0);
941 } else {
942 list_printer->SetSelection(0, false);
943 sel_printers_count = list_printer->GetSelections(sel_printers);
944 }
945 }
946 if (sel_printers[0] != 0) {
947 for (int i = 0; i < sel_printers_count; i++) {
948 const std::string& printer_name = list_printer->get_data(sel_printers[i]);
949 const Preset* printer = nullptr;
950 for (const Preset* it : materials->printers) {
951 if (it->name == printer_name) {
952 printer = it;
953 break;
954 }
955 }
956 materials->filter_presets(printer, EMPTY, EMPTY, [this](const Preset* p) {
957 const std::string& type = this->materials->get_type(p);
958 if (list_type->find(type) == wxNOT_FOUND) {
959 list_type->append(type, &type);
960 }
961 });
962 }
963 } else {
964 //clear selection except "ALL"
965 list_printer->SetSelection(wxNOT_FOUND);
966 list_printer->SetSelection(0);
967 sel_printers_count = list_printer->GetSelections(sel_printers);
968
969 materials->filter_presets(nullptr, EMPTY, EMPTY, [this](const Preset* p) {
970 const std::string& type = this->materials->get_type(p);
971 if (list_type->find(type) == wxNOT_FOUND) {
972 list_type->append(type, &type);
973 }
974 });
975 }
976 sort_list_data(list_type, true, true);
977 }
978
979 sel_printers_prev = sel_printers;
980 sel_type = 0;
981 sel_type_prev = wxNOT_FOUND;
982 list_type->SetSelection(sel_type);
983 list_profile->Clear();
984 }
985
986 if (sel_type != sel_type_prev) {
987 // Refresh vendor list
988
989 // XXX: The vendor list is created with quadratic complexity here,
990 // but the number of vendors is going to be very small this shouldn't be a problem.
991
992 list_vendor->Clear();
993 list_vendor->append(_L("(All)"), &EMPTY);
994 if (sel_printers_count != 0 && sel_type != wxNOT_FOUND) {
995 const std::string& type = list_type->get_data(sel_type);
996 // find printer preset
997 for (int i = 0; i < sel_printers_count; i++) {
998 const std::string& printer_name = list_printer->get_data(sel_printers[i]);
999 const Preset* printer = nullptr;
1000 for (const Preset* it : materials->printers) {
1001 if (it->name == printer_name) {
1002 printer = it;
1003 break;
1004 }
1005 }
1006 materials->filter_presets(printer, type, EMPTY, [this](const Preset* p) {
1007 const std::string& vendor = this->materials->get_vendor(p);
1008 if (list_vendor->find(vendor) == wxNOT_FOUND) {
1009 list_vendor->append(vendor, &vendor);
1010 }
1011 });
1012 }
1013 sort_list_data(list_vendor, true, false);
1014 }
1015
1016 sel_type_prev = sel_type;
1017 sel_vendor = 0;
1018 sel_vendor_prev = wxNOT_FOUND;
1019 list_vendor->SetSelection(sel_vendor);
1020 list_profile->Clear();
1021 }
1022
1023 if (sel_vendor != sel_vendor_prev) {
1024 // Refresh material list
1025
1026 list_profile->Clear();
1028 if (sel_printers_count != 0 && sel_type != wxNOT_FOUND && sel_vendor != wxNOT_FOUND) {
1029 const std::string& type = list_type->get_data(sel_type);
1030 const std::string& vendor = list_vendor->get_data(sel_vendor);
1031 // finst printer preset
1032 std::vector<ProfilePrintData> to_list;
1033 for (int i = 0; i < sel_printers_count; i++) {
1034 const std::string& printer_name = list_printer->get_data(sel_printers[i]);
1035 const Preset* printer = nullptr;
1036 for (const Preset* it : materials->printers) {
1037 if (it->name == printer_name) {
1038 printer = it;
1039 break;
1040 }
1041 }
1042
1043 materials->filter_presets(printer, type, vendor, [this, &to_list](const Preset* p) {
1044 const std::string& section = materials->appconfig_section();
1045 bool checked = wizard_p()->appconfig_new.has(section, p->name);
1046 bool was_checked = false;
1047
1048 int cur_i = list_profile->find(p->alias);
1049 if (cur_i == wxNOT_FOUND) {
1050 cur_i = list_profile->append(p->alias + (materials->get_omnipresent(p) ? "" : " *"), &p->alias);
1051 to_list.emplace_back(p->alias, materials->get_omnipresent(p), checked);
1052 }
1053 else {
1054 was_checked = list_profile->IsChecked(cur_i);
1055 to_list[cur_i].checked = checked || was_checked;
1056 }
1057 list_profile->Check(cur_i, checked || was_checked);
1058
1059 /* Update preset selection in config.
1060 * If one preset from aliases bundle is selected,
1061 * than mark all presets with this aliases as selected
1062 * */
1063 if (checked && !was_checked)
1064 wizard_p()->update_presets_in_config(section, p->alias, true);
1065 else if (!checked && was_checked)
1066 wizard_p()->appconfig_new.set(section, p->name, "true");
1067 });
1068 }
1069 sort_list_data(list_profile, to_list);
1070 }
1071
1072 sel_vendor_prev = sel_vendor;
1073 }
1074 //wxGetApp().UpdateDarkUI(list_profile);
1075}
bool has(const std::string &section, const std::string &key) const
Definition AppConfig.hpp:222
void set(const std::string &section, const std::string &key, const std::string &value)
Definition AppConfig.hpp:167
AppConfig appconfig_new
Definition ConfigWizard_private.hpp:544

References _L, Slic3r::Preset::alias, Slic3r::GUI::ConfigWizard::priv::appconfig_new, clear_compatible_printers_label(), EMPTY, Slic3r::AppConfig::has(), list_printer, list_profile, list_type, list_vendor, materials, Slic3r::Preset::name, sel_printers_prev, sel_type_prev, sel_vendor_prev, Slic3r::AppConfig::set(), sort_list_data(), Slic3r::GUI::ConfigWizard::priv::update_presets_in_config(), and Slic3r::GUI::ConfigWizardPage::wizard_p().

Referenced by PageMaterials(), and reload_presets().

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

◆ wizard_p()

ConfigWizard::priv * Slic3r::GUI::ConfigWizardPage::wizard_p ( ) const
inlineinherited
236{ return parent->p.get(); }

References parent.

Referenced by Slic3r::GUI::PageBedShape::PageBedShape(), Slic3r::GUI::PageCustom::PageCustom(), Slic3r::GUI::PagePrinters::PagePrinters(), Slic3r::GUI::PageMaterials::on_activate(), Slic3r::GUI::PageMaterials::select_material(), and Slic3r::GUI::PageMaterials::update_lists().

Here is the caller graph for this function:

Member Data Documentation

◆ compatible_printers_width

int Slic3r::GUI::PageMaterials::compatible_printers_width = { 100 }
359{ 100 };

◆ content

wxBoxSizer* Slic3r::GUI::ConfigWizardPage::content
inherited

◆ EMPTY

const std::string Slic3r::GUI::PageMaterials::EMPTY
static

◆ empty_printers_label

std::string Slic3r::GUI::PageMaterials::empty_printers_label

◆ first_paint

bool Slic3r::GUI::PageMaterials::first_paint = { false }
361{ false };

Referenced by on_activate().

◆ grid

wxFlexGridSizer* Slic3r::GUI::PageMaterials::grid

Referenced by PageMaterials().

◆ html_window

wxHtmlWindow* Slic3r::GUI::PageMaterials::html_window

◆ indent

const unsigned Slic3r::GUI::ConfigWizardPage::indent
inherited

◆ last_hovered_item

int Slic3r::GUI::PageMaterials::last_hovered_item = { -1 }
363{ -1 } ;

Referenced by on_material_highlighted().

◆ list_printer

StringList* Slic3r::GUI::PageMaterials::list_printer

◆ list_profile

◆ list_type

StringList * Slic3r::GUI::PageMaterials::list_type

Referenced by PageMaterials(), clear(), and update_lists().

◆ list_vendor

StringList * Slic3r::GUI::PageMaterials::list_vendor

Referenced by PageMaterials(), clear(), and update_lists().

◆ materials

◆ parent

◆ presets_loaded

bool Slic3r::GUI::PageMaterials::presets_loaded

Referenced by clear(), on_activate(), and reload_presets().

◆ sel_printers_prev

wxArrayInt Slic3r::GUI::PageMaterials::sel_printers_prev

Referenced by clear(), reload_presets(), and update_lists().

◆ sel_type_prev

int Slic3r::GUI::PageMaterials::sel_type_prev

Referenced by clear(), reload_presets(), and update_lists().

◆ sel_vendor_prev

int Slic3r::GUI::PageMaterials::sel_vendor_prev

Referenced by clear(), reload_presets(), and update_lists().

◆ shortname


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