OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::PhysicalPrinterDialog Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/PhysicalPrinterDialog.hpp>

Inheritance diagram for Slic3r::GUI::PhysicalPrinterDialog:
Collaboration diagram for Slic3r::GUI::PhysicalPrinterDialog:

Public Types

enum  ValidationType { Valid , NoValid , Warning }

Public Member Functions

 PhysicalPrinterDialog (wxWindow *parent)
 ~PhysicalPrinterDialog ()
void update (bool printer_change=false)
void update_host_type (bool printer_change)
void update_preset_input ()
void update_printhost_buttons ()
void update_printers ()
void update_ports ()
void update_webui ()
void EndModal (int retCode) override
float scale_factor () const
float prev_scale_factor () const
void set_scale_factor (float v)
void set_prev_scale_factor (float v)
void set_em_unit (int v)
bool force_rescale () const
int em_unit () const
const wxFont & normal_font () const
void enable_force_rescale ()
int ShowModal ()

Public Attributes

PresetCollection * m_presets {nullptr}
ValidationType m_valid_type
std::string m_preset_name

Protected Member Functions

void on_dpi_changed (const wxRect &suggested_rect) override
void on_sys_color_changed () override
void check_host_key_valid ()

Private Member Functions

void build_printhost_settings (ConfigOptionsGroup *optgroup)
void OnOK (wxEvent &event)
void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

DynamicPrintConfig * m_config { nullptr }
ConfigOptionsGroup * m_optgroup { nullptr }
Button * m_printhost_browse_btn {nullptr}
Button * m_printhost_test_btn {nullptr}
Button * m_printhost_generate_creds_btn {nullptr}
Button * m_printhost_logout_btn {nullptr}
Button * m_printhost_cafile_browse_btn {nullptr}
Button * m_printhost_port_browse_btn {nullptr}
RoundedRectangle * m_input_area {nullptr}
wxStaticText * m_valid_label {nullptr}
wxTextCtrl * m_input_ctrl {nullptr}
Button * btnOK {nullptr}
float m_scale_factor
int m_em_unit
wxFont m_normal_font
float m_prev_scale_factor
bool m_can_rescale
bool m_force_rescale
int m_new_font_point_size

Detailed Description

Member Enumeration Documentation

◆ ValidationType

Enumerator
Valid 
NoValid 
Warning 
55 {
56 Valid,
57 NoValid,
59 };
@ Warning
Definition PhysicalPrinterDialog.hpp:58
@ Valid
Definition PhysicalPrinterDialog.hpp:56
@ NoValid
Definition PhysicalPrinterDialog.hpp:57

Constructor & Destructor Documentation

◆ PhysicalPrinterDialog()

Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog ( wxWindow * parent)
75 :
76 DPIDialog(parent, wxID_ANY, _L("Physical Printer"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
77{
78 SetFont(wxGetApp().normal_font());
79 SetBackgroundColour(*wxWHITE);
80
81 // input the preset name
82 Tab *tab = wxGetApp().get_tab(Preset::TYPE_PRINTER);
83 m_presets = tab->get_presets();
84 const Preset &sel_preset = m_presets->get_selected_preset();
85 std::string suffix = _u8L_CONTEXT(L_CONTEXT("Copy", "PresetName"), "PresetName");
86 std::string preset_name = sel_preset.is_default ? _u8L("Untitled") : sel_preset.is_system ? (boost::format(("%1% - %2%")) % sel_preset.name % suffix).str() : sel_preset.name;
87
88 auto input_sizer = new wxBoxSizer(wxVERTICAL);
89
90 wxStaticText *label_top = new wxStaticText(this, wxID_ANY, from_u8((boost::format(_utf8(L("Save %s as"))) % into_u8(tab->title())).str()));
91 label_top->SetFont(::Label::Body_14);
92 label_top->SetForegroundColour(wxColour(38,46,48));
93
94 m_input_area = new RoundedRectangle(this, StateColor::darkModeColorFor(wxColour("#DBDBDB")), wxDefaultPosition, wxSize(-1,-1), 3, 1);
95 m_input_area->SetMinSize(wxSize(FromDIP(360), FromDIP(32)));
96
97 wxBoxSizer *input_sizer_h = new wxBoxSizer(wxHORIZONTAL);
98 wxBoxSizer *input_sizer_v = new wxBoxSizer(wxVERTICAL);
99
100 m_input_ctrl = new wxTextCtrl(m_input_area, -1, from_u8(preset_name), wxDefaultPosition, wxSize(wxSize(FromDIP(360), FromDIP(32)).x, -1), 0 | wxBORDER_NONE);
101 m_input_ctrl->SetBackgroundColour(wxColour(255, 255, 255));
102 m_input_ctrl->Bind(wxEVT_TEXT, [this](wxCommandEvent &) { update(); });
103
104
105 input_sizer_v->Add(m_input_ctrl, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 12);
106 input_sizer_h->Add(input_sizer_v, 0, wxALIGN_CENTER, 0);
107
108 m_input_area->SetSizer(input_sizer_h);
109 m_input_area->Layout();
110
111 m_valid_label = new wxStaticText(this, wxID_ANY, "");
112 m_valid_label->SetForegroundColour(wxColor(255, 111, 0));
113
114 input_sizer->Add(label_top, 0, wxEXPAND | wxLEFT, BORDER_W);
115 input_sizer->Add(m_input_area, 0, wxEXPAND | wxTOP, BORDER_W);
116 input_sizer->Add(m_valid_label, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, BORDER_W);
117
118
119 m_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
120 m_optgroup = new ConfigOptionsGroup(this, _L("Print Host upload"), m_config);
123
124 auto dlg_btns = new DialogButtons(this, {"OK"});
125
126 btnOK = dlg_btns->GetOK();
127 btnOK->Bind(wxEVT_BUTTON, &PhysicalPrinterDialog::OnOK, this);
128
129 wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
130
131 // topSizer->Add(label_top , 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, BORDER_W);
132 topSizer->Add(input_sizer , 0, wxEXPAND | wxALL, BORDER_W);
133 topSizer->Add(m_optgroup->sizer , 1, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, BORDER_W);
134 topSizer->Add(dlg_btns, 0, wxEXPAND);
135
136 Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {this->EndModal(wxID_NO);});
137
138 SetSizer(topSizer);
139 topSizer->SetSizeHints(this);
140 this->CenterOnParent();
141 wxGetApp().UpdateDlgDarkUI(this);
142}
#define BORDER_W
Definition BitmapComboBox.cpp:48
#define L_CONTEXT(s, context)
Definition DesignOffer.hpp:17
#define L(s)
Definition ExtrusionEntity.cpp:25
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Body_14
Definition Label.hpp:53
int em_unit() const
Definition GUI_Utils.hpp:203
const wxFont & normal_font() const
Definition GUI_Utils.hpp:205
void EndModal(int retCode) override
Definition GUI_Utils.hpp:305
RoundedRectangle * m_input_area
Definition PhysicalPrinterDialog.hpp:42
void update(bool printer_change=false)
Definition PhysicalPrinterDialog.cpp:650
ConfigOptionsGroup * m_optgroup
Definition PhysicalPrinterDialog.hpp:33
Button * btnOK
Definition PhysicalPrinterDialog.hpp:45
void check_host_key_valid()
Definition PhysicalPrinterDialog.cpp:882
void build_printhost_settings(ConfigOptionsGroup *optgroup)
Definition PhysicalPrinterDialog.cpp:148
void OnOK(wxEvent &event)
Definition PhysicalPrinterDialog.cpp:892
wxTextCtrl * m_input_ctrl
Definition PhysicalPrinterDialog.hpp:44
wxStaticText * m_valid_label
Definition PhysicalPrinterDialog.hpp:43
DynamicPrintConfig * m_config
Definition PhysicalPrinterDialog.hpp:32
PresetCollection * m_presets
Definition PhysicalPrinterDialog.hpp:60
@ TYPE_PRINTER
Definition Preset.hpp:250
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:36
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
@ Preset
Definition calib.hpp:39
#define _u8L_CONTEXT(s, ctx)
Definition I18N.hpp:16
#define _utf8(s)
Definition I18N.hpp:10
#define _u8L(s)
Definition I18N.hpp:11

References _L, _u8L, _u8L_CONTEXT, _utf8, Label::Body_14, BORDER_W, btnOK, build_printhost_settings(), check_host_key_valid(), StateColor::darkModeColorFor(), Slic3r::GUI::DPIAware< wxDialog >::em_unit(), Slic3r::GUI::DPIDialog::EndModal(), Slic3r::GUI::from_u8(), Slic3r::GUI::Tab::get_presets(), Slic3r::GUI::into_u8(), Slic3r::Preset::is_default, Slic3r::Preset::is_system, L, L_CONTEXT, m_config, m_input_area, m_input_ctrl, m_optgroup, m_presets, m_valid_label, Slic3r::Preset::name, Slic3r::GUI::DPIAware< wxDialog >::normal_font(), OnOK(), Slic3r::GUI::Tab::title(), Slic3r::Preset::TYPE_PRINTER, update(), and wxStaticText.

Here is the call graph for this function:

◆ ~PhysicalPrinterDialog()

Slic3r::GUI::PhysicalPrinterDialog::~PhysicalPrinterDialog ( )
145{
146}

Member Function Documentation

◆ build_printhost_settings()

void Slic3r::GUI::PhysicalPrinterDialog::build_printhost_settings ( ConfigOptionsGroup * optgroup)
private
149{
150 m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
151 if (opt_key == "host_type" || opt_key == "printhost_authorization_type")
152 this->update();
153 if (opt_key == "print_host")
155 if (opt_key == "printhost_port")
156 this->update_ports();
157 if (opt_key == "bbl_use_print_host_webui")
158 this->update_webui();
159 };
160
161 m_optgroup->append_single_option_line("host_type");
162
163 auto create_sizer_with_btn = [](wxWindow* parent, Button** btn, const std::string& icon_name, const wxString& label) {
164 *btn = new Button(parent, label);
166
167 auto sizer = new wxBoxSizer(wxHORIZONTAL);
168 sizer->Add(*btn);
169 return sizer;
170 };
171
172 auto printhost_browse = [=](wxWindow* parent)
173 {
174 auto sizer = create_sizer_with_btn(parent, &m_printhost_browse_btn, "printer_host_browser", _L("Browse") + " " + dots);
175 m_printhost_browse_btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent& e) {
176 const auto host_type = m_config->opt_enum<PrintHostType>("host_type");
177
178 // Creality K-series printers announce themselves via DNS-SD under a
179 // per-device-unique service type _Creality-<MAC-hex>._udp, so the
180 // standard fixed-service-name Bonjour browser does not find them.
181 // Dispatch to the Creality-specific scanner instead.
182 if (host_type == htCrealityPrint) {
183 CrealityDiscoveryDialog dialog(this);
184 if (dialog.ShowModal() == wxID_OK && !dialog.selected_ip().empty()) {
185 // set_value expects the value wrapped as wxString -- TextCtrl::set_value
186 // any_casts to wxString, so a raw std::string throws bad_any_cast.
187 wxString new_url = wxString::FromUTF8("http://" + dialog.selected_ip());
188 m_optgroup->set_value("print_host", new_url, true);
189 m_optgroup->get_field("print_host")->field_changed();
190 }
191 return;
192 }
193
194 if (host_type == htFlashforge) {
195 wxBusyCursor wait;
196 std::vector<FlashforgeDiscoveredPrinter> printers;
197 wxString error_msg;
198 if (!Flashforge::discover_printers(printers, error_msg)) {
199 show_error(this, error_msg);
200 return;
201 }
202
203 wxArrayString choices;
204 for (const auto& printer : printers)
205 choices.Add(from_u8((boost::format("%1% (%2%) [%3%]") % printer.name % printer.ip_address % printer.serial_number).str()));
206
207 wxSingleChoiceDialog dialog(this, _L("Select a Flashforge printer"), _L("Discovered Printers"), choices);
208 if (dialog.ShowModal() == wxID_OK) {
209 const int idx = dialog.GetSelection();
210 if (idx >= 0 && idx < static_cast<int>(printers.size())) {
211 m_optgroup->set_value("print_host", from_u8(printers[idx].ip_address), true);
212 m_optgroup->set_value("flashforge_serial_number", from_u8(printers[idx].serial_number), true);
213 m_config->opt_string("print_host") = printers[idx].ip_address;
214 m_config->opt_string("flashforge_serial_number") = printers[idx].serial_number;
216 }
217 }
218 return;
219 }
220
221 BonjourDialog dialog(this, Preset::printer_technology(*m_config));
222 if (dialog.show_and_lookup()) {
223 m_optgroup->set_value("print_host", dialog.get_selected(), true);
224 m_optgroup->get_field("print_host")->field_changed();
225 }
226 });
227
228 return sizer;
229 };
230
231 auto print_host_test = [=](wxWindow* parent) {
232 auto sizer = create_sizer_with_btn(parent, &m_printhost_test_btn, "printer_host_test", _L("Test"));
233
234 m_printhost_test_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
235 std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
236 if (!host) {
237 const wxString text = _L("Could not get a valid Printer Host reference");
238 show_error(this, text);
239 return;
240 }
241
242 wxString msg;
243 bool result;
244 {
245 // Show a wait cursor during the connection test, as it is blocking UI.
246 wxBusyCursor wait;
247 result = host->test(msg);
248
249 if (!result && host->is_cloud()) {
250 if (const auto h = dynamic_cast<SimplyPrint*>(host.get()); h) {
251 OAuthDialog dlg(this, h->get_oauth_params());
252 dlg.ShowModal();
253
254 const auto& r = dlg.get_result();
255 result = r.success;
256 if (r.success) {
257 h->save_oauth_credential(r);
258 } else {
259 msg = r.error_message;
260 }
261 } else if (const auto h = dynamic_cast<C3DPrinterOS*>(host.get()); h) {
262 GUI::MessageDialog dlg(this, _L("Valid session not detected. Proceed with login to 3DPrinterOS?"), _L("Proceed"),
263 wxICON_INFORMATION | wxYES | wxNO);
264 if (dlg.ShowModal() == wxID_YES) {
265 result = h->login(msg);
266 }
267 } else {
268 PrinterCloudAuthDialog dlg(this->GetParent(), host.get());
269 dlg.ShowModal();
270
271 const auto api_key = dlg.GetApiKey();
272 m_config->opt_string("printhost_apikey") = api_key;
273 result = !api_key.empty();
274 }
275 }
276 }
277 if (result)
278 show_info(this, host->get_test_ok_msg(), _L("Success!"));
279 else
280 show_error(this, host->get_test_failed_msg(msg));
281
282 update();
283 });
284
285 return sizer;
286 };
287
288
289 auto ultimaker_generate_creds = [=](wxWindow* parent) {
290 auto sizer = create_sizer_with_btn(parent, &m_printhost_generate_creds_btn, "ultimaker_generate_creds", _L("Generate API Key"));
291
292 m_printhost_generate_creds_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
293 std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
294 if (!host) {
295 const wxString text = _L("Could not get a valid Printer Host reference");
296 show_error(this, text);
297 return;
298 }
299
300 wxString msg = "generate_auth_creds";
301 bool result;
302 {
303 // Show a wait cursor during the connection test, as it is blocking UI.
304 wxBusyCursor wait;
305 // Send request to printer for api key and such
306 result = host->test(msg); // using test with special input because I don't want to create the generate_auth_creds func for every printer
307
308 // Prompt user to approve access on the machine.
309 show_info(this, _L("API Key created. Go to the physical printer and hit \"authorize\" on the screen, then run \"Test\" again.") + "\n" + msg, _L("API Key created."));
310
311
312 }
313 if (result)
314 show_info(this, host->get_test_ok_msg(), _L("Success!"));
315 else
316 show_error(this, host->get_test_failed_msg(msg));
317
318 update();
319 });
320
321 return sizer;
322 };
323
324
325 auto print_host_logout = [&](wxWindow* parent) {
326 auto sizer = create_sizer_with_btn(parent, &m_printhost_logout_btn, "", _L("Log Out"));
327
328 m_printhost_logout_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
329 std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
330 if (!host) {
331 const wxString text = _L("Could not get a valid Printer Host reference");
332 show_error(this, text);
333 return;
334 }
335
336 wxString msg_text = _L("Are you sure to log out?");
337 MessageDialog dialog(this, msg_text, "", wxICON_QUESTION | wxYES_NO);
338
339 if (dialog.ShowModal() == wxID_YES) {
340 host->log_out();
341 update();
342 }
343 });
344
345 return sizer;
346 };
347
348 auto print_host_printers = [this, create_sizer_with_btn](wxWindow* parent) {
349 //add_scaled_button(parent, &m_printhost_port_browse_btn, "browse", _(L("Refresh Printers")), wxBU_LEFT | wxBU_EXACTFIT);
350 auto sizer = create_sizer_with_btn(parent, &m_printhost_port_browse_btn, "monitor_signal_strong", _L("Refresh") + " " + dots);
351 Button* btn = m_printhost_port_browse_btn;
353 btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent e) { update_printers(); });
354 return sizer;
355 };
356
357 // Set a wider width for a better alignment
358 Option option = m_optgroup->get_option("print_host");
359 option.opt.width = Field::def_width_wider();
360 Line host_line = m_optgroup->create_single_option_line(option);
361 host_line.append_widget(printhost_browse);
362 host_line.append_widget(print_host_test);
363 host_line.append_widget(ultimaker_generate_creds);
364 host_line.append_widget(print_host_logout);
365 m_optgroup->append_line(host_line);
366
367 option = m_optgroup->get_option("print_host_webui");
368 option.opt.width = Field::def_width_wider();
369 m_optgroup->append_single_option_line(option);
370
371 {
372 // For bbl printers, we build a fake option to control whether the original device tab should be used
373 ConfigOptionDef def;
374 def.type = coBool;
375 def.width = Field::def_width_wider();
376 def.label = L("View print host webui in Device tab");
377 def.tooltip = L("Replace the BambuLab's device tab with print host webui");
378 def.set_default_value(new ConfigOptionBool(false));
379
380 auto option = Option(def, "bbl_use_print_host_webui");
381 m_optgroup->append_single_option_line(option);
382 }
383
384 m_optgroup->append_single_option_line("printhost_authorization_type");
385
386 option = m_optgroup->get_option("printhost_apikey");
387 option.opt.width = Field::def_width_wider();
388 m_optgroup->append_single_option_line(option);
389
390 option = m_optgroup->get_option("flashforge_serial_number");
391 option.opt.width = Field::def_width_wider();
392 m_optgroup->append_single_option_line(option);
393
394 option = m_optgroup->get_option("printhost_port");
395 option.opt.width = Field::def_width_wider();
396 Line port_line = m_optgroup->create_single_option_line(option);
397 port_line.append_widget(print_host_printers);
398 m_optgroup->append_line(port_line);
399
400 const auto ca_file_hint = _u8L("HTTPS CA file is optional. It is only needed if you use HTTPS with a self-signed certificate.");
401
403 option = m_optgroup->get_option("printhost_cafile");
404 option.opt.width = Field::def_width_wider();
405 Line cafile_line = m_optgroup->create_single_option_line(option);
406
407 auto printhost_cafile_browse = [=](wxWindow* parent) {
408 auto sizer = create_sizer_with_btn(parent, &m_printhost_cafile_browse_btn, "monitor_signal_strong", _L("Browse") + " " + dots);
409 m_printhost_cafile_browse_btn->Bind(wxEVT_BUTTON, [this, m_optgroup](wxCommandEvent e) {
410 static const auto filemasks = _L("Certificate files (*.crt, *.pem)|*.crt;*.pem|All files|*.*");
411 wxFileDialog openFileDialog(this, _L("Open CA certificate file"), "", "", filemasks, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
412 if (openFileDialog.ShowModal() != wxID_CANCEL) {
413 m_optgroup->set_value("printhost_cafile", openFileDialog.GetPath(), true);
414 m_optgroup->get_field("printhost_cafile")->field_changed();
415 }
416 });
417
418 return sizer;
419 };
420
421 cafile_line.append_widget(printhost_cafile_browse);
422 m_optgroup->append_line(cafile_line);
423
424 Line cafile_hint{ "", "" };
425 cafile_hint.full_width = 1;
426 cafile_hint.widget = [ca_file_hint](wxWindow* parent) {
427 auto txt = new wxStaticText(parent, wxID_ANY, from_u8(ca_file_hint));
428 auto sizer = new wxBoxSizer(wxHORIZONTAL);
429 sizer->Add(txt);
430 return sizer;
431 };
432 m_optgroup->append_line(cafile_hint);
433 }
434 else {
435
436 Line line{ "", "" };
437 line.full_width = 1;
438
439 line.widget = [ca_file_hint](wxWindow* parent) {
440 std::string info = _u8L("HTTPS CA File") + ":\n\t" +
441 (boost::format(_u8L("On this system, %s uses HTTPS certificates from the system Certificate Store or Keychain.")) % SLIC3R_APP_NAME).str() +
442 "\n\t" + _u8L("To use a custom CA file, please import your CA file into Certificate Store / Keychain.");
443
444 //auto txt = new wxStaticText(parent, wxID_ANY, from_u8((boost::format("%1%\n\n\t%2%") % info % ca_file_hint).str()));
445 auto txt = new wxStaticText(parent, wxID_ANY, from_u8((boost::format("%1%\n\t%2%") % info % ca_file_hint).str()));
446 txt->SetFont(wxGetApp().normal_font());
447 auto sizer = new wxBoxSizer(wxHORIZONTAL);
448 sizer->Add(txt, 1, wxEXPAND);
449 return sizer;
450 };
451 m_optgroup->append_line(line);
452 }
453
454 for (const std::string& opt_key : std::vector<std::string>{ "printhost_user", "printhost_password" }) {
455 option = m_optgroup->get_option(opt_key);
456 option.opt.width = Field::def_width_wider();
457 m_optgroup->append_single_option_line(option);
458 }
459
460#ifdef WIN32
461 option = m_optgroup->get_option("printhost_ssl_ignore_revoke");
462 option.opt.width = Field::def_width_wider();
463 m_optgroup->append_single_option_line(option);
464#endif
465
466 m_optgroup->activate();
467
468 Field* printhost_field = m_optgroup->get_field("print_host");
469 if (printhost_field)
470 {
471 wxTextCtrl* temp = dynamic_cast<wxTextCtrl*>(printhost_field->getWindow());
472 if (temp)
473 temp->Bind(wxEVT_TEXT, ([printhost_field, temp](wxEvent& e)
474 {
475#ifndef __WXGTK__
476 e.Skip();
477 temp->GetToolTip()->Enable(true);
478#endif // __WXGTK__
479 // Remove all leading and trailing spaces from the input
480 std::string trimed_str, str = trimed_str = temp->GetValue().ToStdString();
481 boost::trim(trimed_str);
482 if (trimed_str != str)
483 temp->SetValue(trimed_str);
484
485 TextCtrl* field = dynamic_cast<TextCtrl*>(printhost_field);
486 if (field)
487 field->propagate_value();
488 }), temp->GetId());
489 }
490
491 // Always fill in the "printhost_port" combo box from the config and select it.
492 {
493 Choice* choice = dynamic_cast<Choice*>(m_optgroup->get_field("printhost_port"));
494 choice->set_values(std::vector<std::string>{ m_config->opt_string("printhost_port") });
495 choice->set_selection();
496 }
497
498 update();
499}
@ Regular
Definition Button.hpp:24
@ Choice
Definition Button.hpp:33
@ Parameter
Definition Button.hpp:34
wxTextCtrl TextCtrl
Definition TextCtrl.h:14
void SetStyle(const ButtonStyle style, const ButtonType type)
Definition Button.cpp:200
static bool discover_printers(std::vector< FlashforgeDiscoveredPrinter > &printers, wxString &msg, int timeout_ms=10000, int idle_timeout_ms=1500, int max_retries=3)
Definition Flashforge.cpp:241
static int def_width_wider()
Definition Field.cpp:402
void update_printers()
Definition PhysicalPrinterDialog.cpp:842
void update_webui()
Definition PhysicalPrinterDialog.cpp:537
void update_ports()
Definition PhysicalPrinterDialog.cpp:501
void update_printhost_buttons()
Definition PhysicalPrinterDialog.cpp:561
Button * m_printhost_browse_btn
Definition PhysicalPrinterDialog.hpp:35
Button * m_printhost_generate_creds_btn
Definition PhysicalPrinterDialog.hpp:37
Button * m_printhost_logout_btn
Definition PhysicalPrinterDialog.hpp:38
Button * m_printhost_cafile_browse_btn
Definition PhysicalPrinterDialog.hpp:39
Button * m_printhost_port_browse_btn
Definition PhysicalPrinterDialog.hpp:40
Button * m_printhost_test_btn
Definition PhysicalPrinterDialog.hpp:36
static bool ca_file_supported()
Definition Http.cpp:943
PrinterTechnology printer_technology() const
Definition Preset.hpp:399
static PrintHost * get_print_host(DynamicPrintConfig *config)
Definition PrintHost.cpp:58
static wxString dots("...", wxConvUTF8)
void show_error(wxWindow *parent, const wxString &message, bool has_code_excerpts)
Definition GUI.cpp:296
void show_info(wxWindow *parent, const wxString &message, const wxString &title)
Definition GUI.cpp:316
std::string t_config_option_key
Definition Config.hpp:96
PrintHostType
Definition PrintConfig.hpp:118
@ htCrealityPrint
Definition PrintConfig.hpp:119
@ htFlashforge
Definition PrintConfig.hpp:119
@ coBool
Definition Config.hpp:210

References _L, _u8L, Slic3r::GUI::ConfigOptionsGroup::append_single_option_line(), Slic3r::GUI::Line::append_widget(), Slic3r::Http::ca_file_supported(), Slic3r::coBool, Slic3r::GUI::Field::def_width_wider(), Slic3r::Flashforge::discover_printers(), Slic3r::GUI::dots(), Slic3r::GUI::from_u8(), Slic3r::GUI::Line::full_width, Slic3r::PrintHost::get_print_host(), Slic3r::GUI::OAuthDialog::get_result(), Slic3r::BonjourDialog::get_selected(), Slic3r::GUI::PrinterCloudAuthDialog::GetApiKey(), Slic3r::GUI::Field::getWindow(), Slic3r::htCrealityPrint, Slic3r::htFlashforge, L, Slic3r::ConfigOptionDef::label, m_config, m_optgroup, m_printhost_browse_btn, m_printhost_cafile_browse_btn, m_printhost_generate_creds_btn, m_printhost_logout_btn, m_printhost_port_browse_btn, m_printhost_test_btn, Slic3r::GUI::DPIAware< wxDialog >::normal_font(), Slic3r::GUI::Option::opt, Parameter, Slic3r::Preset::printer_technology(), Slic3r::GUI::TextCtrl::propagate_value(), Regular, Slic3r::GUI::CrealityDiscoveryDialog::selected_ip(), Slic3r::ConfigOptionDef::set_default_value(), Slic3r::GUI::Choice::set_selection(), Slic3r::GUI::Choice::set_values(), Button::SetStyle(), Slic3r::BonjourDialog::show_and_lookup(), Slic3r::GUI::show_error(), Slic3r::GUI::show_info(), Slic3r::GUI::DPIAware< P >::ShowModal(), Slic3r::GUI::OAuthResult::success, Slic3r::ConfigOptionDef::tooltip, Slic3r::ConfigOptionDef::type, update(), update_ports(), update_printers(), update_printhost_buttons(), update_webui(), Slic3r::GUI::Line::widget, Slic3r::ConfigOptionDef::width, and wxStaticText.

Referenced by PhysicalPrinterDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_host_key_valid()

void Slic3r::GUI::PhysicalPrinterDialog::check_host_key_valid ( )
protected
883{
884 std::vector<std::string> keys = {"print_host", "print_host_webui", "printhost_apikey", "flashforge_serial_number", "printhost_cafile", "printhost_user", "printhost_password", "printhost_port"};
885 for (auto &key : keys) {
886 auto it = m_config->option<ConfigOptionString>(key);
887 if (!it) m_config->set_key_value(key, new ConfigOptionString(""));
888 }
889 return;
890}
zaa_minimize_perimeter_height ConfigOptionString
Definition PrintConfig.hpp:1702

References Slic3r::ConfigOptionString, and m_config.

Referenced by PhysicalPrinterDialog().

Here is the caller graph for this function:

◆ em_unit()

int Slic3r::GUI::DPIAware< wxDialog >::em_unit ( ) const
inlineinherited
203{ return m_em_unit; }
Definition GUI_Utils.hpp:107

Referenced by Slic3r::GUI::AuxiliaryDialog::AuxiliaryDialog(), Slic3r::GUI::CopyrightsDialog::CopyrightsDialog(), Slic3r::GUI::DesignTextDialog::DesignTextDialog(), Slic3r::GUI::EditGCodeDialog::EditGCodeDialog(), Slic3r::GUI::FileArchiveDialog::FileArchiveDialog(), Slic3r::GUI::MsgNoUpdates::MsgNoUpdates(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::OAuthDialog::OAuthDialog(), Slic3r::GUI::ParamsDialog::ParamsDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::SettingsDialog::SettingsDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), anonymous_namespace{3DPrinterOS.cpp}::UploadOptionsDialog::UploadOptionsDialog(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::DiffPresetDialog::complete_dialog_creation(), Slic3r::GUI::DiffPresetDialog::create_edit_sizer(), Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), Slic3r::GUI::DiffPresetDialog::create_tree(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::AboutDialog::on_dpi_changed(), Slic3r::GUI::AuxiliaryDialog::on_dpi_changed(), Slic3r::GUI::BedShapeDialog::on_dpi_changed(), Slic3r::GUI::ConfigWizard::on_dpi_changed(), Slic3r::GUI::CopyrightsDialog::on_dpi_changed(), Slic3r::GUI::DiffPresetDialog::on_dpi_changed(), Slic3r::GUI::EditGCodeDialog::on_dpi_changed(), Slic3r::GUI::FileArchiveDialog::on_dpi_changed(), Slic3r::GUI::OAuthDialog::on_dpi_changed(), Slic3r::GUI::ObjectTableDialog::on_dpi_changed(), Slic3r::GUI::ParamsDialog::on_dpi_changed(), Slic3r::GUI::PhysicalPrinterDialog::on_dpi_changed(), Slic3r::GUI::PrintHostQueueDialog::on_dpi_changed(), Slic3r::GUI::PurgeModeDialog::on_dpi_changed(), Slic3r::GUI::SavePresetDialog::on_dpi_changed(), Slic3r::GUI::SendSystemInfoDialog::on_dpi_changed(), Slic3r::GUI::SettingsDialog::on_dpi_changed(), and Slic3r::GUI::UnsavedChangesDialog::on_dpi_changed().

Here is the caller graph for this function:

◆ enable_force_rescale()

void Slic3r::GUI::DPIAware< wxDialog >::enable_force_rescale ( )
inlineinherited
206{ m_force_rescale = true; }

◆ EndModal()

void Slic3r::GUI::DPIDialog::EndModal ( int retCode)
inlineoverrideinherited
306 {
307 if (!dialogStack.empty() && dialogStack.front() != this) {
308 // This is a bug in wxWidgets
309 // when the dialog is not top modal dialog, EndModal() just hide dialog without quit
310 // the modal event loop. And the modal event loop blocks us from bottom widgets.
311 // Solution: let user click it manually or close outside. FIXME
312 BOOST_LOG_TRIVIAL(warning) << "DPIAware::EndModal Error: dialogStack is not empty, but top dialog is not this one. retCode=" << retCode;
313 return;
314 }
315
316 return wxDialog::EndModal(retCode);
317 }
std::deque< wxDialog * > dialogStack
Definition GUI_Utils.cpp:549

References Slic3r::GUI::dialogStack.

Referenced by Slic3r::GUI::CloneDialog::CloneDialog(), Slic3r::GUI::ConfigWizard::ConfigWizard(), Slic3r::GUI::CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(), Slic3r::GUI::DeleteConfirmDialog::DeleteConfirmDialog(), Slic3r::GUI::DesignVariableDialog::DesignVariableDialog(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::FlashforgeSlotDialog(), Slic3r::GUI::GuideFrame::GuideFrame(), Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MsgUpdateConfig::MsgUpdateConfig(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::MultiChoiceDialog::MultiChoiceDialog(), Slic3r::GUI::NetworkErrorDialog::NetworkErrorDialog(), Slic3r::GUI::NetworkPluginRestartDialog::NetworkPluginRestartDialog(), Slic3r::GUI::PartSkipConfirmDialog::PartSkipConfirmDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::PlateNameEditDialog::PlateNameEditDialog(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PublishSettingsDialog::PublishSettingsDialog(), Slic3r::GUI::SelectMachineDialog::SelectMachineDialog(), Slic3r::GUI::SendFailedConfirm::SendFailedConfirm(), Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), Slic3r::GUI::SingleChoiceDialog::SingleChoiceDialog(), StepMeshDialog::StepMeshDialog(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), Slic3r::GUI::UpdatePluginDialog::UpdatePluginDialog(), Slic3r::GUI::UpdateVersionDialog::UpdateVersionDialog(), Slic3r::GUI::wgtDeviceNozzleRackUpgradeDlg::wgtDeviceNozzleRackUpgradeDlg(), Slic3r::GUI::SavePresetDialog::accept(), Slic3r::GUI::MsgDialog::add_button(), Slic3r::GUI::TipsDialog::add_button(), Slic3r::GUI::FilamentPickerDialog::BindEvents(), Slic3r::GUI::PluginPickerDialog::build_capability_ui(), Slic3r::GUI::BedShapeDialog::build_dialog(), Slic3r::GUI::PluginPickerDialog::build_ui(), Slic3r::GUI::UnsavedChangesDialog::close(), Slic3r::GUI::FileArchiveDialog::create_btn_sizer(), Slic3r::GUI::ColorDecomposeDialog::create_button_panel(), Slic3r::GUI::MixedFilamentDialog::create_button_panel(), Slic3r::GUI::CreateFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::CreatePresetForPrinterDialog::create_dialog_buttons(), Slic3r::GUI::EditFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::create_dialog_buttons(), Slic3r::GUI::PreferencesDialog::create_item_language_combobox(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::GUI::PreferencesDialog::create_items(), Slic3r::GUI::CreatePrinterPresetDialog::create_page1_dialog_buttons(), Slic3r::GUI::CreatePrinterPresetDialog::create_page2_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::data_init(), Slic3r::GUI::WebDialog::destroy_silently(), Slic3r::GUI::EditFilamentPresetDialog::edit_preset(), Slic3r::GUI::ConnectPrinterDialog::end_modal(), Slic3r::GUI::PrintHostSendDialog::EndModal(), Slic3r::GUI::ColorPickerDialog::finish(), Slic3r::GUI::WebDialog::finish(), Slic3r::GUI::Newer3mfVersionDialog::get_btn_sizer(), Slic3r::GUI::ScoreDialog::get_button_sizer(), Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), Slic3r::GUI::ExportPresetBundleDialog::InitExportData(), Slic3r::GUI::SelectMachineDialog::navigate_to_timelapse_page(), Slic3r::GUI::BindMachineDialog::on_bind_success(), Slic3r::GUI::ConnectPrinterDialog::on_button_confirm(), Slic3r::GUI::RecenterDialog::on_button_confirm(), Slic3r::GUI::BindMachineDialog::on_cancel(), Slic3r::GUI::EditCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::InputIpAddressDialog::on_cancel(), Slic3r::GUI::NewCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::OAuthDialog::on_cancel(), Slic3r::GUI::PingCodeBindDialog::on_cancel(), Slic3r::GUI::SelectMachineDialog::on_cancel(), Slic3r::GUI::SendToPrinterDialog::on_cancel(), Slic3r::GUI::SyncAmsInfoDialog::on_cancel(), Slic3r::GUI::UnBindMachineDialog::on_cancel(), Slic3r::GUI::WebDialog::on_close_window(), Slic3r::GUI::NetworkPluginDownloadDialog::on_dont_ask(), Slic3r::GUI::NetworkPluginDownloadDialog::on_download(), Slic3r::GUI::EditDevNameDialog::on_edit_name(), Slic3r::GUI::ConfirmBeforeSendDialog::on_hide(), Slic3r::GUI::PrivacyUpdateDialog::on_hide(), Slic3r::GUI::ShortcutCaptureDialog::on_key(), Slic3r::GUI::TextureImportDialog::on_ok_clicked(), Slic3r::GUI::FileArchiveDialog::on_open_button(), Slic3r::GUI::NetworkPluginDownloadDialog::on_remind_later(), Slic3r::GUI::ProjectDropDialog::on_select_cancel(), Slic3r::GUI::SavePresetDialog::on_select_cancel(), Slic3r::GUI::ProjectDropDialog::on_select_ok(), Slic3r::GUI::SendMultiMachinePage::on_send(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip(), Slic3r::GUI::TextureImportDialog::on_skip_clicked(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip_version(), Slic3r::GUI::Cornering_Test_Dlg::on_start(), Slic3r::GUI::FlowRateCalibrationDialog::on_start(), Slic3r::GUI::Input_Shaping_Damp_Test_Dlg::on_start(), Slic3r::GUI::Input_Shaping_Freq_Test_Dlg::on_start(), Slic3r::GUI::MaxVolumetricSpeed_Test_Dlg::on_start(), Slic3r::GUI::PA_Calibration_Dlg::on_start(), Slic3r::GUI::Retraction_Test_Dlg::on_start(), Slic3r::GUI::Temp_Calibration_Dlg::on_start(), Slic3r::GUI::VFA_Test_Dlg::on_start(), Slic3r::GUI::CalibrationDialog::on_start_calibration(), Slic3r::GUI::UnBindMachineDialog::on_unbind_printer(), Slic3r::GUI::PartSkipDialog::OnApplyDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::OnCancel(), Slic3r::GUI::AboutDialog::onCloseDialog(), Slic3r::GUI::CopyrightsDialog::onCloseDialog(), Slic3r::GUI::MultiNozzleSyncDialog::OnRackStatusReadingFinished(), Slic3r::GUI::GuideFrame::OnScriptMessage(), Slic3r::GUI::InputIpAddressDialog::OnTimer(), Slic3r::GUI::KBShortcutsDialog::open_mouse_preferences(), Slic3r::GUI::TroubleshootDialog::PackAll(), Slic3r::GUI::TroubleshootDialog::RebuildSystemProfiles(), Slic3r::GUI::SpeedDialWebDialog::run_action(), Slic3r::GUI::OAuthDialog::Show(), Slic3r::GUI::MultiNozzleSyncDialog::UpdateButton(), and Slic3r::GUI::CreatePrinterPresetDialog::validate_input_valid().

◆ force_rescale()

bool Slic3r::GUI::DPIAware< wxDialog >::force_rescale ( ) const
inlineinherited
201{ return m_force_rescale; }

◆ is_new_scale_factor()

bool Slic3r::GUI::DPIAware< wxDialog >::is_new_scale_factor ( ) const
inlineprivateinherited
262{ return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }

◆ normal_font()

◆ on_dpi_changed()

void Slic3r::GUI::PhysicalPrinterDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprotectedvirtual

Implements Slic3r::GUI::DPIAware< wxDialog >.

863{
864 const int& em = em_unit();
865
866 m_printhost_browse_btn->Rescale();
867 m_printhost_test_btn->Rescale();
869 m_printhost_logout_btn->Rescale();
872
873 m_optgroup->msw_rescale();
874
875 const wxSize& size = wxSize(45 * em, 35 * em);
876 SetMinSize(size);
877
878 Fit();
879 Refresh();
880}

References Slic3r::GUI::DPIAware< wxDialog >::em_unit(), m_optgroup, m_printhost_browse_btn, m_printhost_cafile_browse_btn, m_printhost_generate_creds_btn, m_printhost_logout_btn, and m_printhost_test_btn.

Here is the call graph for this function:

◆ on_sys_color_changed()

void Slic3r::GUI::PhysicalPrinterDialog::on_sys_color_changed ( )
inlineoverrideprotectedvirtual

Reimplemented from Slic3r::GUI::DPIAware< wxDialog >.

74{};

◆ OnOK()

void Slic3r::GUI::PhysicalPrinterDialog::OnOK ( wxEvent & event)
private
893{
894 wxGetApp().get_tab(Preset::TYPE_PRINTER)->save_preset("", false, false, true, m_preset_name);
895 event.Skip();
896}
std::string m_preset_name
Definition PhysicalPrinterDialog.hpp:62

References m_preset_name, and Slic3r::Preset::TYPE_PRINTER.

Referenced by PhysicalPrinterDialog().

Here is the caller graph for this function:

◆ prev_scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::prev_scale_factor ( ) const
inlineinherited
196{ return m_prev_scale_factor; }

◆ rescale()

void Slic3r::GUI::DPIAware< wxDialog >::rescale ( const wxRect & suggested_rect)
inlineprivateinherited
265 {
266 this->Freeze();
267
268 m_force_rescale = false;
269
270 // set normal application font as a current window font
271 m_normal_font = this->GetFont();
272
274
275 // rescale missed controls sizes and images
277
278 this->Layout();
279 this->Thaw();
280
281 // reset previous scale factor from current scale factor value
283 }
virtual void on_dpi_changed(const wxRect &suggested_rect)=0
void update_em_unit()
Definition GUI_Utils.hpp:249

◆ scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::scale_factor ( ) const
inlineinherited
195{ return m_scale_factor; }

◆ set_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::set_em_unit ( int v)
inlineinherited
200{ m_em_unit = v; }

◆ set_prev_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_prev_scale_factor ( float v)
inlineinherited

◆ set_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_scale_factor ( float v)
inlineinherited
198{ m_scale_factor = v; }

◆ ShowModal()

◆ update()

void Slic3r::GUI::PhysicalPrinterDialog::update ( bool printer_change = false)
651{
652 m_optgroup->reload_config();
653
655 // Only offer the host type selection for FFF, for SLA it's always the SL1 printer (at the moment)
656 bool supports_multiple_printers = false;
657 if (tech == ptFFF) {
658 update_host_type(printer_change);
659 const auto opt = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type");
660 m_optgroup->show_field("host_type");
661
662 m_optgroup->enable_field("print_host");
663 m_optgroup->show_field("print_host_webui");
664 m_optgroup->hide_field("bbl_use_print_host_webui");
665 m_optgroup->enable_field("printhost_cafile");
666 m_optgroup->enable_field("printhost_ssl_ignore_revoke");
668
669 // hide pre-configured address, in case user switched to a different host type
670 if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) {
671 if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_field)->text_ctrl(); temp) {
672 const auto current_host = temp->GetValue();
673 if (current_host == L"https://connect.prusa3d.com" ||
674 current_host == L"https://app.obico.io" ||
675 current_host == "https://simplyprint.io" || current_host == "https://simplyprint.io/panel" ||
676 current_host == C3DPrinterOS::default_host()) {
677 temp->SetValue(wxString());
678 m_config->opt_string("print_host") = "";
679 }
680 }
681 }
682 if (opt->value == htPrusaLink) { // PrusaConnect does NOT allow http digest
683 m_optgroup->show_field("printhost_authorization_type");
684 AuthorizationType auth_type = m_config->option<ConfigOptionEnum<AuthorizationType>>("printhost_authorization_type")->value;
685 m_optgroup->show_field("printhost_apikey", auth_type == AuthorizationType::atKeyPassword);
686 for (const char* opt_key : { "printhost_user", "printhost_password" })
687 m_optgroup->show_field(opt_key, auth_type == AuthorizationType::atUserPassword);
688 } else {
689 m_optgroup->hide_field("printhost_authorization_type");
690 m_optgroup->show_field("printhost_apikey", true);
691 for (const std::string& opt_key : std::vector<std::string>{ "printhost_user", "printhost_password" })
692 m_optgroup->hide_field(opt_key);
693 supports_multiple_printers = opt->value == htRepetier || opt->value == htObico;
694
695 if (opt->value == htPrusaConnect) { // automatically show default prusaconnect address
696 if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) {
697 if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_field)->text_ctrl(); temp && temp->GetValue().IsEmpty()) {
698 temp->SetValue(L"https://connect.prusa3d.com");
699 m_config->opt_string("print_host") = "https://connect.prusa3d.com";
700 }
701 }
702 } else if (opt->value == htObico) { // automatically show default obico address
703 if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) {
704 if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_field)->text_ctrl(); temp && temp->GetValue().IsEmpty()) {
705 temp->SetValue(L"https://app.obico.io");
706 m_config->opt_string("print_host") = "https://app.obico.io";
707 }
708 }
709 } else if (opt->value == htSimplyPrint) {
710 // Set the host url
711 if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) {
712 printhost_field->disable();
713 if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_field)->text_ctrl(); temp && temp->GetValue().IsEmpty()) {
714 temp->SetValue("https://simplyprint.io/panel");
715 }
716 m_config->opt_string("print_host") = "https://simplyprint.io/panel";
717 }
718
719 const auto current_webui = m_config->opt_string("print_host_webui");
720 if (!current_webui.empty()) {
721 if (Field* printhost_webui_field = m_optgroup->get_field("print_host_webui"); printhost_webui_field) {
722 if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_webui_field)->text_ctrl(); temp) {
723 temp->SetValue("https://simplyprint.io/panel");
724 }
725 }
726 m_config->opt_string("print_host_webui") = "https://simplyprint.io/panel";
727 }
728
729 // For bbl printers, show option to control the device tab
730 if (wxGetApp().preset_bundle->is_bbl_vendor() || wxGetApp().app_config->get_bool("use_printer_agents")) {
731 m_optgroup->show_field("bbl_use_print_host_webui");
732 const bool use_print_host_webui = !current_webui.empty();
733 if (Field* printhost_webui_field = m_optgroup->get_field("bbl_use_print_host_webui"); printhost_webui_field) {
734 if (CheckBox* temp = dynamic_cast<CheckBox*>(printhost_webui_field); temp) {
735 temp->set_value(use_print_host_webui);
736 }
737 }
738 }
739
740 m_optgroup->hide_field("print_host_webui");
741 m_optgroup->hide_field("printhost_apikey");
742 m_optgroup->disable_field("printhost_cafile");
743 m_optgroup->disable_field("printhost_ssl_ignore_revoke");
746 } else if (opt->value == ht3DPrinterOS) {
747 if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) {
748 if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_field)->text_ctrl(); temp && temp->GetValue().IsEmpty()) {
749 temp->SetValue(C3DPrinterOS::default_host());
750 m_config->opt_string("print_host") = C3DPrinterOS::default_host();
751 }
752 }
753 m_optgroup->hide_field("print_host_webui");
754 m_optgroup->hide_field("printhost_apikey");
755 }
756 }
757
758 if (opt->value == htFlashforge) {
759 m_optgroup->show_field("printhost_apikey");
760 m_optgroup->show_field("flashforge_serial_number");
761 m_optgroup->hide_field("printhost_authorization_type");
762 } else {
763 m_optgroup->hide_field("flashforge_serial_number");
764 }
765
766 if (opt->value == htUltiMaker) {
767 m_optgroup->hide_field("printhost_apikey");
768 m_optgroup->hide_field("printhost_authorization_type");
769 m_optgroup->hide_field("bbl_use_print_host_webui");
770 m_optgroup->hide_field("printhost_cafile");
771 m_optgroup->show_field("printhost_user");
772 m_optgroup->show_field("printhost_password");
773 m_optgroup->enable_field("print_host");
774 m_optgroup->show_field("print_host_webui");
777 }
780 }
781 }
782 }
783 else {
784 m_optgroup->set_value("host_type", int(PrintHostType::htOctoPrint), false);
785 m_optgroup->hide_field("host_type");
786 m_optgroup->hide_field("flashforge_serial_number");
787
788 m_optgroup->show_field("printhost_authorization_type");
789
790 AuthorizationType auth_type = m_config->option<ConfigOptionEnum<AuthorizationType>>("printhost_authorization_type")->value;
791 m_optgroup->show_field("printhost_apikey", auth_type == AuthorizationType::atKeyPassword);
792
793 for (const char *opt_key : { "printhost_user", "printhost_password" })
794 m_optgroup->show_field(opt_key, auth_type == AuthorizationType::atUserPassword);
795 }
796
797 // The "Generate API Key" button is only meaningful for UltiMaker printers.
799 m_printhost_generate_creds_btn->Show(tech == ptFFF && m_config->opt_enum<PrintHostType>("host_type") == htUltiMaker);
800
801 m_optgroup->show_field("printhost_port", supports_multiple_printers);
802 m_printhost_port_browse_btn->Show(supports_multiple_printers);
803
805
807
808 this->SetSize(this->GetBestSize());
809 this->Layout();
810}
static std::string default_host()
Definition 3DPrinterOS.hpp:42
void update_preset_input()
Definition PhysicalPrinterDialog.cpp:572
void update_host_type(bool printer_change)
Definition PhysicalPrinterDialog.cpp:812
AuthorizationType
Definition PrintConfig.hpp:122
@ atUserPassword
Definition PrintConfig.hpp:123
@ atKeyPassword
Definition PrintConfig.hpp:123
PrinterTechnology
Definition Config.hpp:229
@ ptFFF
Definition Config.hpp:231
@ htSimplyPrint
Definition PrintConfig.hpp:119
@ ht3DPrinterOS
Definition PrintConfig.hpp:119
@ htPrusaLink
Definition PrintConfig.hpp:119
@ htRepetier
Definition PrintConfig.hpp:119
@ htPrusaConnect
Definition PrintConfig.hpp:119
@ htUltiMaker
Definition PrintConfig.hpp:119
@ htObico
Definition PrintConfig.hpp:119
@ htOctoPrint
Definition PrintConfig.hpp:119

References Slic3r::atKeyPassword, Slic3r::atUserPassword, Slic3r::C3DPrinterOS::default_host(), Slic3r::ht3DPrinterOS, Slic3r::htFlashforge, Slic3r::htObico, Slic3r::htOctoPrint, Slic3r::htPrusaConnect, Slic3r::htPrusaLink, Slic3r::htRepetier, Slic3r::htSimplyPrint, Slic3r::htUltiMaker, L, m_config, m_optgroup, m_printhost_cafile_browse_btn, m_printhost_generate_creds_btn, m_printhost_port_browse_btn, Slic3r::Preset::printer_technology(), Slic3r::ptFFF, update_host_type(), update_preset_input(), and update_printhost_buttons().

Referenced by PhysicalPrinterDialog(), and build_printhost_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::update_em_unit ( )
inlineprivateinherited
250 {
251 // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
252 // So, calculate the m_em_unit value from the font size, as before
253#if !defined(__WXGTK__)
255#else
256 // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
257 m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
258#endif // __WXGTK__
259 }

◆ update_host_type()

void Slic3r::GUI::PhysicalPrinterDialog::update_host_type ( bool printer_change)
813{
814 if (m_config == nullptr)
815 return;
816 Field* ht = m_optgroup->get_field("host_type");
817 wxArrayString types;
818 int last_in_conf = m_config->option("host_type")->getInt(); // this is real position in last choice
819
820 // Append localized enum_labels
821 assert(ht->m_opt.enum_labels.size() == ht->m_opt.enum_values.size());
822 for (size_t i = 0; i < ht->m_opt.enum_labels.size(); ++ i) {
823 wxString label = _(ht->m_opt.enum_labels[i]);
824 types.Add(label);
825 }
826
827 Choice* choice = dynamic_cast<Choice*>(ht);
828 choice->set_values(types);
829 int index_in_choice = (printer_change ? std::clamp(last_in_conf - ((int)ht->m_opt.enum_values.size() - (int)types.size()), 0, (int)ht->m_opt.enum_values.size() - 1) : last_in_conf);
830 choice->set_value(index_in_choice);
831 if ("prusalink" == ht->m_opt.enum_values.at(index_in_choice))
832 m_config->set_key_value("host_type", new ConfigOptionEnum<PrintHostType>(htPrusaLink));
833 else if ("prusaconnect" == ht->m_opt.enum_values.at(index_in_choice))
834 m_config->set_key_value("host_type", new ConfigOptionEnum<PrintHostType>(htPrusaConnect));
835 else {
836 int host_type = std::clamp(index_in_choice + ((int)ht->m_opt.enum_values.size() - (int)types.size()), 0, (int)ht->m_opt.enum_values.size() - 1);
837 PrintHostType type = static_cast<PrintHostType>(host_type);
838 m_config->set_key_value("host_type", new ConfigOptionEnum<PrintHostType>(type));
839 }
840}
#define _(s)
Definition 3mf.cpp:306

References _, Slic3r::ConfigOptionDef::enum_labels, Slic3r::ConfigOptionDef::enum_values, Slic3r::htPrusaConnect, Slic3r::htPrusaLink, m_config, Slic3r::GUI::Field::m_opt, m_optgroup, Slic3r::GUI::Choice::set_value(), and Slic3r::GUI::Choice::set_values().

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_ports()

void Slic3r::GUI::PhysicalPrinterDialog::update_ports ( )
501 {
503 if (tech == ptFFF) {
504 const auto opt = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type");
505 if (opt->value == htObico) {
506 auto build_web_ui = [](DynamicPrintConfig* config) {
507 auto host = config->opt_string("print_host");
508 auto port = config->opt_string("printhost_port");
509 auto api_key = config->opt_string("printhost_apikey");
510 if (host.empty() || port.empty()) {
511 return std::string();
512 }
513 boost::regex re("\\[(\\d+)\\]");
514 boost::smatch match;
515 if (!boost::regex_search(port, match, re))
516 return std::string();
517 if (match.size() <= 1) {
518 return std::string();
519 }
520 boost::format urlFormat("%1%/printers/%2%/control");
521 urlFormat % host % match[1];
522 return urlFormat.str();
523 };
524 auto url = build_web_ui(m_config);
525 if (Field* print_host_webui_field = m_optgroup->get_field("print_host_webui"); print_host_webui_field) {
526 if (TextInput* temp_input = dynamic_cast<TextInput*>(print_host_webui_field->getWindow()); temp_input) {
527 if (wxTextCtrl* temp = temp_input->GetTextCtrl()) {
528 temp->SetValue(wxString(url));
529 m_config->opt_string("print_host_webui") = url;
530 }
531 }
532 }
533 }
534 }
535}

References Slic3r::htObico, m_config, m_optgroup, Slic3r::Preset::printer_technology(), and Slic3r::ptFFF.

Referenced by build_printhost_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_preset_input()

void Slic3r::GUI::PhysicalPrinterDialog::update_preset_input ( )
572 {
573 m_preset_name = into_u8(m_input_ctrl->GetValue());
574
576 wxString info_line;
577
578 const char *unusable_symbols = "<>[]:/\\|?*\"";
579
580 const std::string unusable_suffix = PresetCollection::get_suffix_modified(); //"(modified)";
581 for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
582 if (m_preset_name.find_first_of(unusable_symbols[i]) != std::string::npos) {
583 info_line = _L("Name is invalid;") + "\n" + _L("illegal characters:") + " " + unusable_symbols;
585 break;
586 }
587 }
588
589
590 if (m_valid_type == Valid && m_preset_name.find(unusable_suffix) != std::string::npos) {
591 info_line = _L("Name is invalid;") + "\n" + _L("illegal suffix:") + "\n\t" + from_u8(PresetCollection::get_suffix_modified());
593 }
594
595 if (m_valid_type == Valid &&
596 (m_preset_name == "Default Setting" || m_preset_name == PresetBundle::ORCA_DEFAULT_FILAMENT_PLACEHOLDER || m_preset_name == "Default Printer")) {
597 info_line = _L("Name is unavailable.");
599 }
600
601 const Preset *existing = m_presets->find_preset(m_preset_name, false);
602 if (m_valid_type == Valid && existing && (existing->is_default || existing->is_system)) {
603 info_line = _L("Overwriting a system profile is not allowed.");
605 }
606
607 if (m_valid_type == Valid && existing && m_preset_name != m_presets->get_selected_preset_name()) {
608 if (existing->is_compatible)
609 info_line = from_u8((boost::format(_u8L("Preset \"%1%\" already exists.")) % m_preset_name).str());
610 else
611 info_line = from_u8((boost::format(_u8L("Preset \"%1%\" already exists and is incompatible with the current printer.")) % m_preset_name).str());
612 info_line += "\n" + _L("Please note that saving will overwrite the current preset.");
614 }
615
616 if (m_valid_type == Valid && m_preset_name.empty()) {
617 info_line = _L("The name field is not allowed to be empty.");
619 }
620
621 if (m_valid_type == Valid && m_preset_name.find_first_of(' ') == 0) {
622 info_line = _L("The name is not allowed to start with a space.");
624 }
625
626 if (m_valid_type == Valid && m_preset_name.find_last_of(' ') == m_preset_name.length() - 1) {
627 info_line = _L("The name is not allowed to end with a space.");
629 }
630
631 if (m_valid_type == Valid && m_presets->get_preset_name_by_alias(m_preset_name) != m_preset_name) {
632 info_line = _L("The name cannot be the same as a preset alias name.");
634 }
635
636 m_valid_label->SetLabel(info_line);
637 m_input_area->Refresh();
638 m_valid_label->Show(!info_line.IsEmpty());
639
640 if (m_valid_type == NoValid) {
641 if (btnOK)
642 btnOK->Disable();
643 }
644 else {
645 if (btnOK)
646 btnOK->Enable();
647 }
648}
ValidationType m_valid_type
Definition PhysicalPrinterDialog.hpp:61
static const char * ORCA_DEFAULT_FILAMENT_PLACEHOLDER
Definition PresetBundle.hpp:691
static const std::string & get_suffix_modified()
Definition Preset.cpp:3766

References _L, _u8L, btnOK, Slic3r::GUI::from_u8(), Slic3r::PresetCollection::get_suffix_modified(), Slic3r::GUI::into_u8(), Slic3r::Preset::is_compatible, Slic3r::Preset::is_default, Slic3r::Preset::is_system, m_input_area, m_input_ctrl, m_preset_name, m_presets, m_valid_label, m_valid_type, NoValid, Slic3r::PresetBundle::ORCA_DEFAULT_FILAMENT_PLACEHOLDER, Valid, and Warning.

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_printers()

void Slic3r::GUI::PhysicalPrinterDialog::update_printers ( )
843{
844 wxBusyCursor wait;
845
846 std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
847
848 wxArrayString printers;
849 Field *rs = m_optgroup->get_field("printhost_port");
850 try {
851 if (! host->get_printers(printers))
852 printers.clear();
853 } catch (const HostNetworkError &err) {
854 printers.clear();
855 show_error(this, _L("Connection to printers connected via the print host failed.") + "\n\n" + from_u8(err.what()));
856 }
857 Choice *choice = dynamic_cast<Choice*>(rs);
858 choice->set_values(printers);
859 printers.empty() ? rs->disable() : rs->enable();
860}

References _L, Slic3r::GUI::Field::disable(), Slic3r::GUI::Field::enable(), Slic3r::GUI::from_u8(), Slic3r::PrintHost::get_print_host(), m_config, m_optgroup, Slic3r::GUI::Choice::set_values(), and Slic3r::GUI::show_error().

Referenced by build_printhost_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_printhost_buttons()

void Slic3r::GUI::PhysicalPrinterDialog::update_printhost_buttons ( )
562{
563 std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
564 if (host) {
565 m_printhost_test_btn->Enable(!m_config->opt_string("print_host").empty() && host->can_test());
566 m_printhost_browse_btn->Show(host->has_auto_discovery());
567 m_printhost_logout_btn->Show(host->is_logged_in());
568 m_printhost_test_btn->SetLabel(host->is_cloud() ? _L("Login/Test") : _L("Test"));
569 }
570}

References _L, Slic3r::PrintHost::get_print_host(), m_config, m_printhost_browse_btn, m_printhost_logout_btn, and m_printhost_test_btn.

Referenced by build_printhost_settings(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_webui()

void Slic3r::GUI::PhysicalPrinterDialog::update_webui ( )
538{
540 if (tech == ptFFF) {
541 const auto opt = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type");
542 if (opt->value == htSimplyPrint) {
543 bool bbl_use_print_host_webui = false;
544 if (Field* printhost_webui_field = m_optgroup->get_field("bbl_use_print_host_webui"); printhost_webui_field) {
545 if (CheckBox* temp = dynamic_cast<CheckBox*>(printhost_webui_field); temp) {
546 bbl_use_print_host_webui = boost::any_cast<bool>(temp->get_value());
547 }
548 }
549
550 const std::string v = bbl_use_print_host_webui ? "https://simplyprint.io/panel" : "";
551 if (Field* printhost_webui_field = m_optgroup->get_field("print_host_webui"); printhost_webui_field) {
552 if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_webui_field)->text_ctrl(); temp) {
553 temp->SetValue(v);
554 }
555 }
556 m_config->opt_string("print_host_webui") = v;
557 }
558 }
559}

References Slic3r::htSimplyPrint, m_config, m_optgroup, Slic3r::Preset::printer_technology(), and Slic3r::ptFFF.

Referenced by build_printhost_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ btnOK

Button* Slic3r::GUI::PhysicalPrinterDialog::btnOK {nullptr}
private
45{nullptr};

Referenced by PhysicalPrinterDialog(), and update_preset_input().

◆ m_can_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_can_rescale
privateinherited
235{ true };

◆ m_config

◆ m_em_unit

int Slic3r::GUI::DPIAware< wxDialog >::m_em_unit
privateinherited

◆ m_force_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_force_rescale
privateinherited
236{ false };

◆ m_input_area

RoundedRectangle* Slic3r::GUI::PhysicalPrinterDialog::m_input_area {nullptr}
private
42{nullptr};

Referenced by PhysicalPrinterDialog(), and update_preset_input().

◆ m_input_ctrl

wxTextCtrl* Slic3r::GUI::PhysicalPrinterDialog::m_input_ctrl {nullptr}
private
44{nullptr};

Referenced by PhysicalPrinterDialog(), and update_preset_input().

◆ m_new_font_point_size

int Slic3r::GUI::DPIAware< wxDialog >::m_new_font_point_size
privateinherited

◆ m_normal_font

wxFont Slic3r::GUI::DPIAware< wxDialog >::m_normal_font
privateinherited

◆ m_optgroup

ConfigOptionsGroup* Slic3r::GUI::PhysicalPrinterDialog::m_optgroup { nullptr }
private

◆ m_preset_name

std::string Slic3r::GUI::PhysicalPrinterDialog::m_preset_name

Referenced by OnOK(), and update_preset_input().

◆ m_presets

PresetCollection* Slic3r::GUI::PhysicalPrinterDialog::m_presets {nullptr}
60{nullptr};

Referenced by PhysicalPrinterDialog(), and update_preset_input().

◆ m_prev_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_prev_scale_factor
privateinherited

◆ m_printhost_browse_btn

Button* Slic3r::GUI::PhysicalPrinterDialog::m_printhost_browse_btn {nullptr}
private

◆ m_printhost_cafile_browse_btn

Button* Slic3r::GUI::PhysicalPrinterDialog::m_printhost_cafile_browse_btn {nullptr}
private
39{nullptr};

Referenced by build_printhost_settings(), on_dpi_changed(), and update().

◆ m_printhost_generate_creds_btn

Button* Slic3r::GUI::PhysicalPrinterDialog::m_printhost_generate_creds_btn {nullptr}
private
37{nullptr};

Referenced by build_printhost_settings(), on_dpi_changed(), and update().

◆ m_printhost_logout_btn

Button* Slic3r::GUI::PhysicalPrinterDialog::m_printhost_logout_btn {nullptr}
private

◆ m_printhost_port_browse_btn

Button* Slic3r::GUI::PhysicalPrinterDialog::m_printhost_port_browse_btn {nullptr}
private
40{nullptr};

Referenced by build_printhost_settings(), and update().

◆ m_printhost_test_btn

Button* Slic3r::GUI::PhysicalPrinterDialog::m_printhost_test_btn {nullptr}
private

◆ m_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_scale_factor
privateinherited

◆ m_valid_label

wxStaticText* Slic3r::GUI::PhysicalPrinterDialog::m_valid_label {nullptr}
private
43{nullptr};

Referenced by PhysicalPrinterDialog(), and update_preset_input().

◆ m_valid_type

ValidationType Slic3r::GUI::PhysicalPrinterDialog::m_valid_type

Referenced by update_preset_input().


The documentation for this class was generated from the following files: