mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-28 05:12:27 +00:00
ENH: [STUDIO-4047] Export presets dialog
Jira: 4047 Change-Id: I91c5b684784c6c3e31fa0ac53698976732f843cf
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@
|
||||
#include "Widgets/RadioBox.hpp"
|
||||
#include "Widgets/CheckBox.hpp"
|
||||
#include "Widgets/ComboBox.hpp"
|
||||
#include "miniz.h"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
@@ -100,8 +101,6 @@ protected:
|
||||
wxBoxSizer *create_hot_bed_svg_item(wxWindow *parent);
|
||||
wxBoxSizer *create_max_print_height_item(wxWindow *parent);
|
||||
wxBoxSizer *create_page1_btns_item(wxWindow *parent);
|
||||
void load_texture();
|
||||
void load_model_stl();
|
||||
//Improt Presets Page2
|
||||
void create_printer_page2(wxWindow *parent);
|
||||
wxBoxSizer *create_printer_preset_item(wxWindow *parent);
|
||||
@@ -123,6 +122,8 @@ protected:
|
||||
bool save_printable_area_config(Preset *preset);
|
||||
bool check_printable_area();
|
||||
bool validate_input_valid();
|
||||
void load_texture();
|
||||
void load_model_stl();
|
||||
wxArrayString printer_preset_sort_with_nozzle_diameter(const VendorProfile &vendor_profile, float nozzle_diameter);
|
||||
|
||||
wxBoxSizer *create_radio_item(wxString title, wxWindow *parent, wxString tooltip, std::vector<std::pair<RadioBox *, wxString>> &radiobox_list);
|
||||
@@ -201,16 +202,11 @@ public:
|
||||
~ExportConfigsDialog();//to do: delete preset
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
wxBoxSizer *create_txport_config_item(wxWindow* parent);
|
||||
wxBoxSizer *create_button_item(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);
|
||||
|
||||
|
||||
struct ExportType
|
||||
{
|
||||
wxString preset_bundle;
|
||||
wxString filament_bundle;
|
||||
wxString printer_preset;
|
||||
wxString filament_preset;
|
||||
wxString process_preset;
|
||||
@@ -219,30 +215,48 @@ protected:
|
||||
enum ExportCase {
|
||||
INITIALIZE_FAIL = 0,
|
||||
ADD_FILE_FAIL,
|
||||
ADD_BUNDLE_STRUCTURE_FAIL,
|
||||
FINALIZE_FAIL,
|
||||
OPEN_ZIP_WRITTEN_FILE,
|
||||
EXPORT_CANCEL,
|
||||
EXPORT_SUCCESS,
|
||||
CASE_COUNT,
|
||||
};
|
||||
|
||||
private:
|
||||
void data_init();
|
||||
void select_curr_radiobox(std::vector<std::pair<RadioBox *, wxString>> &radiobox_list, int btn_idx);
|
||||
ExportCase archive_preset_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 data_init();
|
||||
void select_curr_radiobox(std::vector<std::pair<RadioBox *, wxString>> &radiobox_list, int btn_idx);
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
void show_export_result(const ExportCase &export_case);
|
||||
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_txport_config_item(wxWindow *parent);
|
||||
wxBoxSizer *create_button_item(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);
|
||||
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);
|
||||
|
||||
private:
|
||||
std::vector<std::pair<RadioBox *, wxString>> m_export_type_btns;
|
||||
std::vector<std::pair<CheckBox *, Preset *>> m_preset;
|
||||
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::vector<std::pair<CheckBox *, Preset *>> m_preset;//for printer preset bundle,printer preset, process preset export
|
||||
std::vector<std::pair<CheckBox *, std::string>> m_printer_name;//for filament and peocess preset export, collaborate with m_filament_name_to_presets
|
||||
std::unordered_map<std::string, Preset *> m_printer_presets;//first: printer name, second: printer presets have same printer name
|
||||
std::unordered_map<std::string, std::vector<Preset *>> m_filament_presets;//first: printer name, second: filament presets have same printer name
|
||||
std::unordered_map<std::string, std::vector<Preset *>> m_process_presets;//first: printer name, second: filament presets have same printer name
|
||||
std::unordered_map<std::string, std::vector<std::pair<std::string, Preset *>>> m_filament_name_to_presets;//first: filament name, second presets have same filament name and printer name in vector
|
||||
ExportType m_exprot_type;
|
||||
wxGridSizer * m_preset_sizer = nullptr;
|
||||
wxWindow * m_presets_window = nullptr;
|
||||
Button * m_button_ok = nullptr;
|
||||
Button * m_button_cancel = nullptr;
|
||||
wxStaticText * m_serial_text = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -3173,7 +3173,7 @@ void MainFrame::load_config_file()
|
||||
// return;
|
||||
wxFileDialog dlg(this, _L("Select profile to load:"),
|
||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
||||
"config.json", "Config files (*.json)|*.json", wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
|
||||
"config.json", "Config files (*.json;*.zip;*.bbscfg;*.bbsflmt)|*.json;*.zip;*.bbscfg;*.bbsflmt", wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
|
||||
wxArrayString files;
|
||||
if (dlg.ShowModal() != wxID_OK)
|
||||
return;
|
||||
|
||||
@@ -565,50 +565,10 @@ Sidebar::Sidebar(Plater *parent)
|
||||
wxGetApp().run_wizard(ConfigWizard::RR_USER, ConfigWizard::SP_PRINTERS);
|
||||
});
|
||||
|
||||
StateColor create_printer_bg_col(std::pair<wxColour, int>(wxColour(219, 253, 231), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Normal));
|
||||
|
||||
StateColor create_printer_fg_col(std::pair<wxColour, int>(wxColour(107, 107, 106), StateColor::Pressed),
|
||||
std::pair<wxColour, int>(wxColour(107, 107, 106), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(107, 107, 106), StateColor::Normal));
|
||||
|
||||
StateColor create_printer_bd_col(std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Pressed), std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(172, 172, 172), StateColor::Normal));
|
||||
|
||||
auto create_printer_preset_btn = new Button(p->m_panel_printer_title, _L("Create Printer"));
|
||||
create_printer_preset_btn->SetFont(Label::Body_10);
|
||||
create_printer_preset_btn->SetPaddingSize(wxSize(FromDIP(8), FromDIP(3)));
|
||||
create_printer_preset_btn->SetCornerRadius(FromDIP(8));
|
||||
create_printer_preset_btn->SetBackgroundColor(create_printer_bg_col);
|
||||
create_printer_preset_btn->SetBorderColor(create_printer_bd_col);
|
||||
create_printer_preset_btn->SetTextColor(create_printer_fg_col);
|
||||
create_printer_preset_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
|
||||
//CreateFilamentPresetDialog dlg(p->m_panel_printer_title);
|
||||
CreatePrinterPresetDialog dlg(p->m_panel_printer_title);
|
||||
int res = dlg.ShowModal();
|
||||
if (wxID_OK == res) {
|
||||
wxGetApp().mainframe->update_side_preset_ui();
|
||||
update_all_preset_comboboxes();
|
||||
Tab *printer_tab = wxGetApp().get_tab(Preset::TYPE_PRINTER);
|
||||
if (printer_tab) {
|
||||
printer_tab->load_current_preset();
|
||||
printer_tab->update();
|
||||
}
|
||||
CreatePresetSuccessfulDialog success_dlg(p->m_panel_filament_title, SuccessType::PRINTER);
|
||||
int res = success_dlg.ShowModal();
|
||||
if (res == wxID_OK) {
|
||||
p->editing_filament = -1;
|
||||
if (p->combo_printer->switch_to_tab())
|
||||
p->editing_filament = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
wxBoxSizer* h_sizer_title = new wxBoxSizer(wxHORIZONTAL);
|
||||
h_sizer_title->Add(p->m_printer_icon, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, em);
|
||||
h_sizer_title->Add(p->m_text_printer_settings, 0, wxALIGN_CENTER);
|
||||
h_sizer_title->AddStretchSpacer();
|
||||
h_sizer_title->Add(create_printer_preset_btn, 0, wxRIGHT | wxALIGN_CENTER, FromDIP(10));
|
||||
h_sizer_title->Add(p->m_printer_setting, 0, wxALIGN_CENTER);
|
||||
h_sizer_title->Add(15 * em / 10, 0, 0, 0, 0);
|
||||
h_sizer_title->SetMinSize(-1, 3 * em);
|
||||
@@ -1045,7 +1005,29 @@ Sidebar::Sidebar(Plater *parent)
|
||||
|
||||
Sidebar::~Sidebar() {}
|
||||
|
||||
void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filament_idx) {
|
||||
void Sidebar::create_printer_preset()
|
||||
{
|
||||
CreatePrinterPresetDialog dlg(p->m_panel_printer_title);
|
||||
int res = dlg.ShowModal();
|
||||
if (wxID_OK == res) {
|
||||
wxGetApp().mainframe->update_side_preset_ui();
|
||||
update_all_preset_comboboxes();
|
||||
Tab *printer_tab = wxGetApp().get_tab(Preset::TYPE_PRINTER);
|
||||
if (printer_tab) {
|
||||
printer_tab->load_current_preset();
|
||||
printer_tab->update();
|
||||
}
|
||||
CreatePresetSuccessfulDialog success_dlg(p->m_panel_filament_title, SuccessType::PRINTER);
|
||||
int res = success_dlg.ShowModal();
|
||||
if (res == wxID_OK) {
|
||||
p->editing_filament = -1;
|
||||
if (p->combo_printer->switch_to_tab()) p->editing_filament = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filament_idx)
|
||||
{
|
||||
*combo = new PlaterPresetComboBox(p->m_panel_filament_content, Slic3r::Preset::TYPE_FILAMENT);
|
||||
(*combo)->set_filament_idx(filament_idx);
|
||||
|
||||
@@ -5867,6 +5849,12 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||
// So, use GetSelection() from event parameter
|
||||
int selection = evt.GetSelection();
|
||||
|
||||
auto marker = reinterpret_cast<size_t>(combo->GetClientData(selection));
|
||||
if (PresetComboBox::LabelItemType::LABEL_ITEM_WIZARD_ADD_PRINTERS == marker) {
|
||||
sidebar->create_printer_preset();
|
||||
return;
|
||||
}
|
||||
|
||||
auto idx = combo->get_filament_idx();
|
||||
|
||||
// BBS:Save the plate parameters before switching
|
||||
|
||||
@@ -111,6 +111,7 @@ public:
|
||||
Sidebar &operator=(const Sidebar &) = delete;
|
||||
~Sidebar();
|
||||
|
||||
void create_printer_preset();
|
||||
void init_filament_combo(PlaterPresetComboBox **combo, const int filament_idx);
|
||||
void remove_unused_filament_combos(const size_t current_extruder_count);
|
||||
void update_all_preset_comboboxes();
|
||||
|
||||
@@ -749,6 +749,10 @@ void PlaterPresetComboBox::OnSelect(wxCommandEvent &evt)
|
||||
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
||||
if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) {
|
||||
this->SetSelection(m_last_selected);
|
||||
if (LABEL_ITEM_WIZARD_ADD_PRINTERS == marker) {
|
||||
evt.Skip();
|
||||
return;
|
||||
}
|
||||
evt.StopPropagation();
|
||||
if (marker == LABEL_ITEM_MARKER)
|
||||
return;
|
||||
@@ -1082,8 +1086,10 @@ void PlaterPresetComboBox::update()
|
||||
set_label_marker(Append(separator(L("Add/Remove filaments")), *bmp), LABEL_ITEM_WIZARD_FILAMENTS);
|
||||
else if (m_type == Preset::TYPE_SLA_MATERIAL)
|
||||
set_label_marker(Append(separator(L("Add/Remove materials")), *bmp), LABEL_ITEM_WIZARD_MATERIALS);
|
||||
else
|
||||
set_label_marker(Append(separator(L("Add/Remove printers")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
|
||||
else {
|
||||
set_label_marker(Append(separator(L("Select/Remove printers(system presets)")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
|
||||
set_label_marker(Append(separator(L("Create printer")), *bmp), LABEL_ITEM_WIZARD_ADD_PRINTERS);
|
||||
}
|
||||
}
|
||||
|
||||
update_selection();
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
LABEL_ITEM_WIZARD_PRINTERS,
|
||||
LABEL_ITEM_WIZARD_FILAMENTS,
|
||||
LABEL_ITEM_WIZARD_MATERIALS,
|
||||
LABEL_ITEM_WIZARD_ADD_PRINTERS,
|
||||
|
||||
LABEL_ITEM_MAX,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user