diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2019-10-24 12:08:39 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2019-10-24 12:08:39 +0300 |
commit | a417da8fea69547009ddb5994c44ade60c5fa9ac (patch) | |
tree | f68635c8dc843971b5b944d874806d8bdf056dd0 /src | |
parent | a1f2ecb285daebbac4271a6b145ead6433affcd7 (diff) |
ENABLE_THUMBNAIL_GENERATOR -> Fixed volumes visibility test to render them into thumbnail
Diffstat (limited to 'src')
-rw-r--r-- | src/slic3r/GUI/ThumbnailGenerator.cpp | 34 | ||||
-rw-r--r-- | src/slic3r/GUI/ThumbnailGenerator.hpp | 2 |
2 files changed, 7 insertions, 29 deletions
diff --git a/src/slic3r/GUI/ThumbnailGenerator.cpp b/src/slic3r/GUI/ThumbnailGenerator.cpp index f2a74cae9..634f9e61c 100644 --- a/src/slic3r/GUI/ThumbnailGenerator.cpp +++ b/src/slic3r/GUI/ThumbnailGenerator.cpp @@ -29,34 +29,14 @@ void ThumbnailGenerator::generate(const GLVolumePtrs& volumes, unsigned int w, u render_and_store(volumes, printable_only); } -bool ThumbnailGenerator::save_to_png_file(const std::string& filename) -{ - if (!m_data.is_valid()) - return false; - - wxImage image(m_data.width, m_data.height); - image.InitAlpha(); - - for (unsigned int r = 0; r < m_data.height; ++r) - { - unsigned int rr = (m_data.height - 1 - r) * m_data.width; - for (unsigned int c = 0; c < m_data.width; ++c) - { - unsigned char* px = m_data.pixels.data() + 4 * (rr + c); - image.SetRGB((int)c, (int)r, px[0], px[1], px[2]); - image.SetAlpha((int)c, (int)r, px[3]); - } - } - - std::string path = filename; - if (!boost::iends_with(path, ".png")) - path = boost::filesystem::path(path).replace_extension(".png").string(); - - return image.SaveFile(from_u8(path), wxBITMAP_TYPE_PNG); -} - void ThumbnailGenerator::render_and_store(const GLVolumePtrs& volumes, bool printable_only) { + auto is_visible = [] (const GLVolume& v) -> bool { + bool ret = v.printable; + ret &= (!v.shader_outside_printer_detection_enabled || !v.is_outside); + return ret; + }; + static const float orange[] = { 0.99f, 0.49f, 0.26f }; static const float gray[] = { 0.64f, 0.64f, 0.64f }; @@ -64,7 +44,7 @@ void ThumbnailGenerator::render_and_store(const GLVolumePtrs& volumes, bool prin for (const GLVolume* vol : volumes) { - if (!printable_only || vol->printable) + if (!printable_only || is_visible(*vol)) visible_volumes.push_back(vol); } diff --git a/src/slic3r/GUI/ThumbnailGenerator.hpp b/src/slic3r/GUI/ThumbnailGenerator.hpp index ae7509b3c..20087b79b 100644 --- a/src/slic3r/GUI/ThumbnailGenerator.hpp +++ b/src/slic3r/GUI/ThumbnailGenerator.hpp @@ -27,8 +27,6 @@ namespace GUI { const ThumbnailData& get_data() const { return m_data; } - bool save_to_png_file(const std::string& filename); - private: void render_and_store(const GLVolumePtrs& volumes, bool printable_only); }; |