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

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Loidl <martin.loidl@gmail.com>2018-07-08 15:32:48 +0300
committerVojtech Kral <vojtech@kral.hk>2018-08-21 12:12:53 +0300
commitdd1fd66a47f64ca8bfba736728787d2781a983e1 (patch)
tree1819abf9b93200ed4bbe7fcff4b9584a152a5a69 /xs/src/slic3r/GUI/Tab.cpp
parent3433e8e3743f8aebea940ae92e3f26fec03c7a22 (diff)
Added possibility for upload to Duet
Further changes: - Added new configuration option Host Type - Added abstract base class for future printer hosts - Moved location of upload dialog (also made it a little bit more configureable) - added possibility to send file via postfield instead a new frame
Diffstat (limited to 'xs/src/slic3r/GUI/Tab.cpp')
-rw-r--r--xs/src/slic3r/GUI/Tab.cpp61
1 files changed, 36 insertions, 25 deletions
diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp
index 7c4322c5a..13b0ece5f 100644
--- a/xs/src/slic3r/GUI/Tab.cpp
+++ b/xs/src/slic3r/GUI/Tab.cpp
@@ -5,7 +5,8 @@
#include "../../libslic3r/Utils.hpp"
#include "slic3r/Utils/Http.hpp"
-#include "slic3r/Utils/OctoPrint.hpp"
+#include "slic3r/Utils/PrintHostFactory.hpp"
+#include "slic3r/Utils/PrintHost.hpp"
#include "slic3r/Utils/Serial.hpp"
#include "BonjourDialog.hpp"
#include "WipeTowerDialog.hpp"
@@ -1521,10 +1522,12 @@ void TabPrinter::build()
optgroup->append_line(line);
}
- optgroup = page->new_optgroup(_(L("OctoPrint upload")));
+ optgroup = page->new_optgroup(_(L("Printer Host upload")));
- auto octoprint_host_browse = [this, optgroup] (wxWindow* parent) {
- auto btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
+ optgroup->append_single_option_line("host_type");
+
+ auto printhost_browse = [this, optgroup] (wxWindow* parent) {
+ auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG));
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn);
@@ -1532,47 +1535,52 @@ void TabPrinter::build()
btn->Bind(wxEVT_BUTTON, [this, parent, optgroup](wxCommandEvent e) {
BonjourDialog dialog(parent);
if (dialog.show_and_lookup()) {
- optgroup->set_value("octoprint_host", std::move(dialog.get_selected()), true);
+ optgroup->set_value("print_host", std::move(dialog.get_selected()), true);
}
});
return sizer;
};
- auto octoprint_host_test = [this](wxWindow* parent) {
- auto btn = m_octoprint_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")),
+ auto print_host_test = [this](wxWindow* parent) {
+ auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")),
wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("wrench.png")), wxBITMAP_TYPE_PNG));
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn);
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent e) {
- OctoPrint octoprint(m_config);
+ PrintHost *host = PrintHostFactory::get_print_host(m_config);
+ if (host == NULL) {
+ const auto text = wxString::Format("%s",
+ _(L("Could not get a valid Printer Host reference")));
+ show_error(this, text);
+ return;
+ }
wxString msg;
- if (octoprint.test(msg)) {
- show_info(this, _(L("Connection to OctoPrint works correctly.")), _(L("Success!")));
+ if (host->test(msg)) {
+ show_info(this, host->get_test_ok_msg(), _(L("Success!")));
} else {
- const auto text = wxString::Format("%s: %s\n\n%s",
- _(L("Could not connect to OctoPrint")), msg, _(L("Note: OctoPrint version at least 1.1.0 is required."))
- );
- show_error(this, text);
+ show_error(this, host->get_test_failed_msg(msg));
}
+
+ delete (host);
});
return sizer;
};
- Line host_line = optgroup->create_single_option_line("octoprint_host");
- host_line.append_widget(octoprint_host_browse);
- host_line.append_widget(octoprint_host_test);
+ Line host_line = optgroup->create_single_option_line("print_host");
+ host_line.append_widget(printhost_browse);
+ host_line.append_widget(print_host_test);
optgroup->append_line(host_line);
- optgroup->append_single_option_line("octoprint_apikey");
+ optgroup->append_single_option_line("printhost_apikey");
if (Http::ca_file_supported()) {
- Line cafile_line = optgroup->create_single_option_line("octoprint_cafile");
+ Line cafile_line = optgroup->create_single_option_line("printhost_cafile");
- auto octoprint_cafile_browse = [this, optgroup] (wxWindow* parent) {
+ auto printhost_cafile_browse = [this, optgroup] (wxWindow* parent) {
auto btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG));
auto sizer = new wxBoxSizer(wxHORIZONTAL);
@@ -1582,17 +1590,17 @@ void TabPrinter::build()
static const auto filemasks = _(L("Certificate files (*.crt, *.pem)|*.crt;*.pem|All files|*.*"));
wxFileDialog openFileDialog(this, _(L("Open CA certificate file")), "", "", filemasks, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (openFileDialog.ShowModal() != wxID_CANCEL) {
- optgroup->set_value("octoprint_cafile", std::move(openFileDialog.GetPath()), true);
+ optgroup->set_value("printhost_cafile", std::move(openFileDialog.GetPath()), true);
}
});
return sizer;
};
- cafile_line.append_widget(octoprint_cafile_browse);
+ cafile_line.append_widget(printhost_cafile_browse);
optgroup->append_line(cafile_line);
- auto octoprint_cafile_hint = [this, optgroup] (wxWindow* parent) {
+ auto printhost_cafile_hint = [this, optgroup] (wxWindow* parent) {
auto txt = new wxStaticText(parent, wxID_ANY,
_(L("HTTPS CA file is optional. It is only needed if you use HTTPS with a self-signed certificate.")));
auto sizer = new wxBoxSizer(wxHORIZONTAL);
@@ -1602,7 +1610,7 @@ void TabPrinter::build()
Line cafile_hint { "", "" };
cafile_hint.full_width = 1;
- cafile_hint.widget = std::move(octoprint_cafile_hint);
+ cafile_hint.widget = std::move(printhost_cafile_hint);
optgroup->append_line(cafile_hint);
}
@@ -1897,7 +1905,10 @@ void TabPrinter::update(){
m_serial_test_btn->Disable();
}
- m_octoprint_host_test_btn->Enable(!m_config->opt_string("octoprint_host").empty());
+ PrintHost *host = PrintHostFactory::get_print_host(m_config);
+ m_print_host_test_btn->Enable(!m_config->opt_string("print_host").empty() && host->can_test());
+ m_printhost_browse_btn->Enable(host->have_auto_discovery());
+ delete (host);
bool have_multiple_extruders = m_extruders_count > 1;
get_field("toolchange_gcode")->toggle(have_multiple_extruders);