Files
OrcaSlicer/src/slic3r/GUI/Tab.hpp
T
SoftFever 6609ca0503 Make calls say whether they ask, and show Prepare after an agent's new project
Calls into the plater, object list and tabs now say in words whether they ask a
person or run without prompts, instead of passing bare true/false flags. An
agent's project_new now does what New Project does: it shows the Prepare tab and
tells plugins about the new project.
2026-11-26 01:04:13 +08:00

885 lines
38 KiB
C++

#ifndef slic3r_Tab_hpp_
#define slic3r_Tab_hpp_
// The "Expert" tab at the right of the main tabbed window.
//
// This file implements following packages:
// Slic3r::GUI::Tab;
// Slic3r::GUI::Tab::Print;
// Slic3r::GUI::Tab::Filament;
// Slic3r::GUI::Tab::Printer;
// Slic3r::GUI::Tab::Page
// - Option page: For example, the Slic3r::GUI::Tab::Print has option pages "Layers and perimeters", "Infill", "Skirt and brim" ...
// Slic3r::GUI::SavePresetWindow
// - Dialog to select a new preset name to store the configuration.
// Slic3r::GUI::Tab::Preset;
// - Single preset item: name, file is default or external.
#include "libslic3r/PrintConfig.hpp"
#include <cstddef>
#include "libslic3r/Config.hpp"
#include <functional>
#include "slic3r/GUI/Field.hpp"
#include <boost/any.hpp>
#include <string>
#include <wx/event.h>
#include <utility>
#include <wx/anybutton.h>
#include <wx/panel.h>
#include <wx/notebook.h>
#include <wx/listbook.h>
#include <wx/scrolwin.h>
#include <wx/sizer.h>
#include <wx/bmpcbox.h>
#include <wx/bmpbuttn.h>
#include <wx/string.h>
#include <wx/treectrl.h>
#include <wx/imaglist.h>
#include <map>
#include <vector>
#include <memory>
//#include "BedShapeDialog.hpp"
#include "wxExtensions.hpp"
#include "ConfigManipulation.hpp"
#include "OptionsGroup.hpp"
#include "OptionStateRegistry.hpp"
#include "Operations/Outcome.hpp"
#include "libslic3r/Preset.hpp"
//BBS: GUI refactor
#include "Notebook.hpp"
#include "ParamsPanel.hpp"
#include "Widgets/TextInput.hpp"
#include "Widgets/CheckBox.hpp" // ORCA
#include "Widgets/LabeledCheckBox.hpp" // ORCA
#include "Widgets/ComboBox.hpp"
class TabCtrl;
class ModeSwitchButton;
class SwitchButton;
class MultiSwitchButton;
namespace Slic3r {
class ModelConfig;
class ObjectBase;
namespace GUI {
class TabPresetComboBox;
class OG_CustomCtrl;
std::vector<InputShaperType> input_shaper_types_for_flavor(GCodeFlavor flavor);
// Single Tab page containing a{ vsizer } of{ optgroups }
// package Slic3r::GUI::Tab::Page;
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
class Page: public std::enable_shared_from_this<Page>// : public wxScrolledWindow
{
//BBS: GUI refactor
wxPanel* m_tab_owner;
wxWindow* m_parent;
wxString m_title;
size_t m_iconID;
wxBoxSizer* m_vsizer;
// BBS: new layout
wxStaticText* m_page_title;
bool m_show = true;
bool m_visibility_applied = false;
public:
//BBS: GUI refactor
Page(wxWindow* parent, const wxString& title, int iconID, wxPanel* tab_owner);
~Page() {}
bool m_is_modified_values{ false };
bool m_is_nonsys_values{ true };
// BBS
bool m_split_multi_line = false;
bool m_option_label_at_right = false;
public:
std::vector <ConfigOptionsGroupShp> m_optgroups;
DynamicPrintConfig* m_config;
wxBoxSizer* vsizer() const { return m_vsizer; }
wxWindow* parent() const { return m_parent; }
const wxString& title() const { return m_title; }
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, bool update_contolls_visibility);
void activate(ConfigOptionMode mode, std::function<void()> throw_if_canceled);
// Whether an option group has no controls yet.
bool build_pending() const;
// Builds the next option group that has no controls yet; true while some remain.
bool build_step(ConfigOptionMode mode);
// Whether the controls have not been shown or hidden for a mode since they were built.
bool visibility_pending() const { return !m_visibility_applied; }
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;
Line * get_line(const t_config_option_key &opt_key, int opt_index = -1);
bool set_value(const t_config_option_key& opt_key, const boost::any& value);
// BBS. Add is_extruder_og parameter.
ConfigOptionsGroupShp new_optgroup(const wxString& title, const wxString& icon = wxEmptyString, int noncommon_label_width = -1, bool is_extruder_og = false);
const ConfigOptionsGroupShp get_optgroup(const wxString& title) const;
bool set_item_colour(const wxColour *clr) {
if (m_item_color != clr) {
m_item_color = clr;
return true;
}
return false;
}
const wxColour get_item_colour() {
return *m_item_color;
}
bool get_show() const { return m_show; }
std::map<std::string, std::string> m_opt_id_map;
protected:
size_t next_group_to_build() const;
bool activate_group(size_t i, ConfigOptionMode mode, std::function<void()> throw_if_canceled);
// Color of TreeCtrlItem. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one.
const wxColour* m_item_color;
};
using PageShp = std::shared_ptr<Page>;
class Tab: public wxPanel
{
//BBS: GUI refactor
protected:
ParamsPanel* m_parent;
/*#ifdef __WXOSX__
wxPanel* m_tmp_panel;
int m_size_move = -1;
#endif // __WXOSX__*/
Preset::Type m_type;
std::string m_name;
const wxString m_title;
TabPresetComboBox* m_presets_choice { nullptr };
//BBS: GUI refactor
wxPanel* m_top_panel;
wxBoxSizer* m_main_sizer;
wxBoxSizer* m_top_sizer;
wxBoxSizer* m_top_left_sizer;
wxGridSizer* m_top_right_sizer;
wxBoxSizer* m_select_sizer;
wxBoxSizer* m_tree_sizer;
ScalableButton* m_btn_compare_preset;
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;
TabCtrl* m_tabctrl;
wxImageList* m_icons;
wxScrolledWindow* m_page_view {nullptr};
//wxBoxSizer* m_page_sizer {nullptr};
struct PresetDependencies {
Preset::Type type = Preset::TYPE_INVALID;
LabeledCheckBox* checkbox = nullptr;
Button *btn = nullptr;
std::string key_list; // "compatible_printers"
std::string key_condition;
wxString dialog_title;
wxString dialog_label;
};
PresetDependencies m_compatible_printers;
PresetDependencies m_compatible_prints;
/* Indicates, that default preset or preset inherited from default is selected
* This value is used for a options color updating
* (use green color only for options, which values are equal to system values)
*/
bool m_is_default_preset {false};
// just be used for edit filament dialog
bool m_just_edit{false};
ScalableButton* m_undo_btn;
ScalableButton* m_undo_to_sys_btn;
//ScalableButton* m_question_btn;
ScalableButton* m_btn_search;
StaticBox * m_search_item;
TextInput * m_search_input;
// Cached bitmaps.
// A "flag" icon to be displayned next to the preset name in the Tab's combo box.
ScalableBitmap m_bmp_show_incompatible_presets;
ScalableBitmap m_bmp_hide_incompatible_presets;
// Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field.
ScalableBitmap m_bmp_value_lock;
ScalableBitmap m_bmp_value_unlock;
ScalableBitmap m_bmp_white_bullet;
// The following bitmap points to either m_bmp_value_unlock or m_bmp_white_bullet, depending on whether the current preset has a parent preset.
ScalableBitmap *m_bmp_non_system;
// Bitmaps to be shown on the "Undo user changes" button next to each input field.
ScalableBitmap m_bmp_value_revert;
// Bitmaps to be shown on the "Undo user changes" button next to each input field.
ScalableBitmap m_bmp_edit_value;
std::vector<ScalableButton*> m_scaled_buttons = {};
std::vector<ScalableBitmap*> m_scaled_bitmaps = {};
std::vector<ScalableBitmap> m_scaled_icons_list = {};
// Colors for ui "decoration"
wxColour m_sys_label_clr;
wxColour m_modified_label_clr;
wxColour m_default_text_clr;
// Tooltip text for reset buttons (for whole options group)
wxString m_ttg_value_lock;
wxString m_ttg_value_unlock;
wxString m_ttg_white_bullet_ns;
// The following text points to either m_ttg_value_unlock or m_ttg_white_bullet_ns, depending on whether the current preset has a parent preset.
wxString *m_ttg_non_system;
// Tooltip text to be shown on the "Undo user changes" button next to each input field.
wxString m_ttg_white_bullet;
wxString m_ttg_value_revert;
// Tooltip text for reset buttons (for each option in group)
wxString m_tt_value_lock;
wxString m_tt_value_unlock;
// The following text points to either m_tt_value_unlock or m_ttg_white_bullet_ns, depending on whether the current preset has a parent preset.
wxString *m_tt_non_system;
// Tooltip text to be shown on the "Undo user changes" button next to each input field.
wxString m_tt_white_bullet;
wxString m_tt_value_revert;
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;
Page* m_active_page {nullptr};
bool m_disable_tree_sel_changed_event {false};
bool m_show_incompatible_presets;
int m_last_select_item = -1;
std::vector<Preset::Type> m_dependent_tabs;
enum OptStatus { osSystemValue = 1, osInitValue = 2 };
std::map<std::string, int> m_options_list;
std::map<std::string, int> m_all_extruder_options_status;
int m_opt_status_value = 0;
bool m_is_modified_values{ false };
bool m_is_nonsys_values{ true };
bool m_postpone_update_ui {false};
void set_type();
int m_em_unit;
// To avoid actions with no-completed Tab
bool m_completed { false };
ConfigOptionMode m_mode = comAdvanced; // to correct first Tab update_visibility() set mode to Advanced
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;
std::vector<std::string> m_cache_options;
bool m_page_switch_running = false;
bool m_page_switch_planned = false;
bool m_is_timelapse_wipe_tower_already_prompted = false;
public:
PresetBundle* m_preset_bundle;
bool m_show_btn_incompatible_presets = false;
PresetCollection* m_presets = nullptr;
DynamicPrintConfig* m_config;
ogStaticText* m_parent_preset_description_line = nullptr;
ScalableButton* m_detach_preset_btn = nullptr;
// 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, 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
// 2. decrease value at the end of an update() function
// 3. propagate changed configuration to the Plater when (m_update_cnt == 0) only
int m_update_cnt = 0;
ModeSwitchButton *m_mode_view = nullptr;
ScalableButton* m_mode_icon = nullptr; // ORCA m_static_title replacement
wxSizer * m_variant_sizer = nullptr;
MultiSwitchButton * m_extruder_switch = nullptr;
MultiSwitchButton * m_variant_combo = nullptr;
ScalableButton *m_extruder_sync = nullptr;
wxPanel * m_extruder_sync_box = nullptr;
// Orca: whether m_extruder_switch switches nozzle variants (it then offers sync between them).
// The printer tab also enables the switch for printers without variants, to choose the extruder
// its Extruder and Motion ability pages edit.
bool m_extruder_switch_variants = false;
std::vector<NozzleVolumeType> m_actual_nozzle_volumes;
public:
// BBS
Tab(ParamsPanel* parent, const wxString& title, Preset::Type type);
~Tab() {}
wxWindow* parent() const { return m_parent; }
wxString title() const { return m_title; }
std::string name() const { return m_presets->name(); }
Preset::Type type() const { return m_type; }
// The tab is already constructed.
bool completed() const { return m_completed; }
virtual bool supports_printer_technology(const PrinterTechnology tech) const = 0;
void create_preset_tab();
void add_scaled_button(wxWindow* parent, ScalableButton** btn, const std::string& icon_name,
const wxString& label = wxEmptyString,
long style = wxBU_EXACTFIT | wxNO_BORDER);
void add_scaled_bitmap(wxWindow* parent, ScalableBitmap& btn, const std::string& icon_name);
void update_ui_items_related_on_parent_preset(const Preset* selected_preset_parent);
void load_current_preset();
//BBS: reactive preset combo box
void reactive_preset_combo_box();
void rebuild_page_tree();
void update_btns_enabling();
void update_preset_choice();
// Select a new preset, possibly delete the current one.
bool select_preset(std::string preset_name = "", bool delete_current = false, const std::string &last_selected_ph_printer_name = "", bool force_select = false, bool force_no_transfer = false);
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "", bool no_transfer = false, bool no_transfer_variant = false);
// Whether the unsaved-changes prompt of a switch to `preset_name` offers Transfer for this tab's own
// changes: never on the printer tab, and not between filaments of different types.
bool can_transfer_changes_to(const std::string& preset_name) const;
// How this tab's preset switches answer their unsaved-changes prompts: by a person in
// UnsavedChangesDialog (Ask), or with the dialog's Transfer or Discard without showing it, for a
// caller that already has the answer (MCP's preset_select). A caller sets it around one switch.
enum class DirtyPresetAnswer { Ask, Transfer, Discard };
DirtyPresetAnswer m_dirty_preset_answer = DirtyPresetAnswer::Ask;
virtual void clear_pages();
virtual void update_description_lines();
virtual void activate_selected_page(std::function<void()> throw_if_canceled);
void OnTreeSelChange(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event);
void compare_preset();
void transfer_options(const std::string&name_from, const std::string&name_to, std::vector<std::string> options);
//BBS: add project embedded preset relate logic
// Returns false when the save was cancelled (the unresolved-plugin warning, the temperature
// safety check or the save-name dialog), so callers that were about to discard the edited
// preset can abort instead. `plugin_warning_confirmed` is set only by a caller that already ran
// the warning (UnsavedChangesDialog::save) and must not repeat it.
bool save_preset(std::string name = std::string(), bool detach = false, bool save_to_project = false, bool from_input = false, std::string input_name = "", bool plugin_warning_confirmed = false);
//void save_preset(std::string name = std::string(), bool detach = false);
// Deletes the selected preset. Prompts::Skip skips the confirmations, for a caller that has made the
// same checks itself; the refusal for a preset other presets inherit from still shows.
void delete_preset(Ops::Prompts prompts = Ops::Prompts::Ask);
// What keeps a preset from being deleted: a system (or default) preset and a preset of a bundle are
// never deleted, and a base preset is not while other presets inherit from it.
enum class DeleteBlock { None, System, FromBundle, InheritedFrom };
// What keeps `preset` of `presets` from being deleted. The tab applies it in two places: it shows no
// Delete button for the first two (Preset::can_overwrite()), and delete_preset() refuses the third in
// a dialog. `inherited_by` gets the presets that inherit from it when it is a base preset, whatever
// blocks it first.
static DeleteBlock can_delete_preset(const PresetCollection& presets, const Preset& preset, std::vector<std::string>* inherited_by = nullptr);
void toggle_show_hide_incompatible();
void update_show_hide_incompatible_button();
void update_ui_from_settings();
void update_label_colours();
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();
void update_undo_buttons();
void update_extruder_switch_colors();
// Whether the variant switch (m_extruder_switch / m_variant_combo) is enabled: on the printer tab for
// any multi-extruder printer, on the other tabs when it switches nozzle variants.
bool variant_switch_active() const;
// Orca: whether `page` is the printer tab's single "Extruder" page, which edits the extruder selected on the switch.
bool is_printer_extruder_page(const Page* page) const { return m_type == Preset::TYPE_PRINTER && page && page->title() == "Extruder"; }
// Shows the variant switch row on pages with options that follow it.
void update_variant_sizer_visibility();
void update_all_extruder_options_status();
void check_extruder_options_status(int index, bool &sys_extruder, bool &modified_extruder, const std::vector<PageShp>& pages_to_check);
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);
// The name a category is displayed under. A few printer pages are renamed for display (BBL
// "Extruder 1/2" -> "Left/Right Extruder", the shared "Extruder" page -> "Extruders" when there are
// several). With `translate` false the same name is returned untranslated, i.e. as an English UI
// displays it.
static wxString translate_category(const wxString& title, Preset::Type preset_type, bool translate = true);
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();
std::string options_list_storage_key(const std::string& opt_key) const;
virtual void update_custom_dirty(std::vector<std::string> &dirty_options, std::vector<std::string> &nonsys_options) {}
void load_initial_data();
void update_dirty();
//BBS update plater presets if update_plater_presets = true
void update_tab_ui(bool update_plater_presets = false);
void load_config(const DynamicPrintConfig& config);
// Host/plugin API: set one option of this tab's currently edited preset from its serialized
// string value, then run the same committed-change path a field edit runs. `opt_key` must be a
// setting of this tab's preset type, so a key of another preset type (e.g. a printer setting
// passed to the process tab) is rejected instead of written silently. `value` is parsed by the
// strict config deserializer, which raises std::invalid_argument for an unknown key or a value
// the option cannot parse, and leaves the preset unchanged. The key-specific behaviour runs
// through its ConfigOptionsGroup::on_change_OG(): with the option's built field it uses the
// field's typed value, otherwise the owning group builds the value and dispatches the same call,
// so a not-yet-built field still gets it. A key the GUI edits through a custom widget instead
// takes the shared no-field commit path, Tab::load_key_value() in saved mode.
void apply_preset_config_value(const std::string& opt_key, const std::string& value);
// Host/plugin API: apply a batch of settings to this tab's currently edited preset as one
// transaction. Each pair is a setting of this tab's preset type and its serialized string value.
// The whole batch is parsed and validated before the edited preset is touched; each setting then
// runs the same committed-change path apply_preset_config_value() uses, so setting-specific
// validation, correction and on_change callbacks stay authoritative. Duplicate keys are rejected,
// because the transaction must not resolve an incidental write order, and the batch order is
// preserved. If applying the batch fails, the edited preset's config is restored to its pre-batch
// state and the state derived from it (compatibility marks, the preset selector, dependent tabs,
// the Plater and the printer agent) is recomputed, so the edited preset never keeps a subset of
// the staged settings.
//
// Only the edited preset is restored. A setting's on_change callback is a GUI method, not a pure
// function of the config, so effects outside the edited preset cannot be prepared or undone: the
// transaction does not reverse preset/slot selection made while resolving the target, a dialog
// decision the user already accepted, an undo snapshot, a dependent preset's rewritten config, or
// anything already sent to a device. Exact all-or-nothing across those is not achievable while the
// authoritative GUI callbacks run; this method guarantees the edited preset's own settings, not
// those external effects.
//
// Throws std::invalid_argument for an unknown key, a value the option cannot parse, or a duplicate
// key; std::runtime_error when the preset or main window is unavailable.
void apply_preset_config_values(const std::vector<std::pair<std::string, std::string>>& values);
virtual void reload_config();
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;
Line* get_line(const t_config_option_key& opt_key);
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, const wxString& reason = {});
void toggle_line(const std::string &opt_key, bool toggle, int opt_index = -1, const wxString& reason = {});
const OptionStateRegistry& option_state_registry() const { return m_option_state_registry; }
// Renames the row that owns the option. `label` is the untranslated English msgid (an L("...")
// string); it is translated for display and kept as the row's English search alias.
void set_option_label(const std::string &opt_key, const wxString &label, int opt_index = -1);
// Live state of the settings row that owns an option, read from the built pages.
struct SettingRowState
{
bool visible{true}; // false when ConfigManipulation hides the row
wxString label; // Line::label the row draws (may change at runtime)
wxString label_en; // Line::label_en, the untranslated English of label
bool multi{false}; // row packs several options, so label is precomposed
};
SettingRowState setting_row_state(const std::string &opt_id) const;
wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText, wxString text = wxEmptyString);
bool current_preset_is_dirty() const;
bool saved_preset_is_dirty() const;
void update_saved_preset_from_current_preset();
void update_pages_with_multi_variant();
DynamicPrintConfig* get_config() { return m_config; }
PresetCollection * get_presets() { return m_presets; }
const std::vector<PageShp>& pages() const { return m_pages; }
TabPresetComboBox * get_combo_box() { return m_presets_choice; }
virtual void on_value_change(const std::string& opt_key, const boost::any& value);
void update_wiping_button_visibility();
virtual 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, const DynamicPrintConfig* config = nullptr);
void apply_config_from_cache();
void show_timelapse_warning_dialog();
const std::map<wxString, std::string>& get_category_icon_map() { return m_category_icon; }
//BBS: GUI refactor
bool update_current_page_in_background(int& item);
void unselect_tree_item();
// BBS: new layout
void set_expanded(bool value);
void restore_last_select_item();
// page_build_pending() says whether the selected page has groups without controls or controls
// not yet shown for the mode, and page_build_step() does the next of those.
bool page_build_pending() const;
bool page_build_step();
static bool validate_custom_gcode(const wxString& title, const std::string& gcode);
bool validate_custom_gcodes();
bool validate_filament_temperature_pairs();
bool validate_custom_gcodes_was_shown{ false };
void set_just_edit(bool just_edit);
void edit_custom_gcode(const t_config_option_key& opt_key);
virtual const std::string& get_custom_gcode(const t_config_option_key& opt_key);
virtual void set_custom_gcode(const t_config_option_key& opt_key, const std::string& value);
void update_extruder_variants(int extruder_id = -1, bool reload = true);
void switch_excluder(int extruder_id = -1, bool reload = true);
void sync_excluder();
void parse_extruder_selection(int selection, int &extruder_id, NozzleVolumeType &nozzle_type);
int calculate_selection_index_for_extruder(int extruder_id, NozzleVolumeType nozzle_type);
std::vector<int> get_extruder_sync_targets(int extruder_id);
bool extruder_sync_enabled();
int get_current_active_extruder();
std::vector<wxString> generate_extruder_options();
NozzleVolumeType get_actual_nozzle_volume_type(int extruder_id);
protected:
void create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, const std::string& 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);
// Commit one option whose new value already sits in m_config through the same path a field edit
// runs (throwing field, otherwise the owning group's on_change_OG()). Reloads the option's page
// so a built field reports the committed value, but performs no tab-wide refresh. Returns true
// when a built field or a group owns the option, false when the GUI edits it through a custom
// widget with no group entry.
bool commit_preset_config_value(const std::string& opt_key);
// The unsaved-changes prompt's Transfer: caches `selected_options` of `presets`' unsaved changes for
// the preset selected next, less the options of other extruder variants on a switch to a printer
// with other variants (`no_transfer_variant`), which a person is told about in a message box.
void transfer_dirty_options(PresetCollection* presets, std::vector<std::string> selected_options, bool no_transfer,
bool no_transfer_variant);
//BBS: GUI refactor
// return true if cancelled
bool tree_sel_change_delayed(wxCommandEvent& event);
void on_presets_changed();
void update_printer_agent_if_needed();
void build_preset_description_line(ConfigOptionsGroup* optgroup);
void update_preset_description_line();
void update_frequently_changed_parameters();
void set_tooltips_text();
void filter_diff_option(std::vector<std::string> &options);
ConfigManipulation m_config_manipulation;
OptionStateRegistry m_option_state_registry;
std::string m_last_sparse_infill_rotate_template_value;
ConfigManipulation get_config_manipulation();
friend class EditGCodeDialog;
friend class PublishSettingsDialog;
};
// Resolves the same object/global settings owner for navigation and availability descriptions.
Tab* get_tab_for_option(const std::string& opt_key, Preset::Type type);
// The unsaved changes of `presets`' edited preset that UnsavedChangesDialog lists, all of which its Transfer moves:
// the changed options (key#index for one entry of a vector) that a settings page shows in the current mode.
std::vector<std::string> listed_dirty_options(const PresetCollection& presets);
class TabPrint : public Tab
{
public:
//BBS: GUI refactor
TabPrint(ParamsPanel* parent, Preset::Type type = Preset::TYPE_PRINT) :
Tab(parent, _(L("Process")), type) {}
~TabPrint() {}
void build() override;
void reload_config() override;
void update_description_lines() override;
void toggle_options() override;
void update() override;
void clear_pages() override;
bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptFFF; }
// Column of the extruder's variant in the per-variant process vectors, as the extruder switch
// selects it; -1 when the printer has no such extruder variant.
int extruder_variant_index(int extruder_id, NozzleVolumeType nozzle_type);
private:
ogStaticText* m_recommended_thin_wall_thickness_description_line = nullptr;
ogStaticText* m_top_bottom_shell_thickness_explanation = nullptr;
};
class TabPrintModel : public TabPrint
{
public:
//BBS: GUI refactor
TabPrintModel(ParamsPanel* parent, std::vector<std::string> const & keys);
~TabPrintModel() {}
void build() override;
void set_model_config(std::map<ObjectBase *, ModelConfig *> const & object_configs);
bool has_model_config() const { return !m_object_configs.empty(); }
void update_model_config();
virtual void reset_model_config();
bool has_key(std::string const &key);
protected:
virtual void activate_selected_page(std::function<void()> throw_if_canceled) override;
virtual void on_value_change(const std::string& opt_key, const boost::any& value) override;
virtual void notify_changed(ObjectBase * object) = 0;
virtual void reload_config() override;
virtual void update_custom_dirty(std::vector<std::string> &dirty_options, std::vector<std::string> &nonsys_options) override;
protected:
std::vector<std::string> m_keys;
PresetCollection m_prints;
Tab * m_parent_tab;
std::map<ObjectBase *, ModelConfig *> m_object_configs;
std::vector<std::string> m_all_keys;
std::vector<std::string> m_null_keys;
bool m_back_to_sys = false;
};
class TabPrintPlate : public TabPrintModel
{
public:
//BBS: GUI refactor
TabPrintPlate(ParamsPanel* parent);
~TabPrintPlate() {}
void build() override;
void reset_model_config() override;
int show_spiral_mode_settings_dialog(bool is_object_config) { return m_config_manipulation.show_spiral_mode_settings_dialog(is_object_config); }
// Disables the user-defined filament print order while a mixed-color filament exists.
void update_mixed_filament_seq_state();
protected:
virtual void on_value_change(const std::string& opt_key, const boost::any& value) override;
virtual void notify_changed(ObjectBase* object) override;
virtual void update_custom_dirty(std::vector<std::string> &dirty_options, std::vector<std::string> &nonsys_options) override;
};
class TabPrintObject : public TabPrintModel
{
public:
//BBS: GUI refactor
TabPrintObject(ParamsPanel* parent);
~TabPrintObject() {}
protected:
virtual void notify_changed(ObjectBase * object) override;
};
class TabPrintPart : public TabPrintModel
{
public:
//BBS: GUI refactor
TabPrintPart(ParamsPanel* parent);
~TabPrintPart() {}
protected:
virtual void notify_changed(ObjectBase * object) override;
};
class TabPrintLayer : public TabPrintModel
{
public:
//BBS: GUI refactor
TabPrintLayer(ParamsPanel* parent);
~TabPrintLayer() {}
protected:
virtual void notify_changed(ObjectBase* object) override;
virtual void update_custom_dirty(std::vector<std::string> &dirty_options, std::vector<std::string> &nonsys_options) override;
};
class TabFilament : public Tab
{
private:
ogStaticText* m_volumetric_speed_description_line {nullptr};
ogStaticText* m_cooling_description_line {nullptr};
void add_filament_overrides_page();
void update_filament_overrides_page(const DynamicPrintConfig* printers_config);
void update_volumetric_flow_preset_hints();
// The variant index the variant switch shows, 0 without one.
unsigned int selected_variant_index() const;
std::map<std::string, ::CheckBox*> m_overrides_options;
public:
//BBS: GUI refactor
TabFilament(ParamsPanel* parent) :
Tab(parent, _(L("Filament")), Slic3r::Preset::TYPE_FILAMENT) {}
~TabFilament() {}
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) const override { return tech == ptFFF; }
void on_value_change(const std::string& opt_key, const boost::any& value) override;
const std::string& get_custom_gcode(const t_config_option_key& opt_key) override;
void set_custom_gcode(const t_config_option_key& opt_key, const std::string& value) override;
};
class IMEXModesCtrl;
class TabPrinter : public Tab
{
private:
void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key, const std::string& label_path = "");
void update_input_shaper_menu(GCodeFlavor flavor);
// R8: track the belt->non-belt transition so update_fff() only clears the belt-derived
// build_plate_tilt on a genuine in-place belt-off toggle, never on a manual tilt or a
// preset switch. m_belt_synced_tilt_{x,y} hold the exact values belt-sync last wrote.
bool m_was_belt_printer = false;
double m_belt_synced_tilt_x = 0.;
double m_belt_synced_tilt_y = 0.;
std::vector<PageShp> m_pages_fff;
std::vector<PageShp> m_pages_sla;
IMEXModesCtrl* m_imex_modes_ctrl {nullptr};
public:
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;
std::vector<std::string> m_extruder_variant_list;
std::string m_base_preset_name;
PrinterTechnology m_printer_technology = ptFFF;
//BBS: GUI refactor
TabPrinter(ParamsPanel* parent) :
Tab(parent, _L("Machine"), Slic3r::Preset::TYPE_PRINTER) {}
~TabPrinter() {}
void build() override;
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 on_gcode_flavor_changed();
void extruders_count_changed(size_t extruders_count);
// What a change of the Extruders field (Multimaterial page) does: the count, then the options list, the dirty
// marks and the variant switches that follow it.
void change_extruders_count(size_t extruders_count);
PageShp build_kinematics_page();
void build_unregular_pages(bool from_initial_build = false);
void on_preset_loaded() override;
void init_options_list() override;
void msw_rescale() override;
bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; }
void set_extruder_volume_type(int extruder_id, NozzleVolumeType type);
void on_value_change(const std::string& opt_key, const boost::any& value) override;
wxSizer* create_bed_shape_widget(wxWindow* parent);
void cache_extruder_cnt(const DynamicPrintConfig* config = nullptr);
bool apply_extruder_cnt_from_cache();
void refresh_printer_agent_dropdown() const;
// Orca: a single "Extruder" page for all extruders. Its controls are created once (index 0) and
// switch_excluder() re-targets them to the extruder selected on m_extruder_switch.
Page* extruder_page() const;
// Config index an "Extruder" page field (e.g. "retraction_length#0") currently edits, -1 if not on that page.
int extruder_page_data_index(const std::string& field_id) const;
// Config index of an extruder's per-variant options (Retraction, Z-Hop, ...): its variant column
// for the nozzle selected on the switch, or the extruder index on a printer without variants.
int extruder_variant_index(int extruder);
// After the config was restored (roll back): follow its extruder count, if it differs.
void sync_extruders_count();
// Search jump to "Extruder N" / "key#N": selects extruder N on the switch, then activates the
// page's own field on the "Extruder" page.
void activate_option(const std::string& opt_key, const wxString& category) override;
protected:
// Orca: values of extruders added by raising the extruder count have no saved / system value to
// revert to; the change is shown on "extruders_count", not on each of their parameters.
void update_custom_dirty(std::vector<std::string> &dirty_options, std::vector<std::string> &nonsys_options) override;
};
class TabSLAMaterial : public Tab
{
public:
//BBS: GUI refactor
TabSLAMaterial(ParamsPanel* parent) :
Tab(parent, _(_devL("Material Settings")), Slic3r::Preset::TYPE_SLA_MATERIAL) {}
~TabSLAMaterial() {}
void build() override;
void reload_config() override;
void toggle_options() override;
void update() override;
bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptSLA; }
};
class TabSLAPrint : public Tab
{
public:
//BBS: GUI refactor
TabSLAPrint(ParamsPanel* parent) :
Tab(parent, _(L("Process 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 clear_pages() override;
bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptSLA; }
};
} // GUI
} // Slic3r
#endif /* slic3r_Tab_hpp_ */