diff options
Diffstat (limited to 'src/slic3r/GUI/Tab.hpp')
-rw-r--r-- | src/slic3r/GUI/Tab.hpp | 176 |
1 files changed, 109 insertions, 67 deletions
diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index e2b00dc40..927787933 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -33,15 +33,19 @@ #include "Event.hpp" #include "wxExtensions.hpp" #include "ConfigManipulation.hpp" +#include "OptionsGroup.hpp" +#include "libslic3r/Preset.hpp" namespace Slic3r { namespace GUI { +class TabPresetComboBox; +class OG_CustomCtrl; // Single Tab page containing a{ vsizer } of{ optgroups } // package Slic3r::GUI::Tab::Page; using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>; -class Page : public wxScrolledWindow +class Page// : public wxScrolledWindow { wxWindow* m_parent; wxString m_title; @@ -49,26 +53,12 @@ class Page : public wxScrolledWindow wxBoxSizer* m_vsizer; bool m_show = true; public: - Page(wxWindow* parent, const wxString title, const int iconID, const std::vector<ScalableBitmap>& mode_bmp_cache) : - m_parent(parent), - m_title(title), - m_iconID(iconID), - m_mode_bitmap_cache(mode_bmp_cache) - { - Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); - m_vsizer = new wxBoxSizer(wxVERTICAL); - m_item_color = &wxGetApp().get_label_clr_default(); - SetSizer(m_vsizer); - } + Page(wxWindow* parent, const wxString& title, int iconID); ~Page() {} bool m_is_modified_values{ false }; bool m_is_nonsys_values{ true }; - // Delayed layout after resizing the main window. - bool layout_valid = false; - const std::vector<ScalableBitmap>& m_mode_bitmap_cache; - public: std::vector <ConfigOptionsGroupShp> m_optgroups; DynamicPrintConfig* m_config; @@ -79,8 +69,12 @@ public: size_t iconID() const { return m_iconID; } void set_config(DynamicPrintConfig* config_in) { m_config = config_in; } void reload_config(); - void update_visibility(ConfigOptionMode mode); + void update_visibility(ConfigOptionMode mode, bool update_contolls_visibility); + void activate(ConfigOptionMode mode, std::function<void()> throw_if_canceled); + void clear(); void msw_rescale(); + void sys_color_changed(); + void refresh(); Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; bool set_value(const t_config_option_key& opt_key, const boost::any& value); ConfigOptionsGroupShp new_optgroup(const wxString& title, int noncommon_label_width = -1); @@ -104,10 +98,6 @@ protected: }; -wxDECLARE_EVENT(EVT_TAB_VALUE_CHANGED, wxCommandEvent); -wxDECLARE_EVENT(EVT_TAB_PRESETS_CHANGED, SimpleEvent); - - using PageShp = std::shared_ptr<Page>; class Tab: public wxPanel { @@ -120,16 +110,21 @@ protected: Preset::Type m_type; std::string m_name; const wxString m_title; - PresetBitmapComboBox* m_presets_choice; + TabPresetComboBox* m_presets_choice; + ScalableButton* m_search_btn; ScalableButton* m_btn_save_preset; ScalableButton* m_btn_delete_preset; + ScalableButton* m_btn_edit_ph_printer {nullptr}; ScalableButton* m_btn_hide_incompatible_presets; wxBoxSizer* m_hsizer; wxBoxSizer* m_left_sizer; wxTreeCtrl* m_treectrl; wxImageList* m_icons; - ModeSizer* m_mode_sizer; + wxScrolledWindow* m_page_view {nullptr}; + wxBoxSizer* m_page_sizer {nullptr}; + + ModeSizer* m_mode_sizer; struct PresetDependencies { Preset::Type type = Preset::TYPE_INVALID; @@ -137,8 +132,8 @@ protected: ScalableButton *btn = nullptr; std::string key_list; // "compatible_printers" std::string key_condition; - std::string dialog_title; - std::string dialog_label; + wxString dialog_title; + wxString dialog_label; }; PresetDependencies m_compatible_printers; PresetDependencies m_compatible_prints; @@ -169,7 +164,6 @@ protected: std::vector<ScalableButton*> m_scaled_buttons = {}; std::vector<ScalableBitmap*> m_scaled_bitmaps = {}; std::vector<ScalableBitmap> m_scaled_icons_list = {}; - std::vector<ScalableBitmap> m_mode_bitmap_cache = {}; // Colors for ui "decoration" wxColour m_sys_label_clr; @@ -197,8 +191,10 @@ protected: int m_icon_count; std::map<std::string, size_t> m_icon_index; // Map from an icon file name to its index + std::map<wxString, std::string> m_category_icon; // Map from a category name to an icon file name std::vector<PageShp> m_pages; - bool m_disable_tree_sel_changed_event; + Page* m_active_page {nullptr}; + bool m_disable_tree_sel_changed_event {false}; bool m_show_incompatible_presets; std::vector<Preset::Type> m_dependent_tabs; @@ -212,8 +208,6 @@ protected: bool m_is_nonsys_values{ true }; bool m_postpone_update_ui {false}; - size_t m_selected_preset_item{ 0 }; - void set_type(); int m_em_unit; @@ -221,17 +215,38 @@ protected: bool m_completed { false }; ConfigOptionMode m_mode = comExpert; // to correct first Tab update_visibility() set mode to Expert + struct Highlighter + { + void set_timer_owner(wxEvtHandler* owner, int timerid = wxID_ANY); + void init(std::pair<OG_CustomCtrl*, bool*>); + void blink(); + void invalidate(); + + private: + OG_CustomCtrl* m_custom_ctrl {nullptr}; + bool* m_show_blink_ptr{nullptr}; + int m_blink_counter {0}; + wxTimer m_timer; + } + m_highlighter; + + DynamicPrintConfig m_cache_config; + + + bool m_page_switch_running = false; + bool m_page_switch_planned = false; + public: PresetBundle* m_preset_bundle; bool m_show_btn_incompatible_presets = false; PresetCollection* m_presets; DynamicPrintConfig* m_config; - ogStaticText* m_parent_preset_description_line; + ogStaticText* m_parent_preset_description_line = nullptr; ScalableButton* m_detach_preset_btn = nullptr; - // map of option name -> wxStaticText (colored label, associated with option) + // map of option name -> wxColour (color of the colored label, associated with option) // Used for options which don't have corresponded field - std::map<std::string, wxStaticText*> m_colored_Labels; + std::map<std::string, wxColour> m_colored_Label_colors; // Counter for the updating (because of an update() function can have a recursive behavior): // 1. increase value from the very beginning of an update() function @@ -261,12 +276,17 @@ public: void update_ui_items_related_on_parent_preset(const Preset* selected_preset_parent); void load_current_preset(); void rebuild_page_tree(); - void update_page_tree_visibility(); - // Select a new preset, possibly delete the current one. - void select_preset(std::string preset_name = "", bool delete_current = false); + void update_btns_enabling(); + void update_preset_choice(); + // Select a new preset, possibly delete the current one. + void select_preset(std::string preset_name = "", bool delete_current = false, const std::string& last_selected_ph_printer_name = ""); bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = ""); bool may_switch_to_SLA_preset(); + virtual void clear_pages(); + virtual void update_description_lines(); + virtual void activate_selected_page(std::function<void()> throw_if_canceled); + void OnTreeSelChange(wxTreeEvent& event); void OnKeyDown(wxKeyEvent& event); @@ -276,6 +296,7 @@ public: void update_show_hide_incompatible_button(); void update_ui_from_settings(); void update_labels_colour(); + void decorate(); void update_changed_ui(); void get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page); void update_changed_tree_ui(); @@ -284,11 +305,13 @@ public: void on_roll_back_value(const bool to_sys = false); PageShp add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages = false); + static wxString translate_category(const wxString& title, Preset::Type preset_type); virtual void OnActivate(); virtual void on_preset_loaded() {} virtual void build() = 0; virtual void update() = 0; + virtual void toggle_options() = 0; virtual void init_options_list(); void load_initial_data(); void update_dirty(); @@ -298,25 +321,36 @@ public: void update_mode(); void update_visibility(); virtual void msw_rescale(); + virtual void sys_color_changed(); Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; - bool set_value(const t_config_option_key& opt_key, const boost::any& value); - wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText); + std::pair<OG_CustomCtrl*, bool*> get_custom_ctrl_with_blinking_ptr(const t_config_option_key& opt_key, int opt_index = -1); + + Field* get_field(const t_config_option_key &opt_key, Page** selected_page, int opt_index = -1); + void toggle_option(const std::string& opt_key, bool toggle, int opt_index = -1); + wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText, wxString text = wxEmptyString); bool current_preset_is_dirty(); DynamicPrintConfig* get_config() { return m_config; } PresetCollection* get_presets() { return m_presets; } - size_t get_selected_preset_item() { return m_selected_preset_item; } void on_value_change(const std::string& opt_key, const boost::any& value); void update_wiping_button_visibility(); + void activate_option(const std::string& opt_key, const wxString& category); + void apply_searcher(); + void cache_config_diff(const std::vector<std::string>& selected_options); + void apply_config_from_cache(); + + const std::map<wxString, std::string>& get_category_icon_map() { return m_category_icon; } protected: - void create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, widget_t widget); + void create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, const wxString& path, widget_t widget); wxSizer* compatible_widget_create(wxWindow* parent, PresetDependencies &deps); void compatible_widget_reload(PresetDependencies &deps); void load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value = false); + // return true if cancelled + bool tree_sel_change_delayed(); void on_presets_changed(); void build_preset_description_line(ConfigOptionsGroup* optgroup); void update_preset_description_line(); @@ -336,21 +370,25 @@ public: Tab(parent, _(L("Print Settings")), Slic3r::Preset::TYPE_PRINT) {} ~TabPrint() {} - ogStaticText* m_recommended_thin_wall_thickness_description_line = nullptr; - ogStaticText* m_top_bottom_shell_thickness_explanation = nullptr; - bool m_support_material_overhangs_queried = false; - void build() override; void reload_config() override; + void update_description_lines() override; + void toggle_options() override; void update() override; - void OnActivate() override; + void clear_pages() override; bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptFFF; } + +private: + ogStaticText* m_recommended_thin_wall_thickness_description_line = nullptr; + ogStaticText* m_top_bottom_shell_thickness_explanation = nullptr; + bool m_support_material_overhangs_queried = false; }; class TabFilament : public Tab { - ogStaticText* m_volumetric_speed_description_line; - ogStaticText* m_cooling_description_line; +private: + ogStaticText* m_volumetric_speed_description_line {nullptr}; + ogStaticText* m_cooling_description_line {nullptr}; void add_filament_overrides_page(); void update_filament_overrides_page(); @@ -365,32 +403,37 @@ public: void build() override; void reload_config() override; + void update_description_lines() override; + void toggle_options() override; void update() override; - void OnActivate() override; + void clear_pages() override; bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptFFF; } }; class TabPrinter : public Tab { +private: bool m_has_single_extruder_MM_page = false; bool m_use_silent_mode = false; void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key); bool m_rebuild_kinematics_page = false; + ogStaticText* m_machine_limits_description_line {nullptr}; + void update_machine_limits_description(const MachineLimitsUsage usage); + + ogStaticText* m_fff_print_host_upload_description_line {nullptr}; + ogStaticText* m_sla_print_host_upload_description_line {nullptr}; std::vector<PageShp> m_pages_fff; std::vector<PageShp> m_pages_sla; - void build_printhost(ConfigOptionsGroup *optgroup); public: - wxButton* m_serial_test_btn = nullptr; - ScalableButton* m_print_host_test_btn = nullptr; - ScalableButton* m_printhost_browse_btn = nullptr; ScalableButton* m_reset_to_filament_color = nullptr; size_t m_extruders_count; size_t m_extruders_count_old = 0; size_t m_initial_extruders_count; size_t m_sys_extruders_count; + size_t m_cache_extruder_count = 0; PrinterTechnology m_printer_technology = ptFFF; @@ -400,22 +443,29 @@ public: ~TabPrinter() {} void build() override; + void build_print_host_upload_group(Page* page); void build_fff(); void build_sla(); + void reload_config() override; + void activate_selected_page(std::function<void()> throw_if_canceled) override; + void clear_pages() override; + void toggle_options() override; void update() override; void update_fff(); void update_sla(); void update_pages(); // update m_pages according to printer technology - void update_serial_ports(); void extruders_count_changed(size_t extruders_count); PageShp build_kinematics_page(); void build_unregular_pages(); void on_preset_loaded() override; void init_options_list() override; void msw_rescale() override; + void sys_color_changed() override; bool supports_printer_technology(const PrinterTechnology /* tech */) override { return true; } wxSizer* create_bed_shape_widget(wxWindow* parent); + void cache_extruder_cnt(); + void apply_extruder_cnt_from_cache(); }; class TabSLAMaterial : public Tab @@ -428,6 +478,7 @@ public: void build() override; void reload_config() override; + void toggle_options() override {}; void update() override; void init_options_list() override; bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptSLA; } @@ -440,27 +491,18 @@ public: // Tab(parent, _(L("Print Settings")), L("sla_print")) {} Tab(parent, _(L("Print Settings")), Slic3r::Preset::TYPE_SLA_PRINT) {} ~TabSLAPrint() {} + + ogStaticText* m_support_object_elevation_description_line = nullptr; + void build() override; void reload_config() override; + void update_description_lines() override; + void toggle_options() override; void update() override; -// void init_options_list() override; + void clear_pages() override; bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptSLA; } }; -class SavePresetWindow :public wxDialog -{ -public: - SavePresetWindow(wxWindow* parent) :wxDialog(parent, wxID_ANY, _(L("Save preset"))) {} - ~SavePresetWindow() {} - - std::string m_chosen_name; - wxComboBox* m_combo; - - void build(const wxString& title, const std::string& default_name, std::vector<std::string> &values); - void accept(); - std::string get_name() { return m_chosen_name; } -}; - } // GUI } // Slic3r |