From 5294c85dfcf0092483c7179cbfd3bbe2b6a77732 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 6 Jan 2020 09:32:13 +0100 Subject: [PATCH 1/8] Some minor polishing of Color print back end. --- src/libslic3r/GCode.hpp | 11 +++++------ src/libslic3r/Model.cpp | 22 ++++++++++------------ src/libslic3r/Model.hpp | 26 ++++++++++---------------- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 68bb85a988..497dc8c718 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -362,12 +362,11 @@ protected: bool m_second_layer_things_done; // Index of a last object copy extruded. std::pair m_last_obj_copy; - /* Extensions for colorprint - now it's not a just color_print_heights, - * there can be some custom gcode. - * Updated before the export and erased during the process, - * so no toolchange occurs twice. - * */ - std::vector m_custom_gcode_per_print_z; + // Extensions for colorprint - now it's not a just color_print_heights, + // there can be some custom gcode. + // Updated before the export and erased during the process, + // so no toolchange occurs twice. + std::vector m_custom_gcode_per_print_z; // Time estimators GCodeTimeEstimator m_normal_time_estimator; diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 5167337086..96a32680e6 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -66,7 +66,7 @@ Model& Model::assign_copy(Model &&rhs) rhs.objects.clear(); // copy custom code per height - this->custom_gcode_per_print_z = rhs.custom_gcode_per_print_z; + this->custom_gcode_per_print_z = std::move(rhs.custom_gcode_per_print_z); return *this; } @@ -1946,25 +1946,23 @@ extern bool model_has_advanced_features(const Model &model) extern void update_custom_gcode_per_print_z_from_config(std::vector& custom_gcode_per_print_z, DynamicPrintConfig* config) { - if (!config->has("colorprint_heights")) + auto *colorprint_heights = config->option("colorprint_heights"); + if (colorprint_heights == nullptr) return; - const std::vector& colors = GCodePreviewData::ColorPrintColors(); - - const auto& colorprint_values = config->option("colorprint_heights")->values; - - if (!colorprint_values.empty()) - { + if (custom_gcode_per_print_z.empty() && ! colorprint_heights->values.empty()) { + // Convert the old colorprint_heighs only if there is no equivalent data in a new format. + const std::vector& colors = GCodePreviewData::ColorPrintColors(); + const auto& colorprint_values = colorprint_heights->values; custom_gcode_per_print_z.clear(); custom_gcode_per_print_z.reserve(colorprint_values.size()); int i = 0; for (auto val : colorprint_values) custom_gcode_per_print_z.emplace_back(Model::CustomGCode{ val, ColorChangeCode, 1, colors[(++i)%7] }); - } + } - /* There is one and only place this configuration option is used now. - * It wouldn't be used in the future, so erase it. - * */ + // The "colorprint_heights" config value has been deprecated. At this point of time it has been converted + // to a new format and therefore it shall be erased. config->erase("colorprint_heights"); } diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index c5a992e49d..44f5049c9f 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -755,21 +755,15 @@ public: // Extensions for color print struct CustomGCode { - bool operator<(const CustomGCode& other) const { return other.print_z > this->print_z; } - bool operator==(const CustomGCode& other) const + bool operator<(const CustomGCode& rhs) const { return this->print_z < rhs.print_z; } + bool operator==(const CustomGCode& rhs) const { - return (other.print_z == this->print_z ) && - (other.gcode == this->gcode ) && - (other.extruder == this->extruder ) && - (other.color == this->color ); - } - bool operator!=(const CustomGCode& other) const - { - return (other.print_z != this->print_z ) || - (other.gcode != this->gcode ) || - (other.extruder != this->extruder ) || - (other.color != this->color ); + return (rhs.print_z == this->print_z ) && + (rhs.gcode == this->gcode ) && + (rhs.extruder == this->extruder ) && + (rhs.color == this->color ); } + bool operator!=(const CustomGCode& rhs) const { return ! (*this == rhs); } double print_z; std::string gcode; @@ -880,9 +874,9 @@ extern bool model_volume_list_changed(const ModelObject &model_object_old, const extern bool model_has_multi_part_objects(const Model &model); // If the model has advanced features, then it cannot be processed in simple mode. extern bool model_has_advanced_features(const Model &model); -/* If loaded configuration has a "colorprint_heights" option (if it was imported from older Slicer), - * then model.custom_gcode_per_print_z should be updated considering this option - * */ +// If loaded configuration has a "colorprint_heights" option (if it was imported from older Slicer), +// and if model.custom_gcode_per_print_z is empty (there is no color print data available in a new format +// then model.custom_gcode_per_print_z should be updated considering this option. extern void update_custom_gcode_per_print_z_from_config(std::vector& custom_gcode_per_print_z, DynamicPrintConfig* config); #ifndef NDEBUG From afbc4a4cf2e71d11885f9a7d449df3deaa4eaf2b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 6 Jan 2020 09:36:03 +0100 Subject: [PATCH 2/8] Fixing perl bindings after refactoring --- xs/xsp/Layer.xsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xs/xsp/Layer.xsp b/xs/xsp/Layer.xsp index 6f3164707a..6ca953f82c 100644 --- a/xs/xsp/Layer.xsp +++ b/xs/xsp/Layer.xsp @@ -61,7 +61,7 @@ Ref add_region(PrintRegion* print_region); ExPolygonCollection* slices() - %code%{ RETVAL = new ExPolygonCollection(THIS->slices); %}; + %code%{ RETVAL = new ExPolygonCollection(THIS->lslices); %}; int ptr() %code%{ RETVAL = (int)(intptr_t)THIS; %}; @@ -110,7 +110,7 @@ Ref add_region(PrintRegion* print_region); ExPolygonCollection* slices() - %code%{ RETVAL = new ExPolygonCollection(THIS->slices); %}; + %code%{ RETVAL = new ExPolygonCollection(THIS->lslices); %}; void export_region_slices_to_svg(const char *path); void export_region_fill_surfaces_to_svg(const char *path); From e7b835dc523df5c2cf1981f6e93aa9ad4b463f9b Mon Sep 17 00:00:00 2001 From: Spencer Owen Date: Sat, 28 Dec 2019 10:41:48 -0700 Subject: [PATCH 3/8] Add Astrobox to Print Host options --- resources/localization/list.txt | 1 + src/libslic3r/PrintConfig.cpp | 2 + src/libslic3r/PrintConfig.hpp | 3 +- src/slic3r/CMakeLists.txt | 2 + src/slic3r/Utils/AstroBox.cpp | 215 ++++++++++++++++++++++++++++++++ src/slic3r/Utils/AstroBox.hpp | 65 ++++++++++ src/slic3r/Utils/PrintHost.cpp | 2 + 7 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 src/slic3r/Utils/AstroBox.cpp create mode 100644 src/slic3r/Utils/AstroBox.hpp diff --git a/resources/localization/list.txt b/resources/localization/list.txt index 7f0b672526..93ee2f441d 100644 --- a/resources/localization/list.txt +++ b/resources/localization/list.txt @@ -50,6 +50,7 @@ src/slic3r/GUI/ExtruderSequenceDialog.cpp src/slic3r/Utils/Duet.cpp src/slic3r/Utils/OctoPrint.cpp src/slic3r/Utils/FlashAir.cpp +src/slic3r/Utils/AstroBox.cpp src/slic3r/Utils/PresetUpdater.cpp src/slic3r/Utils/FixModelByWin10.cpp src/libslic3r/SLA/SLAPad.cpp diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 82815131e2..0835693b2e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1333,9 +1333,11 @@ void PrintConfigDef::init_fff_params() def->enum_values.push_back("octoprint"); def->enum_values.push_back("duet"); def->enum_values.push_back("flashair"); + def->enum_values.push_back("astrobox"); def->enum_labels.push_back("OctoPrint"); def->enum_labels.push_back("Duet"); def->enum_labels.push_back("FlashAir"); + def->enum_values.push_back("AstroBox"); def->mode = comAdvanced; def->set_default_value(new ConfigOptionEnum(htOctoPrint)); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 5f5a861da3..6d70f54082 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -30,7 +30,7 @@ enum GCodeFlavor : unsigned char { }; enum PrintHostType { - htOctoPrint, htDuet, htFlashAir + htOctoPrint, htDuet, htFlashAir, htAstroBox }; enum InfillPattern { @@ -103,6 +103,7 @@ template<> inline const t_config_enum_values& ConfigOptionEnum::g keys_map["octoprint"] = htOctoPrint; keys_map["duet"] = htDuet; keys_map["flashair"] = htFlashAir; + keys_map["astrobox"] = htAstroBox; } return keys_map; } diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 5b55b96b4b..9fd8462727 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -152,6 +152,8 @@ set(SLIC3R_GUI_SOURCES Utils/Duet.hpp Utils/FlashAir.cpp Utils/FlashAir.hpp + Utils/AstroBox.cpp + Utils/AstroBox.hpp Utils/PrintHost.cpp Utils/PrintHost.hpp Utils/Bonjour.cpp diff --git a/src/slic3r/Utils/AstroBox.cpp b/src/slic3r/Utils/AstroBox.cpp new file mode 100644 index 0000000000..ded03ed4ce --- /dev/null +++ b/src/slic3r/Utils/AstroBox.cpp @@ -0,0 +1,215 @@ +#include "AstroBox.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "libslic3r/PrintConfig.hpp" +#include "slic3r/GUI/I18N.hpp" +#include "Http.hpp" + + +namespace fs = boost::filesystem; +namespace pt = boost::property_tree; + + +namespace Slic3r { + +AstroBox::AstroBox(DynamicPrintConfig *config) : + host(config->opt_string("print_host")), + apikey(config->opt_string("printhost_apikey")), + cafile(config->opt_string("printhost_cafile")) +{} + +AstroBox::~AstroBox() {} + +const char* AstroBox::get_name() const { return "AstroBox"; } + +bool AstroBox::test(wxString &msg) const +{ + // Since the request is performed synchronously here, + // it is ok to refer to `msg` from within the closure + + const char *name = get_name(); + + bool res = true; + auto url = make_url("api/version"); + + BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url; + + auto http = Http::get(std::move(url)); + set_auth(http); + http.on_error([&](std::string body, std::string error, unsigned status) { + BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; + res = false; + msg = format_error(body, error, status); + }) + .on_complete([&, this](std::string body, unsigned) { + BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got version: %2%") % name % body; + + try { + std::stringstream ss(body); + pt::ptree ptree; + pt::read_json(ss, ptree); + + if (! ptree.get_optional("api")) { + res = false; + return; + } + + const auto text = ptree.get_optional("text"); + res = validate_version_text(text); + if (! res) { + msg = wxString::Format(_(L("Mismatched type of print host: %s")), text ? *text : "AstroBox"); + } + } + catch (const std::exception &) { + res = false; + msg = "Could not parse server response"; + } + }) + .perform_sync(); + + return res; +} + +wxString AstroBox::get_test_ok_msg () const +{ + return _(L("Connection to AstroBox works correctly.")); +} + +wxString AstroBox::get_test_failed_msg (wxString &msg) const +{ + return wxString::Format("%s: %s\n\n%s", + _(L("Could not connect to AstroBox")), msg, _(L("Note: AstroBox version at least 1.1.0 is required."))); +} + +bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const +{ + const char *name = get_name(); + + const auto upload_filename = upload_data.upload_path.filename(); + const auto upload_parent_path = upload_data.upload_path.parent_path(); + + wxString test_msg; + if (! test(test_msg)) { + error_fn(std::move(test_msg)); + return false; + } + + bool res = true; + + auto url = make_url("api/files/local"); + + BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% at %3%, filename: %4%, path: %5%, print: %6%") + % name + % upload_data.source_path + % url + % upload_filename.string() + % upload_parent_path.string() + % upload_data.start_print; + + auto http = Http::post(std::move(url)); + set_auth(http); + http.form_add("print", upload_data.start_print ? "true" : "false") + .form_add("path", upload_parent_path.string()) // XXX: slashes on windows ??? + .form_add_file("file", upload_data.source_path.string(), upload_filename.string()) + .on_complete([&](std::string body, unsigned status) { + BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: File uploaded: HTTP %2%: %3%") % name % status % body; + }) + .on_error([&](std::string body, std::string error, unsigned status) { + BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; + error_fn(format_error(body, error, status)); + res = false; + }) + .on_progress([&](Http::Progress progress, bool &cancel) { + prorgess_fn(std::move(progress), cancel); + if (cancel) { + // Upload was canceled + BOOST_LOG_TRIVIAL(info) << "AstroBox: Upload canceled"; + res = false; + } + }) + .perform_sync(); + + return res; +} + +bool AstroBox::has_auto_discovery() const +{ + return true; +} + +bool AstroBox::can_test() const +{ + return true; +} + +bool AstroBox::can_start_print() const +{ + return true; +} + +bool AstroBox::validate_version_text(const boost::optional &version_text) const +{ + return version_text ? boost::starts_with(*version_text, "AstroBox") : true; +} + +void AstroBox::set_auth(Http &http) const +{ + http.header("X-Api-Key", apikey); + + if (! cafile.empty()) { + http.ca_file(cafile); + } +} + +std::string AstroBox::make_url(const std::string &path) const +{ + if (host.find("http://") == 0 || host.find("https://") == 0) { + if (host.back() == '/') { + return (boost::format("%1%%2%") % host % path).str(); + } else { + return (boost::format("%1%/%2%") % host % path).str(); + } + } else { + return (boost::format("http://%1%/%2%") % host % path).str(); + } +} + + +// SL1Host + +SL1Host::~SL1Host() {} + +const char* SL1Host::get_name() const { return "SL1Host"; } + +wxString SL1Host::get_test_ok_msg () const +{ + return _(L("Connection to Prusa SL1 works correctly.")); +} + +wxString SL1Host::get_test_failed_msg (wxString &msg) const +{ + return wxString::Format("%s: %s", _(L("Could not connect to Prusa SLA")), msg); +} + +bool SL1Host::can_start_print() const +{ + return false; +} + +bool SL1Host::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/AstroBox.hpp b/src/slic3r/Utils/AstroBox.hpp new file mode 100644 index 0000000000..1474132da6 --- /dev/null +++ b/src/slic3r/Utils/AstroBox.hpp @@ -0,0 +1,65 @@ +#ifndef slic3r_AstroBox_hpp_ +#define slic3r_AstroBox_hpp_ + +#include +#include +#include + +#include "PrintHost.hpp" + + +namespace Slic3r { + + +class DynamicPrintConfig; +class Http; + +class AstroBox : public PrintHost +{ +public: + AstroBox(DynamicPrintConfig *config); + virtual ~AstroBox(); + + virtual const char* get_name() const; + + virtual bool test(wxString &curl_msg) const; + virtual wxString get_test_ok_msg () const; + virtual wxString get_test_failed_msg (wxString &msg) const; + 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: + virtual bool validate_version_text(const boost::optional &version_text) const; + +private: + std::string host; + std::string apikey; + std::string cafile; + + void set_auth(Http &http) const; + std::string make_url(const std::string &path) const; +}; + + +class SL1Host: public AstroBox +{ +public: + SL1Host(DynamicPrintConfig *config) : AstroBox(config) {} + virtual ~SL1Host(); + + virtual const char* get_name() const; + + 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; +}; + + +} + +#endif diff --git a/src/slic3r/Utils/PrintHost.cpp b/src/slic3r/Utils/PrintHost.cpp index 59a929ecca..0a49b78153 100644 --- a/src/slic3r/Utils/PrintHost.cpp +++ b/src/slic3r/Utils/PrintHost.cpp @@ -15,6 +15,7 @@ #include "OctoPrint.hpp" #include "Duet.hpp" #include "FlashAir.hpp" +#include "AstroBox.hpp" #include "../GUI/PrintHostDialogs.hpp" namespace fs = boost::filesystem; @@ -45,6 +46,7 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config) case htOctoPrint: return new OctoPrint(config); case htDuet: return new Duet(config); case htFlashAir: return new FlashAir(config); + case htAstroBox: return new AstroBox(config); default: return nullptr; } } else { From b08a315a469c38f23a30908e2cf6170c11e90ad1 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 6 Jan 2020 10:34:13 +0100 Subject: [PATCH 4/8] Fix of #3359: Ender icon case was not matching profile name Also added an icon to show when the correct one is not found --- resources/icons/printer_placeholder.png | Bin 0 -> 2936 bytes .../{Creality_Ender3.png => Creality_ENDER3.png} | Bin 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 resources/icons/printer_placeholder.png rename resources/icons/printers/{Creality_Ender3.png => Creality_ENDER3.png} (100%) diff --git a/resources/icons/printer_placeholder.png b/resources/icons/printer_placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..8274019d83e2883c6e7d62d1fa6aa313f27b1154 GIT binary patch literal 2936 zcmeH}**6=C7RHel)fjH|P^mF>sv7DTj{fX@3q%nzj*r_7NQ~`5k5XXQ7cO` z_>oue@$vHs3mzrVw8#9B9eZG6MIys5)ObH8%&UlbK$;(a*?aekyH*bx@y=dSE8!I1I z&%fZWX?`tHRm9EKf##inlX5&=k&&0%cKV;{f42=)%=fdU4PX$gp;-e^V@JIa#%f4e zO!4D?@#P$4fedp7*lb2|RW41sxgI*Sck^PiA3g`@jNl#SuIg5H456NW{`^Q=KNTDa z8()|TjL94&PEcB^FA(d0X`WMU8l-A4F#MEM_i*;9nEg^BN{TCpTHA8esVOc_6Ea>9 zCti2`vFRqC1*7zyR1ZYD{>@8a%nr0JIIszeq}r0$-Vg}yU>+r_nCc4!O`}JD`*}WH zS2orJloJ!{bv*GAeWMJ57Xwp zQ>wY*8e&r}vJ0(i`NP#|U`*(qU>Wcg!uy^oq4ScES%1i3?yKncFLbM`#79r`G&!9@MrEjs1%|BkZ!d=m z27CId_4%GXT+s3Ywsi)%rYhBzZpDlqi*24A|Ae`^ZApV%Rl>{9Sx)>0t*hw?7%2f` z9&)r4O*aQD_R9~qmkPsgC$)A{rct6(KUw||ztTvhKEn3IyIJy?L}oMxE(s|GZLVML zFLPL^I-tFex4SfZUyTI4WqwD;u4(nSx9#~Zf3?1ib2m=BoWAaX9dFs(Li>wU%x>vO z7H$2}Sk{FL!^zc@HBn=rb0#~N1F%o-1h++-5cHa7_SI~X0TGuP;pKWVatL})S;V4B zV?$_Xna(v|{w5o?gK^uqtZw^Fm`^~kl6LcG3wd<%6BYcrk!9oqAp~;i6m_1I>x`tN zGC$G>n^gqR`GrN{3-{CW_1mJqiWVcC!!S=-EMdKL{se!K(b)<8>Vky)gvw_!Kfx#I zdqIDt+G4^pyS+R~b;vl@T*HLb<%I2TKm`7;dWiKDOOU?cQ-M#`%JIu^hc}P43C7EK z6V9)zbv}!L&zWpH+b@3|*iL`CV}}loTeODo6Ny(9?F@=ZmsX7Meif!xj&X)Uw=)T^ zU0vW}v62C91cb07tDaC%LddN7BWQHaVf#RuXOpkpefEMI5mj(Bz38ii0qs|c5|>C|*}ObRpZgn6Ps$2pbBYlaFoPa>te-sw z+6SciYH5k`+^ntTI&39=pm&6^j%X}x?EbYNv5V}2Zd_{SyzUm>;i^vuY>mbjujYFb z&iHzf$XDhb!G4Ad&76U5P zVw_JOycJxo2|UWks0>p};ft9?qdm&6~PVm^b;{qb-LOdMDaH5I*)_Gy_pVYdxnCqgAcc@{8KO;@emVMZ z%FxD$vHX4^FDZqyl+PuNpG}uFVAUWOGX=RcObB}x8|3|W*{$H_LZ)SIP?XSwh}iR@ z)ue2>oV$d`QXz0;WCrArJ^gblaGxBAH)Gfogb8qlBV6chg(`G>%r4ansNEFs%D=DZm;!!`0}*GLyBpCS$j%X%4?3-J#mX?Ju%(%_ovHoyBIm9@ zgH+40kS(FUbeEaGr~C*uDOKC(1}YlOF-`xh(2*ws%F0r8j}*HCZG$&@;cI$2ZhC2j zF^#J{kDbN~=~q;DoT3WRfuA%PtW`pn%{{9Y&@p$;rWyw(`d#A^u;KkFN0Tx+L`%Ro&*} zA(%K!X?<`_!M^KB?+1g@04g|&=;?i76~BuxKoN3g+Av;G(&Y6`)(HLU^UsYGvcPtw zyf^2Bhng03!fW6?Q&7fAR>?zP8OgjFpfKv=3h$5E=zL?{d)eVdqG?38W->X5_hYEl z8A{QroIfFiU8TVcvR9v+4B_qXO)OIZzy?V{n)=FENC6L;o_1e=zC)PKI5F{CXCZW~quFB#uy; O&&vFU*(a0Rxc>mZu5M8P literal 0 HcmV?d00001 diff --git a/resources/icons/printers/Creality_Ender3.png b/resources/icons/printers/Creality_ENDER3.png similarity index 100% rename from resources/icons/printers/Creality_Ender3.png rename to resources/icons/printers/Creality_ENDER3.png From 791f487c76d5a5f07609a93e584f9b518247319c Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 6 Jan 2020 10:59:46 +0100 Subject: [PATCH 5/8] Clean-up of the "Upload to" code (AstroBox, Duet, FlashAir, OctoPrint) --- src/slic3r/Utils/AstroBox.cpp | 45 ---------------------------------- src/slic3r/Utils/AstroBox.hpp | 41 +++++++++---------------------- src/slic3r/Utils/Duet.cpp | 17 ------------- src/slic3r/Utils/Duet.hpp | 23 ++++++++--------- src/slic3r/Utils/FlashAir.cpp | 17 ------------- src/slic3r/Utils/FlashAir.hpp | 22 ++++++++--------- src/slic3r/Utils/OctoPrint.cpp | 26 -------------------- src/slic3r/Utils/OctoPrint.hpp | 36 +++++++++++++-------------- 8 files changed, 48 insertions(+), 179 deletions(-) diff --git a/src/slic3r/Utils/AstroBox.cpp b/src/slic3r/Utils/AstroBox.cpp index ded03ed4ce..83a72e64a0 100644 --- a/src/slic3r/Utils/AstroBox.cpp +++ b/src/slic3r/Utils/AstroBox.cpp @@ -28,8 +28,6 @@ AstroBox::AstroBox(DynamicPrintConfig *config) : cafile(config->opt_string("printhost_cafile")) {} -AstroBox::~AstroBox() {} - const char* AstroBox::get_name() const { return "AstroBox"; } bool AstroBox::test(wxString &msg) const @@ -142,21 +140,6 @@ bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error return res; } -bool AstroBox::has_auto_discovery() const -{ - return true; -} - -bool AstroBox::can_test() const -{ - return true; -} - -bool AstroBox::can_start_print() const -{ - return true; -} - bool AstroBox::validate_version_text(const boost::optional &version_text) const { return version_text ? boost::starts_with(*version_text, "AstroBox") : true; @@ -184,32 +167,4 @@ std::string AstroBox::make_url(const std::string &path) const } } - -// SL1Host - -SL1Host::~SL1Host() {} - -const char* SL1Host::get_name() const { return "SL1Host"; } - -wxString SL1Host::get_test_ok_msg () const -{ - return _(L("Connection to Prusa SL1 works correctly.")); -} - -wxString SL1Host::get_test_failed_msg (wxString &msg) const -{ - return wxString::Format("%s: %s", _(L("Could not connect to Prusa SLA")), msg); -} - -bool SL1Host::can_start_print() const -{ - return false; -} - -bool SL1Host::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/AstroBox.hpp b/src/slic3r/Utils/AstroBox.hpp index 1474132da6..38542275c5 100644 --- a/src/slic3r/Utils/AstroBox.hpp +++ b/src/slic3r/Utils/AstroBox.hpp @@ -7,10 +7,8 @@ #include "PrintHost.hpp" - namespace Slic3r { - class DynamicPrintConfig; class Http; @@ -18,21 +16,21 @@ class AstroBox : public PrintHost { public: AstroBox(DynamicPrintConfig *config); - virtual ~AstroBox(); + ~AstroBox() override = default; - virtual const char* get_name() const; + const char* get_name() const override; - virtual bool test(wxString &curl_msg) const; - virtual wxString get_test_ok_msg () const; - virtual wxString get_test_failed_msg (wxString &msg) const; - 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; } + bool test(wxString &curl_msg) const override; + wxString get_test_ok_msg () const override; + wxString get_test_failed_msg (wxString &msg) const override; + bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; + bool has_auto_discovery() const override { return true; } + bool can_test() const override { return true; } + bool can_start_print() const override { return true; } + std::string get_host() const override { return host; } protected: - virtual bool validate_version_text(const boost::optional &version_text) const; + bool validate_version_text(const boost::optional &version_text) const; private: std::string host; @@ -43,23 +41,6 @@ private: std::string make_url(const std::string &path) const; }; - -class SL1Host: public AstroBox -{ -public: - SL1Host(DynamicPrintConfig *config) : AstroBox(config) {} - virtual ~SL1Host(); - - virtual const char* get_name() const; - - 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; -}; - - } #endif diff --git a/src/slic3r/Utils/Duet.cpp b/src/slic3r/Utils/Duet.cpp index b0d8c0b8d7..554d3f5f55 100644 --- a/src/slic3r/Utils/Duet.cpp +++ b/src/slic3r/Utils/Duet.cpp @@ -32,8 +32,6 @@ Duet::Duet(DynamicPrintConfig *config) : password(config->opt_string("printhost_apikey")) {} -Duet::~Duet() {} - const char* Duet::get_name() const { return "Duet"; } bool Duet::test(wxString &msg) const @@ -111,21 +109,6 @@ bool Duet::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn e return res; } -bool Duet::has_auto_discovery() const -{ - return false; -} - -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 04ceec36fd..702efbddb6 100644 --- a/src/slic3r/Utils/Duet.hpp +++ b/src/slic3r/Utils/Duet.hpp @@ -6,10 +6,8 @@ #include "PrintHost.hpp" - namespace Slic3r { - class DynamicPrintConfig; class Http; @@ -17,18 +15,18 @@ class Duet : public PrintHost { public: Duet(DynamicPrintConfig *config); - virtual ~Duet(); + ~Duet() override = default; - virtual const char* get_name() const; + const char* get_name() const override; - virtual bool test(wxString &curl_msg) const; - virtual wxString get_test_ok_msg () const; - virtual wxString get_test_failed_msg (wxString &msg) const; - 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; } + bool test(wxString &curl_msg) const override; + wxString get_test_ok_msg() const override; + wxString get_test_failed_msg(wxString &msg) const override; + bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; + bool has_auto_discovery() const override { return false; } + bool can_test() const override { return true; } + bool can_start_print() const override { return true; } + std::string get_host() const override { return host; } private: std::string host; @@ -44,7 +42,6 @@ private: int get_err_code_from_body(const std::string &body) const; }; - } #endif diff --git a/src/slic3r/Utils/FlashAir.cpp b/src/slic3r/Utils/FlashAir.cpp index 3fc913c994..79f3f2c2bd 100644 --- a/src/slic3r/Utils/FlashAir.cpp +++ b/src/slic3r/Utils/FlashAir.cpp @@ -30,8 +30,6 @@ FlashAir::FlashAir(DynamicPrintConfig *config) : host(config->opt_string("print_host")) {} -FlashAir::~FlashAir() {} - const char* FlashAir::get_name() const { return "FlashAir"; } bool FlashAir::test(wxString &msg) const @@ -150,21 +148,6 @@ bool FlashAir::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error return res; } -bool FlashAir::has_auto_discovery() const -{ - return false; -} - -bool FlashAir::can_test() const -{ - return true; -} - -bool FlashAir::can_start_print() const -{ - return false; -} - std::string FlashAir::timestamp_str() const { auto t = std::time(nullptr); diff --git a/src/slic3r/Utils/FlashAir.hpp b/src/slic3r/Utils/FlashAir.hpp index 1499eee5d8..40af48da1b 100644 --- a/src/slic3r/Utils/FlashAir.hpp +++ b/src/slic3r/Utils/FlashAir.hpp @@ -9,7 +9,6 @@ namespace Slic3r { - class DynamicPrintConfig; class Http; @@ -17,18 +16,18 @@ class FlashAir : public PrintHost { public: FlashAir(DynamicPrintConfig *config); - virtual ~FlashAir(); + ~FlashAir() override = default; - virtual const char* get_name() const; + const char* get_name() const override; - virtual bool test(wxString &curl_msg) const; - virtual wxString get_test_ok_msg () const; - virtual wxString get_test_failed_msg (wxString &msg) const; - 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; } + bool test(wxString &curl_msg) const override; + wxString get_test_ok_msg() const override; + wxString get_test_failed_msg(wxString &msg) const override; + bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; + bool has_auto_discovery() const override { return false; } + bool can_test() const override { return true; } + bool can_start_print() const override { return false; } + std::string get_host() const override { return host; } private: std::string host; @@ -38,7 +37,6 @@ private: std::string make_url(const std::string &path, const std::string &arg, const std::string &val) const; }; - } #endif diff --git a/src/slic3r/Utils/OctoPrint.cpp b/src/slic3r/Utils/OctoPrint.cpp index 09ca02071a..48f8ba0b9a 100644 --- a/src/slic3r/Utils/OctoPrint.cpp +++ b/src/slic3r/Utils/OctoPrint.cpp @@ -28,8 +28,6 @@ OctoPrint::OctoPrint(DynamicPrintConfig *config) : cafile(config->opt_string("printhost_cafile")) {} -OctoPrint::~OctoPrint() {} - const char* OctoPrint::get_name() const { return "OctoPrint"; } bool OctoPrint::test(wxString &msg) const @@ -142,21 +140,6 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro return res; } -bool OctoPrint::has_auto_discovery() const -{ - return true; -} - -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,9 +169,6 @@ std::string OctoPrint::make_url(const std::string &path) const // SL1Host - -SL1Host::~SL1Host() {} - const char* SL1Host::get_name() const { return "SL1Host"; } wxString SL1Host::get_test_ok_msg () const @@ -201,15 +181,9 @@ wxString SL1Host::get_test_failed_msg (wxString &msg) const return wxString::Format("%s: %s", _(L("Could not connect to Prusa SLA")), msg); } -bool SL1Host::can_start_print() const -{ - return false; -} - bool SL1Host::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 0e372c7c95..965019d859 100644 --- a/src/slic3r/Utils/OctoPrint.hpp +++ b/src/slic3r/Utils/OctoPrint.hpp @@ -10,7 +10,6 @@ namespace Slic3r { - class DynamicPrintConfig; class Http; @@ -18,18 +17,18 @@ class OctoPrint : public PrintHost { public: OctoPrint(DynamicPrintConfig *config); - virtual ~OctoPrint(); + ~OctoPrint() override = default; - virtual const char* get_name() const; + const char* get_name() const; - virtual bool test(wxString &curl_msg) const; - virtual wxString get_test_ok_msg () const; - virtual wxString get_test_failed_msg (wxString &msg) const; - 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; } + bool test(wxString &curl_msg) const override; + wxString get_test_ok_msg () const override; + wxString get_test_failed_msg (wxString &msg) const override; + bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; + bool has_auto_discovery() const override { return true; } + bool can_test() const override { return true; } + bool can_start_print() const override { return true; } + std::string get_host() const override { return host; } protected: virtual bool validate_version_text(const boost::optional &version_text) const; @@ -43,23 +42,22 @@ private: std::string make_url(const std::string &path) const; }; - class SL1Host: public OctoPrint { public: SL1Host(DynamicPrintConfig *config) : OctoPrint(config) {} - virtual ~SL1Host(); + ~SL1Host() override = default; - virtual const char* get_name() const; + const char* get_name() const override; + + wxString get_test_ok_msg() const override; + wxString get_test_failed_msg(wxString &msg) const override; + bool can_start_print() const override { return false; } - 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; + bool validate_version_text(const boost::optional &version_text) const override; }; - } #endif From 704e10c55a51492c65829985cb2947c6e9a86862 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 6 Jan 2020 11:32:17 +0100 Subject: [PATCH 6/8] Replaced unix basename() with boost::filesystem::basename(), as various unices define basename() differently. --- src/slic3r/GUI/RemovableDriveManager.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 9ef31748de..8586cf4748 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -21,6 +21,7 @@ GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72, #include #include #include +#include #endif namespace Slic3r { @@ -321,14 +322,8 @@ void RemovableDriveManager::inspect_file(const std::string &path, const std::str uid_t uid = buf.st_uid; std::string username(std::getenv("USER")); struct passwd *pw = getpwuid(uid); - if(pw != 0) - { - if(pw->pw_name == username) - { - std::string name = basename(path.data()); - m_current_drives.push_back(DriveData(name,path)); - } - } + if (pw != 0 && pw->pw_name == username) + m_current_drives.push_back(DriveData(boost::filesystem::basename(boost::filesystem::path(path)), path)); } } From 5078604182459d796ef4e410a6b070ac4399576f Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 6 Jan 2020 11:59:24 +0100 Subject: [PATCH 7/8] Trying to fix Linux compilation --- src/slic3r/GUI/RemovableDriveManager.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 8586cf4748..5041e21205 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -18,7 +18,6 @@ GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72, #include #include #include -#include #include #include #include @@ -240,10 +239,8 @@ void RemovableDriveManager::search_for_drives() //search /media/* folder search_path("/media/*", "/media"); -/* //search /Volumes/* folder (OSX) - search_path("/Volumes/*", "/Volumes"); -*/ + //search_path("/Volumes/*", "/Volumes"); std::string path(std::getenv("USER")); std::string pp(path); //std::cout << "user: "<< path << "\n"; From 68d0f5b4ef76bbc5e1bd59b5246f75123828b459 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 6 Jan 2020 12:07:23 +0100 Subject: [PATCH 8/8] Corrected description of --loglevel parameter on command line output --- src/libslic3r/PrintConfig.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 0835693b2e..761507a2e9 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3435,7 +3435,8 @@ CLIMiscConfigDef::CLIMiscConfigDef() def = this->add("loglevel", coInt); def->label = L("Logging level"); - def->tooltip = L("Messages with severity lower or eqal to the loglevel will be printed out. 0:trace, 1:debug, 2:info, 3:warning, 4:error, 5:fatal"); + def->tooltip = L("Sets logging sensitivity. 0:fatal, 1:error, 2:warning, 3:info, 4:debug, 5:trace\n" + "For example. loglevel=2 logs fatal, error and warning level messages."); def->min = 0; #if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(SLIC3R_GUI)