diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4e3ed4797..3062741eb 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3144,7 +3144,7 @@ void Plater::send_gcode() } default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string())); - PrintHostSendDialog dlg(default_output_file); + PrintHostSendDialog dlg(default_output_file, upload_job.printhost->can_start_print()); if (dlg.ShowModal() == wxID_OK) { upload_job.upload_data.upload_path = dlg.filename(); upload_job.upload_data.start_print = dlg.start_print(); diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index 1ec1c3a6a..76185b1ba 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -28,14 +28,15 @@ namespace GUI { static const char *CONFIG_KEY_PATH = "printhost_path"; static const char *CONFIG_KEY_PRINT = "printhost_print"; -PrintHostSendDialog::PrintHostSendDialog(const fs::path &path) +PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_print) : MsgDialog(nullptr, _(L("Send G-Code to printer host")), _(L("Upload to Printer Host with the following filename:")), wxID_NONE) , txt_filename(new wxTextCtrl(this, wxID_ANY)) - , box_print(new wxCheckBox(this, wxID_ANY, _(L("Start printing after upload")))) + , box_print(can_start_print ? new wxCheckBox(this, wxID_ANY, _(L("Start printing after upload"))) : nullptr) { #ifdef __APPLE__ txt_filename->OSXDisableAllSmartSubstitutions(); #endif + const AppConfig *app_config = wxGetApp().app_config; auto *label_dir_hint = new wxStaticText(this, wxID_ANY, _(L("Use forward slashes ( / ) as a directory separator if needed."))); label_dir_hint->Wrap(CONTENT_WIDTH * wxGetApp().em_unit()); @@ -43,12 +44,13 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path) content_sizer->Add(txt_filename, 0, wxEXPAND); content_sizer->Add(label_dir_hint); content_sizer->AddSpacer(VERT_SPACING); - content_sizer->Add(box_print, 0, wxBOTTOM, 2*VERT_SPACING); + if (box_print != nullptr) { + content_sizer->Add(box_print, 0, wxBOTTOM, 2*VERT_SPACING); + box_print->SetValue(app_config->get("recent", CONFIG_KEY_PRINT) == "1"); + } btn_sizer->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL)); - const AppConfig *app_config = wxGetApp().app_config; - box_print->SetValue(app_config->get("recent", CONFIG_KEY_PRINT) == "1"); wxString recent_path = from_u8(app_config->get("recent", CONFIG_KEY_PATH)); if (recent_path.Length() > 0 && recent_path[recent_path.Length() - 1] != '/') { @@ -80,7 +82,7 @@ fs::path PrintHostSendDialog::filename() const bool PrintHostSendDialog::start_print() const { - return box_print->GetValue(); + return box_print != nullptr ? box_print->GetValue() : false; } void PrintHostSendDialog::EndModal(int ret) @@ -94,8 +96,7 @@ void PrintHostSendDialog::EndModal(int ret) wxGetApp().app_config->set("recent", CONFIG_KEY_PATH, into_u8(path)); } - bool print = box_print->GetValue(); - GUI::get_app_config()->set("recent", CONFIG_KEY_PRINT, print ? "1" : "0"); + GUI::get_app_config()->set("recent", CONFIG_KEY_PRINT, start_print() ? "1" : "0"); } MsgDialog::EndModal(ret); diff --git a/src/slic3r/GUI/PrintHostDialogs.hpp b/src/slic3r/GUI/PrintHostDialogs.hpp index e7c84fefd..105899cf0 100644 --- a/src/slic3r/GUI/PrintHostDialogs.hpp +++ b/src/slic3r/GUI/PrintHostDialogs.hpp @@ -29,7 +29,7 @@ namespace GUI { class PrintHostSendDialog : public GUI::MsgDialog { public: - PrintHostSendDialog(const boost::filesystem::path &path); + PrintHostSendDialog(const boost::filesystem::path &path, bool can_start_print); boost::filesystem::path filename() const; bool start_print() const; diff --git a/src/slic3r/Utils/Duet.cpp b/src/slic3r/Utils/Duet.cpp index 77137a7d2..c85bd90e8 100644 --- a/src/slic3r/Utils/Duet.cpp +++ b/src/slic3r/Utils/Duet.cpp @@ -119,6 +119,11 @@ bool Duet::can_test() const return true; } +bool Duet::can_start_print() const +{ + return true; +} + bool Duet::connect(wxString &msg) const { bool res = false; diff --git a/src/slic3r/Utils/Duet.hpp b/src/slic3r/Utils/Duet.hpp index e1c28d149..0b40fe8b3 100644 --- a/src/slic3r/Utils/Duet.hpp +++ b/src/slic3r/Utils/Duet.hpp @@ -25,6 +25,7 @@ public: virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const; virtual bool has_auto_discovery() const; virtual bool can_test() const; + virtual bool can_start_print() const; virtual std::string get_host() const { return host; } private: diff --git a/src/slic3r/Utils/OctoPrint.cpp b/src/slic3r/Utils/OctoPrint.cpp index 2e2e169b8..594c2e3da 100644 --- a/src/slic3r/Utils/OctoPrint.cpp +++ b/src/slic3r/Utils/OctoPrint.cpp @@ -144,6 +144,11 @@ bool OctoPrint::can_test() const return true; } +bool OctoPrint::can_start_print() const +{ + return true; +} + bool OctoPrint::validate_version_text(const boost::optional &version_text) const { return version_text ? boost::starts_with(*version_text, "OctoPrint") : true; @@ -186,6 +191,11 @@ wxString SLAHost::get_test_failed_msg (wxString &msg) const return wxString::Format("%s: %s", _(L("Could not connect to Prusa SLA")), msg); } +bool SLAHost::can_start_print() const +{ + return false; +} + bool SLAHost::validate_version_text(const boost::optional &version_text) const { return version_text ? boost::starts_with(*version_text, "Prusa SLA") : false; diff --git a/src/slic3r/Utils/OctoPrint.hpp b/src/slic3r/Utils/OctoPrint.hpp index 8da149f53..a7caa7129 100644 --- a/src/slic3r/Utils/OctoPrint.hpp +++ b/src/slic3r/Utils/OctoPrint.hpp @@ -26,6 +26,7 @@ public: virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const; virtual bool has_auto_discovery() const; virtual bool can_test() const; + virtual bool can_start_print() const; virtual std::string get_host() const { return host; } protected: @@ -49,6 +50,7 @@ public: virtual wxString get_test_ok_msg () const; virtual wxString get_test_failed_msg (wxString &msg) const; + virtual bool can_start_print() const ; protected: virtual bool validate_version_text(const boost::optional &version_text) const; }; diff --git a/src/slic3r/Utils/PrintHost.cpp b/src/slic3r/Utils/PrintHost.cpp index 0c6d6bb0f..5c39f8542 100644 --- a/src/slic3r/Utils/PrintHost.cpp +++ b/src/slic3r/Utils/PrintHost.cpp @@ -25,16 +25,16 @@ namespace Slic3r { PrintHost::~PrintHost() {} -PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config) +PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config, Slic3r::PrinterTechnology pt_fallback) { const auto opt = config->option>("host_type"); - if (opt == nullptr) { return nullptr; } + const auto host_type = opt != nullptr ? opt->value : (pt_fallback == ptFFF ? htOctoPrint : htSL1); - switch (opt->value) { + switch (host_type) { case htOctoPrint: return new OctoPrint(config); case htDuet: return new Duet(config); case htSL1: return new SLAHost(config); - default: return nullptr; + default: return nullptr; } } diff --git a/src/slic3r/Utils/PrintHost.hpp b/src/slic3r/Utils/PrintHost.hpp index d740ea99e..010889642 100644 --- a/src/slic3r/Utils/PrintHost.hpp +++ b/src/slic3r/Utils/PrintHost.hpp @@ -8,6 +8,7 @@ #include +#include "libslic3r/PrintConfig.hpp" #include "Http.hpp" @@ -38,9 +39,10 @@ public: virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const = 0; virtual bool has_auto_discovery() const = 0; virtual bool can_test() const = 0; + virtual bool can_start_print() const = 0; virtual std::string get_host() const = 0; - static PrintHost* get_print_host(DynamicPrintConfig *config); + static PrintHost* get_print_host(DynamicPrintConfig *config, Slic3r::PrinterTechnology pt_fallback = ptFFF); protected: virtual wxString format_error(const std::string &body, const std::string &error, unsigned status) const;