From 70bc392003738cf30882f40ca9a7501b24db80f8 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 7 Jan 2020 14:08:21 +0100 Subject: [PATCH] Support for Vendor / Printer Model specific print bed texture and model. --- src/slic3r/GUI/3DBed.cpp | 32 ++++++++++++++++++++++++++++++++ src/slic3r/GUI/Preset.cpp | 2 ++ src/slic3r/GUI/Preset.hpp | 3 +++ 3 files changed, 37 insertions(+) diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index f6f80d822..ecbca4228 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -341,6 +341,38 @@ void Bed3D::calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox) printf("Unable to create bed grid lines\n"); } +static const VendorProfile::PrinterModel* system_printer_model(const Preset &preset) +{ + const VendorProfile::PrinterModel *out = nullptr; + if (preset.vendor != nullptr) { + auto *printer_model = preset.config.opt("printer_model"); + if (printer_model != nullptr && ! printer_model->value.empty()) { + auto it = std::find_if(preset.vendor->models.begin(), preset.vendor->models.end(), [printer_model](const VendorProfile::PrinterModel &pm) { return pm.id == printer_model->value; }); + if (it != preset.vendor->models.end()) + out = &(*it); + } + } + return out; +} + +static std::string system_print_bed_model(const Preset &preset) +{ + std::string out; + const VendorProfile::PrinterModel *pm = system_printer_model(preset); + if (pm != nullptr && ! pm->bed_model.empty()) + out = Slic3r::resources_dir() + "/profiles/" + preset.vendor->id + "/" + pm->bed_model; + return out; +} + +static std::string system_print_bed_texture(const Preset &preset) +{ + std::string out; + const VendorProfile::PrinterModel *pm = system_printer_model(preset); + if (pm != nullptr && ! pm->bed_texture.empty()) + out = Slic3r::resources_dir() + "/profiles/" + preset.vendor->id + "/" + pm->bed_texture; + return out; +} + Bed3D::EType Bed3D::detect_type(const Pointfs& shape) const { EType type = Custom; diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index c2439b26f..c20a5bb28 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -184,6 +184,8 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem } else { BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: Malformed variants field: `%2%`") % id % variants_field; } + model.bed_model = section.second.get("bed_model", ""); + model.bed_texture = section.second.get("bed_texture", ""); if (! model.id.empty() && ! model.variants.empty()) res.models.push_back(std::move(model)); } diff --git a/src/slic3r/GUI/Preset.hpp b/src/slic3r/GUI/Preset.hpp index 547814559..55791eb09 100644 --- a/src/slic3r/GUI/Preset.hpp +++ b/src/slic3r/GUI/Preset.hpp @@ -61,6 +61,9 @@ public: PrinterTechnology technology; std::string family; std::vector variants; + // Vendor & Printer Model specific print bed model & texture. + std::string bed_model; + std::string bed_texture; PrinterVariant* variant(const std::string &name) { for (auto &v : this->variants)