mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 12:41:20 -06:00 
			
		
		
		
	PrintHost: Don't offer print start for SL1
This commit is contained in:
		
							parent
							
								
									96d09ce0ad
								
							
						
					
					
						commit
						bd725a47f4
					
				
					 9 changed files with 36 additions and 15 deletions
				
			
		|  | @ -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(); | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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: | ||||
|  |  | |||
|  | @ -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<std::string> &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<std::string> &version_text) const | ||||
| { | ||||
|     return version_text ? boost::starts_with(*version_text, "Prusa SLA") : false; | ||||
|  |  | |||
|  | @ -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<std::string> &version_text) const; | ||||
| }; | ||||
|  |  | |||
|  | @ -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<ConfigOptionEnum<PrintHostType>>("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; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| 
 | ||||
| #include <wx/string.h> | ||||
| 
 | ||||
| #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; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vojtech Kral
						Vojtech Kral