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

240 lines
5.6 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 "slic3r/Utils/PresetUpdater.hpp"
#include "AppConfig.hpp"
#include "Preset.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 {
enum {
WRAP_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
{
struct Checkbox : wxCheckBox
{
Checkbox(wxWindow *parent, const wxString &label, const std::string &model, const std::string &variant) :
wxCheckBox(parent, wxID_ANY, label),
model(model),
variant(variant)
{}
std::string model;
std::string variant;
};
const std::string vendor_id;
std::vector<Checkbox*> cboxes;
unsigned variants_checked;
PrinterPicker(wxWindow *parent, const VendorProfile &vendor, const AppConfig &appconfig_vendors);
void select_all(bool select);
void on_checkbox(const Checkbox *cbox, bool checked);
};
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;
wxCheckBox *cbox_reset;
2018-03-13 11:39:57 +00:00
PageWelcome(ConfigWizard *parent);
2018-03-13 11:39:57 +00:00
virtual wxPanel* extra_buttons() { return others_buttons; }
virtual void on_page_set();
2018-04-19 14:49:22 +00:00
bool reset_user_profile() const { return cbox_reset != nullptr ? cbox_reset->GetValue() : false; }
2018-03-13 11:39:57 +00:00
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;
ConfigWizard::RunReason run_reason;
AppConfig appconfig_vendors;
std::unordered_map<std::string, VendorProfile> vendors;
std::unordered_map<std::string, std::string> vendors_rsrc;
std::unique_ptr<DynamicPrintConfig> custom_config;
wxScrolledWindow *hscroll = nullptr;
wxBoxSizer *hscroll_sizer = nullptr;
2018-03-13 11:39:57 +00:00
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, const PresetUpdater *updater);
2018-03-13 11:39:57 +00:00
};
}
}
#endif