Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ConfigWizard_private.hpp « GUI « slic3r « src « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 72cb88655f56fa2836f1005e57b2b9471223775f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#ifndef slic3r_ConfigWizard_private_hpp_
#define slic3r_ConfigWizard_private_hpp_

#include "ConfigWizard.hpp"

#include <vector>
#include <set>
#include <unordered_map>
#include <boost/filesystem.hpp>

#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/choice.h>
#include <wx/spinctrl.h>

#include "libslic3r/PrintConfig.hpp"
#include "slic3r/Utils/PresetUpdater.hpp"
#include "AppConfig.hpp"
#include "Preset.hpp"
#include "BedShapeDialog.hpp"

namespace fs = boost::filesystem;

namespace Slic3r {
namespace GUI {

enum {
	WRAP_WIDTH = 500,

	DIALOG_MARGIN = 15,
	INDEX_MARGIN = 40,
	BTN_SPACING = 10,
	INDENT_SPACING = 30,
	VERTICAL_SPACING = 10,
};

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);
};

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; }
	ConfigWizardPage* chain(ConfigWizardPage *page);

	template<class T>
	void append(T *thing, int proportion = 0, int flag = wxEXPAND|wxTOP|wxBOTTOM, int border = 10)
	{
		content->Add(thing, proportion, flag, border);
	}

	void append_text(wxString text);
	void append_spacer(int space);

	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() {}
	virtual void apply_custom_config(DynamicPrintConfig &config) {}

	void enable_next(bool enable);
private:
	ConfigWizardPage *p_prev;
	ConfigWizardPage *p_next;
};

struct PageWelcome: ConfigWizardPage
{
	PrinterPicker *printer_picker;
	wxPanel *others_buttons;
	wxCheckBox *cbox_reset;

	PageWelcome(ConfigWizard *parent);

	virtual wxPanel* extra_buttons() { return others_buttons; }
	virtual void on_page_set();

	bool reset_user_profile() const { return cbox_reset != nullptr ? cbox_reset->GetValue() : false; }
	void on_variant_checked();
};

struct PageUpdate: ConfigWizardPage
{
	bool version_check;
	bool preset_update;

	PageUpdate(ConfigWizard *parent);
};

struct PageVendors: ConfigWizardPage
{
	std::vector<PrinterPicker*> pickers;

	PageVendors(ConfigWizard *parent);

	virtual void on_page_set();

	void on_vendor_pick(size_t i);
	void on_variant_checked();
};

struct PageFirmware: ConfigWizardPage
{
	const ConfigOptionDef &gcode_opt;
	wxChoice *gcode_picker;

	PageFirmware(ConfigWizard *parent);
	virtual void apply_custom_config(DynamicPrintConfig &config);
};

struct PageBedShape: ConfigWizardPage
{
	BedShapePanel *shape_panel;

	PageBedShape(ConfigWizard *parent);
	virtual void apply_custom_config(DynamicPrintConfig &config);
};

struct PageDiameters: ConfigWizardPage
{
	wxSpinCtrlDouble *spin_nozzle;
	wxSpinCtrlDouble *spin_filam;

	PageDiameters(ConfigWizard *parent);
	virtual void apply_custom_config(DynamicPrintConfig &config);
};

struct PageTemperatures: ConfigWizardPage
{
	wxSpinCtrlDouble *spin_extr;
	wxSpinCtrlDouble *spin_bed;

	PageTemperatures(ConfigWizard *parent);
	virtual void apply_custom_config(DynamicPrintConfig &config);
};


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;

	void on_paint(wxPaintEvent &evt);
};

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;
	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();
	void add_page(ConfigWizardPage *page);
	void index_refresh();
	void set_page(ConfigWizardPage *page);
	void layout_fit();
	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();

	void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater);
};



}
}

#endif