2017-12-05 14:54:01 +00:00
|
|
|
// 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 <wx/panel.h>
|
|
|
|
#include <wx/notebook.h>
|
|
|
|
#include <wx/scrolwin.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/bmpcbox.h>
|
|
|
|
#include <wx/bmpbuttn.h>
|
|
|
|
#include <wx/treectrl.h>
|
|
|
|
#include <wx/imaglist.h>
|
2017-12-13 13:45:10 +00:00
|
|
|
#include <wx/statbox.h>
|
2017-12-05 14:54:01 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2017-12-13 13:45:10 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "OptionsGroup.hpp"
|
|
|
|
|
|
|
|
//!enum { ID_TAB_TREE = wxID_HIGHEST + 1 };
|
2017-12-05 14:54:01 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
// Single Tab page containing a{ vsizer } of{ optgroups }
|
|
|
|
// package Slic3r::GUI::Tab::Page;
|
2017-12-13 13:45:10 +00:00
|
|
|
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
|
2018-01-05 14:11:33 +00:00
|
|
|
class Page : public wxScrolledWindow
|
2017-12-05 14:54:01 +00:00
|
|
|
{
|
2017-12-26 22:04:54 +00:00
|
|
|
wxWindow* m_parent;
|
|
|
|
wxString m_title;
|
|
|
|
size_t m_iconID;
|
|
|
|
wxBoxSizer* m_vsizer;
|
2017-12-05 14:54:01 +00:00
|
|
|
public:
|
2018-01-05 14:11:33 +00:00
|
|
|
Page(wxWindow* parent, const wxString title, const int iconID) :
|
2017-12-26 22:04:54 +00:00
|
|
|
m_parent(parent),
|
|
|
|
m_title(title),
|
|
|
|
m_iconID(iconID)
|
2017-12-05 14:54:01 +00:00
|
|
|
{
|
2017-12-26 22:04:54 +00:00
|
|
|
Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
|
|
|
m_vsizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
SetSizer(m_vsizer);
|
2017-12-05 14:54:01 +00:00
|
|
|
}
|
2018-01-05 14:11:33 +00:00
|
|
|
~Page(){}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
|
|
|
public:
|
2017-12-26 22:04:54 +00:00
|
|
|
std::vector <ConfigOptionsGroupShp> m_optgroups; // $self->{optgroups} = [];
|
|
|
|
DynamicPrintConfig* m_config;
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2017-12-26 22:04:54 +00:00
|
|
|
wxBoxSizer* vsizer() const { return m_vsizer; }
|
|
|
|
wxWindow* parent() const { return m_parent; }
|
|
|
|
wxString title() const { return m_title; }
|
|
|
|
size_t iconID() const { return m_iconID; }
|
|
|
|
void set_config(DynamicPrintConfig* config_in) { m_config = config_in; }
|
2018-01-09 08:41:07 +00:00
|
|
|
void reload_config(){
|
|
|
|
for (auto group: m_optgroups)
|
|
|
|
group->reload_config();
|
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2017-12-22 10:50:28 +00:00
|
|
|
ConfigOptionsGroupShp new_optgroup(std::string title, int noncommon_label_width = -1);
|
2017-12-05 14:54:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Slic3r::GUI::Tab;
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-01-05 14:11:33 +00:00
|
|
|
using PageShp = std::shared_ptr<Page>;
|
|
|
|
class Tab: public wxPanel
|
2017-12-05 14:54:01 +00:00
|
|
|
{
|
2017-12-26 22:04:54 +00:00
|
|
|
wxNotebook* m_parent;
|
2017-12-05 14:54:01 +00:00
|
|
|
protected:
|
2017-12-26 22:04:54 +00:00
|
|
|
const wxString m_title;
|
|
|
|
wxBitmapComboBox* m_presets_choice;
|
|
|
|
wxBitmapButton* m_btn_save_preset;
|
|
|
|
wxBitmapButton* m_btn_delete_preset;
|
|
|
|
wxBitmap* m_bmp_show_incompatible_presets;
|
|
|
|
wxBitmap* m_bmp_hide_incompatible_presets;
|
|
|
|
wxBitmapButton* m_btn_hide_incompatible_presets;
|
|
|
|
wxBoxSizer* m_hsizer;
|
|
|
|
wxBoxSizer* m_left_sizer;
|
|
|
|
wxTreeCtrl* m_treectrl;
|
|
|
|
wxImageList* m_icons;
|
|
|
|
wxCheckBox* m_compatible_printers_checkbox;
|
|
|
|
wxButton* m_compatible_printers_btn;
|
|
|
|
|
|
|
|
int m_icon_count;
|
|
|
|
std::map<std::string, size_t> m_icon_index; // Map from an icon file name to its index in $self->{icons}.
|
2018-01-05 14:11:33 +00:00
|
|
|
std::vector<PageShp> m_pages; // $self->{pages} = [];
|
2017-12-26 22:04:54 +00:00
|
|
|
bool m_disable_tree_sel_changed_event;
|
2017-12-13 13:45:10 +00:00
|
|
|
|
|
|
|
public:
|
2017-12-26 22:04:54 +00:00
|
|
|
PresetBundle* m_preset_bundle;
|
2018-01-05 14:11:33 +00:00
|
|
|
bool m_no_controller;
|
|
|
|
PresetCollection* m_presets;
|
2017-12-26 22:04:54 +00:00
|
|
|
DynamicPrintConfig m_config; //! tmp_val
|
|
|
|
const ConfigDef* m_config_def; // It will be used in get_option_(const std::string title)
|
2018-01-05 14:11:33 +00:00
|
|
|
t_change m_on_value_change{ nullptr };
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2017-12-05 14:54:01 +00:00
|
|
|
public:
|
2018-01-05 14:11:33 +00:00
|
|
|
Tab() {}
|
|
|
|
Tab(wxNotebook* parent, const char *title) : m_parent(parent), m_title(title) {
|
2017-12-13 13:45:10 +00:00
|
|
|
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
|
|
|
|
}
|
2018-01-05 14:11:33 +00:00
|
|
|
~Tab(){}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2017-12-26 22:04:54 +00:00
|
|
|
wxWindow* parent() const { return m_parent; }
|
|
|
|
wxString title() const { return m_title; }
|
2017-12-05 14:54:01 +00:00
|
|
|
|
2018-01-05 14:11:33 +00:00
|
|
|
void create_preset_tab(PresetBundle *preset_bundle);
|
|
|
|
void on_value_change(std::string opt_key, boost::any value){
|
|
|
|
if (m_on_value_change != nullptr)
|
|
|
|
m_on_value_change(opt_key, value);
|
|
|
|
update();
|
|
|
|
};
|
|
|
|
void on_presets_changed(){};
|
|
|
|
void load_current_preset();
|
2017-12-13 13:45:10 +00:00
|
|
|
void rebuild_page_tree();
|
|
|
|
void select_preset(wxString preset_name){};
|
|
|
|
|
2017-12-26 22:04:54 +00:00
|
|
|
wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox* checkbox, wxButton* btn);
|
2017-12-22 10:50:28 +00:00
|
|
|
|
2017-12-26 22:04:54 +00:00
|
|
|
void load_key_value(std::string opt_key, std::vector<std::string> value);
|
2017-12-19 10:59:42 +00:00
|
|
|
|
2017-12-13 13:45:10 +00:00
|
|
|
void OnTreeSelChange(wxTreeEvent& event);
|
|
|
|
void OnKeyDown(wxKeyEvent& event);
|
2017-12-26 22:04:54 +00:00
|
|
|
void OnComboBox(wxCommandEvent& event) { select_preset(m_presets_choice->GetStringSelection()); }
|
2017-12-13 13:45:10 +00:00
|
|
|
void save_preset(wxCommandEvent &event);
|
|
|
|
void delete_preset(wxCommandEvent &event);
|
2017-12-26 22:04:54 +00:00
|
|
|
void toggle_show_hide_incompatible(wxCommandEvent &event);
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-01-05 14:11:33 +00:00
|
|
|
PageShp add_options_page(wxString title, std::string icon, bool is_extruder_pages = false);
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-01-03 09:12:42 +00:00
|
|
|
virtual void build() = 0;
|
|
|
|
virtual void update() = 0;
|
2018-01-05 14:11:33 +00:00
|
|
|
void update_dirty();
|
|
|
|
void load_config(DynamicPrintConfig config);
|
2018-01-09 08:41:07 +00:00
|
|
|
void reload_config();
|
2017-12-05 14:54:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//Slic3r::GUI::Tab::Print;
|
2018-01-05 14:11:33 +00:00
|
|
|
class TabPrint : public Tab
|
2017-12-05 14:54:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-01-05 14:11:33 +00:00
|
|
|
TabPrint() {}
|
|
|
|
TabPrint(wxNotebook* parent, const char *title) : Tab(parent, title) {}
|
|
|
|
~TabPrint(){}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-01-03 09:12:42 +00:00
|
|
|
void build() override;
|
2018-01-05 14:11:33 +00:00
|
|
|
void update() override;
|
2017-12-05 14:54:01 +00:00
|
|
|
};
|
|
|
|
|
2017-12-26 22:04:54 +00:00
|
|
|
//Slic3r::GUI::Tab::Filament;
|
2018-01-05 14:11:33 +00:00
|
|
|
class TabFilament : public Tab
|
2017-12-22 10:50:28 +00:00
|
|
|
{
|
2017-12-26 22:04:54 +00:00
|
|
|
wxStaticText* m_cooling_description_line;
|
|
|
|
wxStaticText* m_volumetric_speed_description_line;
|
2017-12-22 10:50:28 +00:00
|
|
|
public:
|
2018-01-05 14:11:33 +00:00
|
|
|
TabFilament() {}
|
|
|
|
TabFilament(wxNotebook* parent, const char *title) : Tab(parent, title) {}
|
|
|
|
~TabFilament(){}
|
2017-12-22 10:50:28 +00:00
|
|
|
|
2017-12-26 22:04:54 +00:00
|
|
|
wxSizer* description_line_widget(wxWindow* parent, wxStaticText* StaticText);
|
2017-12-22 10:50:28 +00:00
|
|
|
|
2018-01-03 09:12:42 +00:00
|
|
|
void build() override;
|
|
|
|
void update() override{};
|
2017-12-22 10:50:28 +00:00
|
|
|
};
|
|
|
|
|
2017-12-26 22:04:54 +00:00
|
|
|
//Slic3r::GUI::Tab::Printer;
|
2018-01-05 14:11:33 +00:00
|
|
|
class TabPrinter : public Tab
|
2017-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxButton* serial_test_btn;
|
|
|
|
wxButton* octoprint_host_test_btn;
|
2018-01-02 11:50:27 +00:00
|
|
|
|
|
|
|
size_t m_extruders_count;
|
|
|
|
|
2017-12-22 10:50:28 +00:00
|
|
|
public:
|
2018-01-05 14:11:33 +00:00
|
|
|
TabPrinter() {}
|
|
|
|
TabPrinter(wxNotebook* parent, const char *title) : Tab(parent, title) {}
|
|
|
|
~TabPrinter(){}
|
2017-12-22 10:50:28 +00:00
|
|
|
|
2018-01-03 09:12:42 +00:00
|
|
|
void build() override;
|
|
|
|
void update() override{};
|
|
|
|
void build_extruder_pages();
|
2017-12-22 10:50:28 +00:00
|
|
|
};
|
|
|
|
|
2017-12-05 14:54:01 +00:00
|
|
|
} // GUI
|
|
|
|
} // Slic3r
|