OrcaSlicer/src/slic3r/GUI/CreatePresetsDialog.hpp
SoftFever 3cb573dcb9
Feature/merge 1.8.4 (#3827)
* FIX: the logic of buried points that were not buried

JIRA: none

Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com>
Change-Id: Id95174659c5fce7feba409eb5e14916608745fa4

* ci: update network module based on commit bc7ca98

Change-Id: I923526f0bf9ce5a288144fa1f9b0f2fc640f41b7

* Fix Firefox
Co-authored-by: hadess <hadess@hadess.net>

* FIX: cali: custom created filament from AMS displayed as incompatible

jira: new

remove the condition: is_system

Change-Id: Ib1366966bbdbe01bc9e2483d9914d270ebefa976

* FIX: duplicated items in comboBox at calibration completed page

jira: new

Change-Id: I4749a2206df16c438e0d3098e36274b2a20f313e

* ENH:update support for P1S plus

jira:[for p1s plus]

Change-Id: Id577d4e94e2162cb0045d261dfaa5f396ecded2f

* ENH: CLI: add mk information support

JIRA: no jira
Change-Id: Idd89b143d439de50d9f52eb8aec95b262d66875d

* ENH:calibration support p1p plus

jira:[plus]

Change-Id: Ia290d3a8a8b9adaac7a6ee26d9a8b5ea0c1b3aee

* FIX: add log for base_id and filament_id

github: #3087

Change-Id: Iebfbd0f224fce49f33fc81c71e6108f6e3abb5ff

* FIX: sync whole preset vendor directory

Change-Id: I191dbe979a87ff35d38cab1149b7975664344838
Jira: STUDIO-5534
(cherry picked from commit 628866608116336453804aa1217dd55db04d47ad)

* FIX: use t_utc for debug only

Change-Id: Ia05d8969d4de3dd38908980d6e17a3ebb11ca279
Github 3045

Change-Id: I77935df53bbf2772b1146e5c330c537165a3a2e6

* FIX:make sort_volumes right

Jira: STUDIO-5645
Change-Id: If324c9115bfaaf0c1b7b4be7c7ee96ba6b8ac890

* ENH:keep an unload logic

jira:[for unload]

Change-Id: Id30ec71ffa5b2dac89346ea47ca48a62479e3ab1

* FIX: several problems with mesh boolean

1. Cut with multiple volumes are OK now.
2. Close mesh boolean fail error with new object or open object
3. Fix wrong name and config of boolean resulting object

github: #3118
jira: none

Change-Id: If2c9dbfb36cbdfe4917a2371217923891bb7909c
(cherry picked from commit 982c0ecb92cf7c2b5ae5972ab900a6b10e7dda50)

* NEW:limit the length of project name

jira:[project name]

Change-Id: I955620f7073b3b7fda280d1118524f561d047751

* ENH:adjusting the warning level of timelpase

jira:[STUDIO-5662]

Change-Id: I4902b22d316f5e09a97a62c88b8a98e55c405434

* FIX: 3mf specification: change namespace form slic3rpe to BambuStudio

Jira: XXXX

Change-Id: Id705affc875ef23fdf2ac6d79f0cb0aafc4f7050

* NEW: Open MakerWorld With BambuStudio GetParam

JIRA: none
Change-Id: I0d65b364f1cd2d634a88882ab072c3e61ea89167
(cherry picked from commit 8eaf45e5359439a7c796fd79876c86775abcf48e)

* FIX: Filament issue generated when creating a printer

Jira: XXXX

Change-Id: I976770b69b47641bd54aa7a9c56fba7f58d1ab68
(cherry picked from commit ba42188b93c58b3954234d72acdd9769a68e3d3c)

* FIX: Blank page appears when editing presets

Jira: 5563

Change-Id: I4c49e05515b1beff55991e92f8079c4499c27eab
(cherry picked from commit e86517d290f4cd0765a230d811b0ddf2c9f34c17)

* FIX: context menu didn't update UI

jira: STUDIO-5691

Change-Id: Ia66b8623d832eba805aff5320941233a68ff258b

* FIX: crash of "filling bed"

"get_arrange_settings() const" gets trapped in infinite recursive calling.
Now we delete this function.

jira: STUDIO-5688
Change-Id: Ia39974734bb37b2a2f06b5bf78185f01be726872

* FIX: boolean hangs in the middle of color painting

Can't do splits in combine_mesh_fff, as do_boolean of mcut will split meshes.

jira: STUDIO-5693
Change-Id: Idddb7d20dd7ca386c39ddd3d87d9defc3136aa5d
(cherry picked from commit 6c67d015941458e37faaf0015b6509b5a0eadc0e)

* Fix: Fix a number of compilation problems

issues found when using gcc version 13.2.0 (GCC) in a Flatpak sandbox

github : https://github.com/bambulab/BambuStudio/issues/3074
github pull request: https://github.com/bambulab/BambuStudio/pull/3096

Change-Id: I08aeac593eb1ce7675894df72e8489200bae713d
(cherry picked from commit 069d133d66bfa682de4a860e379d5dc16b3d907c)

* fix: macos icns issue when icon was not attached

github pull request:https://github.com/bambulab/BambuStudio/pull/3116

Change-Id: I49072ad49f3af7669a6d307c791594ade210da50
(cherry picked from commit c977e5582e3a30ad16dd267810037423aad9a53c)

* FIX: Add flush_length for change_filament_gcode

Change-Id: I30f4b97d3d61c2a57f0e92f157cbd31c38aa7265
Jira: XXXX
(cherry picked from commit 92eb2bac977a0c4095b316cbbc6580fb5228b710)

* FIX: edit preset dialog can't close on mac

Jira: 5696

Change-Id: Ib33dfd07cc588ddd3805e3490a4d8c36dcd890ac

* ENH: add dev_ota_version in ssdp

JIRA: STUDIO-5740

Change-Id: Ic80e6d4b9bf82813fdc4a76604a3d36213d12b03
Signed-off-by: Stone Li <stone.li@bambulab.com>

* NEW:Adapt to multicolour and gradient colour

JIRA:xxxx
Change-Id: I8084cab603d5681cbcaf2d6f5e0d7ad5419cb2af

* NEW:Adaptation of semi transparent materials

JIRA: XXXX
Change-Id: Ie32d8ce67c37b85eb6d7d6594cb514a696307e68

* FIX: disable flush options if prime tower is unchecked

jira: STUDIO-5639

Change-Id: I25081584d430bc7d062e14bcc2cdbf7522cf9d99

* ENH: refine GetVersion for HMS query

JIRA: STUDIO-5763

Change-Id: Ia3ccc07d79cc0736eb12e9782da50211abb74772
Signed-off-by: Stone Li <stone.li@bambulab.com>

* FIX: Prefer old selection when sync AMS not compatible

Change-Id: I6b18db51887132a997cf78d70fff9a92e23bc44a
Jira: STUDIO-5416
(cherry picked from commit 077fae29823cf4f3071d408b1b40f55ee0cb33c6)

* FIX: The flushing was not auto-calc when sync ams list

JIRA: STUDIO-5551

1. flushing volume auto-calc when sync ams list
2. flushing volume takes the larger calculation value when filament has
   multi-colors

Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com>
Change-Id: I72e6f9780ea56103a44c2da6068440a4615c254d

* FIX:fixed invalid links

jira:[fixed link]

Change-Id: I036a38b6e8e94da762f93805bd7be706538771fe

* FIX: Prompt to delete problematic presets

Jira: XXXX

Change-Id: Ic43f7bb782794d7ab0b6acbffbb5d73e94f6ed73

* FIX:fixed incorrect HMS content

jira:[STUDIO-5818]

Change-Id: Ia2896d6f0ab1ffedbc850e54168acece8e47bdbb

* FIX:external transparent material display error

JIRA: STUDIO-5845
Change-Id: I0a4f05ac5d5c0ac49d85a704ee65a7221c5f1e1d

* FIX: [5846] Custom Filament Page show System Filament

Simultaneously solve: When downloading Preset from the cloud, the filament_id of the preset in m_preset is null.

Jira: 5846

Change-Id: I6ba1b46fe92e345614b6a4af3fffa87d81fa2456

* FIX:A1 and p1 series do not support custom materials

JIRA:XXXX
Change-Id: Ib0459273d1f9a7152a5563757204634a8d0cd6f5

* FIX: exception when comparing profiles

jira:[NEW]

Signed-off-by: XunZhangBambu <xun.zhang@bambulab.com>
Change-Id: I946b5fcd35f779d271df2b3de731fdcada5aab29
(cherry picked from commit 00e739570812e5c4be3e0f7702ce8c72c0f9e72b)

* FIX: hide_id_middle_string

Change-Id: I28f32ec526b443d31d7992971b80ab1cb737deb6
Github: STUDIO-5825

* ENH: modify some logs level

JIRA: STUDIO-5958

Change-Id: I5a8592dfb8ffa9a81952535cb30944f867aa0e22
Signed-off-by: Stone Li <stone.li@bambulab.com>

* NEW:build plate marker detect

Change-Id: I70f03efea688bb6ce71c3f5990bb3c50605ab184

* FIX: Studio UI Freeze when saving user preset

github: #3335

Change-Id: Idaf53f673a3e46408826c06bdde2c592395d358b

* update bbl plugin version

* fix build errors

* update bbl profiles

* update color

---------

Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com>
Signed-off-by: Stone Li <stone.li@bambulab.com>
Co-authored-by: Kunlong Ma <kunlong.ma@bambulab.com>
Co-authored-by: gerrit <gerrit@bambulab.com>
Co-authored-by: liz.li <liz.li@bambulab.com>
Co-authored-by: tao wang <tao.wang@bambulab.com>
Co-authored-by: lane.wei <lane.wei@bambulab.com>
Co-authored-by: maosheng.wei <maosheng.wei@bambulab.com>
Co-authored-by: chunmao.guo <chunmao.guo@bambulab.com>
Co-authored-by: zhou.xu <zhou.xu@bambulab.com>
Co-authored-by: Arthur <arthur.tang@bambulab.com>
Co-authored-by: Bastien Nocera <hadess@hadess.net>
Co-authored-by: zhimin.zeng <zhimin.zeng@bambulab.com>
Co-authored-by: hu.wang <hu.wang@bambulab.com>
Co-authored-by: Stone Li <stone.li@bambulab.com>
Co-authored-by: XunZhangBambu <xun.zhang@bambulab.com>
2024-01-26 20:18:10 +08:00

400 lines
No EOL
22 KiB
C++

#ifndef slic3r_CreatePresetsDialog_hpp_
#define slic3r_CreatePresetsDialog_hpp_
#include "libslic3r/Preset.hpp"
#include "wxExtensions.hpp"
#include "GUI_Utils.hpp"
#include "Widgets/Label.hpp"
#include "Widgets/TextInput.hpp"
#include "Widgets/Button.hpp"
#include "Widgets/RadioBox.hpp"
#include "Widgets/CheckBox.hpp"
#include "Widgets/ComboBox.hpp"
#include "miniz.h"
#include "ParamsDialog.hpp"
namespace Slic3r {
namespace GUI {
class CreateFilamentPresetDialog : public DPIDialog
{
public:
CreateFilamentPresetDialog(wxWindow *parent);
~CreateFilamentPresetDialog();
protected:
enum FilamentOptionType {
VENDOR = 0,
TYPE,
SERIAL,
FILAMENT_PRESET,
PRESET_FOR_PRINTER,
FILAMENT_NAME_COUNT
};
protected:
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();
wxBoxSizer *create_button_item();
private:
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);
private:
struct CreateType
{
wxString base_filament;
wxString base_filament_preset;
};
private:
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::set<std::string> m_visible_printers;
CreateType m_create_type;
Button * m_button_create = nullptr;
Button * m_button_cancel = nullptr;
ComboBox * m_filament_vendor_combobox = nullptr;
::CheckBox * m_can_not_find_vendor_checkbox = nullptr;
ComboBox * m_filament_type_combobox = nullptr;
ComboBox * m_exist_vendor_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;
};
class CreatePrinterPresetDialog : public DPIDialog
{
public:
CreatePrinterPresetDialog(wxWindow *parent);
~CreatePrinterPresetDialog();
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
/******************************************************** Control Construction *****************************************************/
wxBoxSizer *create_step_switch_item();
//Create Printer Page1
void create_printer_page1(wxWindow *parent);
wxBoxSizer *create_type_item(wxWindow *parent);
wxBoxSizer *create_printer_item(wxWindow *parent);
wxBoxSizer *create_nozzle_diameter_item(wxWindow *parent);
wxBoxSizer *create_bed_shape_item(wxWindow *parent);
wxBoxSizer *create_bed_size_item(wxWindow *parent);
wxBoxSizer *create_origin_item(wxWindow *parent);
wxBoxSizer *create_hot_bed_stl_item(wxWindow *parent);
wxBoxSizer *create_hot_bed_svg_item(wxWindow *parent);
wxBoxSizer *create_max_print_height_item(wxWindow *parent);
wxBoxSizer *create_page1_btns_item(wxWindow *parent);
//Improt Presets Page2
void create_printer_page2(wxWindow *parent);
wxBoxSizer *create_printer_preset_item(wxWindow *parent);
wxBoxSizer *create_presets_item(wxWindow *parent);
wxBoxSizer *create_presets_template_item(wxWindow *parent);
wxBoxSizer *create_page2_btns_item(wxWindow *parent);
void show_page1();
void show_page2();
/********************************************************** Data Interaction *******************************************************/
bool data_init();
void set_current_visible_printer();
void select_curr_radiobox(std::vector<std::pair<RadioBox *, wxString>> &radiobox_list, int btn_idx);
void select_all_preset_template(std::vector<std::pair<::CheckBox *, Preset *>> &preset_templates);
void deselect_all_preset_template(std::vector<std::pair<::CheckBox *, Preset *>> &preset_templates);
void update_presets_list(bool jast_template = false);
void on_preset_model_value_change(wxCommandEvent &e);
void clear_preset_combobox();
bool save_printable_area_config(Preset *preset);
bool check_printable_area();
bool validate_input_valid();
void load_texture();
void load_model_stl();
bool load_system_and_user_presets_with_curr_model(PresetBundle &temp_preset_bundle, bool just_template = false);
void generate_process_presets_data(std::vector<Preset const *> presets, std::string nozzle);
void update_preset_list_size();
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);
wxString curr_create_preset_type();
wxString curr_create_printer_type();
private:
struct CreatePrinterType
{
wxString create_printer;
wxString create_nozzle;
wxString base_template;
wxString base_curr_printer;
};
CreatePrinterType m_create_type;
std::vector<std::pair<RadioBox *, wxString>> m_create_type_btns;
std::vector<std::pair<RadioBox *, wxString>> m_create_presets_btns;
std::vector<std::pair<::CheckBox *, Preset *>> m_filament_preset;
std::vector<std::pair<::CheckBox *, Preset *>> m_process_preset;
std::unordered_map<std::string, std::shared_ptr<Preset>> m_printer_name_to_preset;
VendorProfile m_printer_preset_vendor_selected;
Slic3r::VendorProfile::PrinterModel m_printer_preset_model_selected;
bool rewritten = false;
Preset * m_printer_preset = nullptr;
wxStaticBitmap * m_step_1 = nullptr;
wxStaticBitmap * m_step_2 = nullptr;
Button * m_button_OK = nullptr;
Button * m_button_create = nullptr;
Button * m_button_page1_cancel = nullptr;
Button * m_button_page2_cancel = nullptr;
Button * m_button_page2_back = nullptr;
Button * m_button_bed_stl = nullptr;
Button * m_button_bed_svg = nullptr;
wxScrolledWindow * m_page1 = nullptr;
wxPanel * m_page2 = nullptr;
wxScrolledWindow * m_scrolled_preset_window = nullptr;
wxBoxSizer * m_scrooled_preset_sizer = nullptr;
ComboBox * m_select_vendor = nullptr;
ComboBox * m_select_model = nullptr;
ComboBox * m_select_printer = nullptr;
::CheckBox * m_can_not_find_vendor_combox = nullptr;
wxStaticText * m_can_not_find_vendor_text = nullptr;
wxTextCtrl * m_custom_vendor_text_ctrl = nullptr;
wxTextCtrl * m_custom_model_text_ctrl = nullptr;
ComboBox * m_nozzle_diameter = nullptr;
ComboBox * m_printer_vendor = nullptr;
ComboBox * m_printer_model = nullptr;
TextInput * m_bed_size_x_input = nullptr;
TextInput * m_bed_size_y_input = nullptr;
TextInput * m_bed_origin_x_input = nullptr;
TextInput * m_bed_origin_y_input = nullptr;
TextInput * m_print_height_input = nullptr;
wxGridSizer * m_filament_preset_template_sizer = nullptr;
wxGridSizer * m_process_preset_template_sizer = nullptr;
wxPanel * m_filament_preset_panel = nullptr;
wxPanel * m_process_preset_panel = nullptr;
wxPanel * m_preset_template_panel = nullptr;
wxBoxSizer * m_filament_sizer = nullptr;
wxPanel * m_printer_info_panel = nullptr;
wxBoxSizer * m_page1_sizer = nullptr;
wxBoxSizer * m_printer_info_sizer = nullptr;
wxBoxSizer * m_page2_sizer = nullptr;
wxStaticText * m_upload_stl_tip_text = nullptr;
wxStaticText * m_upload_svg_tip_text = nullptr;
std::string m_custom_texture;
std::string m_custom_model;
};
enum SuccessType {
PRINTER = 0,
FILAMENT
};
class CreatePresetSuccessfulDialog : public DPIDialog
{
public:
CreatePresetSuccessfulDialog(wxWindow *parent, const SuccessType &create_success_type);
~CreatePresetSuccessfulDialog();
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
private:
Button *m_button_ok = nullptr;
Button *m_button_cancel = nullptr;
};
class ExportConfigsDialog : public DPIDialog
{
public:
ExportConfigsDialog(wxWindow *parent);
~ExportConfigsDialog();//to do: delete preset
protected:
struct ExportType
{
wxString preset_bundle;
wxString filament_bundle;
wxString printer_preset;
wxString filament_preset;
wxString process_preset;
};
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);
void on_dpi_changed(const wxRect &suggested_rect) override;
void show_export_result(const ExportCase &export_case);
bool has_check_box_selected();
bool preset_is_not_compatible_bbl_printer(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);
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; // 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;
wxBoxSizer * m_main_sizer = nullptr;
wxScrolledWindow * m_scrolled_preset_window = nullptr;
wxGridSizer * m_preset_sizer = nullptr;
wxPanel * m_presets_window = nullptr;
Button * m_button_ok = nullptr;
Button * m_button_cancel = nullptr;
wxStaticText * m_serial_text = nullptr;
};
class CreatePresetForPrinterDialog : public DPIDialog
{
public:
CreatePresetForPrinterDialog(wxWindow *parent, std::string filament_type, std::string filament_id, std::string filament_vendor, std::string filament_name);
~CreatePresetForPrinterDialog();
private:
void on_dpi_changed(const wxRect &suggested_rect) override;
void get_visible_printer_and_compatible_filament_presets();
wxBoxSizer *create_selected_printer_preset_sizer();
wxBoxSizer *create_selected_filament_preset_sizer();
wxBoxSizer *create_button_sizer();
private:
std::string m_filament_id;
std::string m_filament_name;
std::string m_filament_vendor;
std::string m_filament_type;
std::shared_ptr<PresetBundle> m_preset_bundle;
std::string m_filamnt_type;
ComboBox * m_selected_printer = nullptr;
ComboBox * m_selected_filament = nullptr;
Button * m_ok_btn = nullptr;
Button * m_cancel_btn = nullptr;
std::unordered_map<wxString, std::shared_ptr<Preset>> filament_choice_to_filament_preset;
std::unordered_map<std::string, std::vector<std::shared_ptr<Preset>>> m_printer_compatible_filament_presets; // need be used when add presets
};
class EditFilamentPresetDialog;
class PresetTree
{
public:
PresetTree(EditFilamentPresetDialog *dialog);
wxPanel *get_preset_tree(std::pair<std::string, std::vector<std::shared_ptr<Preset>>> printer_and_presets);
private:
wxPanel *get_root_item(wxPanel *parent, const std::string &printer_name);
wxPanel *get_child_item(wxPanel *parent, std::shared_ptr<Preset> preset, std::string printer_name, int preset_index, bool is_last = false);
void delete_preset(std::string printer_name, int need_delete_preset_index);
void edit_preset(std::string printer_name, int need_edit_preset_index);
private:
EditFilamentPresetDialog * m_parent_dialog = nullptr;
std::pair<std::string, std::vector<std::shared_ptr<Preset>>> m_printer_and_presets;
};
class EditFilamentPresetDialog : public DPIDialog
{
public:
EditFilamentPresetDialog(wxWindow *parent, FilamentInfomation *filament_info);
~EditFilamentPresetDialog();
wxPanel *get_preset_tree_panel() { return m_preset_tree_panel; }
std::shared_ptr<Preset> get_need_edit_preset() { return m_need_edit_preset; }
void set_printer_name(const std::string &printer_name) { m_selected_printer = printer_name; }
void set_need_delete_preset_index(int need_delete_preset_index) { m_need_delete_preset_index = need_delete_preset_index; }
void set_need_edit_preset_index(int need_edit_preset_index) { m_need_edit_preset_index = need_edit_preset_index; }
void delete_preset();
void edit_preset();
private:
void on_dpi_changed(const wxRect &suggested_rect) override;
bool get_same_filament_id_presets(std::string filament_id);
void update_preset_tree();
wxBoxSizer *create_filament_basic_info();
wxBoxSizer *create_add_filament_btn();
wxBoxSizer *create_preset_tree_sizer();
wxBoxSizer *create_button_sizer();
private:
PresetTree * m_preset_tree_creater = nullptr;
std::string m_filament_id;
std::string m_filament_name;
std::string m_vendor_name;
std::string m_filament_type;
std::string m_filament_serial;
Button * m_add_filament_btn = nullptr;
Button * m_del_filament_btn = nullptr;
Button * m_ok_btn = nullptr;
wxBoxSizer * m_preset_tree_sizer = nullptr;
wxPanel * m_preset_tree_panel = nullptr;
wxScrolledWindow * m_preset_tree_window = nullptr;
wxBoxSizer * m_main_sizer = nullptr;
wxStaticText * m_note_text = nullptr;
int m_need_delete_preset_index = -1;
int m_need_edit_preset_index = -1;
std::shared_ptr<Preset> m_need_edit_preset;
std::string m_selected_printer = "";
std::unordered_map<std::string, std::vector<std::shared_ptr<Preset>>> m_printer_compatible_presets;
};
}
}
#endif