一、界面类
主框架使用的是wxWidgets库;3D模型的渲染区的控件,使用的是imgui库。
1、Plater
此类在OrcaSlicer\src\slic3r\GUI\Plater.hpp文件中定义
1.1 Plater::priv
此结构体是Plater的数据类,各种数据的对象和指针保存在此结构体中。如Sidebar *sidebar。
2、Sidebar 边栏(左侧栏)类
此类在OrcaSlicer\src\slic3r\GUI\Plater.hpp文件中定义,此类是从wxPanel派生而来。
2.1 成员变量
1、struct Sidebar::priv
此结构体是Sidebar用来保存数据。申明为std::unique_ptr<priv> p,在构造函数中,通过new priv(parent)进行赋值。
2.1 成员函数
1、Sidebar::Sidebar(Plater *parent)
在构造函数中会创建:1)打印机下拉框(PlaterPresetComboBox类),new出来的对象指针保存在Sidebar::priv中,变量名为combo_printer;2)会创建耗材下拉框(PlaterPresetComboBox类),new出来的对象指针保存在Sidebar::priv中,变量名为combos_filament。3)工艺下拉框在TabPrint的父类Tab中定义,此指针在MainFrame::create_preset_tabs()函数中创建。
Sidebar对象指针保存在Plater::priv中,指针的在priv构造函数中创建,Plater对象指针保存在MainFrame::m_plater中,此指针在MainFrame::init_tabpanel()函数中创建。
3、下拉框
3.1 ComboBox
此类在OrcaSlicer\src\slic3r\GUI\Widgets\ComboBox.hpp文件中定义。是从public wxWindowWithItems<TextInput, wxItemContainer>派生而来。
3.1.1 成员变量
1、std::vector<wxString> texts;下拉框中显示的文本内容
2、std::vector<wxString> tips;下拉框中显示行的提示内容
3、std::vector<wxBitmap> icons;下拉框显示行的图标
4、std::vector<void *> datas;下拉框显示行的数据
5、std::vector<wxClientDataType> types;下拉框显示行数据类型
6、DropDown drop; 点击下拉时的弹窗
3.1.2 成员函数
1、int Append(const wxString &item, const wxBitmap &bitmap = wxNullBitmap);向下拉框中添加数据。
3.2 PresetComboBox
此类在OrcaSlicer\src\slic3r\GUI\PresetComboBoxs.hpp文件中定义。是从ComboBox派生而来。
3.2.1 成员变量
1、Preset::Type m_type;//TYPE_PRINTER打印机预设;TYPE_FILAMENT耗材预设;TYPE_PRINT工艺预设;
2、int m_last_selected; 最后一个选择的行的下标。
3.2.2 成员函数
1、void update(std::string select_preset);
将collection中的用户预设和系统预设,通过Append函数进行添加。
3.3 PlaterPresetComboBox
此类是从PresetComboBox派生而来。打印机预设下拉框和耗材预设下拉框,是由此类创建的对象。
3.3.1 成员函数
1、void update() override;
重写update函数。循环collection中的presets,1)如果是default或system,则是系统预设;2)如果是is_project_embedded,则是项目预设;3)其他的是用户预设。
2、void OnSelect(wxCommandEvent& evt) override;
重写OnSelect函数。
3.3.2 切换打印机的流程
1、在Plater::priv::priv构造函数中,使用sidebar->Bind(wxEVT_COMBOBOX, &priv::on_combobox_select, this);将sidebar中的wxEVT_COMBOBOX消息绑定到on_combobox_select中。所在切换打印机预设时,会调用此函数。
4、Tab页
在MainFrame::create_preset_tabs()函数中会创建各Tab页
wxGetApp().update_label_colours_from_appconfig();
//BBS: GUI refactor
//m_param_panel = new ParamsPanel(m_tabpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
m_param_dialog = new ParamsDialog(m_plater);
add_created_tab(new TabPrint(m_param_panel), "cog");
add_created_tab(new TabPrintPlate(m_param_panel), "cog");
add_created_tab(new TabPrintObject(m_param_panel), "cog");
add_created_tab(new TabPrintPart(m_param_panel), "cog");
add_created_tab(new TabPrintLayer(m_param_panel), "cog");
add_created_tab(new TabFilament(m_param_dialog->panel()), "spool");
/* BBS work around to avoid appearance bug */
//add_created_tab(new TabSLAPrint(m_param_panel));
//add_created_tab(new TabSLAMaterial(m_param_panel));
add_created_tab(new TabPrinter(m_param_dialog->panel()), "printer");
m_param_panel->rebuild_panels();
m_param_dialog->panel()->rebuild_panels();
//m_tabpanel->AddPage(m_param_panel, "Parameters", "notebook_presets_active");
//m_tabpanel->InsertPage(tpSettings, m_param_panel, _L("Parameters"), std::string("cog"));
创建后的对象,会保存在 GUI_App::tabs_list,Tab类的构造函数中执行了此动作。TabPrint的Tab::m_type为Preset::TYPE_PRINT,TabPrintPlate为Preset::TYPE_PLATE,TabPrintObject为Preset::TYPE_MODEL,TabPrintPart为Preset::TYPE_MODEL,TabPrintLayer为Preset::TYPE_MODEL,TabFilament为Preset::TYPE_FILAMENT,TabPrinter为Preset::TYPE_PRINTER
4.0 Page
4.1 TabCtrl
4.1.1 成员变量
1、std::vector<Button*> btns; 在AppendItem函数中会创建一个Button,并把对象指针保存到此变量中。
4.1.2 成员函数
1、构造函数
在构造函数中绑定了wxEVT_COMMAND_BUTTON_CLICKED点击事件,此事件的响应函数为buttonClicked
2、void buttonClicked(wxCommandEvent & event);
通过event.GetEventObject()获取到点击对象指针,再在btns查找是否点击了某个按钮,将位置传给SelectItem函数
3、void SelectItem(int item);
在此函数中通过sendTabCtrlEvent函数先发送wxEVT_TAB_SEL_CHANGING事件,再发送wxEVT_TAB_SEL_CHANGED事件。在Tab类的Tab::create_preset_tab()函数中有对m_tabctrl的wxEVT_TAB_SEL_CHANGED事件进行捕捉响应。
4.2 Tab
此类在OrcaSlicer\src\slic3r\GUI\Tab.hpp中定义。工艺Tab、修改打印机预设窗口的Tab、修改耗材预设窗口的Tab的父类
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;
wxStaticText* m_static_title;
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};
//ModeSizer* m_mode_sizer {nullptr};
struct PresetDependencies {
Preset::Type type = Preset::TYPE_INVALID;
wxCheckBox *checkbox = nullptr;
ScalableButton *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;
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

最低0.47元/天 解锁文章
1435

被折叠的 条评论
为什么被折叠?



