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

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

Inheritance diagram for Slic3r::GUI::ExportConfigsDialog:
Collaboration diagram for Slic3r::GUI::ExportConfigsDialog:

Classes

struct  ExportType

Public Member Functions

 ExportConfigsDialog (wxWindow *parent)
 ~ExportConfigsDialog ()
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  ExportCase {
  INITIALIZE_FAIL = 0 , ADD_FILE_FAIL , ADD_BUNDLE_STRUCTURE_FAIL , FINALIZE_FAIL ,
  OPEN_ZIP_WRITTEN_FILE , EXPORT_CANCEL , EXPORT_SUCCESS , CASE_COUNT
}

Protected Member Functions

virtual void on_sys_color_changed ()

Private Member Functions

void data_init ()
void select_curr_radiobox (std::vector< std::pair< RadioBox *, wxString > > &radiobox_list, int btn_idx)
void update_include_bed_assets_enabled ()
void on_dpi_changed (const wxRect &suggested_rect) override
void show_export_result (const ExportCase &export_case)
bool has_check_box_selected ()
bool earse_preset_fields_for_safe (Preset *preset)
std::string initial_file_path (const wxString &path, const std::string &sub_file_path)
std::string initial_file_name (const wxString &path, const std::string file_name)
wxBoxSizer * create_export_config_item (wxWindow *parent)
wxWindow * create_dialog_buttons (wxWindow *parent)
wxBoxSizer * create_select_printer (wxWindow *parent)
wxBoxSizer * create_radio_item (wxString title, wxWindow *parent, wxString tooltip, std::vector< std::pair< RadioBox *, wxString > > &radiobox_list)
int initial_zip_archive (mz_zip_archive &zip_archive, const std::string &file_path)
ExportCase save_zip_archive_to_file (mz_zip_archive &zip_archive)
ExportCase save_presets_to_zip (const std::string &export_file, const std::vector< std::pair< std::string, std::string > > &config_paths)
ExportCase archive_preset_bundle_to_file (const wxString &path, bool include_bed_assets)
ExportCase archive_filament_bundle_to_file (const wxString &path)
ExportCase archive_printer_preset_to_file (const wxString &path)
ExportCase archive_filament_preset_to_file (const wxString &path)
ExportCase archive_process_preset_to_file (const wxString &path)
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_export_type_btns
std::vector< std::pair<::CheckBox *, Preset * > > m_preset
std::vector< std::pair<::CheckBox *, std::string > > m_printer_name
std::unordered_map< std::string, Preset * > m_printer_presets
std::unordered_map< std::string, std::vector< Preset * > > m_filament_presets
std::unordered_map< std::string, std::vector< Preset * > > m_process_presets
std::unordered_map< std::string, std::vector< std::pair< std::string, Preset * > > > m_filament_name_to_presets
ExportType m_exprot_type
wxBoxSizer * m_main_sizer = nullptr
wxScrolledWindow * m_scrolled_preset_window = nullptr
wxGridSizer * m_preset_sizer = nullptr
wxPanel * m_presets_window = nullptr
wxStaticText * m_serial_text = nullptr
::CheckBox * m_include_bed_assets = nullptr
wxStaticText * m_include_bed_assets_label = 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::ExportConfigsDialog::ExportType

struct Slic3r::GUI::ExportConfigsDialog::ExportType
Class Members
wxString filament_bundle
wxString filament_preset
wxString preset_bundle
wxString printer_preset
wxString process_preset

Member Enumeration Documentation

◆ ExportCase

Enumerator
INITIALIZE_FAIL 
ADD_FILE_FAIL 
ADD_BUNDLE_STRUCTURE_FAIL 
FINALIZE_FAIL 
OPEN_ZIP_WRITTEN_FILE 
EXPORT_CANCEL 
EXPORT_SUCCESS 
CASE_COUNT 
260 {
261 INITIALIZE_FAIL = 0,
269 };
@ CASE_COUNT
Definition CreatePresetsDialog.hpp:268
@ INITIALIZE_FAIL
Definition CreatePresetsDialog.hpp:261
@ ADD_FILE_FAIL
Definition CreatePresetsDialog.hpp:262
@ EXPORT_SUCCESS
Definition CreatePresetsDialog.hpp:267
@ EXPORT_CANCEL
Definition CreatePresetsDialog.hpp:266
@ OPEN_ZIP_WRITTEN_FILE
Definition CreatePresetsDialog.hpp:265
@ ADD_BUNDLE_STRUCTURE_FAIL
Definition CreatePresetsDialog.hpp:263
@ FINALIZE_FAIL
Definition CreatePresetsDialog.hpp:264

Constructor & Destructor Documentation

◆ ExportConfigsDialog()

Slic3r::GUI::ExportConfigsDialog::ExportConfigsDialog ( wxWindow * parent)
3604 : DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Export Preset Bundle"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
3605{
3606 m_exprot_type.preset_bundle = _L("Printer config bundle(.orca_printer)");
3607 m_exprot_type.filament_bundle = _L("Filament bundle(.orca_filament)");
3608 m_exprot_type.printer_preset = _L("Printer presets(.zip)");
3609 m_exprot_type.filament_preset = _L("Filament presets(.zip)");
3610 m_exprot_type.process_preset = _L("Process presets(.zip)");
3611
3612 this->SetBackgroundColour(*wxWHITE);
3613 this->SetSize(wxSize(FromDIP(600), FromDIP(600)));
3614
3615 m_main_sizer = new wxBoxSizer(wxVERTICAL);
3616 // top line
3617 auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
3618 m_line_top->SetBackgroundColour(wxColour(0xA6, 0xa9, 0xAA));
3619 m_main_sizer->Add(m_line_top, 0, wxEXPAND, 0);
3620 m_main_sizer->Add(0, 0, 0, wxTOP, FromDIP(5));
3621
3622 m_main_sizer->Add(create_export_config_item(this), 0, wxEXPAND | wxALL, FromDIP(5));
3623 m_main_sizer->Add(create_select_printer(this), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP(5));
3624 m_main_sizer->Add(create_dialog_buttons(this), 0, wxEXPAND);
3625
3626 data_init();
3627
3628 this->SetSizer(m_main_sizer);
3629
3630 this->Layout();
3631 this->Fit();
3632
3633 wxGetApp().UpdateDlgDarkUI(this);
3634
3635}
#define _L(s)
Definition OBJ.cpp:34
void data_init()
Definition CreatePresetsDialog.cpp:4427
ExportType m_exprot_type
Definition CreatePresetsDialog.hpp:302
wxBoxSizer * create_select_printer(wxWindow *parent)
Definition CreatePresetsDialog.cpp:4396
wxWindow * create_dialog_buttons(wxWindow *parent)
Definition CreatePresetsDialog.cpp:4351
wxBoxSizer * m_main_sizer
Definition CreatePresetsDialog.hpp:303
wxBoxSizer * create_export_config_item(wxWindow *parent)
Definition CreatePresetsDialog.cpp:3815

References _L, create_dialog_buttons(), create_export_config_item(), create_select_printer(), data_init(), m_exprot_type, and m_main_sizer.

Here is the call graph for this function:

◆ ~ExportConfigsDialog()

Slic3r::GUI::ExportConfigsDialog::~ExportConfigsDialog ( )
3638{
3639 for (std::pair<std::string, Preset *> printer_preset : m_printer_presets) {
3640 Preset *preset = printer_preset.second;
3641 if (preset) {
3642 delete preset;
3643 preset = nullptr;
3644 }
3645 }
3646 for (std::pair<std::string, std::vector<Preset *>> filament_presets : m_filament_presets) {
3647 for (Preset* preset : filament_presets.second) {
3648 if (preset) {
3649 delete preset;
3650 preset = nullptr;
3651 }
3652 }
3653 }
3654 for (std::pair<std::string, std::vector<Preset *>> filament_presets : m_process_presets) {
3655 for (Preset *preset : filament_presets.second) {
3656 if (preset) {
3657 delete preset;
3658 preset = nullptr;
3659 }
3660 }
3661 }
3662 for (std::pair<std::string, std::vector<std::pair<std::string, Preset *>>> filament_preset : m_filament_name_to_presets) {
3663 for (std::pair<std::string, Preset*> printer_name_preset : filament_preset.second) {
3664 Preset *preset = printer_name_preset.second;
3665 if (preset) {
3666 delete preset;
3667 preset = nullptr;
3668 }
3669 }
3670 }
3671
3672 // Delete the Temp folder
3673 boost::filesystem::path temp_folder(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp");
3674 if (boost::filesystem::exists(temp_folder)) boost::filesystem::remove_all(temp_folder);
3675}
#define PRESET_USER_DIR
Definition Preset.hpp:32
std::unordered_map< std::string, Preset * > m_printer_presets
Definition CreatePresetsDialog.hpp:298
std::unordered_map< std::string, std::vector< std::pair< std::string, Preset * > > > m_filament_name_to_presets
Definition CreatePresetsDialog.hpp:301
std::unordered_map< std::string, std::vector< Preset * > > m_process_presets
Definition CreatePresetsDialog.hpp:300
std::unordered_map< std::string, std::vector< Preset * > > m_filament_presets
Definition CreatePresetsDialog.hpp:299
const std::string & data_dir()
Definition utils.cpp:365
@ Preset
Definition calib.hpp:39

References Slic3r::data_dir(), m_filament_name_to_presets, m_filament_presets, m_printer_presets, m_process_presets, and PRESET_USER_DIR.

Here is the call graph for this function:

Member Function Documentation

◆ archive_filament_bundle_to_file()

ExportConfigsDialog::ExportCase Slic3r::GUI::ExportConfigsDialog::archive_filament_bundle_to_file ( const wxString & path)
private
4144{
4145 std::string export_path = initial_file_path(path, "");
4146 if (export_path.empty() || "initial_failed" == export_path) return ExportCase::EXPORT_CANCEL;
4147 BOOST_LOG_TRIVIAL(info) << "Export filament preset bundle";
4148
4149 for (std::pair<::CheckBox *, std::string> checkbox_filament_name : m_printer_name) {
4150 if (checkbox_filament_name.first->GetValue()) {
4151 std::string filament_name = checkbox_filament_name.second;
4152
4153 json bundle_structure;
4154 NetworkAgent *agent = wxGetApp().getAgent();
4155 std::string clock = get_curr_timestmp();
4156 if (agent) {
4157 bundle_structure["version"] = agent->get_version();
4158 bundle_structure["bundle_id"] = agent->get_user_id() + "_" + filament_name + "_" + clock;
4159 } else {
4160 bundle_structure["version"] = "";
4161 bundle_structure["bundle_id"] = "offline_" + filament_name + "_" + clock;
4162 }
4163 bundle_structure["bundle_type"] = "filament config bundle";
4164 bundle_structure["filament_name"] = filament_name;
4165 std::unordered_map<std::string, json> vendor_structure;
4166
4167 mz_zip_archive zip_archive;
4168 mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + filament_name + ".orca_filament");
4169 if (MZ_FALSE == status) {
4170 BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive";
4172 }
4173
4174 std::unordered_map<std::string, std::vector<std::pair<std::string, Preset *>>>::iterator iter = m_filament_name_to_presets.find(filament_name);
4175 if (m_filament_name_to_presets.end() == iter) {
4176 BOOST_LOG_TRIVIAL(info) << "Filament name do not find, filament name:" << filament_name;
4177 continue;
4178 }
4179 std::set<std::pair<std::string, std::string>> vendor_to_filament_name;
4180 for (std::pair<std::string, Preset *> printer_name_to_preset : iter->second) {
4181 std::string printer_vendor = printer_name_to_preset.first;
4182 if (printer_vendor.empty()) continue;
4183 Preset * filament_preset = printer_name_to_preset.second;
4184 if (vendor_to_filament_name.find(std::make_pair(printer_vendor, filament_preset->name)) != vendor_to_filament_name.end()) continue;
4185 vendor_to_filament_name.insert(std::make_pair(printer_vendor, filament_preset->name));
4186 std::string preset_path = boost::filesystem::path(filament_preset->file).make_preferred().string();
4187 if (preset_path.empty()) {
4188 BOOST_LOG_TRIVIAL(info) << "Export printer preset: " << filament_preset->name << " skip because of the preset file path is empty.";
4189 continue;
4190 }
4191 // Add a file to the ZIP file
4192 std::string file_name = printer_vendor + "/" + filament_preset->name + ".json";
4193 status = mz_zip_writer_add_file(&zip_archive, file_name.c_str(), encode_path(preset_path.c_str()).c_str(), NULL, 0, MZ_DEFAULT_COMPRESSION);
4194 // status = mz_zip_writer_add_mem(&zip_archive, ("printer/" + printer_preset->name + ".json").c_str(), json_contents, strlen(json_contents), MZ_DEFAULT_COMPRESSION);
4195 if (MZ_FALSE == status) {
4196 BOOST_LOG_TRIVIAL(info) << filament_preset->name << " Failed to add file to ZIP archive";
4197 mz_zip_writer_end(&zip_archive);
4199 }
4200 std::unordered_map<std::string, json>::iterator iter = vendor_structure.find(printer_vendor);
4201 if (vendor_structure.end() == iter) {
4202 json j = json::array();
4203 j.push_back(file_name);
4204 vendor_structure[printer_vendor] = j;
4205 } else {
4206 iter->second.push_back(file_name);
4207 }
4208 BOOST_LOG_TRIVIAL(info) << "Filament preset json add successful: " << filament_preset->name;
4209 }
4210
4211 for (const auto& vendor_name_to_json : vendor_structure) {
4212 json j;
4213 std::string printer_vendor = vendor_name_to_json.first;
4214 j["vendor"] = printer_vendor;
4215 j["filament_path"] = vendor_name_to_json.second;
4216 bundle_structure["printer_vendor"].push_back(j);
4217 }
4218
4219 std::string bundle_structure_str = bundle_structure.dump();
4220 status = mz_zip_writer_add_mem(&zip_archive, BUNDLE_STRUCTURE_JSON_NAME, bundle_structure_str.data(), bundle_structure_str.size(), MZ_DEFAULT_COMPRESSION);
4221 if (MZ_FALSE == status) {
4222 BOOST_LOG_TRIVIAL(info) << " Failed to add file: " << BUNDLE_STRUCTURE_JSON_NAME;
4223 mz_zip_writer_end(&zip_archive);
4225 }
4226 BOOST_LOG_TRIVIAL(info) << " Success to add file: " << BUNDLE_STRUCTURE_JSON_NAME;
4227
4228 // Complete writing of ZIP file
4229 ExportCase save_result = save_zip_archive_to_file(zip_archive);
4230 if (ExportCase::CASE_COUNT != save_result) return save_result;
4231 }
4232 }
4233 BOOST_LOG_TRIVIAL(info) << "ZIP archive created successfully";
4234
4236}
#define BUNDLE_STRUCTURE_JSON_NAME
Definition PresetBundle.hpp:32
ExportCase
Definition CreatePresetsDialog.hpp:260
ExportCase save_zip_archive_to_file(mz_zip_archive &zip_archive)
Definition CreatePresetsDialog.cpp:3894
int initial_zip_archive(mz_zip_archive &zip_archive, const std::string &file_path)
Definition CreatePresetsDialog.cpp:3882
std::vector< std::pair<::CheckBox *, std::string > > m_printer_name
Definition CreatePresetsDialog.hpp:297
std::string initial_file_path(const wxString &path, const std::string &sub_file_path)
Definition CreatePresetsDialog.cpp:3755
static std::string get_curr_timestmp()
Definition CreatePresetsDialog.cpp:341
std::string encode_path(const char *src)
Definition utils.cpp:1382
nlohmann::json json
Definition AssembleList.cpp:42

References ADD_BUNDLE_STRUCTURE_FAIL, ADD_FILE_FAIL, BUNDLE_STRUCTURE_JSON_NAME, CASE_COUNT, Slic3r::encode_path(), EXPORT_CANCEL, EXPORT_SUCCESS, Slic3r::Preset::file, Slic3r::GUI::get_curr_timestmp(), Slic3r::NetworkAgent::get_user_id(), Slic3r::NetworkAgent::get_version(), initial_file_path(), initial_zip_archive(), INITIALIZE_FAIL, m_filament_name_to_presets, m_printer_name, Slic3r::Preset::name, and save_zip_archive_to_file().

Referenced by create_dialog_buttons().

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

◆ archive_filament_preset_to_file()

ExportConfigsDialog::ExportCase Slic3r::GUI::ExportConfigsDialog::archive_filament_preset_to_file ( const wxString & path)
private
4270{
4271 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "start exprot filament presets";
4272 std::string export_file = "Filament presets.zip";
4273 export_file = initial_file_name(path, export_file);
4274 if (export_file.empty() || "initial_failed" == export_file) return ExportCase::EXPORT_CANCEL;
4275
4276 std::vector<std::pair<std::string, std::string>> config_paths;
4277
4278 std::set<std::string> filament_presets;
4279 for (std::pair<::CheckBox *, std::string> checkbox_preset : m_printer_name) {
4280 if (checkbox_preset.first->GetValue()) {
4281 std::string filament_name = checkbox_preset.second;
4282
4283 std::unordered_map<std::string, std::vector<std::pair<std::string, Preset *>>>::iterator iter = m_filament_name_to_presets.find(filament_name);
4284 if (m_filament_name_to_presets.end() == iter) {
4285 BOOST_LOG_TRIVIAL(info) << "Filament name do not find, filament name:" << filament_name;
4286 continue;
4287 }
4288 for (std::pair<std::string, Preset*> printer_name_preset : iter->second) {
4289 Preset * filament_preset = printer_name_preset.second;
4290 if (filament_presets.find(filament_preset->name) != filament_presets.end()) continue;
4291 filament_presets.insert(filament_preset->name);
4292 std::string preset_path = boost::filesystem::path(filament_preset->file).make_preferred().string();
4293 if (preset_path.empty()) {
4294 BOOST_LOG_TRIVIAL(info) << "Export filament preset: " << filament_preset->name << " skip because of the filament file path is empty.";
4295 continue;
4296 }
4297
4298 std::string preset_name = filament_preset->name + ".json";
4299 config_paths.push_back(std::make_pair(preset_name, preset_path));
4300 }
4301 }
4302 }
4303
4304 ExportCase save_result = save_presets_to_zip(export_file, config_paths);
4305 if (ExportCase::CASE_COUNT != save_result) return save_result;
4306
4307 BOOST_LOG_TRIVIAL(info) << "ZIP archive created successfully";
4308
4310}
std::string initial_file_name(const wxString &path, const std::string file_name)
Definition CreatePresetsDialog.cpp:3768
ExportCase save_presets_to_zip(const std::string &export_file, const std::vector< std::pair< std::string, std::string > > &config_paths)
Definition CreatePresetsDialog.cpp:3910

References CASE_COUNT, EXPORT_CANCEL, EXPORT_SUCCESS, Slic3r::Preset::file, initial_file_name(), m_filament_name_to_presets, m_printer_name, Slic3r::Preset::name, and save_presets_to_zip().

Referenced by create_dialog_buttons().

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

◆ archive_preset_bundle_to_file()

ExportConfigsDialog::ExportCase Slic3r::GUI::ExportConfigsDialog::archive_preset_bundle_to_file ( const wxString & path,
bool include_bed_assets )
private
4018{
4019 std::string export_path = initial_file_path(path, "");
4020 if (export_path.empty() || "initial_failed" == export_path) return ExportCase::EXPORT_CANCEL;
4021 BOOST_LOG_TRIVIAL(info) << "Export printer preset bundle";
4022
4023 for (std::pair<::CheckBox *, Preset *> checkbox_preset : m_preset) {
4024 if (checkbox_preset.first->GetValue()) {
4025 Preset *printer_preset = checkbox_preset.second;
4026 std::string printer_preset_name_ = printer_preset->name;
4027
4028 json bundle_structure;
4029 NetworkAgent *agent = wxGetApp().getAgent();
4030 std::string clock = get_curr_timestmp();
4031 if (agent) {
4032 bundle_structure["version"] = agent->get_version();
4033 bundle_structure["bundle_id"] = agent->get_user_id() + "_" + printer_preset_name_ + "_" + clock;
4034 } else {
4035 bundle_structure["version"] = "";
4036 bundle_structure["bundle_id"] = "offline_" + printer_preset_name_ + "_" + clock;
4037 }
4038 bundle_structure["bundle_type"] = "printer config bundle";
4039 bundle_structure["printer_preset_name"] = printer_preset_name_;
4040 json printer_config = json::array();
4041 json filament_configs = json::array();
4042 json process_configs = json::array();
4043
4044 mz_zip_archive zip_archive;
4045 mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + printer_preset->name + ".orca_printer");
4046 if (MZ_FALSE == status) {
4047 BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive";
4049 }
4050
4051 boost::filesystem::path printer_file_path = boost::filesystem::path(printer_preset->file);
4052 std::string preset_path = printer_file_path.make_preferred().string();
4053 if (preset_path.empty()) {
4054 BOOST_LOG_TRIVIAL(info) << "Export printer preset: " << printer_preset->name << " skip because of the preset file path is empty.";
4055 continue;
4056 }
4057
4058 // Add a file to the ZIP file
4059 std::string printer_config_file_name = "printer/" + printer_file_path.filename().string();
4060 status = mz_zip_writer_add_file(&zip_archive, printer_config_file_name.c_str(), encode_path(preset_path.c_str()).c_str(), NULL, 0, MZ_DEFAULT_COMPRESSION);
4061 //status = mz_zip_writer_add_mem(&zip_archive, ("printer/" + printer_preset->name + ".json").c_str(), json_contents, strlen(json_contents), MZ_DEFAULT_COMPRESSION);
4062 if (MZ_FALSE == status) {
4063 BOOST_LOG_TRIVIAL(info) << printer_preset->name << " Failed to add file to ZIP archive";
4064 mz_zip_writer_end(&zip_archive);
4066 }
4067 printer_config.push_back(printer_config_file_name);
4068 BOOST_LOG_TRIVIAL(info) << "Printer preset json add successful: " << printer_preset->name;
4069
4070 const std::string printer_preset_name = printer_preset->name;
4071 std::unordered_map<std::string, std::vector<Preset *>>::iterator iter = m_filament_presets.find(printer_preset_name);
4072 if (m_filament_presets.end() != iter) {
4073 for (Preset *preset : iter->second) {
4074 boost::filesystem::path filament_file_path = boost::filesystem::path(preset->file);
4075 std::string filament_preset_path = filament_file_path.make_preferred().string();
4076 if (filament_preset_path.empty()) {
4077 BOOST_LOG_TRIVIAL(info) << "Export filament preset: " << preset->name << " skip because of the preset file path is empty.";
4078 continue;
4079 }
4080
4081 std::string filament_config_file_name = "filament/" + filament_file_path.filename().string();
4082 status = mz_zip_writer_add_file(&zip_archive, filament_config_file_name.c_str(), encode_path(filament_preset_path.c_str()).c_str(), NULL, 0, MZ_DEFAULT_COMPRESSION);
4083 if (MZ_FALSE == status) {
4084 BOOST_LOG_TRIVIAL(info) << preset->name << " Failed to add file to ZIP archive";
4085 mz_zip_writer_end(&zip_archive);
4087 }
4088 filament_configs.push_back(filament_config_file_name);
4089 BOOST_LOG_TRIVIAL(info) << "Filament preset json add successful.";
4090 }
4091 }
4092
4093 iter = m_process_presets.find(printer_preset_name);
4094 if (m_process_presets.end() != iter) {
4095 for (Preset *preset : iter->second) {
4096 boost::filesystem::path process_file_path = boost::filesystem::path(preset->file);
4097 std::string process_preset_path = process_file_path.make_preferred().string();
4098 if (process_preset_path.empty()) {
4099 BOOST_LOG_TRIVIAL(info) << "Export process preset: " << preset->name << " skip because of the preset file path is empty.";
4100 continue;
4101 }
4102
4103 std::string process_config_file_name = "process/" + process_file_path.filename().string();
4104 status = mz_zip_writer_add_file(&zip_archive, process_config_file_name.c_str(), encode_path(process_preset_path.c_str()).c_str(), NULL, 0, MZ_DEFAULT_COMPRESSION);
4105 if (MZ_FALSE == status) {
4106 BOOST_LOG_TRIVIAL(info) << preset->name << " Failed to add file to ZIP archive";
4107 mz_zip_writer_end(&zip_archive);
4109 }
4110 process_configs.push_back(process_config_file_name);
4111 BOOST_LOG_TRIVIAL(info) << "Process preset json add successful: ";
4112 }
4113 }
4114
4115 bundle_structure["printer_config"] = printer_config;
4116 bundle_structure["filament_config"] = filament_configs;
4117 bundle_structure["process_config"] = process_configs;
4118
4119 if (include_bed_assets &&
4120 !append_printer_bed_assets(zip_archive, printer_preset->config, bundle_structure, printer_config_file_name, 0)) {
4121 mz_zip_writer_end(&zip_archive);
4123 }
4124
4125 std::string bundle_structure_str = bundle_structure.dump();
4126 status = mz_zip_writer_add_mem(&zip_archive, BUNDLE_STRUCTURE_JSON_NAME, bundle_structure_str.data(), bundle_structure_str.size(), MZ_DEFAULT_COMPRESSION);
4127 if (MZ_FALSE == status) {
4128 BOOST_LOG_TRIVIAL(info) << " Failed to add file: " << BUNDLE_STRUCTURE_JSON_NAME;
4129 mz_zip_writer_end(&zip_archive);
4131 }
4132 BOOST_LOG_TRIVIAL(info) << " Success to add file: " << BUNDLE_STRUCTURE_JSON_NAME;
4133
4134 ExportCase save_result = save_zip_archive_to_file(zip_archive);
4135 if (ExportCase::CASE_COUNT != save_result) return save_result;
4136 }
4137 }
4138 BOOST_LOG_TRIVIAL(info) << "ZIP archive created successfully";
4139
4141}
std::vector< std::pair<::CheckBox *, Preset * > > m_preset
Definition CreatePresetsDialog.hpp:296
static DynamicPrintConfig & printer_config()
Definition GUI_ObjectList.cpp:131
bool append_printer_bed_assets(mz_zip_archive &zip, const DynamicPrintConfig &config, json &bundle_structure, const std::string &printer_config_entry, int printer_index)
Definition PresetBundle.cpp:2310

References ADD_BUNDLE_STRUCTURE_FAIL, ADD_FILE_FAIL, Slic3r::append_printer_bed_assets(), BUNDLE_STRUCTURE_JSON_NAME, CASE_COUNT, Slic3r::Preset::config, Slic3r::encode_path(), EXPORT_CANCEL, EXPORT_SUCCESS, Slic3r::Preset::file, Slic3r::GUI::get_curr_timestmp(), Slic3r::NetworkAgent::get_user_id(), Slic3r::NetworkAgent::get_version(), initial_file_path(), initial_zip_archive(), INITIALIZE_FAIL, m_filament_presets, m_preset, m_process_presets, Slic3r::Preset::name, Slic3r::GUI::printer_config(), and save_zip_archive_to_file().

Referenced by create_dialog_buttons().

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

◆ archive_printer_preset_to_file()

ExportConfigsDialog::ExportCase Slic3r::GUI::ExportConfigsDialog::archive_printer_preset_to_file ( const wxString & path)
private
4239{
4240 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "start exprot printer presets";
4241 std::string export_file = "Printer presets.zip";
4242 export_file = initial_file_name(path, export_file);
4243 if (export_file.empty() || "initial_failed" == export_file) return ExportCase::EXPORT_CANCEL;
4244
4245 std::vector<std::pair<std::string, std::string>> config_paths;
4246
4247 for (std::pair<::CheckBox *, Preset *> checkbox_preset : m_preset) {
4248 if (checkbox_preset.first->GetValue()) {
4249 Preset * printer_preset = checkbox_preset.second;
4250 std::string preset_path = boost::filesystem::path(printer_preset->file).make_preferred().string();
4251 if (preset_path.empty()) {
4252 BOOST_LOG_TRIVIAL(info) << "Export printer preset: " << printer_preset->name << " skip because of the preset file path is empty.";
4253 continue;
4254 }
4255 std::string preset_name = printer_preset->name + ".json";
4256 config_paths.push_back(std::make_pair(preset_name, preset_path));
4257 }
4258 }
4259
4260 ExportCase save_result = save_presets_to_zip(export_file, config_paths);
4261 if (ExportCase::CASE_COUNT != save_result) return save_result;
4262
4263 BOOST_LOG_TRIVIAL(info) << "ZIP archive created successfully";
4264
4266
4267}

References CASE_COUNT, EXPORT_CANCEL, EXPORT_SUCCESS, Slic3r::Preset::file, initial_file_name(), m_preset, Slic3r::Preset::name, and save_presets_to_zip().

Referenced by create_dialog_buttons().

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

◆ archive_process_preset_to_file()

ExportConfigsDialog::ExportCase Slic3r::GUI::ExportConfigsDialog::archive_process_preset_to_file ( const wxString & path)
private
4313{
4314 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "start exprot process presets";
4315 std::string export_file = "Process presets.zip";
4316 export_file = initial_file_name(path, export_file);
4317 if (export_file.empty() || "initial_failed" == export_file) return ExportCase::EXPORT_CANCEL;
4318
4319 std::vector<std::pair<std::string, std::string>> config_paths;
4320
4321 std::set<std::string> process_presets;
4322 for (std::pair<::CheckBox *, std::string> checkbox_preset : m_printer_name) {
4323 if (checkbox_preset.first->GetValue()) {
4324 std::string printer_name = checkbox_preset.second;
4325 std::unordered_map<std::string, std::vector<Preset *>>::iterator iter = m_process_presets.find(printer_name);
4326 if (m_process_presets.end() != iter) {
4327 for (Preset *process_preset : iter->second) {
4328 if (process_presets.find(process_preset->name) != process_presets.end()) continue;
4329 process_presets.insert(process_preset->name);
4330 std::string preset_path = boost::filesystem::path(process_preset->file).make_preferred().string();
4331 if (preset_path.empty()) {
4332 BOOST_LOG_TRIVIAL(info) << "Export process preset: " << process_preset->name << " skip because of the preset file path is empty.";
4333 continue;
4334 }
4335
4336 std::string preset_name = process_preset->name + ".json";
4337 config_paths.push_back(std::make_pair(preset_name, preset_path));
4338 }
4339 }
4340 }
4341 }
4342
4343 ExportCase save_result = save_presets_to_zip(export_file, config_paths);
4344 if (ExportCase::CASE_COUNT != save_result) return save_result;
4345
4346 BOOST_LOG_TRIVIAL(info) << "ZIP archive created successfully";
4347
4349}

References CASE_COUNT, EXPORT_CANCEL, EXPORT_SUCCESS, Slic3r::Preset::file, initial_file_name(), m_printer_name, m_process_presets, Slic3r::Preset::name, and save_presets_to_zip().

Referenced by create_dialog_buttons().

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

◆ create_dialog_buttons()

wxWindow * Slic3r::GUI::ExportConfigsDialog::create_dialog_buttons ( wxWindow * parent)
private
4352{
4353 auto dlg_btns = new DialogButtons(parent, {"OK", "Cancel"});
4354 dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
4355 if (!has_check_box_selected()) {
4356 MessageDialog dlg(this, _L("Please select at least one printer or filament."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
4357 wxOK | wxCENTRE);
4358 dlg.ShowModal();
4359 return;
4360 }
4361
4362 wxDirDialog dlg(this, _L("Choose a directory"), "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
4363 wxString path;
4364 if (dlg.ShowModal() == wxID_OK) path = dlg.GetPath();
4366 if (!path.IsEmpty()) {
4367 wxGetApp().app_config->update_config_dir(into_u8(path));
4368 wxGetApp().app_config->save();
4369 const wxString curr_radio_type = get_curr_radio_type(m_export_type_btns);
4370
4371 if (curr_radio_type == m_exprot_type.preset_bundle) {
4372 export_case = archive_preset_bundle_to_file(path, m_include_bed_assets->GetValue());
4373 } else if (curr_radio_type == m_exprot_type.filament_bundle) {
4374 export_case = archive_filament_bundle_to_file(path);
4375 } else if (curr_radio_type == m_exprot_type.printer_preset) {
4376 export_case = archive_printer_preset_to_file(path);
4377 } else if (curr_radio_type == m_exprot_type.filament_preset) {
4378 export_case = archive_filament_preset_to_file(path);
4379 } else if (curr_radio_type == m_exprot_type.process_preset) {
4380 export_case = archive_process_preset_to_file(path);
4381 }
4382 } else {
4383 return;
4384 }
4385 show_export_result(export_case);
4386 if (ExportCase::EXPORT_SUCCESS != export_case) return;
4387
4388 EndModal(wxID_OK);
4389 });
4390
4391 dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); });
4392
4393 return dlg_btns;
4394}
void EndModal(int retCode) override
Definition GUI_Utils.hpp:305
ExportCase archive_preset_bundle_to_file(const wxString &path, bool include_bed_assets)
Definition CreatePresetsDialog.cpp:4017
std::vector< std::pair< RadioBox *, wxString > > m_export_type_btns
Definition CreatePresetsDialog.hpp:295
::CheckBox * m_include_bed_assets
Definition CreatePresetsDialog.hpp:308
ExportCase archive_printer_preset_to_file(const wxString &path)
Definition CreatePresetsDialog.cpp:4238
ExportCase archive_process_preset_to_file(const wxString &path)
Definition CreatePresetsDialog.cpp:4312
bool has_check_box_selected()
Definition CreatePresetsDialog.cpp:3723
void show_export_result(const ExportCase &export_case)
Definition CreatePresetsDialog.cpp:3692
ExportCase archive_filament_bundle_to_file(const wxString &path)
Definition CreatePresetsDialog.cpp:4143
ExportCase archive_filament_preset_to_file(const wxString &path)
Definition CreatePresetsDialog.cpp:4269
#define SLIC3R_APP_FULL_NAME
Definition libslic3r.h:11
static wxString get_curr_radio_type(std::vector< std::pair< RadioBox *, wxString > > &radio_btns)
Definition CreatePresetsDialog.cpp:515
std::string into_u8(const wxString &str)
Definition GUI.cpp:549

References _L, archive_filament_bundle_to_file(), archive_filament_preset_to_file(), archive_preset_bundle_to_file(), archive_printer_preset_to_file(), archive_process_preset_to_file(), Slic3r::GUI::DPIDialog::EndModal(), EXPORT_CANCEL, EXPORT_SUCCESS, Slic3r::GUI::get_curr_radio_type(), Slic3r::GUI::DialogButtons::GetOK(), has_check_box_selected(), Slic3r::GUI::into_u8(), m_export_type_btns, m_exprot_type, m_include_bed_assets, show_export_result(), Slic3r::GUI::DPIAware< P >::ShowModal(), and SLIC3R_APP_FULL_NAME.

Referenced by ExportConfigsDialog().

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

◆ create_export_config_item()

wxBoxSizer * Slic3r::GUI::ExportConfigsDialog::create_export_config_item ( wxWindow * parent)
private
3816{
3817 wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
3818
3819 wxBoxSizer * optionSizer = new wxBoxSizer(wxVERTICAL);
3820 wxStaticText *static_serial_text = new wxStaticText(parent, wxID_ANY, _L("Presets"), wxDefaultPosition, wxDefaultSize);
3821 optionSizer->Add(static_serial_text, 0, wxEXPAND | wxALL, 0);
3822 optionSizer->SetMinSize(OPTION_SIZE);
3823 horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL, FromDIP(10));
3824
3825 wxBoxSizer *radioBoxSizer = new wxBoxSizer(wxVERTICAL);
3826
3827 radioBoxSizer->Add(create_radio_item(m_exprot_type.preset_bundle, parent, wxEmptyString, m_export_type_btns), 0, wxEXPAND | wxALL, 0);
3828 radioBoxSizer->Add(0, 0, 0, wxTOP, FromDIP(6));
3829 wxStaticText *static_export_printer_preset_bundle_text = new wxStaticText(parent, wxID_ANY, _L("Printer and all the filament and process presets that belongs to the printer.\n"
3830 "Can be shared with others."), wxDefaultPosition, wxDefaultSize);
3831 static_export_printer_preset_bundle_text->SetFont(Label::Body_12);
3832 static_export_printer_preset_bundle_text->SetForegroundColour(wxColour("#6B6B6B"));
3833 radioBoxSizer->Add(static_export_printer_preset_bundle_text, 0, wxEXPAND | wxLEFT, FromDIP(22));
3834 wxBoxSizer *include_bed_sizer = new wxBoxSizer(wxHORIZONTAL);
3835 m_include_bed_assets = new ::CheckBox(parent);
3836 m_include_bed_assets->SetValue(true);
3837 include_bed_sizer->Add(m_include_bed_assets, 0, wxALIGN_CENTER_VERTICAL, 0);
3838 m_include_bed_assets_label = new wxStaticText(parent, wxID_ANY, _L("Include custom bed texture and model"));
3840 m_include_bed_assets_label->SetForegroundColour(wxColour("#6B6B6B"));
3841 include_bed_sizer->Add(m_include_bed_assets_label, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(5));
3842 radioBoxSizer->Add(0, 0, 0, wxTOP, FromDIP(6));
3843 radioBoxSizer->Add(include_bed_sizer, 0, wxEXPAND | wxLEFT, FromDIP(22));
3845 radioBoxSizer->Add(create_radio_item(m_exprot_type.filament_bundle, parent, wxEmptyString, m_export_type_btns), 0, wxEXPAND | wxTOP, FromDIP(10));
3846 wxStaticText *static_export_filament_preset_bundle_text = new wxStaticText(parent, wxID_ANY, _L("User's filament preset set.\nCan be shared with others."),
3847 wxDefaultPosition, wxDefaultSize);
3848 static_export_filament_preset_bundle_text->SetFont(Label::Body_12);
3849 static_export_filament_preset_bundle_text->SetForegroundColour(wxColour("#6B6B6B"));
3850 radioBoxSizer->Add(static_export_filament_preset_bundle_text, 0, wxEXPAND | wxLEFT, FromDIP(22));
3851 radioBoxSizer->Add(create_radio_item(m_exprot_type.printer_preset, parent, wxEmptyString, m_export_type_btns), 0, wxEXPAND | wxTOP, FromDIP(10));
3852 radioBoxSizer->Add(create_radio_item(m_exprot_type.filament_preset, parent, wxEmptyString, m_export_type_btns), 0, wxEXPAND | wxTOP, FromDIP(10));
3853 radioBoxSizer->Add(create_radio_item(m_exprot_type.process_preset, parent, wxEmptyString, m_export_type_btns), 0, wxEXPAND | wxTOP, FromDIP(10));
3854 horizontal_sizer->Add(radioBoxSizer, 0, wxEXPAND | wxALL, FromDIP(10));
3855
3856 return horizontal_sizer;
3857}
#define OPTION_SIZE
Definition CreatePresetsDialog.cpp:80
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Body_12
Definition Label.hpp:55
wxBoxSizer * create_radio_item(wxString title, wxWindow *parent, wxString tooltip, std::vector< std::pair< RadioBox *, wxString > > &radiobox_list)
Definition CreatePresetsDialog.cpp:3859
void update_include_bed_assets_enabled()
Definition CreatePresetsDialog.cpp:3683
wxStaticText * m_include_bed_assets_label
Definition CreatePresetsDialog.hpp:309

References _L, Label::Body_12, create_radio_item(), m_export_type_btns, m_exprot_type, m_include_bed_assets, m_include_bed_assets_label, OPTION_SIZE, update_include_bed_assets_enabled(), and wxStaticText.

Referenced by ExportConfigsDialog().

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

◆ create_radio_item()

wxBoxSizer * Slic3r::GUI::ExportConfigsDialog::create_radio_item ( wxString title,
wxWindow * parent,
wxString tooltip,
std::vector< std::pair< RadioBox *, wxString > > & radiobox_list )
private
3860{
3861 wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
3862 RadioBox * radiobox = new RadioBox(parent);
3863 horizontal_sizer->Add(radiobox, 0, wxEXPAND | wxALL, 0);
3864 horizontal_sizer->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(5));
3865 radiobox_list.push_back(std::make_pair(radiobox, title));
3866 int btn_idx = radiobox_list.size() - 1;
3867 radiobox->Bind(wxEVT_LEFT_DOWN, [this, &radiobox_list, btn_idx](wxMouseEvent &e) {
3868 select_curr_radiobox(radiobox_list, btn_idx);
3869 });
3870
3871 wxStaticText *text = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize);
3872 text->Bind(wxEVT_LEFT_DOWN, [this, &radiobox_list, btn_idx](wxMouseEvent &e) {
3873 select_curr_radiobox(radiobox_list, btn_idx);
3874 });
3875 horizontal_sizer->Add(text, 0, wxEXPAND | wxLEFT, 0);
3876
3877 radiobox->SetToolTip(tooltip);
3878 text->SetToolTip(tooltip);
3879 return horizontal_sizer;
3880}
void select_curr_radiobox(std::vector< std::pair< RadioBox *, wxString > > &radiobox_list, int btn_idx)
Definition CreatePresetsDialog.cpp:3936
wxMouseEvent
Definition CameraPopup.cpp:47

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

Referenced by create_export_config_item().

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

◆ create_select_printer()

wxBoxSizer * Slic3r::GUI::ExportConfigsDialog::create_select_printer ( wxWindow * parent)
private
4397{
4398 wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxVERTICAL);
4399
4400 wxBoxSizer * optionSizer = new wxBoxSizer(wxVERTICAL);
4401 m_serial_text = new wxStaticText(parent, wxID_ANY, _L("Please select a preset type you want to export"), wxDefaultPosition, wxDefaultSize);
4402 optionSizer->Add(m_serial_text, 0, wxEXPAND | wxALL, 0);
4403 optionSizer->SetMinSize(OPTION_SIZE);
4404 horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL, FromDIP(10));
4405 m_scrolled_preset_window = new wxScrolledWindow(parent);
4406 m_scrolled_preset_window->SetScrollRate(5, FromDIP(20));
4407 m_scrolled_preset_window->SetBackgroundColour(*wxWHITE);
4408 m_scrolled_preset_window->SetMaxSize(wxSize(FromDIP(660), FromDIP(400)));
4409 m_scrolled_preset_window->SetSize(wxSize(FromDIP(660), FromDIP(400)));
4410 wxBoxSizer *scrolled_window = new wxBoxSizer(wxHORIZONTAL);
4411
4412 m_presets_window = new wxPanel(m_scrolled_preset_window, wxID_ANY);
4413 m_presets_window->SetBackgroundColour(*wxWHITE);
4414 wxBoxSizer *select_printer_sizer = new wxBoxSizer(wxVERTICAL);
4415
4416 m_preset_sizer = new wxGridSizer(3, FromDIP(5), FromDIP(5));
4417 select_printer_sizer->Add(m_preset_sizer, 0, wxEXPAND, FromDIP(5));
4418 m_presets_window->SetSizer(select_printer_sizer);
4419 scrolled_window->Add(m_presets_window, 0, wxEXPAND, 0);
4420 m_scrolled_preset_window->SetSizerAndFit(scrolled_window);
4421
4422 horizontal_sizer->Add(m_scrolled_preset_window, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(10));
4423
4424 return horizontal_sizer;
4425}
wxGridSizer * m_preset_sizer
Definition CreatePresetsDialog.hpp:305
wxScrolledWindow * m_scrolled_preset_window
Definition CreatePresetsDialog.hpp:304
wxPanel * m_presets_window
Definition CreatePresetsDialog.hpp:306
wxStaticText * m_serial_text
Definition CreatePresetsDialog.hpp:307

References _L, m_preset_sizer, m_presets_window, m_scrolled_preset_window, m_serial_text, OPTION_SIZE, and wxStaticText.

Referenced by ExportConfigsDialog().

Here is the caller graph for this function:

◆ data_init()

void Slic3r::GUI::ExportConfigsDialog::data_init ( )
private
4428{
4429 // Delete the Temp folder
4430 boost::filesystem::path folder(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp");
4431 if (boost::filesystem::exists(folder)) boost::filesystem::remove_all(folder);
4432
4433 boost::system::error_code ec;
4434 boost::filesystem::path user_folder(data_dir() + "/" + PRESET_USER_DIR);
4435 bool temp_folder_exist = true;
4436 if (!boost::filesystem::exists(user_folder)) {
4437 if (!boost::filesystem::create_directories(user_folder, ec)) {
4438 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " create directory failed: " << user_folder << " "<<ec.message();
4439 temp_folder_exist = false;
4440 }
4441 }
4442 boost::filesystem::path temp_folder(user_folder / "Temp");
4443 if (!boost::filesystem::exists(temp_folder)) {
4444 if (!boost::filesystem::create_directories(temp_folder, ec)) {
4445 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " create directory failed: " << temp_folder << " " << ec.message();
4446 temp_folder_exist = false;
4447 }
4448 }
4449 if (!temp_folder_exist) {
4450 MessageDialog dlg(this, _L("Failed to create temporary folder, please try Export Configs again."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
4451 dlg.ShowModal();
4452 EndModal(wxCANCEL);
4453 }
4454
4455 PresetBundle preset_bundle(*wxGetApp().preset_bundle);
4456
4457 const std::deque<Preset> & printer_presets = preset_bundle.printers.get_presets();
4458 for (const Preset &printer_preset : printer_presets) {
4459
4460 std::string preset_name = printer_preset.name;
4461 if (!printer_preset.is_visible || printer_preset.is_default || printer_preset.is_project_embedded) continue;
4462 if (preset_bundle.printers.select_preset_by_name(preset_name, true)) {
4463 preset_bundle.update_compatible(PresetSelectCompatibleType::Always);
4464
4465 const std::deque<Preset> &filament_presets = preset_bundle.filaments.get_presets();
4466 for (const Preset &filament_preset : filament_presets) {
4467 if (!filament_preset.is_user()) continue;
4468 if (filament_preset.is_compatible) {
4469 Preset *new_filament_preset = new Preset(filament_preset);
4470 m_filament_presets[preset_name].push_back(new_filament_preset);
4471 }
4472 }
4473
4474 const std::deque<Preset> &process_presets = preset_bundle.prints.get_presets();
4475 for (const Preset &process_preset : process_presets) {
4476 if (!process_preset.is_user()) continue;
4477 if (process_preset.is_compatible) {
4478 Preset *new_prpcess_preset = new Preset(process_preset);
4479 m_process_presets[preset_name].push_back(new_prpcess_preset);
4480 }
4481 }
4482
4483 Preset *new_printer_preset = new Preset(printer_preset);
4484 earse_preset_fields_for_safe(new_printer_preset);
4485 m_printer_presets[preset_name] = new_printer_preset;
4486 }
4487 }
4488 const std::deque<Preset> &filament_presets = preset_bundle.filaments.get_presets();
4489 for (const Preset &filament_preset : filament_presets) {
4490 if (!filament_preset.can_overwrite()) continue;
4491 Preset *new_filament_preset = new Preset(filament_preset);
4492 const Preset *base_filament_preset = preset_bundle.filaments.get_preset_base(*new_filament_preset);
4493
4494 if (base_filament_preset == nullptr) {
4495 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " Failed to find base preset";
4496 continue;
4497 }
4498 std::string filament_preset_name = base_filament_preset->name;
4499 std::string machine_name = get_machine_name(filament_preset_name);
4500 m_filament_name_to_presets[get_filament_name(filament_preset_name)].push_back(std::make_pair(get_vendor_name(machine_name), new_filament_preset));
4501 }
4502}
bool earse_preset_fields_for_safe(Preset *preset)
Definition CreatePresetsDialog.cpp:3735
const std::deque< Preset > & get_presets() const
Definition Preset.hpp:781
static std::string get_machine_name(const std::string &preset_name)
Definition CreatePresetsDialog.cpp:417
static std::string get_filament_name(std::string &preset_name)
Definition CreatePresetsDialog.cpp:427
static std::string get_vendor_name(std::string &preset_name)
Definition CreatePresetsDialog.cpp:461
PresetCollection & printer_presets(PresetBundle &bundle)
Definition PluginHostPresets.cpp:50
@ Always
Definition Preset.hpp:527

References _L, Slic3r::Always, Slic3r::data_dir(), earse_preset_fields_for_safe(), Slic3r::GUI::DPIDialog::EndModal(), Slic3r::PresetBundle::filaments, Slic3r::GUI::get_filament_name(), Slic3r::GUI::get_machine_name(), Slic3r::PresetCollection::get_preset_base(), Slic3r::PresetCollection::get_presets(), Slic3r::GUI::get_vendor_name(), m_filament_name_to_presets, m_filament_presets, m_printer_presets, m_process_presets, Slic3r::Preset::name, Slic3r::Preset, PRESET_USER_DIR, Slic3r::PresetBundle::printers, Slic3r::PresetBundle::prints, Slic3r::PresetCollection::select_preset_by_name(), Slic3r::GUI::DPIAware< P >::ShowModal(), SLIC3R_APP_FULL_NAME, and Slic3r::PresetBundle::update_compatible().

Referenced by ExportConfigsDialog().

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

◆ earse_preset_fields_for_safe()

bool Slic3r::GUI::ExportConfigsDialog::earse_preset_fields_for_safe ( Preset * preset)
private
3736{
3737 if (preset->type != Preset::Type::TYPE_PRINTER) return true;
3738
3739 boost::filesystem::path file_path(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp" + "/" + (preset->name + ".json"));
3740 preset->file = file_path.make_preferred().string();
3741
3742 DynamicPrintConfig &config = preset->config;
3743 config.erase("print_host");
3744 config.erase("print_host_webui");
3745 config.erase("printhost_apikey");
3746 config.erase("printhost_cafile");
3747 config.erase("printhost_user");
3748 config.erase("printhost_password");
3749 config.erase("printhost_port");
3750
3751 preset->save(nullptr);
3752 return true;
3753}
@ TYPE_PRINTER
Definition Preset.hpp:250

References Slic3r::Preset::config, Slic3r::data_dir(), Slic3r::DynamicConfig::erase(), Slic3r::Preset::file, Slic3r::Preset::name, PRESET_USER_DIR, Slic3r::Preset::save(), Slic3r::Preset::type, and Slic3r::Preset::TYPE_PRINTER.

Referenced by data_init().

Here is the call graph for this function:
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; }

◆ has_check_box_selected()

bool Slic3r::GUI::ExportConfigsDialog::has_check_box_selected ( )
private
3724{
3725 for (std::pair<::CheckBox *, Preset *> checkbox_preset : m_preset) {
3726 if (checkbox_preset.first->GetValue()) return true;
3727 }
3728 for (std::pair<::CheckBox *, std::string> checkbox_filament_name : m_printer_name) {
3729 if (checkbox_filament_name.first->GetValue()) return true;
3730 }
3731
3732 return false;
3733}

References m_preset, and m_printer_name.

Referenced by create_dialog_buttons().

Here is the caller graph for this function:

◆ initial_file_name()

std::string Slic3r::GUI::ExportConfigsDialog::initial_file_name ( const wxString & path,
const std::string file_name )
private
3769{
3770 std::string export_path = into_u8(path);
3771 boost::filesystem::path printer_export_path = (boost::filesystem::path(export_path) / file_name).make_preferred();
3772 if (boost::filesystem::exists(printer_export_path)) {
3773 MessageDialog dlg(this, wxString::Format(_L("The \'%s\' folder already exists in the current directory. Do you want to clear it and rebuild it\?\nIf not, a time suffix will be added, and you can modify the name after creation."), file_name), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
3774 int res = dlg.ShowModal();
3775 if (wxID_YES == res) {
3776 try {
3777 boost::filesystem::remove_all(printer_export_path);
3778 }
3779 catch(...) {
3780 MessageDialog dlg(this,
3781 wxString::Format(_L("The file: %s\nmay have been opened by another program.\nPlease close it and try again."),
3782 encode_path(printer_export_path.string().c_str())),
3783 wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
3784 dlg.ShowModal();
3785 return "initial_failed";
3786 }
3787 export_path = printer_export_path.string();
3788 } else if (wxID_NO == res) {
3789 export_path = printer_export_path.string();
3790 export_path = export_path.substr(0, export_path.find(".zip"));
3791 std::string export_path_with_time;
3792 boost::filesystem::path *printer_export_path_with_time = nullptr;
3793 do {
3794 if (printer_export_path_with_time) {
3795 delete printer_export_path_with_time;
3796 printer_export_path_with_time = nullptr;
3797 }
3798 export_path_with_time = export_path + " " + get_curr_time() + ".zip";
3799 printer_export_path_with_time = new boost::filesystem::path(export_path_with_time);
3800 } while (boost::filesystem::exists(*printer_export_path_with_time));
3801 export_path = export_path_with_time;
3802 if (printer_export_path_with_time) {
3803 delete printer_export_path_with_time;
3804 printer_export_path_with_time = nullptr;
3805 }
3806 } else {
3807 return "";
3808 }
3809 } else {
3810 export_path = printer_export_path.string();
3811 }
3812 return export_path;
3813}
static std::string get_curr_time(const char *format="%Y_%m_%d_%H_%M_%S")
Definition CreatePresetsDialog.cpp:327

References _L, Slic3r::encode_path(), Slic3r::GUI::get_curr_time(), Slic3r::GUI::into_u8(), Slic3r::GUI::DPIAware< P >::ShowModal(), and SLIC3R_APP_FULL_NAME.

Referenced by archive_filament_preset_to_file(), archive_printer_preset_to_file(), and archive_process_preset_to_file().

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

◆ initial_file_path()

std::string Slic3r::GUI::ExportConfigsDialog::initial_file_path ( const wxString & path,
const std::string & sub_file_path )
private
3756{
3757 std::string export_path = into_u8(path);
3758 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "initial file path and path is:" << export_path << " and sub path is: " << sub_file_path;
3759 boost::filesystem::path printer_export_path = (boost::filesystem::path(export_path) / sub_file_path).make_preferred();
3760 if (!boost::filesystem::exists(printer_export_path)) {
3761 boost::filesystem::create_directories(printer_export_path);
3762 export_path = printer_export_path.string();
3763 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Same path exists, delete and rebuild, and path is: " << export_path;
3764 }
3765 return export_path;
3766}

References Slic3r::GUI::into_u8().

Referenced by archive_filament_bundle_to_file(), and archive_preset_bundle_to_file().

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

◆ initial_zip_archive()

mz_bool Slic3r::GUI::ExportConfigsDialog::initial_zip_archive ( mz_zip_archive & zip_archive,
const std::string & file_path )
private
3883{
3884 mz_zip_zero_struct(&zip_archive);
3885 mz_bool status;
3886
3887 // Initialize the ZIP file to write to the structure, using memory storage
3888
3889 std::string export_dir = encode_path(file_path.c_str());
3890 status = mz_zip_writer_init_file(&zip_archive, export_dir.c_str(), 0);
3891 return status;
3892}

References Slic3r::encode_path().

Referenced by archive_filament_bundle_to_file(), archive_preset_bundle_to_file(), and save_presets_to_zip().

Here is the call graph for this function:
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::ExportConfigsDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprivatevirtual

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

3677 {
3679 m_include_bed_assets->Rescale();
3680 Layout();
3681}

References m_include_bed_assets.

◆ 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

◆ save_presets_to_zip()

ExportConfigsDialog::ExportCase Slic3r::GUI::ExportConfigsDialog::save_presets_to_zip ( const std::string & export_file,
const std::vector< std::pair< std::string, std::string > > & config_paths )
private
3911{
3912 mz_zip_archive zip_archive;
3913 mz_bool status = initial_zip_archive(zip_archive, export_file);
3914
3915 if (MZ_FALSE == status) {
3916 BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive";
3918 }
3919
3920 for (std::pair<std::string, std::string> config_path : config_paths) {
3921 std::string preset_name = config_path.first;
3922
3923 // Add a file to the ZIP file
3924 status = mz_zip_writer_add_file(&zip_archive, (preset_name).c_str(), encode_path(config_path.second.c_str()).c_str(), NULL, 0, MZ_DEFAULT_COMPRESSION);
3925 // status = mz_zip_writer_add_mem(&zip_archive, ("printer/" + printer_preset->name + ".json").c_str(), json_contents, strlen(json_contents), MZ_DEFAULT_COMPRESSION);
3926 if (MZ_FALSE == status) {
3927 BOOST_LOG_TRIVIAL(info) << preset_name << " Filament preset failed to add file to ZIP archive";
3928 mz_zip_writer_end(&zip_archive);
3930 }
3931 BOOST_LOG_TRIVIAL(info) << "Printer preset json add successful: " << preset_name;
3932 }
3933 return save_zip_archive_to_file(zip_archive);
3934}

References ADD_FILE_FAIL, Slic3r::encode_path(), initial_zip_archive(), INITIALIZE_FAIL, and save_zip_archive_to_file().

Referenced by archive_filament_preset_to_file(), archive_printer_preset_to_file(), and archive_process_preset_to_file().

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

◆ save_zip_archive_to_file()

ExportConfigsDialog::ExportCase Slic3r::GUI::ExportConfigsDialog::save_zip_archive_to_file ( mz_zip_archive & zip_archive)
private
3895{
3896 // Complete writing of ZIP file
3897 mz_bool status = mz_zip_writer_finalize_archive(&zip_archive);
3898 if (MZ_FALSE == status) {
3899 BOOST_LOG_TRIVIAL(info) << "Failed to finalize ZIP archive";
3900 mz_zip_writer_end(&zip_archive);
3902 }
3903
3904 // Release ZIP file to write structure and related resources
3905 mz_zip_writer_end(&zip_archive);
3906
3908}

References CASE_COUNT, and FINALIZE_FAIL.

Referenced by archive_filament_bundle_to_file(), archive_preset_bundle_to_file(), and save_presets_to_zip().

Here is the caller graph for this function:

◆ scale_factor()

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

◆ select_curr_radiobox()

void Slic3r::GUI::ExportConfigsDialog::select_curr_radiobox ( std::vector< std::pair< RadioBox *, wxString > > & radiobox_list,
int btn_idx )
private
3937{
3938 int len = radiobox_list.size();
3939 for (int i = 0; i < len; ++i) {
3940 if (i == btn_idx) {
3941 radiobox_list[i].first->SetValue(true);
3942 const wxString &export_type = radiobox_list[i].second;
3943 m_preset_sizer->Clear(true);
3944 m_printer_name.clear();
3945 m_preset.clear();
3946 PresetBundle *preset_bundle = wxGetApp().preset_bundle;
3947 this->Freeze();
3948 if (export_type == m_exprot_type.preset_bundle) {
3949 for (std::pair<std::string, Preset *> preset : m_printer_presets) {
3950 std::string preset_name = preset.first;
3951 //printer preset mast have user's filament or process preset or printer preset is user preset
3952 if (m_filament_presets.find(preset_name) == m_filament_presets.end() && m_process_presets.find(preset_name) == m_process_presets.end() && preset.second->is_system) continue;
3953 wxString printer_name = wxString::FromUTF8(preset_name);
3954 m_preset_sizer->Add(create_checkbox(m_presets_window, preset.second, printer_name, m_preset), 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, FromDIP(5));
3955 }
3956 m_serial_text->SetLabel(_L("Only display printers with changes to printer, filament, and process presets are displayed."));
3957 }else if (export_type == m_exprot_type.filament_bundle) {
3958 for (std::pair<std::string, std::vector<std::pair<std::string, Preset*>>> filament_name_to_preset : m_filament_name_to_presets) {
3959 if (filament_name_to_preset.second.empty()) continue;
3960 wxString filament_name = wxString::FromUTF8(filament_name_to_preset.first);
3961 m_preset_sizer->Add(create_checkbox(m_presets_window, filament_name, m_printer_name), 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, FromDIP(5));
3962 }
3963 m_serial_text->SetLabel(_L("Only display the filament names with changes to filament presets."));
3964 } else if (export_type == m_exprot_type.printer_preset) {
3965 for (std::pair<std::string, Preset *> preset : m_printer_presets) {
3966 if (preset.second->is_system) continue;
3967 wxString printer_name = wxString::FromUTF8(preset.first);
3968 m_preset_sizer->Add(create_checkbox(m_presets_window, preset.second, printer_name, m_preset), 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT,
3969 FromDIP(5));
3970 }
3971 m_serial_text->SetLabel(_L("Only printer names with user printer presets will be displayed, and each preset you choose will be exported as a ZIP archive."));
3972 } else if (export_type == m_exprot_type.filament_preset) {
3973 for (std::pair<std::string, std::vector<std::pair<std::string, Preset *>>> filament_name_to_preset : m_filament_name_to_presets) {
3974 if (filament_name_to_preset.second.empty()) continue;
3975 wxString filament_name = wxString::FromUTF8(filament_name_to_preset.first);
3976 m_preset_sizer->Add(create_checkbox(m_presets_window, filament_name, m_printer_name), 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, FromDIP(5));
3977 }
3978 m_serial_text->SetLabel(_L("Only the filament names with user filament presets will be displayed, \nand all user filament presets in each filament name you select will be exported as a ZIP archive."));
3979 } else if (export_type == m_exprot_type.process_preset) {
3980 for (std::pair<std::string, std::vector<Preset *>> presets : m_process_presets) {
3981 Preset * printer_preset = preset_bundle->printers.find_preset(presets.first, false);
3982 if (!printer_preset) continue;
3983 if (!printer_preset->is_system) continue;
3984 if (preset_bundle->printers.get_preset_base(*printer_preset) != printer_preset) continue;
3985 for (Preset *preset : presets.second) {
3986 if (!preset->is_system) {
3987 wxString printer_name = wxString::FromUTF8(presets.first);
3988 m_preset_sizer->Add(create_checkbox(m_presets_window, printer_name, m_printer_name), 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, FromDIP(5));
3989 break;
3990 }
3991 }
3992
3993 }
3994 m_serial_text->SetLabel(_L("Only printer names with changed process presets will be displayed, \nand all user process presets in each printer name you select will be exported as a ZIP archive."));
3995 }
3996 //m_presets_window->SetSizerAndFit(m_preset_sizer);
3997 m_presets_window->Layout();
3998 m_presets_window->Fit();
3999 int width = m_presets_window->GetSize().GetWidth();
4000 int height = m_presets_window->GetSize().GetHeight();
4001 m_scrolled_preset_window->SetMinSize(wxSize(std::min(1200, width), std::min(600, height)));
4002 m_scrolled_preset_window->SetMaxSize(wxSize(std::min(1200, width), std::min(600, height)));
4003 m_scrolled_preset_window->SetSize(wxSize(std::min(1200, width), std::min(600, height)));
4004 this->SetSizerAndFit(m_main_sizer);
4005 Layout();
4006 Fit();
4007 Refresh();
4009 this->Thaw();
4010 } else {
4011 radiobox_list[i].first->SetValue(false);
4012 }
4013 }
4015}
static wxBoxSizer * create_checkbox(wxWindow *parent, Preset *preset, wxString &preset_name, std::vector< std::pair<::CheckBox *, Preset * > > &preset_checkbox)
Definition CreatePresetsDialog.cpp:360
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 _L, Slic3r::GUI::adjust_dialog_in_screen(), Slic3r::GUI::create_checkbox(), Slic3r::PresetCollection::find_preset(), Slic3r::PresetCollection::get_preset_base(), Slic3r::Preset::is_system, m_exprot_type, m_filament_name_to_presets, m_filament_presets, m_main_sizer, m_preset, m_preset_sizer, m_presets_window, m_printer_name, m_printer_presets, m_process_presets, m_scrolled_preset_window, m_serial_text, Slic3r::PresetBundle::printers, and update_include_bed_assets_enabled().

Referenced by 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; }

◆ show_export_result()

void Slic3r::GUI::ExportConfigsDialog::show_export_result ( const ExportCase & export_case)
private
3693{
3694 MessageDialog *msg_dlg = nullptr;
3695 switch (export_case) {
3697 msg_dlg = new MessageDialog(this, _L("initialize fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
3698 break;
3700 msg_dlg = new MessageDialog(this, _L("add file fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
3701 break;
3703 msg_dlg = new MessageDialog(this, _L("add bundle structure file fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
3704 break;
3706 msg_dlg = new MessageDialog(this, _L("finalize fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
3707 break;
3709 msg_dlg = new MessageDialog(this, _L("open zip written fail"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
3710 break;
3712 msg_dlg = new MessageDialog(this, _L("Export successful"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxOK | wxCENTRE);
3713 break;
3714 }
3715
3716 if (msg_dlg) {
3717 msg_dlg->ShowModal();
3718 delete msg_dlg;
3719 msg_dlg = nullptr;
3720 }
3721}

References _L, ADD_BUNDLE_STRUCTURE_FAIL, ADD_FILE_FAIL, EXPORT_SUCCESS, FINALIZE_FAIL, INITIALIZE_FAIL, OPEN_ZIP_WRITTEN_FILE, Slic3r::GUI::DPIAware< P >::ShowModal(), and SLIC3R_APP_FULL_NAME.

Referenced by create_dialog_buttons().

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

◆ ShowModal()

◆ 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 }

◆ update_include_bed_assets_enabled()

void Slic3r::GUI::ExportConfigsDialog::update_include_bed_assets_enabled ( )
private
3684{
3685 const bool on = get_curr_radio_type(m_export_type_btns) == m_exprot_type.preset_bundle;
3687 m_include_bed_assets->Enable(on);
3689 m_include_bed_assets_label->Enable(on);
3690}

References Slic3r::GUI::get_curr_radio_type(), m_export_type_btns, m_exprot_type, m_include_bed_assets, and m_include_bed_assets_label.

Referenced by create_export_config_item(), and select_curr_radiobox().

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

Member Data Documentation

◆ m_can_rescale

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

◆ m_em_unit

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

◆ m_export_type_btns

std::vector<std::pair<RadioBox *, wxString> > Slic3r::GUI::ExportConfigsDialog::m_export_type_btns
private

◆ m_exprot_type

◆ m_filament_name_to_presets

std::unordered_map<std::string, std::vector<std::pair<std::string, Preset *> > > Slic3r::GUI::ExportConfigsDialog::m_filament_name_to_presets
private

◆ m_filament_presets

std::unordered_map<std::string, std::vector<Preset *> > Slic3r::GUI::ExportConfigsDialog::m_filament_presets
private

◆ m_force_rescale

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

◆ m_include_bed_assets

::CheckBox* Slic3r::GUI::ExportConfigsDialog::m_include_bed_assets = nullptr
private

◆ m_include_bed_assets_label

wxStaticText* Slic3r::GUI::ExportConfigsDialog::m_include_bed_assets_label = nullptr
private

◆ m_main_sizer

wxBoxSizer* Slic3r::GUI::ExportConfigsDialog::m_main_sizer = nullptr
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_preset

std::vector<std::pair<::CheckBox *, Preset *> > Slic3r::GUI::ExportConfigsDialog::m_preset
private

◆ m_preset_sizer

wxGridSizer* Slic3r::GUI::ExportConfigsDialog::m_preset_sizer = nullptr
private

◆ m_presets_window

wxPanel* Slic3r::GUI::ExportConfigsDialog::m_presets_window = nullptr
private

◆ m_prev_scale_factor

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

◆ m_printer_name

std::vector<std::pair<::CheckBox *, std::string> > Slic3r::GUI::ExportConfigsDialog::m_printer_name
private

◆ m_printer_presets

std::unordered_map<std::string, Preset *> Slic3r::GUI::ExportConfigsDialog::m_printer_presets
private

◆ m_process_presets

std::unordered_map<std::string, std::vector<Preset *> > Slic3r::GUI::ExportConfigsDialog::m_process_presets
private

◆ m_scale_factor

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

◆ m_scrolled_preset_window

wxScrolledWindow* Slic3r::GUI::ExportConfigsDialog::m_scrolled_preset_window = nullptr
private

◆ m_serial_text

wxStaticText* Slic3r::GUI::ExportConfigsDialog::m_serial_text = nullptr
private

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