From 925378ba900e8a13c9a33ecc18cb3b3549693280 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 5 Mar 2019 13:57:41 +0100 Subject: [PATCH] Added background to legend texture --- src/slic3r/GUI/GLCanvas3D.cpp | 11 ++++++----- src/slic3r/GUI/GLCanvas3D.hpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index aacc6f0e3..399ead284 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3493,7 +3493,7 @@ void GLCanvas3D::LegendTexture::fill_color_print_legend_values(const GCodePrevie } } -bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, const std::vector& tool_colors, const GLCanvas3D& canvas, bool use_error_colors) +bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, const std::vector& tool_colors, const GLCanvas3D& canvas) { reset(); @@ -3559,14 +3559,14 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c memDC.SelectObject(bitmap); mask_memDC.SelectObject(mask); - memDC.SetBackground(wxBrush(use_error_colors ? *wxWHITE : *wxBLACK)); + memDC.SetBackground(wxBrush(*wxBLACK)); mask_memDC.SetBackground(wxBrush(*wxBLACK)); memDC.Clear(); mask_memDC.Clear(); // draw title - memDC.SetTextForeground(use_error_colors ? *wxWHITE : *wxBLACK); + memDC.SetTextForeground(*wxWHITE); mask_memDC.SetTextForeground(*wxWHITE); int title_x = scaled_border; @@ -3649,10 +3649,11 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c unsigned char* px_ptr = data.data() + 4 * hh; for (int w = 0; w < m_width; ++w) { + unsigned char alpha = (mask_image.GetRed(w, h) + mask_image.GetGreen(w, h) + mask_image.GetBlue(w, h)) / 3; *px_ptr++ = image.GetRed(w, h); *px_ptr++ = image.GetGreen(w, h); *px_ptr++ = image.GetBlue(w, h); - *px_ptr++ = (mask_image.GetRed(w, h) + mask_image.GetGreen(w, h) + mask_image.GetBlue(w, h)) / 3; + *px_ptr++ = (alpha == 0) ? 128 : 255; } } @@ -8109,7 +8110,7 @@ std::vector GLCanvas3D::_parse_colors(const std::vector& col void GLCanvas3D::_generate_legend_texture(const GCodePreviewData& preview_data, const std::vector& tool_colors) { - m_legend_texture.generate(preview_data, tool_colors, *this, m_dynamic_background_enabled && _is_any_volume_outside()); + m_legend_texture.generate(preview_data, tool_colors, *this); } void GLCanvas3D::_set_warning_texture(WarningTexture::Warning warning, bool state) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index d47b7c976..51a1e9213 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -868,7 +868,7 @@ private: void fill_color_print_legend_values(const GCodePreviewData& preview_data, const GLCanvas3D& canvas, std::vector>& cp_legend_values); - bool generate(const GCodePreviewData& preview_data, const std::vector& tool_colors, const GLCanvas3D& canvas, bool use_error_colors); + bool generate(const GCodePreviewData& preview_data, const std::vector& tool_colors, const GLCanvas3D& canvas); void render(const GLCanvas3D& canvas) const; };