PrusaSlicer-NonPlainar/xs/src/slic3r/GUI/ConfigWizard_private.hpp

222 lines
5.0 KiB
C++
Raw Normal View History

2018-03-13 11:39:57 +00:00
#ifndef slic3r_ConfigWizard_private_hpp_
#define slic3r_ConfigWizard_private_hpp_
#include "ConfigWizard.hpp"
#include <vector>
#include <set>
#include <unordered_map>
#include <boost/filesystem.hpp>
2018-03-13 11:39:57 +00:00
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/button.h>
2018-04-05 14:10:44 +00:00
#include <wx/choice.h>
#include <wx/spinctrl.h>
2018-03-13 11:39:57 +00:00
2018-04-05 14:10:44 +00:00
#include "libslic3r/PrintConfig.hpp"
#include "AppConfig.hpp"
#include "Preset.hpp"
// #include "PresetBundle.hpp"
2018-04-05 14:10:44 +00:00
#include "BedShapeDialog.hpp"
namespace fs = boost::filesystem;
2018-03-13 11:39:57 +00:00
namespace Slic3r {
namespace GUI {
// typedef std::unordered_map<std::string, VendorProfile> VendorMap;
2018-03-13 11:39:57 +00:00
enum {
CONTENT_WIDTH = 500,
2018-03-13 11:39:57 +00:00
DIALOG_MARGIN = 15,
INDEX_MARGIN = 40,
BTN_SPACING = 10,
2018-04-05 14:10:44 +00:00
INDENT_SPACING = 30,
VERTICAL_SPACING = 10,
2018-03-13 11:39:57 +00:00
};
struct PrinterPicker: wxPanel
{
unsigned variants_checked;
PrinterPicker(wxWindow *parent, const VendorProfile &vendor, const AppConfig &appconfig_vendors);
};
2018-03-13 11:39:57 +00:00
struct ConfigWizardPage: wxPanel
{
ConfigWizard *parent;
const wxString shortname;
wxBoxSizer *content;
ConfigWizardPage(ConfigWizard *parent, wxString title, wxString shortname);
virtual ~ConfigWizardPage();
ConfigWizardPage* page_prev() const { return p_prev; }
ConfigWizardPage* page_next() const { return p_next; }
2018-03-13 11:39:57 +00:00
ConfigWizardPage* chain(ConfigWizardPage *page);
template<class T>
2018-04-05 14:10:44 +00:00
void append(T *thing, int proportion = 0, int flag = wxEXPAND|wxTOP|wxBOTTOM, int border = 10)
{
content->Add(thing, proportion, flag, border);
}
2018-04-05 14:10:44 +00:00
void append_text(wxString text);
2018-03-13 11:39:57 +00:00
void append_spacer(int space);
2018-03-13 11:39:57 +00:00
ConfigWizard::priv *wizard_p() const { return parent->p.get(); }
virtual bool Show(bool show = true);
virtual bool Hide() { return Show(false); }
virtual wxPanel* extra_buttons() { return nullptr; }
virtual void on_page_set() {}
2018-04-05 14:10:44 +00:00
virtual void apply_custom_config(DynamicPrintConfig &config) {}
2018-03-13 11:39:57 +00:00
void enable_next(bool enable);
private:
ConfigWizardPage *p_prev;
ConfigWizardPage *p_next;
};
struct PageWelcome: ConfigWizardPage
{
PrinterPicker *printer_picker;
2018-03-13 11:39:57 +00:00
wxPanel *others_buttons;
PageWelcome(ConfigWizard *parent);
2018-03-13 11:39:57 +00:00
virtual wxPanel* extra_buttons() { return others_buttons; }
virtual void on_page_set();
void on_variant_checked();
};
struct PageUpdate: ConfigWizardPage
{
bool version_check;
bool preset_update;
2018-03-13 11:39:57 +00:00
2018-04-05 14:10:44 +00:00
PageUpdate(ConfigWizard *parent);
2018-03-13 11:39:57 +00:00
};
struct PageVendors: ConfigWizardPage
{
std::vector<PrinterPicker*> pickers;
2018-03-13 11:39:57 +00:00
PageVendors(ConfigWizard *parent);
virtual void on_page_set();
void on_vendor_pick(size_t i);
void on_variant_checked();
2018-03-13 11:39:57 +00:00
};
struct PageFirmware: ConfigWizardPage
{
2018-04-05 14:10:44 +00:00
const ConfigOptionDef &gcode_opt;
wxChoice *gcode_picker;
2018-03-13 11:39:57 +00:00
PageFirmware(ConfigWizard *parent);
2018-04-05 14:10:44 +00:00
virtual void apply_custom_config(DynamicPrintConfig &config);
2018-03-13 11:39:57 +00:00
};
struct PageBedShape: ConfigWizardPage
{
2018-04-05 14:10:44 +00:00
BedShapePanel *shape_panel;
2018-03-13 11:39:57 +00:00
PageBedShape(ConfigWizard *parent);
2018-04-05 14:10:44 +00:00
virtual void apply_custom_config(DynamicPrintConfig &config);
2018-03-13 11:39:57 +00:00
};
struct PageDiameters: ConfigWizardPage
{
2018-04-05 14:10:44 +00:00
wxSpinCtrlDouble *spin_nozzle;
wxSpinCtrlDouble *spin_filam;
2018-03-13 11:39:57 +00:00
PageDiameters(ConfigWizard *parent);
2018-04-05 14:10:44 +00:00
virtual void apply_custom_config(DynamicPrintConfig &config);
2018-03-13 11:39:57 +00:00
};
struct PageTemperatures: ConfigWizardPage
{
2018-04-06 11:18:12 +00:00
wxSpinCtrlDouble *spin_extr;
wxSpinCtrlDouble *spin_bed;
2018-04-05 14:10:44 +00:00
2018-03-13 11:39:57 +00:00
PageTemperatures(ConfigWizard *parent);
2018-04-05 14:10:44 +00:00
virtual void apply_custom_config(DynamicPrintConfig &config);
2018-03-13 11:39:57 +00:00
};
class ConfigWizardIndex: public wxPanel
{
public:
ConfigWizardIndex(wxWindow *parent);
void load_items(ConfigWizardPage *firstpage);
void set_active(ConfigWizardPage *page);
private:
const wxBitmap bg;
const wxBitmap bullet_black;
const wxBitmap bullet_blue;
const wxBitmap bullet_white;
int text_height;
std::vector<wxString> items;
std::vector<wxString>::const_iterator item_active;
2018-04-05 14:10:44 +00:00
void on_paint(wxPaintEvent &evt);
2018-03-13 11:39:57 +00:00
};
struct ConfigWizard::priv
{
ConfigWizard *q;
AppConfig appconfig_vendors;
// PresetBundle bundle_vendors;
std::unordered_map<std::string, VendorProfile> vendors;
std::unordered_map<std::string, fs::path> vendors_rsrc;
std::unique_ptr<DynamicPrintConfig> custom_config;
2018-03-13 11:39:57 +00:00
wxBoxSizer *topsizer = nullptr;
wxBoxSizer *btnsizer = nullptr;
ConfigWizardPage *page_current = nullptr;
ConfigWizardIndex *index = nullptr;
wxButton *btn_prev = nullptr;
wxButton *btn_next = nullptr;
wxButton *btn_finish = nullptr;
wxButton *btn_cancel = nullptr;
PageWelcome *page_welcome = nullptr;
PageUpdate *page_update = nullptr;
PageVendors *page_vendors = nullptr;
PageFirmware *page_firmware = nullptr;
PageBedShape *page_bed = nullptr;
PageDiameters *page_diams = nullptr;
PageTemperatures *page_temps = nullptr;
priv(ConfigWizard *q) : q(q) {}
void load_vendors();
2018-03-13 11:39:57 +00:00
void add_page(ConfigWizardPage *page);
void index_refresh();
void set_page(ConfigWizardPage *page);
void layout_fit();
2018-03-13 11:39:57 +00:00
void go_prev() { if (page_current != nullptr) { set_page(page_current->page_prev()); } }
void go_next() { if (page_current != nullptr) { set_page(page_current->page_next()); } }
void enable_next(bool enable);
void on_other_vendors();
void on_custom_setup();
2018-04-05 14:10:44 +00:00
void apply_config(AppConfig *app_config, PresetBundle *preset_bundle);
2018-03-13 11:39:57 +00:00
};
}
}
#endif