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

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

Inheritance diagram for Slic3r::GUI::CreateFilamentPresetDialog:
Collaboration diagram for Slic3r::GUI::CreateFilamentPresetDialog:

Classes

struct  CreateType

Public Member Functions

 CreateFilamentPresetDialog (wxWindow *parent)
 ~CreateFilamentPresetDialog ()
void EndModal (int retCode) override
float scale_factor () const
float prev_scale_factor () const
void set_scale_factor (float v)
void set_prev_scale_factor (float v)
void set_em_unit (int v)
bool force_rescale () const
int em_unit () const
const wxFont & normal_font () const
void enable_force_rescale ()
int ShowModal ()

Protected Types

enum  FilamentOptionType {
  VENDOR = 0 , TYPE , SERIAL , FILAMENT_PRESET ,
  PRESET_FOR_PRINTER , FILAMENT_NAME_COUNT
}

Protected Member Functions

void on_dpi_changed (const wxRect &suggested_rect) override
bool is_check_box_selected ()
wxBoxSizer * create_item (FilamentOptionType option_type)
wxBoxSizer * create_vendor_item ()
wxBoxSizer * create_type_item ()
wxBoxSizer * create_serial_item ()
wxBoxSizer * create_filament_preset_item ()
wxBoxSizer * create_filament_preset_for_printer_item ()
wxWindow * create_dialog_buttons ()
virtual void on_sys_color_changed ()

Private Member Functions

void clear_filament_preset_map ()
wxArrayString get_filament_preset_choices ()
wxBoxSizer * create_radio_item (wxString title, wxWindow *parent, wxString tooltip, std::vector< std::pair< RadioBox *, wxString > > &radiobox_list)
void select_curr_radiobox (std::vector< std::pair< RadioBox *, wxString > > &radiobox_list, int btn_idx)
wxString curr_create_filament_type ()
void get_filament_presets_by_machine ()
void get_all_filament_presets ()
void get_all_visible_printer_name ()
void update_dialog_size ()
template<typename T>
void sort_printer_by_nozzle (std::vector< std::pair< std::string, T > > &printer_name_to_filament_preset)
void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

std::vector< std::pair< RadioBox *, wxString > > m_create_type_btns
std::unordered_map<::CheckBox *, std::pair< std::string, Preset * > > m_filament_preset
std::unordered_map<::CheckBox *, std::pair< std::string, Preset * > > m_machint_filament_preset
std::unordered_map< std::string, std::vector< Preset * > > m_filament_choice_map
std::unordered_map< wxString, std::string > m_public_name_to_filament_id_map
std::unordered_map< std::string, Preset * > m_all_presets_map
std::unordered_set< std::string > m_system_filament_types_set
std::set< std::string > m_visible_printers
CreateType m_create_type
ComboBox * m_filament_vendor_combobox = nullptr
::CheckBox * m_can_not_find_vendor_checkbox = nullptr
ComboBox * m_filament_type_combobox = nullptr
ComboBox * m_filament_preset_combobox = nullptr
TextInput * m_filament_custom_vendor_input = nullptr
wxGridSizer * m_filament_presets_sizer = nullptr
wxPanel * m_filament_preset_panel = nullptr
wxScrolledWindow * m_scrolled_preset_panel = nullptr
TextInput * m_filament_serial_input = nullptr
wxBoxSizer * m_scrolled_sizer = nullptr
wxStaticText * m_filament_preset_text = nullptr
float m_scale_factor
int m_em_unit
wxFont m_normal_font
float m_prev_scale_factor
bool m_can_rescale
bool m_force_rescale
int m_new_font_point_size

Detailed Description


Class Documentation

◆ Slic3r::GUI::CreateFilamentPresetDialog::CreateType

struct Slic3r::GUI::CreateFilamentPresetDialog::CreateType
Class Members
wxString base_filament
wxString base_filament_preset

Member Enumeration Documentation

◆ FilamentOptionType

Enumerator
VENDOR 
TYPE 
SERIAL 
FILAMENT_PRESET 
PRESET_FOR_PRINTER 
FILAMENT_NAME_COUNT 
40 {
41 VENDOR = 0,
42 TYPE,
43 SERIAL,
47 };
@ PRESET_FOR_PRINTER
Definition CreatePresetsDialog.hpp:45
@ TYPE
Definition CreatePresetsDialog.hpp:42
@ VENDOR
Definition CreatePresetsDialog.hpp:41
@ FILAMENT_PRESET
Definition CreatePresetsDialog.hpp:44
@ FILAMENT_NAME_COUNT
Definition CreatePresetsDialog.hpp:46
@ SERIAL
Definition CreatePresetsDialog.hpp:43

Constructor & Destructor Documentation

◆ CreateFilamentPresetDialog()

Slic3r::GUI::CreateFilamentPresetDialog::CreateFilamentPresetDialog ( wxWindow * parent)
721 : DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Create Filament"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxCENTRE | wxRESIZE_BORDER)
722{
723 m_create_type.base_filament = _L("Create Based on Current Filament");
724 m_create_type.base_filament_preset = _L("Copy Current Filament Preset ");
726
727 this->SetBackgroundColour(*wxWHITE);
728 this->SetSize(wxSize(FromDIP(600), FromDIP(480)));
729
730 wxBoxSizer *m_main_sizer = new wxBoxSizer(wxVERTICAL);
731 // top line
732 auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
733 m_line_top->SetBackgroundColour(wxColour(0xA6, 0xa9, 0xAA));
734 m_main_sizer->Add(m_line_top, 0, wxEXPAND, 0);
735 m_main_sizer->Add(0, 0, 0, wxTOP, FromDIP(5));
736
737 wxStaticText *basic_information = new wxStaticText(this, wxID_ANY, _L("Basic Information"));
738 basic_information->SetFont(Label::Head_16);
739 m_main_sizer->Add(basic_information, 0, wxLEFT, FromDIP(10));
740
741 m_main_sizer->Add(create_item(FilamentOptionType::VENDOR), 0, wxEXPAND | wxALL, FromDIP(5));
742 m_main_sizer->Add(create_item(FilamentOptionType::TYPE), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP(5));
743 m_main_sizer->Add(create_item(FilamentOptionType::SERIAL), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP(5));
744
745 // divider line
746 auto line_divider = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
747 line_divider->SetBackgroundColour(wxColour(0xA6, 0xa9, 0xAA));
748 m_main_sizer->Add(line_divider, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(10));
749 m_main_sizer->Add(0, 0, 0, wxTOP, FromDIP(5));
750
751 wxStaticText *presets_information = new wxStaticText(this, wxID_ANY, _L("Add Filament Preset under this filament"));
752 presets_information->SetFont(Label::Head_16);
753 m_main_sizer->Add(presets_information, 0, wxLEFT | wxRIGHT, FromDIP(15));
754
755 m_main_sizer->Add(create_item(FilamentOptionType::FILAMENT_PRESET), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP(5));
756
757 m_filament_preset_text = new wxStaticText(this, wxID_ANY, _L("We could create the filament presets for your following printer:"), wxDefaultPosition, wxDefaultSize);
758 m_main_sizer->Add(m_filament_preset_text, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(15));
759
760 m_scrolled_preset_panel = new wxScrolledWindow(this, wxID_ANY);
761 m_scrolled_preset_panel->SetMaxSize(wxSize(-1, FromDIP(350)));
762 m_scrolled_preset_panel->SetBackgroundColour(*wxWHITE);
763 m_scrolled_preset_panel->SetScrollRate(5, FromDIP(20));
764 m_scrolled_sizer = new wxBoxSizer(wxVERTICAL);
765 m_scrolled_sizer->Add(create_item(FilamentOptionType::PRESET_FOR_PRINTER), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP(5));
766 m_scrolled_sizer->Add(0, 0, 0, wxTOP, FromDIP(5));
768 m_main_sizer->Add(m_scrolled_preset_panel, 1, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(10));
769 m_main_sizer->Add(create_dialog_buttons(), 0, wxEXPAND);
770
773
774 this->SetSizer(m_main_sizer);
775
776 Layout();
777 Fit();
778
779 this->Bind(wxEVT_SIZE, [this](wxSizeEvent &event) {
780 this->Refresh();
781 event.Skip();
782 });
783
784 wxGetApp().UpdateDlgDarkUI(this);
785}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Head_16
Definition Label.hpp:43
void get_all_visible_printer_name()
Definition CreatePresetsDialog.cpp:1545
wxScrolledWindow * m_scrolled_preset_panel
Definition CreatePresetsDialog.hpp:97
wxBoxSizer * m_scrolled_sizer
Definition CreatePresetsDialog.hpp:99
wxWindow * create_dialog_buttons()
Definition CreatePresetsDialog.cpp:1102
void get_all_filament_presets()
Definition CreatePresetsDialog.cpp:1511
std::vector< std::pair< RadioBox *, wxString > > m_create_type_btns
Definition CreatePresetsDialog.hpp:81
wxBoxSizer * create_item(FilamentOptionType option_type)
Definition CreatePresetsDialog.cpp:815
wxStaticText * m_filament_preset_text
Definition CreatePresetsDialog.hpp:100
CreateType m_create_type
Definition CreatePresetsDialog.hpp:89
void select_curr_radiobox(std::vector< std::pair< RadioBox *, wxString > > &radiobox_list, int btn_idx)
Definition CreatePresetsDialog.cpp:1355

References _L, create_dialog_buttons(), create_item(), FILAMENT_PRESET, get_all_filament_presets(), get_all_visible_printer_name(), Label::Head_16, m_create_type, m_create_type_btns, m_filament_preset_text, m_scrolled_preset_panel, m_scrolled_sizer, PRESET_FOR_PRINTER, select_curr_radiobox(), SERIAL, TYPE, VENDOR, and wxStaticText.

Here is the call graph for this function:

◆ ~CreateFilamentPresetDialog()

Slic3r::GUI::CreateFilamentPresetDialog::~CreateFilamentPresetDialog ( )
788{
789 for (std::pair<std::string, Preset *> preset : m_all_presets_map) {
790 Preset *p = preset.second;
791 if (p) {
792 delete p;
793 p = nullptr;
794 }
795 }
796}
std::unordered_map< std::string, Preset * > m_all_presets_map
Definition CreatePresetsDialog.hpp:86
@ Preset
Definition calib.hpp:39

References m_all_presets_map.

Member Function Documentation

◆ clear_filament_preset_map()

void Slic3r::GUI::CreateFilamentPresetDialog::clear_filament_preset_map ( )
private
1627{
1628 m_filament_choice_map.clear();
1629 m_filament_preset.clear();
1632 m_filament_preset_panel->Freeze();
1633 m_filament_presets_sizer->Clear(true);
1635}
std::unordered_map<::CheckBox *, std::pair< std::string, Preset * > > m_filament_preset
Definition CreatePresetsDialog.hpp:82
std::unordered_map< std::string, std::vector< Preset * > > m_filament_choice_map
Definition CreatePresetsDialog.hpp:84
wxGridSizer * m_filament_presets_sizer
Definition CreatePresetsDialog.hpp:95
wxPanel * m_filament_preset_panel
Definition CreatePresetsDialog.hpp:96
std::unordered_map<::CheckBox *, std::pair< std::string, Preset * > > m_machint_filament_preset
Definition CreatePresetsDialog.hpp:83
std::unordered_map< wxString, std::string > m_public_name_to_filament_id_map
Definition CreatePresetsDialog.hpp:85

References clear_filament_preset_map(), m_filament_choice_map, m_filament_preset, m_filament_preset_panel, m_filament_presets_sizer, m_machint_filament_preset, and m_public_name_to_filament_id_map.

Referenced by clear_filament_preset_map(), create_type_item(), and select_curr_radiobox().

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

◆ create_dialog_buttons()

wxWindow * Slic3r::GUI::CreateFilamentPresetDialog::create_dialog_buttons ( )
protected
1103{
1104 auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
1105
1106 auto btn_ok = dlg_btns->GetOK();
1107 btn_ok->SetLabel(_L("Create"));
1108 btn_ok->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
1109 //get vendor name
1110 wxString vendor_str = m_filament_vendor_combobox->GetLabel();
1111 std::string vendor_name;
1112
1113 if (!m_can_not_find_vendor_checkbox->GetValue()) {
1114 if (_L("Select Vendor") == vendor_str) {
1115 MessageDialog dlg(this, _L("Vendor is not selected; please reselect vendor."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
1116 wxOK | wxCENTRE);
1117 dlg.ShowModal();
1118 return;
1119 } else {
1120 vendor_name = into_u8(vendor_str);
1121 }
1122 } else {
1123 if (m_filament_custom_vendor_input->GetTextCtrl()->GetValue().empty()) {
1124 MessageDialog dlg(this, _L("Custom vendor missing; please input custom vendor."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
1125 wxOK | wxCENTRE);
1126 dlg.ShowModal();
1127 return;
1128 } else {
1129 vendor_name = into_u8(m_filament_custom_vendor_input->GetTextCtrl()->GetValue());
1130 if (vendor_name == "Bambu" || vendor_name == "Generic") {
1131 MessageDialog dlg(this, _L("\"Bambu\" or \"Generic\" cannot be used as a Vendor for custom filaments."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
1132 wxOK | wxCENTRE);
1133 dlg.ShowModal();
1134 return;
1135 }
1136 }
1137 }
1138
1139 //get fialment type name
1140 wxString type_str = m_filament_type_combobox->GetLabel();
1141 std::string type_name;
1142 if (_L("Select Type") == type_str) {
1143 MessageDialog dlg(this, _L("Filament type is not selected, please reselect type."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
1144 dlg.ShowModal();
1145 return;
1146 } else {
1147 type_name = into_u8(type_str);
1148 }
1149 //get filament serial
1150 wxString serial_str = m_filament_serial_input->GetTextCtrl()->GetValue();
1151 std::string serial_name;
1152 if (serial_str.empty()) {
1153 MessageDialog dlg(this, _L("Filament serial missing; please input serial."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
1154 wxOK | wxCENTRE);
1155 dlg.ShowModal();
1156 return;
1157 } else {
1158 serial_name = into_u8(serial_str);
1159 }
1160 vendor_name = remove_special_key(vendor_name);
1161 serial_name = remove_special_key(serial_name);
1162
1163 if (vendor_name.empty() || serial_name.empty()) {
1164 MessageDialog dlg(this, _L("There may be disallowed characters in the vendor or serial input of the filament. Please delete and re-enter."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
1165 wxOK | wxCENTRE);
1166 dlg.ShowModal();
1167 return;
1168 }
1169 boost::algorithm::trim(vendor_name);
1170 boost::algorithm::trim(serial_name);
1171 if (vendor_name.empty() || serial_name.empty()) {
1172 MessageDialog dlg(this, _L("All inputs in the custom vendor or serial are spaces. Please re-enter."),
1173 wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
1174 dlg.ShowModal();
1175 return;
1176 }
1177 if (m_can_not_find_vendor_checkbox->GetValue() && str_is_all_digit(vendor_name)) {
1178 MessageDialog dlg(this, _L("The vendor cannot be a number; please re-enter."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
1179 wxOK | wxCENTRE);
1180 dlg.ShowModal();
1181 return;
1182 }
1183
1184 if (!is_check_box_selected()) {
1185 MessageDialog dlg(this, _L("You have not selected a printer or preset yet. Please select at least one."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
1186 wxOK | wxCENTRE);
1187 dlg.ShowModal();
1188 return;
1189 }
1190
1191 std::string filament_preset_name = vendor_name + " " + (type_name == "PLA-AERO" ? "PLA Aero" : type_name) + " " + serial_name;
1192 PresetBundle *preset_bundle = wxGetApp().preset_bundle;
1193 if (preset_bundle->filaments.is_alias_exist(filament_preset_name)) {
1194 MessageDialog dlg(this,
1195 wxString::Format(_L("The Filament name %s you created already exists.\nIf you continue, the preset created will be displayed with its full name. Do you want to continue\?"),
1196 from_u8(filament_preset_name)),
1197 wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
1198 if (wxID_YES != dlg.ShowModal()) { return; }
1199 }
1200
1201 PresetBundle filament_id_sources;
1202 load_filament_id_sources(filament_id_sources);
1203 std::string user_filament_id = get_filament_id(filament_preset_name, filament_id_sources);
1204
1205 const wxString &curr_create_type = curr_create_filament_type();
1206
1207 if (curr_create_type == m_create_type.base_filament) {
1208 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":clone filament create type filament ";
1209 for (const auto& checkbox_preset : m_filament_preset) {
1210 if (checkbox_preset.first->GetValue()) {
1211 std::string compatible_printer_name = checkbox_preset.second.first;
1212 std::vector<std::string> failures;
1213 Preset const *const checked_preset = checkbox_preset.second.second;
1214 DynamicConfig dynamic_config;
1215 dynamic_config.set_key_value("filament_vendor", new ConfigOptionStrings({vendor_name}));
1216 dynamic_config.set_key_value("compatible_printers", new ConfigOptionStrings({compatible_printer_name}));
1217 dynamic_config.set_key_value("filament_type", new ConfigOptionStrings({type_name}));
1218 bool res = preset_bundle->filaments.clone_presets_for_filament(checked_preset, failures, filament_preset_name, user_filament_id, dynamic_config,
1219 compatible_printer_name);
1220 if (!res) {
1221 std::string failure_names;
1222 for (std::string &failure : failures) { failure_names += failure + "\n"; }
1223 MessageDialog dlg(this, _L("Some existing presets have failed to be created, as follows:\n") + from_u8(failure_names) + _L("\nDo you want to rewrite it?"),
1224 wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
1225 if (dlg.ShowModal() == wxID_YES) {
1226 res = preset_bundle->filaments.clone_presets_for_filament(checked_preset, failures, filament_preset_name, user_filament_id, dynamic_config,
1227 compatible_printer_name, true);
1228 BOOST_LOG_TRIVIAL(info) << "clone filament have failures rewritten is successful? " << res;
1229 }
1230 }
1231 BOOST_LOG_TRIVIAL(info) << "clone filament no failures is successful? " << res;
1232 }
1233 }
1234 } else if (curr_create_type == m_create_type.base_filament_preset) {
1235 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":clone filament presets create type filament preset";
1236 for (const auto& checkbox_preset : m_machint_filament_preset) {
1237 if (checkbox_preset.first->GetValue()) {
1238 std::string compatible_printer_name = checkbox_preset.second.first;
1239 std::vector<std::string> failures;
1240 Preset const *const checked_preset = checkbox_preset.second.second;
1241 DynamicConfig dynamic_config;
1242 dynamic_config.set_key_value("filament_vendor", new ConfigOptionStrings({vendor_name}));
1243 dynamic_config.set_key_value("compatible_printers", new ConfigOptionStrings({compatible_printer_name}));
1244 dynamic_config.set_key_value("filament_type", new ConfigOptionStrings({type_name}));
1245 bool res = preset_bundle->filaments.clone_presets_for_filament(checked_preset, failures, filament_preset_name, user_filament_id, dynamic_config,
1246 compatible_printer_name);
1247 if (!res) {
1248 std::string failure_names;
1249 for (std::string &failure : failures) { failure_names += failure + "\n"; }
1250 MessageDialog dlg(this, _L("Some existing presets have failed to be created, as follows:\n") + from_u8(failure_names) + _L("\nDo you want to rewrite it?"),
1251 wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
1252 if (wxID_YES == dlg.ShowModal()) {
1253 res = preset_bundle->filaments.clone_presets_for_filament(checked_preset, failures, filament_preset_name, user_filament_id, dynamic_config,
1254 compatible_printer_name, true);
1255 BOOST_LOG_TRIVIAL(info) << "clone filament presets have failures rewritten is successful? " << res;
1256 }
1257 }
1258 BOOST_LOG_TRIVIAL(info) << "clone filament presets no failures is successful? " << res << " old preset is: " << checked_preset->name
1259 << " compatible_printer_name is: " << compatible_printer_name;
1260 }
1261 }
1262 }
1263 preset_bundle->update_compatible(PresetSelectCompatibleType::Always);
1264 EndModal(wxID_OK);
1265 });
1266
1267 dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
1268 EndModal(wxID_CANCEL);
1269 });
1270
1271 return dlg_btns;
1272}
TextInput * m_filament_custom_vendor_input
Definition CreatePresetsDialog.hpp:94
TextInput * m_filament_serial_input
Definition CreatePresetsDialog.hpp:98
ComboBox * m_filament_vendor_combobox
Definition CreatePresetsDialog.hpp:90
bool is_check_box_selected()
Definition CreatePresetsDialog.cpp:802
ComboBox * m_filament_type_combobox
Definition CreatePresetsDialog.hpp:92
wxString curr_create_filament_type()
Definition CreatePresetsDialog.cpp:1393
::CheckBox * m_can_not_find_vendor_checkbox
Definition CreatePresetsDialog.hpp:91
void EndModal(int retCode) override
Definition GUI_Utils.hpp:305
#define SLIC3R_APP_FULL_NAME
Definition libslic3r.h:11
static void load_filament_id_sources(PresetBundle &temp_preset_bundle)
Definition CreatePresetsDialog.cpp:545
static std::string get_filament_id(std::string vendor_typr_serial, const PresetBundle &temp_preset_bundle)
Definition CreatePresetsDialog.cpp:556
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
static bool str_is_all_digit(const std::string &str)
Definition CreatePresetsDialog.cpp:244
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
static std::string remove_special_key(const std::string &str)
Definition CreatePresetsDialog.cpp:233
@ Always
Definition Preset.hpp:527

References _L, Slic3r::Always, curr_create_filament_type(), Slic3r::GUI::DPIDialog::EndModal(), Slic3r::GUI::from_u8(), Slic3r::GUI::get_filament_id(), Slic3r::GUI::DialogButtons::GetCANCEL(), Slic3r::GUI::DialogButtons::GetOK(), Slic3r::GUI::into_u8(), is_check_box_selected(), Slic3r::GUI::load_filament_id_sources(), m_can_not_find_vendor_checkbox, m_create_type, m_filament_custom_vendor_input, m_filament_preset, m_filament_serial_input, m_filament_type_combobox, m_filament_vendor_combobox, m_machint_filament_preset, Slic3r::Preset::name, Slic3r::GUI::remove_special_key(), Slic3r::DynamicConfig::set_key_value(), Slic3r::GUI::DPIAware< P >::ShowModal(), SLIC3R_APP_FULL_NAME, and Slic3r::GUI::str_is_all_digit().

Referenced by CreateFilamentPresetDialog().

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

◆ create_filament_preset_for_printer_item()

wxBoxSizer * Slic3r::GUI::CreateFilamentPresetDialog::create_filament_preset_for_printer_item ( )
protected
1090{
1091 wxBoxSizer *vertical_sizer = new wxBoxSizer(wxVERTICAL);
1092 m_filament_preset_panel = new wxPanel(m_scrolled_preset_panel, wxID_ANY);
1093 m_filament_preset_panel->SetBackgroundColour(PRINTER_LIST_COLOUR);
1095 m_filament_presets_sizer = new wxGridSizer(3, FromDIP(5), FromDIP(5));
1097 vertical_sizer->Add(m_filament_preset_panel, 0, wxEXPAND | wxTOP, FromDIP(5));
1098
1099 return vertical_sizer;
1100}
#define PRINTER_LIST_COLOUR
Definition CreatePresetsDialog.cpp:90
#define PRINTER_LIST_SIZE
Definition CreatePresetsDialog.cpp:81

References m_filament_preset_panel, m_filament_presets_sizer, m_scrolled_preset_panel, PRINTER_LIST_COLOUR, and PRINTER_LIST_SIZE.

Referenced by create_item().

Here is the caller graph for this function:

◆ create_filament_preset_item()

wxBoxSizer * Slic3r::GUI::CreateFilamentPresetDialog::create_filament_preset_item ( )
protected
999{
1000 wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
1001
1002 wxBoxSizer * optionSizer = new wxBoxSizer(wxVERTICAL);
1003 wxStaticText *static_filament_preset_text = new wxStaticText(this, wxID_ANY, _L("Filament Preset"), wxDefaultPosition, wxDefaultSize);
1004 optionSizer->Add(static_filament_preset_text, 0, wxEXPAND | wxALL, 0);
1005 optionSizer->SetMinSize(OPTION_SIZE);
1006 horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL, FromDIP(10));
1007
1008 wxBoxSizer * comboBoxSizer = new wxBoxSizer(wxVERTICAL);
1009 comboBoxSizer->Add(create_radio_item(m_create_type.base_filament, this, wxEmptyString, m_create_type_btns), 0, wxEXPAND | wxALL, 0);
1010
1011 m_filament_preset_combobox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, FILAMENT_PRESET_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY);
1012 m_filament_preset_combobox->SetLabel(_L("Select Filament Preset"));
1014
1015
1016 m_filament_preset_combobox->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &e) {
1017 m_filament_preset_combobox->SetLabelColor(*wxBLACK);
1018 wxString filament_type = m_filament_preset_combobox->GetStringSelection();
1019 std::unordered_map<std::string, std::vector<Preset *>>::iterator iter = m_filament_choice_map.find(m_public_name_to_filament_id_map[filament_type]);
1020
1021 m_scrolled_preset_panel->Freeze();
1022 m_filament_presets_sizer->Clear(true);
1023 m_filament_preset.clear();
1024
1025 std::vector<std::pair<std::string, Preset *>> printer_name_to_filament_preset;
1026 if (iter != m_filament_choice_map.end()) {
1027 std::unordered_map<std::string, float> nozzle_diameter = nozzle_diameter_map;
1028 for (Preset* preset : iter->second) {
1029 auto compatible_printers = preset->config.option<ConfigOptionStrings>("compatible_printers", true);
1030 if (!compatible_printers || compatible_printers->values.empty()) {
1031 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "there is a preset has no compatible printers and the preset name is: " << preset->name;
1032 // If no compatible printers are defined, add all visible printers
1033 for (const std::string& visible_printer : m_visible_printers) {
1034 std::string nozzle = get_printer_nozzle_diameter(visible_printer);
1035 if (nozzle_diameter[nozzle] == 0) {
1036 BOOST_LOG_TRIVIAL(info)
1037 << __FUNCTION__ << " compatible printer nozzle encounter exception and name is: " << visible_printer;
1038 continue;
1039 }
1040 // Add to the list of available printer-preset pairs
1041 printer_name_to_filament_preset.push_back(std::make_pair(visible_printer, preset));
1042 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "show compatible printer name: " << visible_printer
1043 << " and preset name is: " << preset->name;
1044 }
1045
1046 continue;
1047 }
1048 for (std::string &compatible_printer_name : compatible_printers->values) {
1049 if (m_visible_printers.find(compatible_printer_name) == m_visible_printers.end()) {
1050 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "there is a comppatible printer no exist: " << compatible_printer_name
1051 << "and the preset name is: " << preset->name;
1052 continue;
1053 }
1054 std::string nozzle = get_printer_nozzle_diameter(compatible_printer_name);
1055 if (nozzle_diameter[nozzle] == 0) {
1056 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " compatible printer nozzle encounter exception and name is: " << compatible_printer_name;
1057 continue;
1058 }
1059 printer_name_to_filament_preset.push_back(std::make_pair(compatible_printer_name,preset));
1060 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "show compatible printer name: " << compatible_printer_name << "and preset name is: " << preset;
1061 }
1062 }
1063 } else {
1064 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " not find filament_id corresponding to the type: and the type is" << filament_type;
1065 }
1066 sort_printer_by_nozzle(printer_name_to_filament_preset);
1067 for (std::pair<std::string, Preset *> printer_to_preset : printer_name_to_filament_preset)
1068 m_filament_presets_sizer->Add(create_checkbox(m_filament_preset_panel, printer_to_preset.first, printer_to_preset.second, m_filament_preset), 0,
1069 wxEXPAND | wxTOP | wxLEFT, FromDIP(5));
1072
1074 e.Skip();
1075 });
1076
1077 comboBoxSizer->Add(m_filament_preset_combobox, 0, wxEXPAND | wxTOP, FromDIP(5));
1078
1079 comboBoxSizer->Add(create_radio_item(m_create_type.base_filament_preset, this, wxEmptyString, m_create_type_btns), 0, wxEXPAND | wxTOP, FromDIP(10));
1080
1081 horizontal_sizer->Add(comboBoxSizer, 0, wxEXPAND | wxALL, FromDIP(10));
1082
1083 horizontal_sizer->Add(0, 0, 0, wxLEFT, FromDIP(30));
1084
1085 return horizontal_sizer;
1086
1087}
#define FILAMENT_PRESET_COMBOBOX_SIZE
Definition CreatePresetsDialog.cpp:79
#define OPTION_SIZE
Definition CreatePresetsDialog.cpp:80
#define DEFAULT_PROMPT_TEXT_COLOUR
Definition CreatePresetsDialog.cpp:93
wxBoxSizer * create_radio_item(wxString title, wxWindow *parent, wxString tooltip, std::vector< std::pair< RadioBox *, wxString > > &radiobox_list)
Definition CreatePresetsDialog.cpp:1336
std::set< std::string > m_visible_printers
Definition CreatePresetsDialog.hpp:88
void sort_printer_by_nozzle(std::vector< std::pair< std::string, T > > &printer_name_to_filament_preset)
Definition CreatePresetsDialog.cpp:1587
void update_dialog_size()
Definition CreatePresetsDialog.cpp:1557
ComboBox * m_filament_preset_combobox
Definition CreatePresetsDialog.hpp:93
static std::unordered_map< std::string, float > nozzle_diameter_map
Definition CreatePresetsDialog.cpp:224
static wxBoxSizer * create_checkbox(wxWindow *parent, Preset *preset, wxString &preset_name, std::vector< std::pair<::CheckBox *, Preset * > > &preset_checkbox)
Definition CreatePresetsDialog.cpp:360
static std::string get_printer_nozzle_diameter(std::string printer_name)
Definition CreatePresetsDialog.cpp:671
zaa_minimize_perimeter_height nozzle_diameter((ConfigOptionBool, reduce_infill_retraction))((ConfigOptionBool
zaa_minimize_perimeter_height filament_type((ConfigOptionBools, filament_soluble))((ConfigOptionStrings

References _L, Slic3r::Preset::config, Slic3r::GUI::create_checkbox(), create_radio_item(), DEFAULT_PROMPT_TEXT_COLOUR, FILAMENT_PRESET_COMBOBOX_SIZE, Slic3r::filament_type(), Slic3r::GUI::get_printer_nozzle_diameter(), m_create_type, m_create_type_btns, m_filament_choice_map, m_filament_preset, m_filament_preset_combobox, m_filament_preset_panel, m_filament_presets_sizer, m_public_name_to_filament_id_map, m_scrolled_preset_panel, m_scrolled_sizer, m_visible_printers, Slic3r::Preset::name, Slic3r::nozzle_diameter(), Slic3r::GUI::nozzle_diameter_map, Slic3r::ConfigBase::option(), OPTION_SIZE, sort_printer_by_nozzle(), update_dialog_size(), and wxStaticText.

Referenced by create_item().

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

◆ create_item()

wxBoxSizer * Slic3r::GUI::CreateFilamentPresetDialog::create_item ( FilamentOptionType option_type)
protected
816{
817
818 wxSizer *item = nullptr;
819 switch (option_type) {
820 case VENDOR: return create_vendor_item();
821 case TYPE: return create_type_item();
822 case SERIAL: return create_serial_item();
825 default: return nullptr;
826 }
827}
wxBoxSizer * create_filament_preset_item()
Definition CreatePresetsDialog.cpp:998
wxBoxSizer * create_type_item()
Definition CreatePresetsDialog.cpp:920
wxBoxSizer * create_serial_item()
Definition CreatePresetsDialog.cpp:966
wxBoxSizer * create_vendor_item()
Definition CreatePresetsDialog.cpp:828
wxBoxSizer * create_filament_preset_for_printer_item()
Definition CreatePresetsDialog.cpp:1089

References create_filament_preset_for_printer_item(), create_filament_preset_item(), create_serial_item(), create_type_item(), create_vendor_item(), FILAMENT_PRESET, PRESET_FOR_PRINTER, SERIAL, TYPE, and VENDOR.

Referenced by CreateFilamentPresetDialog().

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

◆ create_radio_item()

wxBoxSizer * Slic3r::GUI::CreateFilamentPresetDialog::create_radio_item ( wxString title,
wxWindow * parent,
wxString tooltip,
std::vector< std::pair< RadioBox *, wxString > > & radiobox_list )
private
1337{
1338 wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
1339 RadioBox * radiobox = new RadioBox(parent);
1340 horizontal_sizer->Add(radiobox, 0, wxEXPAND | wxALL, 0);
1341 horizontal_sizer->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(5));
1342 radiobox_list.push_back(std::make_pair(radiobox, title));
1343 int btn_idx = radiobox_list.size() - 1;
1344 radiobox->Bind(wxEVT_LEFT_DOWN, [this, &radiobox_list, btn_idx](wxMouseEvent &e) { select_curr_radiobox(radiobox_list, btn_idx); });
1345
1346 wxStaticText *text = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize);
1347 text->Bind(wxEVT_LEFT_DOWN, [this, &radiobox_list, btn_idx](wxMouseEvent &e) { select_curr_radiobox(radiobox_list, btn_idx); });
1348 horizontal_sizer->Add(text, 0, wxEXPAND | wxLEFT, 0);
1349
1350 radiobox->SetToolTip(tooltip);
1351 text->SetToolTip(tooltip);
1352 return horizontal_sizer;
1353}
wxMouseEvent
Definition CameraPopup.cpp:47

References select_curr_radiobox(), Slic3r::GUI::wxMouseEvent, and wxStaticText.

Referenced by create_filament_preset_item().

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

◆ create_serial_item()

wxBoxSizer * Slic3r::GUI::CreateFilamentPresetDialog::create_serial_item ( )
protected
967{
968 wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
969
970 wxBoxSizer * optionSizer = new wxBoxSizer(wxVERTICAL);
971 wxStaticText *static_serial_text = new wxStaticText(this, wxID_ANY, _L("Serial"), wxDefaultPosition, wxDefaultSize);
972 optionSizer->Add(static_serial_text, 0, wxEXPAND | wxALL, 0);
973 optionSizer->SetMinSize(OPTION_SIZE);
974 horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL, FromDIP(5));
975
976 wxBoxSizer *comboBoxSizer = new wxBoxSizer(wxVERTICAL);
977 m_filament_serial_input = new TextInput(this, "", "", "", wxDefaultPosition, NAME_OPTION_COMBOBOX_SIZE, wxTE_PROCESS_ENTER);
978 m_filament_serial_input->GetTextCtrl()->SetMaxLength(50);
979 comboBoxSizer->Add(m_filament_serial_input, 0, wxEXPAND | wxALL, 0);
980 m_filament_serial_input->GetTextCtrl()->Bind(wxEVT_CHAR, [](wxKeyEvent &event) {
981 int key = event.GetKeyCode();
982 if (cannot_input_key.find(key) != cannot_input_key.end()) {
983 event.Skip(false);
984 return;
985 }
986 event.Skip();
987 });
988
989 wxStaticText *static_eg_text = new wxStaticText(this, wxID_ANY, _L("e.g. Basic, Matte, Silk, Marble"), wxDefaultPosition, wxDefaultSize);
990 static_eg_text->SetForegroundColour(wxColour("#6B6B6B"));
991 static_eg_text->SetFont(::Label::Body_12);
992 comboBoxSizer->Add(static_eg_text, 0, wxEXPAND | wxTOP, FromDIP(5));
993 horizontal_sizer->Add(comboBoxSizer, 0, wxEXPAND | wxALL, FromDIP(5));
994
995 return horizontal_sizer;
996}
#define NAME_OPTION_COMBOBOX_SIZE
Definition CreatePresetsDialog.cpp:78
static wxFont Body_12
Definition Label.hpp:55
static std::set< int > cannot_input_key
Definition CreatePresetsDialog.cpp:229

References _L, Label::Body_12, Slic3r::GUI::cannot_input_key, m_filament_serial_input, NAME_OPTION_COMBOBOX_SIZE, OPTION_SIZE, and wxStaticText.

Referenced by create_item().

Here is the caller graph for this function:

◆ create_type_item()

wxBoxSizer * Slic3r::GUI::CreateFilamentPresetDialog::create_type_item ( )
protected
921{
922 wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
923
924 wxBoxSizer * optionSizer = new wxBoxSizer(wxVERTICAL);
925 wxStaticText *static_type_text = new wxStaticText(this, wxID_ANY, _L("Type"), wxDefaultPosition, wxDefaultSize);
926 optionSizer->Add(static_type_text, 0, wxEXPAND | wxALL, 0);
927 optionSizer->SetMinSize(OPTION_SIZE);
928 horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL, FromDIP(5));
929
930 wxArrayString filament_type;
931 for (const wxString filament : m_system_filament_types_set) {
932 filament_type.Add(filament);
933 }
934 filament_type.Sort();
935
936 wxBoxSizer *comboBoxSizer = new wxBoxSizer(wxVERTICAL);
937 m_filament_type_combobox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, NAME_OPTION_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY);
938 m_filament_type_combobox->SetLabel(_L("Select Type"));
941 comboBoxSizer->Add(m_filament_type_combobox, 0, wxEXPAND | wxALL, 0);
942 horizontal_sizer->Add(comboBoxSizer, 0, wxEXPAND | wxALL, FromDIP(5));
943
944 m_filament_type_combobox->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &e) {
945 m_filament_type_combobox->SetLabelColor(*wxBLACK);
946 const wxString &curr_create_type = curr_create_filament_type();
948 if (curr_create_type == m_create_type.base_filament) {
949 wxArrayString filament_preset_choice = get_filament_preset_choices();
950 m_filament_preset_combobox->Set(filament_preset_choice);
951 m_filament_preset_combobox->SetLabel(_L("Select Filament Preset"));
953
954 } else if (curr_create_type == m_create_type.base_filament_preset) {
956 }
958
960 e.Skip();
961 });
962
963 return horizontal_sizer;
964}
void get_filament_presets_by_machine()
Definition CreatePresetsDialog.cpp:1404
wxArrayString get_filament_preset_choices()
Definition CreatePresetsDialog.cpp:1274
void clear_filament_preset_map()
Definition CreatePresetsDialog.cpp:1626
std::unordered_set< std::string > m_system_filament_types_set
Definition CreatePresetsDialog.hpp:87

References _L, clear_filament_preset_map(), curr_create_filament_type(), DEFAULT_PROMPT_TEXT_COLOUR, Slic3r::filament_type(), get_filament_preset_choices(), get_filament_presets_by_machine(), m_create_type, m_filament_preset_combobox, m_filament_type_combobox, m_scrolled_preset_panel, m_scrolled_sizer, m_system_filament_types_set, NAME_OPTION_COMBOBOX_SIZE, OPTION_SIZE, update_dialog_size(), and wxStaticText.

Referenced by create_item().

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

◆ create_vendor_item()

wxBoxSizer * Slic3r::GUI::CreateFilamentPresetDialog::create_vendor_item ( )
protected
829{
830 wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
831
832 wxBoxSizer * optionSizer = new wxBoxSizer(wxVERTICAL);
833 wxStaticText *static_vendor_text = new wxStaticText(this, wxID_ANY, _L("Vendor"), wxDefaultPosition, wxDefaultSize);
834 optionSizer->Add(static_vendor_text, 0, wxEXPAND | wxALL, 0);
835 optionSizer->SetMinSize(OPTION_SIZE);
836 horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL, FromDIP(5));
837
838 // Convert all std::any to std::string
839 std::vector<std::string> string_vendors;
840 for (const auto& vendor_any : filament_vendors) {
841 string_vendors.push_back(std::any_cast<std::string>(vendor_any));
842 }
843
844 // Sort the vendors alphabetically
845 std::sort(string_vendors.begin(), string_vendors.end(), caseInsensitiveCompare);
846
847 wxArrayString choices;
848 for (const std::string &vendor : string_vendors) {
849 choices.push_back(wxString(vendor)); // Convert std::string to wxString before adding
850 }
851
852 wxBoxSizer *vendor_sizer = new wxBoxSizer(wxHORIZONTAL);
853 m_filament_vendor_combobox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, NAME_OPTION_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY);
854 m_filament_vendor_combobox->SetLabel(_L("Select Vendor"));
856 m_filament_vendor_combobox->Set(choices);
857 m_filament_vendor_combobox->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &e) {
858 m_filament_vendor_combobox->SetLabelColor(*wxBLACK);
859 e.Skip();
860 });
861 vendor_sizer->Add(m_filament_vendor_combobox, 0, wxEXPAND | wxALL, 0);
862 wxBoxSizer *textInputSizer = new wxBoxSizer(wxVERTICAL);
863 m_filament_custom_vendor_input = new TextInput(this, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, NAME_OPTION_COMBOBOX_SIZE, wxTE_PROCESS_ENTER);
864 m_filament_custom_vendor_input->GetTextCtrl()->SetMaxLength(50);
866 textInputSizer->Add(m_filament_custom_vendor_input, 0, wxEXPAND | wxALL, 0);
867 m_filament_custom_vendor_input->GetTextCtrl()->SetHint(_L("Input Custom Vendor"));
868 m_filament_custom_vendor_input->GetTextCtrl()->Bind(wxEVT_CHAR, [](wxKeyEvent &event) {
869 int key = event.GetKeyCode();
870 if (cannot_input_key.find(key) != cannot_input_key.end()) {
871 event.Skip(false);
872 return;
873 }
874 event.Skip();
875 });
877 vendor_sizer->Add(textInputSizer, 0, wxEXPAND, FromDIP(10));
878
879 wxBoxSizer *comboBoxSizer = new wxBoxSizer(wxVERTICAL);
880 wxBoxSizer *checkbox_sizer = new wxBoxSizer(wxHORIZONTAL);
881 m_can_not_find_vendor_checkbox = new ::CheckBox(this);
882
883 checkbox_sizer->Add(m_can_not_find_vendor_checkbox, 0, wxALIGN_CENTER, 0);
884 checkbox_sizer->Add(0, 0, 0, wxEXPAND | wxRIGHT, FromDIP(5));
885
886 wxStaticText *m_can_not_find_vendor_text = new wxStaticText(this, wxID_ANY, _L("Can't find vendor I want"), wxDefaultPosition, wxDefaultSize, 0);
887 m_can_not_find_vendor_text->SetFont(::Label::Body_13);
888
889 wxSize size = m_can_not_find_vendor_text->GetTextExtent(_L("Can't find vendor I want"));
890 m_can_not_find_vendor_text->SetMinSize(wxSize(size.x + FromDIP(4), -1));
891 m_can_not_find_vendor_text->Wrap(-1);
892 checkbox_sizer->Add(m_can_not_find_vendor_text, 0, wxALIGN_CENTER, 0);
893
894 m_can_not_find_vendor_checkbox->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent &e) {
895 bool value = m_can_not_find_vendor_checkbox->GetValue();
896 if (value) {
897 m_can_not_find_vendor_checkbox->SetValue(true);
900 } else {
901 m_can_not_find_vendor_checkbox->SetValue(false);
904 }
905 Refresh();
906 Layout();
907 Fit();
908
909 e.Skip();
910 });
911
912 comboBoxSizer->Add(vendor_sizer, 0, wxEXPAND | wxTOP, FromDIP(5));
913 comboBoxSizer->Add(checkbox_sizer, 0, wxEXPAND | wxTOP, FromDIP(5));
914 horizontal_sizer->Add(comboBoxSizer, 0, wxEXPAND | wxALL, FromDIP(5));
915
916 return horizontal_sizer;
917
918}
static wxFont Body_13
Definition Label.hpp:54
static bool caseInsensitiveCompare(const std::string &a, const std::string &b)
Definition CreatePresetsDialog.cpp:252
static const std::vector< std::string > filament_vendors
Definition CreatePresetsDialog.cpp:100

References _L, Label::Body_13, Slic3r::GUI::cannot_input_key, Slic3r::GUI::caseInsensitiveCompare(), DEFAULT_PROMPT_TEXT_COLOUR, Slic3r::GUI::filament_vendors, m_can_not_find_vendor_checkbox, m_filament_custom_vendor_input, m_filament_vendor_combobox, NAME_OPTION_COMBOBOX_SIZE, OPTION_SIZE, and wxStaticText.

Referenced by create_item().

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

◆ curr_create_filament_type()

wxString Slic3r::GUI::CreateFilamentPresetDialog::curr_create_filament_type ( )
private
1394{
1395 wxString curr_filament_type;
1396 for (const std::pair<RadioBox *, wxString> &printer_radio : m_create_type_btns) {
1397 if (printer_radio.first->GetValue()) {
1398 curr_filament_type = printer_radio.second;
1399 }
1400 }
1401 return curr_filament_type;
1402}

References m_create_type_btns.

Referenced by create_dialog_buttons(), and create_type_item().

Here is the caller graph for this function:

◆ em_unit()

int Slic3r::GUI::DPIAware< wxDialog >::em_unit ( ) const
inlineinherited
203{ return m_em_unit; }
Definition GUI_Utils.hpp:107

Referenced by Slic3r::GUI::AuxiliaryDialog::AuxiliaryDialog(), Slic3r::GUI::CopyrightsDialog::CopyrightsDialog(), Slic3r::GUI::DesignTextDialog::DesignTextDialog(), Slic3r::GUI::EditGCodeDialog::EditGCodeDialog(), Slic3r::GUI::FileArchiveDialog::FileArchiveDialog(), Slic3r::GUI::MsgNoUpdates::MsgNoUpdates(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::OAuthDialog::OAuthDialog(), Slic3r::GUI::ParamsDialog::ParamsDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::SettingsDialog::SettingsDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), anonymous_namespace{3DPrinterOS.cpp}::UploadOptionsDialog::UploadOptionsDialog(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::DiffPresetDialog::complete_dialog_creation(), Slic3r::GUI::DiffPresetDialog::create_edit_sizer(), Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), Slic3r::GUI::DiffPresetDialog::create_tree(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::AboutDialog::on_dpi_changed(), Slic3r::GUI::AuxiliaryDialog::on_dpi_changed(), Slic3r::GUI::BedShapeDialog::on_dpi_changed(), Slic3r::GUI::ConfigWizard::on_dpi_changed(), Slic3r::GUI::CopyrightsDialog::on_dpi_changed(), Slic3r::GUI::DiffPresetDialog::on_dpi_changed(), Slic3r::GUI::EditGCodeDialog::on_dpi_changed(), Slic3r::GUI::FileArchiveDialog::on_dpi_changed(), Slic3r::GUI::OAuthDialog::on_dpi_changed(), Slic3r::GUI::ObjectTableDialog::on_dpi_changed(), Slic3r::GUI::ParamsDialog::on_dpi_changed(), Slic3r::GUI::PhysicalPrinterDialog::on_dpi_changed(), Slic3r::GUI::PrintHostQueueDialog::on_dpi_changed(), Slic3r::GUI::PurgeModeDialog::on_dpi_changed(), Slic3r::GUI::SavePresetDialog::on_dpi_changed(), Slic3r::GUI::SendSystemInfoDialog::on_dpi_changed(), Slic3r::GUI::SettingsDialog::on_dpi_changed(), and Slic3r::GUI::UnsavedChangesDialog::on_dpi_changed().

Here is the caller graph for this function:

◆ enable_force_rescale()

void Slic3r::GUI::DPIAware< wxDialog >::enable_force_rescale ( )
inlineinherited
206{ m_force_rescale = true; }

◆ EndModal()

void Slic3r::GUI::DPIDialog::EndModal ( int retCode)
inlineoverrideinherited
306 {
307 if (!dialogStack.empty() && dialogStack.front() != this) {
308 // This is a bug in wxWidgets
309 // when the dialog is not top modal dialog, EndModal() just hide dialog without quit
310 // the modal event loop. And the modal event loop blocks us from bottom widgets.
311 // Solution: let user click it manually or close outside. FIXME
312 BOOST_LOG_TRIVIAL(warning) << "DPIAware::EndModal Error: dialogStack is not empty, but top dialog is not this one. retCode=" << retCode;
313 return;
314 }
315
316 return wxDialog::EndModal(retCode);
317 }
std::deque< wxDialog * > dialogStack
Definition GUI_Utils.cpp:549

References Slic3r::GUI::dialogStack.

Referenced by Slic3r::GUI::CloneDialog::CloneDialog(), Slic3r::GUI::ConfigWizard::ConfigWizard(), Slic3r::GUI::CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(), Slic3r::GUI::DeleteConfirmDialog::DeleteConfirmDialog(), Slic3r::GUI::DesignVariableDialog::DesignVariableDialog(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::FlashforgeSlotDialog(), Slic3r::GUI::GuideFrame::GuideFrame(), Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MsgUpdateConfig::MsgUpdateConfig(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::MultiChoiceDialog::MultiChoiceDialog(), Slic3r::GUI::NetworkErrorDialog::NetworkErrorDialog(), Slic3r::GUI::NetworkPluginRestartDialog::NetworkPluginRestartDialog(), Slic3r::GUI::PartSkipConfirmDialog::PartSkipConfirmDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::PlateNameEditDialog::PlateNameEditDialog(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PublishSettingsDialog::PublishSettingsDialog(), Slic3r::GUI::SelectMachineDialog::SelectMachineDialog(), Slic3r::GUI::SendFailedConfirm::SendFailedConfirm(), Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), Slic3r::GUI::SingleChoiceDialog::SingleChoiceDialog(), StepMeshDialog::StepMeshDialog(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), Slic3r::GUI::UpdatePluginDialog::UpdatePluginDialog(), Slic3r::GUI::UpdateVersionDialog::UpdateVersionDialog(), Slic3r::GUI::wgtDeviceNozzleRackUpgradeDlg::wgtDeviceNozzleRackUpgradeDlg(), Slic3r::GUI::SavePresetDialog::accept(), Slic3r::GUI::MsgDialog::add_button(), Slic3r::GUI::TipsDialog::add_button(), Slic3r::GUI::FilamentPickerDialog::BindEvents(), Slic3r::GUI::PluginPickerDialog::build_capability_ui(), Slic3r::GUI::BedShapeDialog::build_dialog(), Slic3r::GUI::PluginPickerDialog::build_ui(), Slic3r::GUI::UnsavedChangesDialog::close(), Slic3r::GUI::FileArchiveDialog::create_btn_sizer(), Slic3r::GUI::ColorDecomposeDialog::create_button_panel(), Slic3r::GUI::MixedFilamentDialog::create_button_panel(), Slic3r::GUI::CreateFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::CreatePresetForPrinterDialog::create_dialog_buttons(), Slic3r::GUI::EditFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::create_dialog_buttons(), Slic3r::GUI::PreferencesDialog::create_item_language_combobox(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::GUI::PreferencesDialog::create_items(), Slic3r::GUI::CreatePrinterPresetDialog::create_page1_dialog_buttons(), Slic3r::GUI::CreatePrinterPresetDialog::create_page2_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::data_init(), Slic3r::GUI::WebDialog::destroy_silently(), Slic3r::GUI::EditFilamentPresetDialog::edit_preset(), Slic3r::GUI::ConnectPrinterDialog::end_modal(), Slic3r::GUI::PrintHostSendDialog::EndModal(), Slic3r::GUI::ColorPickerDialog::finish(), Slic3r::GUI::WebDialog::finish(), Slic3r::GUI::Newer3mfVersionDialog::get_btn_sizer(), Slic3r::GUI::ScoreDialog::get_button_sizer(), Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), Slic3r::GUI::ExportPresetBundleDialog::InitExportData(), Slic3r::GUI::SelectMachineDialog::navigate_to_timelapse_page(), Slic3r::GUI::BindMachineDialog::on_bind_success(), Slic3r::GUI::ConnectPrinterDialog::on_button_confirm(), Slic3r::GUI::RecenterDialog::on_button_confirm(), Slic3r::GUI::BindMachineDialog::on_cancel(), Slic3r::GUI::EditCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::InputIpAddressDialog::on_cancel(), Slic3r::GUI::NewCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::OAuthDialog::on_cancel(), Slic3r::GUI::PingCodeBindDialog::on_cancel(), Slic3r::GUI::SelectMachineDialog::on_cancel(), Slic3r::GUI::SendToPrinterDialog::on_cancel(), Slic3r::GUI::SyncAmsInfoDialog::on_cancel(), Slic3r::GUI::UnBindMachineDialog::on_cancel(), Slic3r::GUI::WebDialog::on_close_window(), Slic3r::GUI::NetworkPluginDownloadDialog::on_dont_ask(), Slic3r::GUI::NetworkPluginDownloadDialog::on_download(), Slic3r::GUI::EditDevNameDialog::on_edit_name(), Slic3r::GUI::ConfirmBeforeSendDialog::on_hide(), Slic3r::GUI::PrivacyUpdateDialog::on_hide(), Slic3r::GUI::ShortcutCaptureDialog::on_key(), Slic3r::GUI::TextureImportDialog::on_ok_clicked(), Slic3r::GUI::FileArchiveDialog::on_open_button(), Slic3r::GUI::NetworkPluginDownloadDialog::on_remind_later(), Slic3r::GUI::ProjectDropDialog::on_select_cancel(), Slic3r::GUI::SavePresetDialog::on_select_cancel(), Slic3r::GUI::ProjectDropDialog::on_select_ok(), Slic3r::GUI::SendMultiMachinePage::on_send(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip(), Slic3r::GUI::TextureImportDialog::on_skip_clicked(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip_version(), Slic3r::GUI::Cornering_Test_Dlg::on_start(), Slic3r::GUI::FlowRateCalibrationDialog::on_start(), Slic3r::GUI::Input_Shaping_Damp_Test_Dlg::on_start(), Slic3r::GUI::Input_Shaping_Freq_Test_Dlg::on_start(), Slic3r::GUI::MaxVolumetricSpeed_Test_Dlg::on_start(), Slic3r::GUI::PA_Calibration_Dlg::on_start(), Slic3r::GUI::Retraction_Test_Dlg::on_start(), Slic3r::GUI::Temp_Calibration_Dlg::on_start(), Slic3r::GUI::VFA_Test_Dlg::on_start(), Slic3r::GUI::CalibrationDialog::on_start_calibration(), Slic3r::GUI::UnBindMachineDialog::on_unbind_printer(), Slic3r::GUI::PartSkipDialog::OnApplyDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::OnCancel(), Slic3r::GUI::AboutDialog::onCloseDialog(), Slic3r::GUI::CopyrightsDialog::onCloseDialog(), Slic3r::GUI::MultiNozzleSyncDialog::OnRackStatusReadingFinished(), Slic3r::GUI::GuideFrame::OnScriptMessage(), Slic3r::GUI::InputIpAddressDialog::OnTimer(), Slic3r::GUI::KBShortcutsDialog::open_mouse_preferences(), Slic3r::GUI::TroubleshootDialog::PackAll(), Slic3r::GUI::TroubleshootDialog::RebuildSystemProfiles(), Slic3r::GUI::SpeedDialWebDialog::run_action(), Slic3r::GUI::OAuthDialog::Show(), Slic3r::GUI::MultiNozzleSyncDialog::UpdateButton(), and Slic3r::GUI::CreatePrinterPresetDialog::validate_input_valid().

◆ force_rescale()

bool Slic3r::GUI::DPIAware< wxDialog >::force_rescale ( ) const
inlineinherited
201{ return m_force_rescale; }

◆ get_all_filament_presets()

void Slic3r::GUI::CreateFilamentPresetDialog::get_all_filament_presets ( )
private
1512{
1513 // temp filament presets
1514 PresetBundle temp_preset_bundle;
1515 std::string dir_user_presets = wxGetApp().app_config->get("preset_folder");
1516 if (dir_user_presets.empty()) {
1518 } else {
1519 temp_preset_bundle.load_user_presets(dir_user_presets, ForwardCompatibilitySubstitutionRule::EnableSilent);
1520 }
1521 const std::deque<Preset> &filament_presets = temp_preset_bundle.filaments.get_presets();
1522
1523 for (const Preset &preset : filament_presets) {
1524 if (preset.filament_id.empty() || "null" == preset.filament_id) continue;
1525 std::string filament_preset_name = preset.name;
1526 Preset *filament_preset = new Preset(preset);
1527 m_all_presets_map[filament_preset_name] = filament_preset;
1528 }
1529 // global filament presets
1530 PresetBundle * preset_bundle = wxGetApp().preset_bundle;
1531 const std::deque<Preset> &temp_filament_presets = preset_bundle->filaments.get_presets();
1532 for (const Preset& preset : temp_filament_presets) {
1533 if (preset.filament_id.empty() || "null" == preset.filament_id) continue;
1534 auto filament_type = preset.config.option<ConfigOptionStrings>("filament_type");
1535 if (filament_type && filament_type->values.size())
1536 m_system_filament_types_set.insert(filament_type->values[0]);
1537 if (!preset.is_visible) continue;
1538 std::string filament_preset_name = preset.name;
1539 Preset *filament_preset = new Preset(preset);
1540 m_all_presets_map[filament_preset_name] = filament_preset;
1541 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " loaded preset name is: " << filament_preset->name;
1542 }
1543}
#define DEFAULT_USER_FOLDER_NAME
Definition PresetBundle.hpp:31
@ EnableSilent
Definition Config.hpp:247

References DEFAULT_USER_FOLDER_NAME, Slic3r::EnableSilent, Slic3r::filament_type(), Slic3r::PresetBundle::filaments, Slic3r::PresetCollection::get_presets(), Slic3r::PresetBundle::load_user_presets(), m_all_presets_map, m_system_filament_types_set, Slic3r::Preset::name, and Slic3r::Preset.

Referenced by CreateFilamentPresetDialog().

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

◆ get_all_visible_printer_name()

void Slic3r::GUI::CreateFilamentPresetDialog::get_all_visible_printer_name ( )
private
1546{
1547 PresetBundle *preset_bundle = wxGetApp().preset_bundle;
1548 for (const Preset &printer_preset : preset_bundle->printers.get_presets()) {
1549 if (!printer_preset.is_visible) continue;
1550 assert(m_visible_printers.find(printer_preset.name) == m_visible_printers.end());
1551 m_visible_printers.insert(printer_preset.name);
1552 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " entry, and visible printer is: " << printer_preset.name;
1553 }
1554
1555}

References Slic3r::PresetCollection::get_presets(), m_visible_printers, and Slic3r::PresetBundle::printers.

Referenced by CreateFilamentPresetDialog().

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

◆ get_filament_preset_choices()

wxArrayString Slic3r::GUI::CreateFilamentPresetDialog::get_filament_preset_choices ( )
private
1275{
1276 wxArrayString choices;
1277 // get fialment type name
1278 wxString type_str = m_filament_type_combobox->GetLabel();
1279 std::string type_name;
1280 if (_L("Select Type") == type_str) {
1281 /*MessageDialog dlg(this, _L("Filament type is not selected, please reselect type."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE);
1282 dlg.ShowModal();*/
1283 return choices;
1284 } else {
1285 type_name = into_u8(type_str);
1286 }
1287
1288 for (std::pair<std::string, Preset*> filament_presets : m_all_presets_map) {
1289 Preset *preset = filament_presets.second;
1290 auto inherit = preset->config.option<ConfigOptionString>("inherits");
1291 if (inherit && !inherit->value.empty()) {
1292 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " inherit user preset is:" << preset->name << " and inherits is: " << inherit->value;
1293 continue;
1294 }
1295 auto fila_type = preset->config.option<ConfigOptionStrings>("filament_type");
1296 if (!fila_type || fila_type->values.empty() || type_name != fila_type->values[0]) continue;
1297 m_filament_choice_map[preset->filament_id].push_back(preset);
1298 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " base user preset is:" << preset->name;
1299 }
1300
1301 int suffix = 0;
1302 for (const auto& preset : m_filament_choice_map) {
1303 if (preset.second.empty()) continue;
1304 std::set<wxString> preset_name_set;
1305 for (Preset* filament_preset : preset.second) {
1306 std::string preset_name = filament_preset->name;
1307 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " filament_id: " << filament_preset->filament_id << " preset name: " << filament_preset->name;
1308 size_t index_at = preset_name.find(" @");
1309 std::string cur_preset_name = preset_name;
1310 if (std::string::npos != index_at) {
1311 cur_preset_name = preset_name.substr(0, index_at);
1312 }
1313 preset_name_set.insert(from_u8(cur_preset_name));
1314 }
1315 assert(1 == preset_name_set.size());
1316 if (preset_name_set.size() > 1) {
1317 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " the same filament has different filament(vendor type serial)";
1318 }
1319 for (const wxString& public_name : preset_name_set) {
1321 suffix++;
1322 m_public_name_to_filament_id_map[public_name + "_" + std::to_string(suffix)] = preset.first;
1323 choices.Add(public_name + "_" + std::to_string(suffix));
1324 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " add filament choice: " << choices.back();
1325 } else {
1326 m_public_name_to_filament_id_map[public_name] = preset.first;
1327 choices.Add(public_name);
1328 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " add filament choice: " << choices.back();
1329 }
1330 }
1331 }
1332
1333 return choices;
1334}
zaa_minimize_perimeter_height ConfigOptionString
Definition PrintConfig.hpp:1702

References _L, Slic3r::Preset::config, Slic3r::Preset::filament_id, Slic3r::GUI::from_u8(), Slic3r::GUI::into_u8(), m_all_presets_map, m_filament_choice_map, m_filament_type_combobox, m_public_name_to_filament_id_map, Slic3r::Preset::name, and Slic3r::ConfigBase::option().

Referenced by create_type_item(), and select_curr_radiobox().

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

◆ get_filament_presets_by_machine()

void Slic3r::GUI::CreateFilamentPresetDialog::get_filament_presets_by_machine ( )
private
1405{
1406 wxArrayString choices;
1407 // get fialment type name
1408 wxString type_str = m_filament_type_combobox->GetLabel();
1409 std::string type_name;
1410 if (_L("Select Type") == type_str) {
1411 /*MessageDialog dlg(this, _L("Filament type is not selected, please reselect type."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT |
1412 wxCENTRE); dlg.ShowModal();*/
1413 return;
1414 } else {
1415 type_name = into_u8(type_str);
1416 }
1417
1418 std::unordered_map<std::string, float> nozzle_diameter = nozzle_diameter_map;
1419 std::unordered_map<std::string, std::vector<Preset *>> machine_name_to_presets;
1420 PresetBundle * preset_bundle = wxGetApp().preset_bundle;
1421 for (std::pair<std::string, Preset*> filament_preset : m_all_presets_map) {
1422 Preset * preset = filament_preset.second;
1423 auto compatible_printers = preset->config.option<ConfigOptionStrings>("compatible_printers", true);
1424 if (!compatible_printers || compatible_printers->values.empty()) {
1425 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "there is a preset has no compatible printers and the preset name is: " << preset->name;
1426 // If no compatible printers are defined, add all visible printers
1427 for (const std::string& visible_printer : m_visible_printers) {
1428 Preset* inherit_preset = nullptr;
1429 auto inherit = dynamic_cast<ConfigOptionString*>(preset->config.option(BBL_JSON_KEY_INHERITS, false));
1430 if (inherit && !inherit->value.empty()) {
1431 std::string inherits_value = inherit->value;
1432 inherit_preset = preset_bundle->filaments.find_preset(inherits_value, false, true);
1433 }
1434
1435 ConfigOptionStrings* filament_types;
1436 if (!inherit_preset) {
1437 filament_types = dynamic_cast<ConfigOptionStrings*>(preset->config.option("filament_type"));
1438 } else {
1439 filament_types = dynamic_cast<ConfigOptionStrings*>(inherit_preset->config.option("filament_type"));
1440 }
1441
1442 if (filament_types && filament_types->values.empty())
1443 continue;
1444 const std::string filament_type = filament_types->values[0];
1445 if (filament_type != type_name) {
1446 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " preset type is not selected type and preset name is: " << preset->name;
1447 continue;
1448 }
1449
1450 std::string nozzle = get_printer_nozzle_diameter(visible_printer);
1451 if (nozzle_diameter[nozzle] == 0) {
1452 BOOST_LOG_TRIVIAL(info) << __FUNCTION__
1453 << " compatible printer nozzle encounter exception and name is: " << visible_printer;
1454 continue;
1455 }
1456
1457 // Add all visible printers as compatible printers
1458 machine_name_to_presets[visible_printer].push_back(preset);
1459 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "show compatible printer name: " << visible_printer
1460 << " and preset name is: " << preset->name;
1461 }
1462
1463 continue;
1464 }
1465 for (std::string &compatible_printer_name : compatible_printers->values) {
1466 if (m_visible_printers.find(compatible_printer_name) == m_visible_printers.end()) {
1467 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " compatable printer is not visible and preset name is: " << preset->name;
1468 continue;
1469 }
1470 Preset * inherit_preset = nullptr;
1471 auto inherit = dynamic_cast<ConfigOptionString*>(preset->config.option(BBL_JSON_KEY_INHERITS,false));
1472 if (inherit && !inherit->value.empty()) {
1473 std::string inherits_value = inherit->value;
1474 inherit_preset = preset_bundle->filaments.find_preset(inherits_value, false, true);
1475 }
1476 ConfigOptionStrings *filament_types;
1477 if (!inherit_preset) {
1478 filament_types = dynamic_cast<ConfigOptionStrings *>(preset->config.option("filament_type"));
1479 } else {
1480 filament_types = dynamic_cast<ConfigOptionStrings *>(inherit_preset->config.option("filament_type"));
1481 }
1482
1483 if (filament_types && filament_types->values.empty()) continue;
1484 const std::string filament_type = filament_types->values[0];
1485 if (filament_type != type_name) {
1486 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " preset type is not selected type and preset name is: " << preset->name;
1487 continue;
1488 }
1489 std::string nozzle = get_printer_nozzle_diameter(compatible_printer_name);
1490 if (nozzle_diameter[nozzle] == 0) {
1491 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " compatible printer nozzle encounter exception and name is: " << compatible_printer_name;
1492 continue;
1493 }
1494 machine_name_to_presets[compatible_printer_name].push_back(preset);
1495 }
1496 }
1497 std::vector<std::pair<std::string, std::vector<Preset *>>> printer_name_to_filament_presets;
1498 for (std::pair<std::string, std::vector<Preset *>> machine_filament_presets : machine_name_to_presets) {
1499 printer_name_to_filament_presets.push_back(machine_filament_presets);
1500 }
1501 sort_printer_by_nozzle(printer_name_to_filament_presets);
1502 m_filament_preset_panel->Freeze();
1503 for (std::pair<std::string, std::vector<Preset *>> machine_filament_presets : printer_name_to_filament_presets) {
1504 std::string compatible_printer = machine_filament_presets.first;
1505 std::vector<Preset *> &presets = machine_filament_presets.second;
1506 m_filament_presets_sizer->Add(create_select_filament_preset_checkbox(m_filament_preset_panel, compatible_printer, presets, m_machint_filament_preset), 0, wxEXPAND | wxALL, FromDIP(5));
1507 }
1509}
#define BBL_JSON_KEY_INHERITS
Definition Preset.hpp:75
static wxBoxSizer * create_select_filament_preset_checkbox(wxWindow *parent, std::string &compatible_printer, std::vector< Preset * > presets, std::unordered_map<::CheckBox *, std::pair< std::string, Preset * > > &machine_filament_preset)
Definition CreatePresetsDialog.cpp:474
static const std::vector< std::string > filament_types
Definition CreatePresetsDialog.cpp:123

References _L, BBL_JSON_KEY_INHERITS, Slic3r::Preset::config, Slic3r::GUI::create_select_filament_preset_checkbox(), Slic3r::filament_type(), Slic3r::GUI::filament_types, Slic3r::PresetBundle::filaments, Slic3r::PresetCollection::find_preset(), Slic3r::GUI::get_printer_nozzle_diameter(), Slic3r::GUI::into_u8(), m_all_presets_map, m_filament_preset_panel, m_filament_presets_sizer, m_filament_type_combobox, m_machint_filament_preset, m_visible_printers, Slic3r::Preset::name, Slic3r::nozzle_diameter(), Slic3r::GUI::nozzle_diameter_map, Slic3r::ConfigBase::option(), and sort_printer_by_nozzle().

Referenced by create_type_item(), and select_curr_radiobox().

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

◆ is_check_box_selected()

bool Slic3r::GUI::CreateFilamentPresetDialog::is_check_box_selected ( )
protected
803{
804 for (const auto& checkbox_preset : m_filament_preset) {
805 if (checkbox_preset.first->GetValue()) { return true; }
806 }
807
808 for (const auto& checkbox_preset : m_machint_filament_preset) {
809 if (checkbox_preset.first->GetValue()) { return true; }
810 }
811
812 return false;
813}

References m_filament_preset, and m_machint_filament_preset.

Referenced by create_dialog_buttons().

Here is the caller graph for this function:

◆ is_new_scale_factor()

bool Slic3r::GUI::DPIAware< wxDialog >::is_new_scale_factor ( ) const
inlineprivateinherited
262{ return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }

◆ normal_font()

◆ on_dpi_changed()

void Slic3r::GUI::CreateFilamentPresetDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprotectedvirtual

Implements Slic3r::GUI::DPIAware< wxDialog >.

798 {
799 Layout();
800}

◆ on_sys_color_changed()

◆ prev_scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::prev_scale_factor ( ) const
inlineinherited
196{ return m_prev_scale_factor; }

◆ rescale()

void Slic3r::GUI::DPIAware< wxDialog >::rescale ( const wxRect & suggested_rect)
inlineprivateinherited
265 {
266 this->Freeze();
267
268 m_force_rescale = false;
269
270 // set normal application font as a current window font
271 m_normal_font = this->GetFont();
272
274
275 // rescale missed controls sizes and images
277
278 this->Layout();
279 this->Thaw();
280
281 // reset previous scale factor from current scale factor value
283 }
virtual void on_dpi_changed(const wxRect &suggested_rect)=0
void update_em_unit()
Definition GUI_Utils.hpp:249

◆ scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::scale_factor ( ) const
inlineinherited
195{ return m_scale_factor; }

◆ select_curr_radiobox()

void Slic3r::GUI::CreateFilamentPresetDialog::select_curr_radiobox ( std::vector< std::pair< RadioBox *, wxString > > & radiobox_list,
int btn_idx )
private
1356{
1357 int len = radiobox_list.size();
1358 for (int i = 0; i < len; ++i) {
1359 if (i == btn_idx) {
1360 radiobox_list[i].first->SetValue(true);
1361 const wxString &curr_selected_type = radiobox_list[i].second;
1362 this->Freeze();
1363 if (curr_selected_type == m_create_type.base_filament) {
1364 m_filament_preset_text->SetLabel(_L("We could create the filament presets for your following printer:"));
1366 if (_L("Select Type") != m_filament_type_combobox->GetLabel()) {
1368 wxArrayString filament_preset_choice = get_filament_preset_choices();
1369 m_filament_preset_combobox->Set(filament_preset_choice);
1370 m_filament_preset_combobox->SetLabel(_L("Select Filament Preset"));
1372 }
1373 } else if (curr_selected_type == m_create_type.base_filament_preset) {
1374 m_filament_preset_text->SetLabel(_L("We would rename the presets as \"Vendor Type Serial @printer you selected\".\n"
1375 "To add preset for more printers, please go to printer selection"));
1377 if (_L("Select Type") != m_filament_type_combobox->GetLabel()) {
1378
1381
1382 }
1383 }
1385 this->Thaw();
1386 } else {
1387 radiobox_list[i].first->SetValue(false);
1388 }
1389 }
1391}

References _L, clear_filament_preset_map(), DEFAULT_PROMPT_TEXT_COLOUR, get_filament_preset_choices(), get_filament_presets_by_machine(), m_create_type, m_filament_preset_combobox, m_filament_preset_text, m_filament_type_combobox, m_scrolled_preset_panel, m_scrolled_sizer, and update_dialog_size().

Referenced by CreateFilamentPresetDialog(), and create_radio_item().

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

◆ set_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::set_em_unit ( int v)
inlineinherited
200{ m_em_unit = v; }

◆ set_prev_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_prev_scale_factor ( float v)
inlineinherited

◆ set_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_scale_factor ( float v)
inlineinherited
198{ m_scale_factor = v; }

◆ ShowModal()

◆ sort_printer_by_nozzle()

template<typename T>
void Slic3r::GUI::CreateFilamentPresetDialog::sort_printer_by_nozzle ( std::vector< std::pair< std::string, T > > & printer_name_to_filament_preset)
private
1588{
1589 std::unordered_map<std::string, float> nozzle_diameter = nozzle_diameter_map;
1590 std::sort(printer_name_to_filament_preset.begin(), printer_name_to_filament_preset.end(),
1591 [&nozzle_diameter](const std::pair<std::string, T> &a, const std::pair<std::string, T> &b) {
1592 size_t nozzle_index_a = a.first.find(" nozzle");
1593 size_t nozzle_index_b = b.first.find(" nozzle");
1594 if (nozzle_index_a == std::string::npos || nozzle_index_b == std::string::npos) return a.first < b.first;
1595 std::string nozzle_str_a;
1596 std::string nozzle_str_b;
1597 try {
1598 nozzle_str_a = a.first.substr(0, nozzle_index_a);
1599 nozzle_str_b = b.first.substr(0, nozzle_index_b);
1600 size_t last_space_index = nozzle_str_a.find_last_of(" ");
1601 nozzle_str_a = nozzle_str_a.substr(last_space_index + 1);
1602 last_space_index = nozzle_str_b.find_last_of(" ");
1603 nozzle_str_b = nozzle_str_b.substr(last_space_index + 1);
1604 } catch (...) {
1605 BOOST_LOG_TRIVIAL(info) << "substr filed, and printer name is: " << a.first << " and " << b.first;
1606 return a.first < b.first;
1607 }
1608 float nozzle_a, nozzle_b;
1609 try {
1610 nozzle_a = nozzle_diameter[nozzle_str_a];
1611 nozzle_b = nozzle_diameter[nozzle_str_b];
1612 assert(nozzle_a != 0 && nozzle_b != 0);
1613 } catch (...) {
1614 BOOST_LOG_TRIVIAL(info) << "find nozzle filed, and nozzle is: " << nozzle_str_a << "mm and " << nozzle_str_b << "mm";
1615 return a.first < b.first;
1616 }
1617 float diff_nozzle_a = std::abs(nozzle_a - 0.4);
1618 float diff_nozzle_b = std::abs(nozzle_b - 0.4);
1619 if (nozzle_a == nozzle_b) return a.first < b.first;
1620 if (diff_nozzle_a == diff_nozzle_b) return nozzle_a < nozzle_b;
1621
1622 return diff_nozzle_a < diff_nozzle_b;
1623 });
1624}

References Slic3r::nozzle_diameter(), and Slic3r::GUI::nozzle_diameter_map.

Referenced by create_filament_preset_item(), and get_filament_presets_by_machine().

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

◆ update_dialog_size()

void Slic3r::GUI::CreateFilamentPresetDialog::update_dialog_size ( )
private
1558{
1559 this->Freeze();
1560 int height_before = m_filament_preset_panel->GetSize().GetHeight();
1561
1563
1564 int width = m_filament_preset_panel->GetSize().GetWidth();
1565 int height = m_filament_preset_panel->GetSize().GetHeight();
1566
1567 int screen_height = wxGetDisplaySize().GetHeight();
1568 wxSize dialog_size = this->GetSize();
1569 int max_available_height = screen_height - FromDIP(100);
1570 int ideal_scroll_height = height + FromDIP(26);
1571 int other_parts_height = dialog_size.GetHeight() - m_scrolled_preset_panel->GetSize().GetHeight() + FromDIP(12);
1572 int max_safe_scroll_height = max_available_height - other_parts_height;
1573 int final_scroll_height = std::min(ideal_scroll_height, max_safe_scroll_height);
1574
1575 m_scrolled_preset_panel->SetMinSize(wxSize(std::min(1400, width + FromDIP(26)), final_scroll_height));
1576 m_scrolled_preset_panel->SetMaxSize(wxSize(std::min(1400, width + FromDIP(26)), final_scroll_height));
1577 m_scrolled_preset_panel->SetSize(wxSize(std::min(1500, width + FromDIP(26)), final_scroll_height));
1578
1579 Layout();
1580 Fit();
1581 Refresh();
1583 this->Thaw();
1584}
static void adjust_dialog_in_screen(DPIDialog *dialog)
Definition CreatePresetsDialog.cpp:698
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References Slic3r::GUI::adjust_dialog_in_screen(), m_filament_preset_panel, m_filament_presets_sizer, and m_scrolled_preset_panel.

Referenced by create_filament_preset_item(), create_type_item(), and select_curr_radiobox().

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

◆ update_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::update_em_unit ( )
inlineprivateinherited
250 {
251 // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
252 // So, calculate the m_em_unit value from the font size, as before
253#if !defined(__WXGTK__)
255#else
256 // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
257 m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
258#endif // __WXGTK__
259 }

Member Data Documentation

◆ m_all_presets_map

std::unordered_map<std::string, Preset *> Slic3r::GUI::CreateFilamentPresetDialog::m_all_presets_map
private

◆ m_can_not_find_vendor_checkbox

::CheckBox* Slic3r::GUI::CreateFilamentPresetDialog::m_can_not_find_vendor_checkbox = nullptr
private

◆ m_can_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_can_rescale
privateinherited
235{ true };

◆ m_create_type

CreateType Slic3r::GUI::CreateFilamentPresetDialog::m_create_type
private

◆ m_create_type_btns

std::vector<std::pair<RadioBox *, wxString> > Slic3r::GUI::CreateFilamentPresetDialog::m_create_type_btns
private

◆ m_em_unit

int Slic3r::GUI::DPIAware< wxDialog >::m_em_unit
privateinherited

◆ m_filament_choice_map

std::unordered_map<std::string, std::vector<Preset *> > Slic3r::GUI::CreateFilamentPresetDialog::m_filament_choice_map
private

◆ m_filament_custom_vendor_input

TextInput* Slic3r::GUI::CreateFilamentPresetDialog::m_filament_custom_vendor_input = nullptr
private

◆ m_filament_preset

std::unordered_map<::CheckBox *, std::pair<std::string, Preset *> > Slic3r::GUI::CreateFilamentPresetDialog::m_filament_preset
private

◆ m_filament_preset_combobox

ComboBox* Slic3r::GUI::CreateFilamentPresetDialog::m_filament_preset_combobox = nullptr
private

◆ m_filament_preset_panel

wxPanel* Slic3r::GUI::CreateFilamentPresetDialog::m_filament_preset_panel = nullptr
private

◆ m_filament_preset_text

wxStaticText* Slic3r::GUI::CreateFilamentPresetDialog::m_filament_preset_text = nullptr
private

◆ m_filament_presets_sizer

wxGridSizer* Slic3r::GUI::CreateFilamentPresetDialog::m_filament_presets_sizer = nullptr
private

◆ m_filament_serial_input

TextInput* Slic3r::GUI::CreateFilamentPresetDialog::m_filament_serial_input = nullptr
private

◆ m_filament_type_combobox

ComboBox* Slic3r::GUI::CreateFilamentPresetDialog::m_filament_type_combobox = nullptr
private

◆ m_filament_vendor_combobox

ComboBox* Slic3r::GUI::CreateFilamentPresetDialog::m_filament_vendor_combobox = nullptr
private

◆ m_force_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_force_rescale
privateinherited
236{ false };

◆ m_machint_filament_preset

std::unordered_map<::CheckBox *, std::pair<std::string, Preset *> > Slic3r::GUI::CreateFilamentPresetDialog::m_machint_filament_preset
private

◆ m_new_font_point_size

int Slic3r::GUI::DPIAware< wxDialog >::m_new_font_point_size
privateinherited

◆ m_normal_font

wxFont Slic3r::GUI::DPIAware< wxDialog >::m_normal_font
privateinherited

◆ m_prev_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_prev_scale_factor
privateinherited

◆ m_public_name_to_filament_id_map

std::unordered_map<wxString, std::string> Slic3r::GUI::CreateFilamentPresetDialog::m_public_name_to_filament_id_map
private

◆ m_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_scale_factor
privateinherited

◆ m_scrolled_preset_panel

wxScrolledWindow* Slic3r::GUI::CreateFilamentPresetDialog::m_scrolled_preset_panel = nullptr
private

◆ m_scrolled_sizer

wxBoxSizer* Slic3r::GUI::CreateFilamentPresetDialog::m_scrolled_sizer = nullptr
private

◆ m_system_filament_types_set

std::unordered_set<std::string> Slic3r::GUI::CreateFilamentPresetDialog::m_system_filament_types_set
private

◆ m_visible_printers

std::set<std::string> Slic3r::GUI::CreateFilamentPresetDialog::m_visible_printers
private

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