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

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

Collaboration diagram for Slic3r::GUI::PresetTree:

Public Member Functions

 PresetTree (EditFilamentPresetDialog *dialog)
wxPanel * get_preset_tree (std::pair< std::string, std::vector< std::shared_ptr< Preset > > > printer_and_presets)

Private Member Functions

wxPanel * get_root_item (wxPanel *parent, const std::string &printer_name)
wxPanel * get_child_item (wxPanel *parent, std::shared_ptr< Preset > preset, std::string printer_name, int preset_index, bool is_last=false)
void delete_preset (std::string printer_name, int need_delete_preset_index)
void edit_preset (std::string printer_name, int need_edit_preset_index)

Private Attributes

EditFilamentPresetDialog * m_parent_dialog = nullptr
std::pair< std::string, std::vector< std::shared_ptr< Preset > > > m_printer_and_presets

Detailed Description

Constructor & Destructor Documentation

◆ PresetTree()

Slic3r::GUI::PresetTree::PresetTree ( EditFilamentPresetDialog * dialog)
5090: m_parent_dialog(dialog)
5091{}
EditFilamentPresetDialog * m_parent_dialog
Definition CreatePresetsDialog.hpp:356

References m_parent_dialog.

Member Function Documentation

◆ delete_preset()

void Slic3r::GUI::PresetTree::delete_preset ( std::string printer_name,
int need_delete_preset_index )
private
5187{
5188 m_parent_dialog->set_printer_name(printer_name);
5189 m_parent_dialog->set_need_delete_preset_index(need_delete_preset_index);
5190 m_parent_dialog->delete_preset();
5191}

References m_parent_dialog.

Referenced by get_child_item().

Here is the caller graph for this function:

◆ edit_preset()

void Slic3r::GUI::PresetTree::edit_preset ( std::string printer_name,
int need_edit_preset_index )
private
5194{
5195 m_parent_dialog->set_printer_name(printer_name);
5196 m_parent_dialog->set_need_edit_preset_index(need_edit_preset_index);
5197 m_parent_dialog->edit_preset();
5198}

References m_parent_dialog.

Referenced by get_child_item().

Here is the caller graph for this function:

◆ get_child_item()

wxPanel * Slic3r::GUI::PresetTree::get_child_item ( wxPanel * parent,
std::shared_ptr< Preset > preset,
std::string printer_name,
int preset_index,
bool is_last = false )
private
5130{
5131 wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
5132 wxPanel * panel = new wxPanel(parent);
5133 wxColour backgroundColor = parent->GetBackgroundColour();
5134 panel->SetBackgroundColour(backgroundColor);
5135 sizer->Add(0, 0, 0, wxLEFT, 10);
5136 wxPanel *line_left = new wxPanel(panel, wxID_ANY, wxDefaultPosition, is_last ? wxSize(1, 12) : wxSize(1, -1));
5137 line_left->SetBackgroundColour(*wxBLACK);
5138 sizer->Add(line_left, 0, is_last ? wxALL : wxEXPAND | wxALL, 0);
5139 wxPanel *line_right = new wxPanel(panel, wxID_ANY, wxDefaultPosition, wxSize(10, 1));
5140 line_right->SetBackgroundColour(*wxBLACK);
5141 sizer->Add(line_right, 0, wxALL | wxALIGN_CENTER_VERTICAL, 0);
5142 sizer->Add(0, 0, 0, wxLEFT, 5);
5143 wxStaticText *preset_name = new wxStaticText(panel, wxID_ANY, from_u8(preset->name));
5144 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " create child item: " << preset->name;
5145 preset_name->SetFont(Label::Body_10);
5146 preset_name->SetForegroundColour(*wxBLACK);
5147 sizer->Add(preset_name, 0, wxEXPAND | wxALL, 5);
5148 bool base_id_error = false;
5149 if (preset->inherits() == "" && preset->base_id != "") base_id_error = true;
5150 if (base_id_error) {
5151 // ORCA standardized HyperLink
5152 HyperLink *m_download_hyperlink = new HyperLink(panel, _L("[Delete Required]"), "https://wiki.bambulab.com/en/software/bambu-studio/custom-filament-issue");
5153 m_download_hyperlink->SetFont(Label::Body_10);
5154 sizer->Add(m_download_hyperlink, 0, wxEXPAND | wxALL, 5);
5155 }
5156 sizer->Add(0, 0, 1, wxEXPAND, 0);
5157
5158 Button *edit_preset_btn = new Button(panel, _L("Edit Preset"));
5160 //edit_preset_btn->Hide();
5161 sizer->Add(edit_preset_btn, 0, wxALL | wxALIGN_CENTER_VERTICAL, 0);
5162 sizer->Add(0, 0, 0, wxLEFT, 5);
5163
5164 Button *del_preset_btn = new Button(panel, _L("Delete Preset"));
5165 if (base_id_error) {
5167 } else {
5169 }
5170
5171 //del_preset_btn->Hide();
5172 sizer->Add(del_preset_btn, 0, wxALL | wxALIGN_CENTER_VERTICAL, 0);
5173
5174 edit_preset_btn->Bind(wxEVT_BUTTON, [this, printer_name, preset_index](wxCommandEvent &e) {
5175 wxGetApp().CallAfter([this, printer_name, preset_index]() { edit_preset(printer_name, preset_index); });
5176 });
5177 del_preset_btn->Bind(wxEVT_BUTTON, [this, printer_name, preset_index](wxCommandEvent &e) {
5178 wxGetApp().CallAfter([this, printer_name, preset_index]() { delete_preset(printer_name, preset_index); });
5179 });
5180
5181 panel->SetSizer(sizer);
5182
5183 return panel;
5184}
@ Confirm
Definition Button.hpp:25
@ Alert
Definition Button.hpp:26
@ Regular
Definition Button.hpp:24
@ Compact
Definition Button.hpp:31
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
void SetStyle(const ButtonStyle style, const ButtonType type)
Definition Button.cpp:200
static wxFont Body_10
Definition Label.hpp:56
void delete_preset(std::string printer_name, int need_delete_preset_index)
Definition CreatePresetsDialog.cpp:5186
void edit_preset(std::string printer_name, int need_edit_preset_index)
Definition CreatePresetsDialog.cpp:5193
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References _L, Alert, Label::Body_10, Compact, Confirm, delete_preset(), edit_preset(), Slic3r::GUI::from_u8(), Regular, Slic3r::GUI::HyperLink::SetFont(), Button::SetStyle(), and wxStaticText.

Referenced by get_preset_tree().

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

◆ get_preset_tree()

wxPanel * Slic3r::GUI::PresetTree::get_preset_tree ( std::pair< std::string, std::vector< std::shared_ptr< Preset > > > printer_and_presets)
5094{
5095 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
5096 wxPanel * parent = m_parent_dialog->get_preset_tree_panel();
5097 wxPanel * panel = new wxPanel(parent);
5098 wxColour backgroundColor = parent->GetBackgroundColour();
5099 panel->SetBackgroundColour(backgroundColor);
5100 const std::string &printer_name = printer_and_presets.first;
5101 sizer->Add(get_root_item(panel, printer_name), 0, wxEXPAND, 0);
5102 int child_count = printer_and_presets.second.size();
5103 for (int i = 0; i < child_count; i++) {
5104 if (i == child_count - 1) {
5105 sizer->Add(get_child_item(panel, printer_and_presets.second[i], printer_name, i, true), 0, wxEXPAND, 0);
5106 } else {
5107 sizer->Add(get_child_item(panel, printer_and_presets.second[i], printer_name, i, false), 0, wxEXPAND, 0);
5108 }
5109 }
5110 panel->SetSizerAndFit(sizer);
5111 return panel;
5112}
wxPanel * get_root_item(wxPanel *parent, const std::string &printer_name)
Definition CreatePresetsDialog.cpp:5114
wxPanel * get_child_item(wxPanel *parent, std::shared_ptr< Preset > preset, std::string printer_name, int preset_index, bool is_last=false)
Definition CreatePresetsDialog.cpp:5129

References get_child_item(), get_root_item(), and m_parent_dialog.

Here is the call graph for this function:

◆ get_root_item()

wxPanel * Slic3r::GUI::PresetTree::get_root_item ( wxPanel * parent,
const std::string & printer_name )
private
5115{
5116 wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
5117 wxPanel * panel = new wxPanel(parent);
5118 wxColour backgroundColor = parent->GetBackgroundColour();
5119 panel->SetBackgroundColour(backgroundColor);
5120 wxStaticText *preset_name = new wxStaticText(panel, wxID_ANY, from_u8(printer_name));
5121 preset_name->SetFont(Label::Body_11);
5122 preset_name->SetForegroundColour(*wxBLACK);
5123 sizer->Add(preset_name, 0, wxEXPAND | wxALL, 5);
5124 panel->SetSizer(sizer);
5125
5126 return panel;
5127}
static wxFont Body_11
Definition Label.hpp:57

References Label::Body_11, Slic3r::GUI::from_u8(), and wxStaticText.

Referenced by get_preset_tree().

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

Member Data Documentation

◆ m_parent_dialog

EditFilamentPresetDialog* Slic3r::GUI::PresetTree::m_parent_dialog = nullptr
private

◆ m_printer_and_presets

std::pair<std::string, std::vector<std::shared_ptr<Preset> > > Slic3r::GUI::PresetTree::m_printer_and_presets
private

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