diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2019-07-24 15:02:36 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2019-07-24 15:02:36 +0300 |
commit | 1483a7fd51dcbafd7ece744efb5c420eb68bf393 (patch) | |
tree | 20f4ddc9cdc7597db5ac4ff747fdb306d80c7307 /src/slic3r/GUI/3DBed.cpp | |
parent | 395e794b9e6bc2d429caa71089a447773b51c96e (diff) |
Render custom bed model on prusa beds
Diffstat (limited to 'src/slic3r/GUI/3DBed.cpp')
-rw-r--r-- | src/slic3r/GUI/3DBed.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index a41b39a7e..3a8a66904 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -189,13 +189,14 @@ void Bed3D::Axes::render_axis(double length) const Bed3D::Bed3D() : m_type(Custom) , m_custom_texture("") + , m_custom_model("") , m_requires_canvas_update(false) , m_vbo_id(0) , m_scale_factor(1.0f) { } -bool Bed3D::set_shape(const Pointfs& shape, const std::string& custom_texture) +bool Bed3D::set_shape(const Pointfs& shape, const std::string& custom_texture, const std::string& custom_model) { EType new_type = detect_type(shape); @@ -207,12 +208,21 @@ bool Bed3D::set_shape(const Pointfs& shape, const std::string& custom_texture) cst_texture = ""; } - if ((m_shape == shape) && (m_type == new_type) && (m_custom_texture == cst_texture)) + // check that the passed custom texture filename is valid + std::string cst_model(custom_model); + if (!cst_model.empty()) + { + if (!boost::algorithm::iends_with(custom_model, ".stl") || !boost::filesystem::exists(custom_model)) + cst_model = ""; + } + + if ((m_shape == shape) && (m_type == new_type) && (m_custom_texture == cst_texture) && (m_custom_model == cst_model)) // No change, no need to update the UI. return false; m_shape = shape; m_custom_texture = cst_texture; + m_custom_model = cst_model; m_type = new_type; calc_bounding_boxes(); @@ -385,7 +395,7 @@ void Bed3D::render_prusa(GLCanvas3D& canvas, const std::string& key, bool bottom { if (!bottom) { - std::string filename = resources_dir() + "/models/" + key + "_bed.stl"; + std::string filename = m_custom_model.empty() ? resources_dir() + "/models/" + key + "_bed.stl" : m_custom_model; if ((m_model.get_filename() != filename) && m_model.init_from_file(filename)) { Vec3d offset = m_bounding_box.center() - Vec3d(0.0, 0.0, 0.5 * m_model.get_bounding_box().size()(2)); |