Tech ENABLE_COLOR_CLASSES - 1st installment -> Introduction of classes ColorRGB and ColorRGBA to unify color data definition and manipulation
This commit is contained in:
parent
48098fbaff
commit
cd4094743e
53 changed files with 1810 additions and 60 deletions
src
libslic3r
slic3r/GUI
3DBed.cpp3DScene.cpp3DScene.hppAboutDialog.cppBitmapCache.cppBitmapCache.hppConfigSnapshotDialog.cppConfigWizard.cppDoubleSlider.cppDoubleSlider.hppDoubleSlider_Utils.hppField.cppGCodeViewer.cppGCodeViewer.hppGLCanvas3D.cppGLCanvas3D.hppGLModel.cppGLModel.hppGLShader.cppGLShader.hppGUI_App.cppGUI_Utils.hpp
Gizmos
GLGizmoBase.cppGLGizmoBase.hppGLGizmoCut.cppGLGizmoCut.hppGLGizmoFlatten.cppGLGizmoHollow.cppGLGizmoMmuSegmentation.cppGLGizmoMmuSegmentation.hppGLGizmoMove.cppGLGizmoPainterBase.cppGLGizmoPainterBase.hppGLGizmoRotate.cppGLGizmoScale.cppGLGizmoSlaSupports.cppGLGizmosCommon.cpp
ImGuiWrapper.cppImGuiWrapper.hppMsgDialog.cppPresetComboBoxes.cppSelection.cppSendSystemInfoDialog.cppSysInfoDialog.cppUnsavedChangesDialog.cppWipeTowerDialog.cppwxExtensions.cpptests/libslic3r
|
@ -29,6 +29,8 @@ add_library(libslic3r STATIC
|
|||
clipper.hpp
|
||||
ClipperUtils.cpp
|
||||
ClipperUtils.hpp
|
||||
Color.cpp
|
||||
Color.hpp
|
||||
Config.cpp
|
||||
Config.hpp
|
||||
EdgeGrid.cpp
|
||||
|
|
402
src/libslic3r/Color.cpp
Normal file
402
src/libslic3r/Color.cpp
Normal file
|
@ -0,0 +1,402 @@
|
|||
#include "libslic3r.h"
|
||||
#include "Color.hpp"
|
||||
|
||||
#include <random>
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// Conversion from RGB to HSV color space
|
||||
// The input RGB values are in the range [0, 1]
|
||||
// The output HSV values are in the ranges h = [0, 360], and s, v = [0, 1]
|
||||
static void RGBtoHSV(float r, float g, float b, float& h, float& s, float& v)
|
||||
{
|
||||
assert(0.0f <= r && r <= 1.0f);
|
||||
assert(0.0f <= g && g <= 1.0f);
|
||||
assert(0.0f <= b && b <= 1.0f);
|
||||
|
||||
const float max_comp = std::max(std::max(r, g), b);
|
||||
const float min_comp = std::min(std::min(r, g), b);
|
||||
const float delta = max_comp - min_comp;
|
||||
|
||||
if (delta > 0.0f) {
|
||||
if (max_comp == r)
|
||||
h = 60.0f * (std::fmod(((g - b) / delta), 6.0f));
|
||||
else if (max_comp == g)
|
||||
h = 60.0f * (((b - r) / delta) + 2.0f);
|
||||
else if (max_comp == b)
|
||||
h = 60.0f * (((r - g) / delta) + 4.0f);
|
||||
|
||||
s = (max_comp > 0.0f) ? delta / max_comp : 0.0f;
|
||||
}
|
||||
else {
|
||||
h = 0.0f;
|
||||
s = 0.0f;
|
||||
}
|
||||
v = max_comp;
|
||||
|
||||
while (h < 0.0f) { h += 360.0f; }
|
||||
while (h > 360.0f) { h -= 360.0f; }
|
||||
|
||||
assert(0.0f <= s && s <= 1.0f);
|
||||
assert(0.0f <= v && v <= 1.0f);
|
||||
assert(0.0f <= h && h <= 360.0f);
|
||||
}
|
||||
|
||||
// Conversion from HSV to RGB color space
|
||||
// The input HSV values are in the ranges h = [0, 360], and s, v = [0, 1]
|
||||
// The output RGB values are in the range [0, 1]
|
||||
static void HSVtoRGB(float h, float s, float v, float& r, float& g, float& b)
|
||||
{
|
||||
assert(0.0f <= s && s <= 1.0f);
|
||||
assert(0.0f <= v && v <= 1.0f);
|
||||
assert(0.0f <= h && h <= 360.0f);
|
||||
|
||||
const float chroma = v * s;
|
||||
const float h_prime = std::fmod(h / 60.0f, 6.0f);
|
||||
const float x = chroma * (1.0f - std::abs(std::fmod(h_prime, 2.0f) - 1.0f));
|
||||
const float m = v - chroma;
|
||||
|
||||
if (0.0f <= h_prime && h_prime < 1.0f) {
|
||||
r = chroma;
|
||||
g = x;
|
||||
b = 0.0f;
|
||||
}
|
||||
else if (1.0f <= h_prime && h_prime < 2.0f) {
|
||||
r = x;
|
||||
g = chroma;
|
||||
b = 0.0f;
|
||||
}
|
||||
else if (2.0f <= h_prime && h_prime < 3.0f) {
|
||||
r = 0.0f;
|
||||
g = chroma;
|
||||
b = x;
|
||||
}
|
||||
else if (3.0f <= h_prime && h_prime < 4.0f) {
|
||||
r = 0.0f;
|
||||
g = x;
|
||||
b = chroma;
|
||||
}
|
||||
else if (4.0f <= h_prime && h_prime < 5.0f) {
|
||||
r = x;
|
||||
g = 0.0f;
|
||||
b = chroma;
|
||||
}
|
||||
else if (5.0f <= h_prime && h_prime < 6.0f) {
|
||||
r = chroma;
|
||||
g = 0.0f;
|
||||
b = x;
|
||||
}
|
||||
else {
|
||||
r = 0.0f;
|
||||
g = 0.0f;
|
||||
b = 0.0f;
|
||||
}
|
||||
|
||||
r += m;
|
||||
g += m;
|
||||
b += m;
|
||||
|
||||
assert(0.0f <= r && r <= 1.0f);
|
||||
assert(0.0f <= g && g <= 1.0f);
|
||||
assert(0.0f <= b && b <= 1.0f);
|
||||
}
|
||||
|
||||
class Randomizer
|
||||
{
|
||||
std::random_device m_rd;
|
||||
|
||||
public:
|
||||
float random_float(float min, float max) {
|
||||
std::mt19937 rand_generator(m_rd());
|
||||
std::uniform_real_distribution<float> distrib(min, max);
|
||||
return distrib(rand_generator);
|
||||
}
|
||||
};
|
||||
|
||||
ColorRGB::ColorRGB(float r, float g, float b)
|
||||
: m_data({ std::clamp(r, 0.0f, 1.0f), std::clamp(g, 0.0f, 1.0f), std::clamp(b, 0.0f, 1.0f) })
|
||||
{
|
||||
}
|
||||
|
||||
ColorRGB::ColorRGB(unsigned char r, unsigned char g, unsigned char b)
|
||||
: m_data({ std::clamp(r * INV_255, 0.0f, 1.0f), std::clamp(g * INV_255, 0.0f, 1.0f), std::clamp(b * INV_255, 0.0f, 1.0f) })
|
||||
{
|
||||
}
|
||||
|
||||
bool ColorRGB::operator < (const ColorRGB& other) const
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (m_data[i] < other.m_data[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ColorRGB::operator > (const ColorRGB& other) const
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (m_data[i] > other.m_data[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ColorRGB ColorRGB::operator + (const ColorRGB& other) const
|
||||
{
|
||||
ColorRGB ret;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
ret.m_data[i] = std::clamp(m_data[i] + other.m_data[i], 0.0f, 1.0f);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorRGB ColorRGB::operator * (float value) const
|
||||
{
|
||||
assert(value >= 0.0f);
|
||||
ColorRGB ret;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
ret.m_data[i] = std::clamp(value * m_data[i], 0.0f, 1.0f);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorRGBA::ColorRGBA(float r, float g, float b, float a)
|
||||
: m_data({ std::clamp(r, 0.0f, 1.0f), std::clamp(g, 0.0f, 1.0f), std::clamp(b, 0.0f, 1.0f), std::clamp(a, 0.0f, 1.0f) })
|
||||
{
|
||||
}
|
||||
|
||||
ColorRGBA::ColorRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
|
||||
: m_data({ std::clamp(r * INV_255, 0.0f, 1.0f), std::clamp(g * INV_255, 0.0f, 1.0f), std::clamp(b * INV_255, 0.0f, 1.0f), std::clamp(a * INV_255, 0.0f, 1.0f) })
|
||||
{
|
||||
}
|
||||
|
||||
bool ColorRGBA::operator < (const ColorRGBA& other) const
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (m_data[i] < other.m_data[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ColorRGBA::operator > (const ColorRGBA& other) const
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (m_data[i] > other.m_data[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ColorRGBA ColorRGBA::operator + (const ColorRGBA& other) const
|
||||
{
|
||||
ColorRGBA ret;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
ret.m_data[i] = std::clamp(m_data[i] + other.m_data[i], 0.0f, 1.0f);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorRGBA ColorRGBA::operator * (float value) const
|
||||
{
|
||||
assert(value >= 0.0f);
|
||||
ColorRGBA ret;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
ret.m_data[i] = std::clamp(value * m_data[i], 0.0f, 1.0f);
|
||||
}
|
||||
ret.m_data[3] = this->m_data[3];
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorRGB operator * (float value, const ColorRGB& other) { return other * value; }
|
||||
ColorRGBA operator * (float value, const ColorRGBA& other) { return other * value; }
|
||||
|
||||
ColorRGB lerp(const ColorRGB& a, const ColorRGB& b, float t)
|
||||
{
|
||||
assert(0.0f <= t && t <= 1.0f);
|
||||
return (1.0f - t) * a + t * b;
|
||||
}
|
||||
|
||||
ColorRGBA lerp(const ColorRGBA& a, const ColorRGBA& b, float t)
|
||||
{
|
||||
assert(0.0f <= t && t <= 1.0f);
|
||||
return (1.0f - t) * a + t * b;
|
||||
}
|
||||
|
||||
ColorRGB complementary(const ColorRGB& color)
|
||||
{
|
||||
return { 1.0f - color.r(), 1.0f - color.g(), 1.0f - color.b() };
|
||||
}
|
||||
|
||||
ColorRGBA complementary(const ColorRGBA& color)
|
||||
{
|
||||
return { 1.0f - color.r(), 1.0f - color.g(), 1.0f - color.b(), color.a() };
|
||||
}
|
||||
|
||||
ColorRGB saturate(const ColorRGB& color, float factor)
|
||||
{
|
||||
float h, s, v;
|
||||
RGBtoHSV(color.r(), color.g(), color.b(), h, s, v);
|
||||
s = std::clamp(s * factor, 0.0f, 1.0f);
|
||||
float r, g, b;
|
||||
HSVtoRGB(h, s, v, r, g, b);
|
||||
return { r, g, b };
|
||||
}
|
||||
|
||||
ColorRGBA saturate(const ColorRGBA& color, float factor)
|
||||
{
|
||||
return to_rgba(saturate(to_rgb(color), factor), color.a());
|
||||
}
|
||||
|
||||
ColorRGB opposite(const ColorRGB& color)
|
||||
{
|
||||
float h, s, v;
|
||||
RGBtoHSV(color.r(), color.g(), color.b(), h, s, v);
|
||||
|
||||
h += 65.0f; // 65 instead 60 to avoid circle values
|
||||
if (h > 360.0f)
|
||||
h -= 360.0f;
|
||||
|
||||
Randomizer rnd;
|
||||
s = rnd.random_float(0.65f, 1.0f);
|
||||
v = rnd.random_float(0.65f, 1.0f);
|
||||
|
||||
float r, g, b;
|
||||
HSVtoRGB(h, s, v, r, g, b);
|
||||
return { r, g, b };
|
||||
}
|
||||
|
||||
ColorRGB opposite(const ColorRGB& a, const ColorRGB& b)
|
||||
{
|
||||
float ha, sa, va;
|
||||
RGBtoHSV(a.r(), a.g(), a.b(), ha, sa, va);
|
||||
float hb, sb, vb;
|
||||
RGBtoHSV(b.r(), b.g(), b.b(), hb, sb, vb);
|
||||
|
||||
float delta_h = std::abs(ha - hb);
|
||||
float start_h = (delta_h > 180.0f) ? std::min(ha, hb) : std::max(ha, hb);
|
||||
|
||||
start_h += 5.0f; // to avoid circle change of colors for 120 deg
|
||||
if (delta_h < 180.0f)
|
||||
delta_h = 360.0f - delta_h;
|
||||
|
||||
Randomizer rnd;
|
||||
float out_h = start_h + 0.5f * delta_h;
|
||||
if (out_h > 360.0f)
|
||||
out_h -= 360.0f;
|
||||
float out_s = rnd.random_float(0.65f, 1.0f);
|
||||
float out_v = rnd.random_float(0.65f, 1.0f);
|
||||
|
||||
float out_r, out_g, out_b;
|
||||
HSVtoRGB(out_h, out_s, out_v, out_r, out_g, out_b);
|
||||
return { out_r, out_g, out_b };
|
||||
}
|
||||
|
||||
bool can_decode_color(const std::string& color) { return color.size() == 7 && color.front() == '#'; }
|
||||
|
||||
bool decode_color(const std::string& color_in, ColorRGB& color_out)
|
||||
{
|
||||
auto hex_digit_to_int = [](const char c) {
|
||||
return
|
||||
(c >= '0' && c <= '9') ? int(c - '0') :
|
||||
(c >= 'A' && c <= 'F') ? int(c - 'A') + 10 :
|
||||
(c >= 'a' && c <= 'f') ? int(c - 'a') + 10 : -1;
|
||||
};
|
||||
|
||||
color_out = ColorRGB::BLACK();
|
||||
if (can_decode_color(color_in)) {
|
||||
const char* c = color_in.data() + 1;
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
const int digit1 = hex_digit_to_int(*c++);
|
||||
const int digit2 = hex_digit_to_int(*c++);
|
||||
if (digit1 != -1 && digit2 != -1)
|
||||
color_out.set(i, float(digit1 * 16 + digit2) * INV_255);
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
assert(0.0f <= color_out.r() && color_out.r() <= 1.0f);
|
||||
assert(0.0f <= color_out.g() && color_out.g() <= 1.0f);
|
||||
assert(0.0f <= color_out.b() && color_out.b() <= 1.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_color(const std::string& color_in, ColorRGBA& color_out)
|
||||
{
|
||||
ColorRGB rgb;
|
||||
if (!decode_color(color_in, rgb))
|
||||
return false;
|
||||
|
||||
color_out = to_rgba(rgb, color_out.a());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGB>& colors_out)
|
||||
{
|
||||
colors_out = std::vector<ColorRGB>(colors_in.size(), ColorRGB::BLACK());
|
||||
for (size_t i = 0; i < colors_in.size(); ++i) {
|
||||
if (!decode_color(colors_in[i], colors_out[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGBA>& colors_out)
|
||||
{
|
||||
colors_out = std::vector<ColorRGBA>(colors_in.size(), ColorRGBA::BLACK());
|
||||
for (size_t i = 0; i < colors_in.size(); ++i) {
|
||||
if (!decode_color(colors_in[i], colors_out[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string encode_color(const ColorRGB& color)
|
||||
{
|
||||
char buffer[64];
|
||||
::sprintf(buffer, "#%02X%02X%02X", color.r_uchar(), color.g_uchar(), color.b_uchar());
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
std::string encode_color(const ColorRGBA& color) { return encode_color(to_rgb(color)); }
|
||||
|
||||
ColorRGB to_rgb(const ColorRGBA& other_rgba) { return { other_rgba.r(), other_rgba.g(), other_rgba.b() }; }
|
||||
ColorRGBA to_rgba(const ColorRGB& other_rgb) { return { other_rgb.r(), other_rgb.g(), other_rgb.b(), 1.0f }; }
|
||||
ColorRGBA to_rgba(const ColorRGB& other_rgb, float alpha) { return { other_rgb.r(), other_rgb.g(), other_rgb.b(), alpha }; }
|
||||
|
||||
ColorRGBA picking_decode(unsigned int id)
|
||||
{
|
||||
return {
|
||||
float((id >> 0) & 0xff) * INV_255, // red
|
||||
float((id >> 8) & 0xff) * INV_255, // green
|
||||
float((id >> 16) & 0xff) * INV_255, // blue
|
||||
float(picking_checksum_alpha_channel(id & 0xff, (id >> 8) & 0xff, (id >> 16) & 0xff)) * INV_255 // checksum for validating against unwanted alpha blending and multi sampling
|
||||
};
|
||||
}
|
||||
|
||||
unsigned int picking_encode(unsigned char r, unsigned char g, unsigned char b) { return r + (g << 8) + (b << 16); }
|
||||
|
||||
unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
// 8 bit hash for the color
|
||||
unsigned char b = ((((37 * red) + green) & 0x0ff) * 37 + blue) & 0x0ff;
|
||||
// Increase enthropy by a bit reversal
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
// Flip every second bit to increase the enthropy even more.
|
||||
b ^= 0x55;
|
||||
return b;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // ENABLE_COLOR_CLASSES
|
174
src/libslic3r/Color.hpp
Normal file
174
src/libslic3r/Color.hpp
Normal file
|
@ -0,0 +1,174 @@
|
|||
#ifndef slic3r_Color_hpp_
|
||||
#define slic3r_Color_hpp_
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class ColorRGB
|
||||
{
|
||||
std::array<float, 3> m_data{1.0f, 1.0f, 1.0f};
|
||||
|
||||
public:
|
||||
ColorRGB() = default;
|
||||
ColorRGB(float r, float g, float b);
|
||||
ColorRGB(unsigned char r, unsigned char g, unsigned char b);
|
||||
ColorRGB(const ColorRGB& other) = default;
|
||||
|
||||
ColorRGB& operator = (const ColorRGB& other) { m_data = other.m_data; return *this; }
|
||||
|
||||
bool operator == (const ColorRGB& other) const { return m_data == other.m_data; }
|
||||
bool operator != (const ColorRGB& other) const { return !operator==(other); }
|
||||
bool operator < (const ColorRGB& other) const;
|
||||
bool operator > (const ColorRGB& other) const;
|
||||
|
||||
ColorRGB operator + (const ColorRGB& other) const;
|
||||
ColorRGB operator * (float value) const;
|
||||
|
||||
const float* const data() const { return m_data.data(); }
|
||||
|
||||
float r() const { return m_data[0]; }
|
||||
float g() const { return m_data[1]; }
|
||||
float b() const { return m_data[2]; }
|
||||
|
||||
void r(float r) { m_data[0] = std::clamp(r, 0.0f, 1.0f); }
|
||||
void g(float g) { m_data[1] = std::clamp(g, 0.0f, 1.0f); }
|
||||
void b(float b) { m_data[2] = std::clamp(b, 0.0f, 1.0f); }
|
||||
|
||||
void set(unsigned int comp, float value) {
|
||||
assert(0 <= comp && comp <= 2);
|
||||
m_data[comp] = std::clamp(value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
unsigned char r_uchar() const { return unsigned char(m_data[0] * 255.0f); }
|
||||
unsigned char g_uchar() const { return unsigned char(m_data[1] * 255.0f); }
|
||||
unsigned char b_uchar() const { return unsigned char(m_data[2] * 255.0f); }
|
||||
|
||||
static const ColorRGB BLACK() { return { 0.0f, 0.0f, 0.0f }; }
|
||||
static const ColorRGB BLUE() { return { 0.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGB BLUEISH() { return { 0.5f, 0.5f, 1.0f }; }
|
||||
static const ColorRGB DARK_GRAY() { return { 0.25f, 0.25f, 0.25f }; }
|
||||
static const ColorRGB DARK_YELLOW() { return { 0.5f, 0.5f, 0.0f }; }
|
||||
static const ColorRGB GRAY() { return { 0.5f, 0.5f, 0.5f }; }
|
||||
static const ColorRGB GREEN() { return { 0.0f, 1.0f, 0.0f }; }
|
||||
static const ColorRGB GREENISH() { return { 0.5f, 1.0f, 0.5f }; }
|
||||
static const ColorRGB LIGHT_GRAY() { return { 0.75f, 0.75f, 0.75f }; }
|
||||
static const ColorRGB ORANGE() { return { 0.92f, 0.50f, 0.26f }; }
|
||||
static const ColorRGB RED() { return { 1.0f, 0.0f, 0.0f }; }
|
||||
static const ColorRGB REDISH() { return { 1.0f, 0.5f, 0.5f }; }
|
||||
static const ColorRGB YELLOW() { return { 1.0f, 1.0f, 0.0f }; }
|
||||
static const ColorRGB WHITE() { return { 1.0f, 1.0f, 1.0f }; }
|
||||
|
||||
static const ColorRGB X() { return { 0.75f, 0.0f, 0.0f }; }
|
||||
static const ColorRGB Y() { return { 0.0f, 0.75f, 0.0f }; }
|
||||
static const ColorRGB Z() { return { 0.0f, 0.0f, 0.75f }; }
|
||||
};
|
||||
|
||||
class ColorRGBA
|
||||
{
|
||||
std::array<float, 4> m_data{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
|
||||
public:
|
||||
ColorRGBA() = default;
|
||||
ColorRGBA(float r, float g, float b, float a);
|
||||
ColorRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
ColorRGBA(const ColorRGBA& other) = default;
|
||||
|
||||
ColorRGBA& operator = (const ColorRGBA& other) { m_data = other.m_data; return *this; }
|
||||
|
||||
bool operator == (const ColorRGBA& other) const { return m_data == other.m_data; }
|
||||
bool operator != (const ColorRGBA& other) const { return !operator==(other); }
|
||||
bool operator < (const ColorRGBA& other) const;
|
||||
bool operator > (const ColorRGBA& other) const;
|
||||
|
||||
ColorRGBA operator + (const ColorRGBA& other) const;
|
||||
ColorRGBA operator * (float value) const;
|
||||
|
||||
const float* const data() const { return m_data.data(); }
|
||||
|
||||
float r() const { return m_data[0]; }
|
||||
float g() const { return m_data[1]; }
|
||||
float b() const { return m_data[2]; }
|
||||
float a() const { return m_data[3]; }
|
||||
|
||||
void r(float r) { m_data[0] = std::clamp(r, 0.0f, 1.0f); }
|
||||
void g(float g) { m_data[1] = std::clamp(g, 0.0f, 1.0f); }
|
||||
void b(float b) { m_data[2] = std::clamp(b, 0.0f, 1.0f); }
|
||||
void a(float a) { m_data[3] = std::clamp(a, 0.0f, 1.0f); }
|
||||
|
||||
void set(unsigned int comp, float value) {
|
||||
assert(0 <= comp && comp <= 3);
|
||||
m_data[comp] = std::clamp(value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
unsigned char r_uchar() const { return unsigned char(m_data[0] * 255.0f); }
|
||||
unsigned char g_uchar() const { return unsigned char(m_data[1] * 255.0f); }
|
||||
unsigned char b_uchar() const { return unsigned char(m_data[2] * 255.0f); }
|
||||
unsigned char a_uchar() const { return unsigned char(m_data[3] * 255.0f); }
|
||||
|
||||
bool is_transparent() const { return m_data[3] < 1.0f; }
|
||||
|
||||
static const ColorRGBA BLACK() { return { 0.0f, 0.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA BLUE() { return { 0.0f, 0.0f, 1.0f, 1.0f }; }
|
||||
static const ColorRGBA BLUEISH() { return { 0.5f, 0.5f, 1.0f, 1.0f }; }
|
||||
static const ColorRGBA DARK_GRAY() { return { 0.25f, 0.25f, 0.25f, 1.0f }; }
|
||||
static const ColorRGBA DARK_YELLOW() { return { 0.5f, 0.5f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA GRAY() { return { 0.5f, 0.5f, 0.5f, 1.0f }; }
|
||||
static const ColorRGBA GREEN() { return { 0.0f, 1.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA GREENISH() { return { 0.5f, 1.0f, 0.5f, 1.0f }; }
|
||||
static const ColorRGBA LIGHT_GRAY() { return { 0.75f, 0.75f, 0.75f, 1.0f }; }
|
||||
static const ColorRGBA ORANGE() { return { 0.923f, 0.504f, 0.264f, 1.0f }; }
|
||||
static const ColorRGBA RED() { return { 1.0f, 0.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA REDISH() { return { 1.0f, 0.5f, 0.5f, 1.0f }; }
|
||||
static const ColorRGBA YELLOW() { return { 1.0f, 1.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA WHITE() { return { 1.0f, 1.0f, 1.0f, 1.0f }; }
|
||||
|
||||
static const ColorRGBA X() { return { 0.75f, 0.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA Y() { return { 0.0f, 0.75f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA Z() { return { 0.0f, 0.0f, 0.75f, 1.0f }; }
|
||||
};
|
||||
|
||||
extern ColorRGB operator * (float value, const ColorRGB& other);
|
||||
extern ColorRGBA operator * (float value, const ColorRGBA& other);
|
||||
|
||||
extern ColorRGB lerp(const ColorRGB& a, const ColorRGB& b, float t);
|
||||
extern ColorRGBA lerp(const ColorRGBA& a, const ColorRGBA& b, float t);
|
||||
|
||||
extern ColorRGB complementary(const ColorRGB& color);
|
||||
extern ColorRGBA complementary(const ColorRGBA& color);
|
||||
|
||||
extern ColorRGB saturate(const ColorRGB& color, float factor);
|
||||
extern ColorRGBA saturate(const ColorRGBA& color, float factor);
|
||||
|
||||
extern ColorRGB opposite(const ColorRGB& color);
|
||||
extern ColorRGB opposite(const ColorRGB& a, const ColorRGB& b);
|
||||
|
||||
extern bool can_decode_color(const std::string& color);
|
||||
|
||||
extern bool decode_color(const std::string& color_in, ColorRGB& color_out);
|
||||
extern bool decode_color(const std::string& color_in, ColorRGBA& color_out);
|
||||
|
||||
extern bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGB>& colors_out);
|
||||
extern bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGBA>& colors_out);
|
||||
|
||||
extern std::string encode_color(const ColorRGB& color);
|
||||
extern std::string encode_color(const ColorRGBA& color);
|
||||
|
||||
extern ColorRGB to_rgb(const ColorRGBA& other_rgba);
|
||||
extern ColorRGBA to_rgba(const ColorRGB& other_rgb);
|
||||
extern ColorRGBA to_rgba(const ColorRGB& other_rgb, float alpha);
|
||||
|
||||
extern ColorRGBA picking_decode(unsigned int id);
|
||||
extern unsigned int picking_encode(unsigned char r, unsigned char g, unsigned char b);
|
||||
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
||||
// were not interpolated by alpha blending or multi sampling.
|
||||
extern unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#endif /* slic3r_Color_hpp_ */
|
|
@ -58,4 +58,13 @@
|
|||
#define ENABLE_ENHANCED_PRINT_VOLUME_FIT (1 && ENABLE_2_4_0_BETA2)
|
||||
|
||||
|
||||
//====================
|
||||
// 2.5.0.alpha1 techs
|
||||
//====================
|
||||
#define ENABLE_2_5_0_ALPHA1 1
|
||||
|
||||
// Enable Color classes definition as unified point for colors manipulation
|
||||
#define ENABLE_COLOR_CLASSES (1 && ENABLE_2_5_0_ALPHA1)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
|
@ -19,8 +19,15 @@
|
|||
#include <boost/log/trivial.hpp>
|
||||
|
||||
static const float GROUND_Z = -0.02f;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const Slic3r::ColorRGBA DEFAULT_MODEL_COLOR = Slic3r::ColorRGBA::DARK_GRAY();
|
||||
static const Slic3r::ColorRGBA PICKING_MODEL_COLOR = Slic3r::ColorRGBA::BLACK();
|
||||
static const Slic3r::ColorRGBA DEFAULT_SOLID_GRID_COLOR = { 0.9f, 0.9f, 0.9f, 1.0f };
|
||||
static const Slic3r::ColorRGBA DEFAULT_TRANSPARENT_GRID_COLOR = { 0.9f, 0.9f, 0.9f, 0.6f };
|
||||
#else
|
||||
static const std::array<float, 4> DEFAULT_MODEL_COLOR = { 0.235f, 0.235f, 0.235f, 1.0f };
|
||||
static const std::array<float, 4> PICKING_MODEL_COLOR = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -121,15 +128,27 @@ void Bed3D::Axes::render() const
|
|||
shader->set_uniform("emission_factor", 0.0f);
|
||||
|
||||
// x axis
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::X());
|
||||
#else
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.75f, 0.0f, 0.0f, 1.0f });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }).cast<float>());
|
||||
|
||||
// y axis
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::Y());
|
||||
#else
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.0f, 0.75f, 0.0f, 1.0f });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }).cast<float>());
|
||||
|
||||
// z axis
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::Z());
|
||||
#else
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.0f, 0.0f, 0.75f, 1.0f });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_axis(Geometry::assemble_transform(m_origin).cast<float>());
|
||||
|
||||
shader->stop_using();
|
||||
|
@ -540,7 +559,11 @@ void Bed3D::render_default(bool bottom, bool picking) const
|
|||
if (!has_model && !bottom) {
|
||||
// draw background
|
||||
glsafe(::glDepthMask(GL_FALSE));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(picking ? PICKING_MODEL_COLOR.data() : DEFAULT_MODEL_COLOR.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(picking ? PICKING_MODEL_COLOR.data() : DEFAULT_MODEL_COLOR.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
glsafe(::glNormal3d(0.0f, 0.0f, 1.0f));
|
||||
glsafe(::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_vertices_data()));
|
||||
glsafe(::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount));
|
||||
|
@ -550,10 +573,14 @@ void Bed3D::render_default(bool bottom, bool picking) const
|
|||
if (!picking) {
|
||||
// draw grid
|
||||
glsafe(::glLineWidth(1.5f * m_scale_factor));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(has_model && !bottom ? DEFAULT_SOLID_GRID_COLOR.data() : DEFAULT_TRANSPARENT_GRID_COLOR.data()));
|
||||
#else
|
||||
if (has_model && !bottom)
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 1.0f));
|
||||
else
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.6f));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
glsafe(::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_gridlines.get_vertices_data()));
|
||||
glsafe(::glDrawArrays(GL_LINES, 0, (GLsizei)m_gridlines.get_vertices_count()));
|
||||
}
|
||||
|
|
|
@ -344,6 +344,23 @@ void GLVolume::SinkingContours::update()
|
|||
m_model.reset();
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA GLVolume::SELECTED_COLOR = ColorRGBA::GREEN();
|
||||
const ColorRGBA GLVolume::HOVER_SELECT_COLOR = { 0.4f, 0.9f, 0.1f, 1.0f };
|
||||
const ColorRGBA GLVolume::HOVER_DESELECT_COLOR = { 1.0f, 0.75f, 0.75f, 1.0f };
|
||||
const ColorRGBA GLVolume::OUTSIDE_COLOR = { 0.0f, 0.38f, 0.8f, 1.0f };
|
||||
const ColorRGBA GLVolume::SELECTED_OUTSIDE_COLOR = { 0.19f, 0.58f, 1.0f, 1.0f };
|
||||
const ColorRGBA GLVolume::DISABLED_COLOR = ColorRGBA::DARK_GRAY();
|
||||
const ColorRGBA GLVolume::SLA_SUPPORT_COLOR = ColorRGBA::LIGHT_GRAY();
|
||||
const ColorRGBA GLVolume::SLA_PAD_COLOR = { 0.0f, 0.2f, 0.0f, 1.0f };
|
||||
const ColorRGBA GLVolume::NEUTRAL_COLOR = { 0.9f, 0.9f, 0.9f, 1.0f };
|
||||
const std::array<ColorRGBA, 4> GLVolume::MODEL_COLOR = { {
|
||||
ColorRGBA::YELLOW(),
|
||||
{ 1.0f, 0.5f, 0.5f, 1.0f },
|
||||
{ 0.5f, 1.0f, 0.5f, 1.0f },
|
||||
{ 0.5f, 0.5f, 1.0f, 1.0f }
|
||||
} };
|
||||
#else
|
||||
const std::array<float, 4> GLVolume::SELECTED_COLOR = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
const std::array<float, 4> GLVolume::HOVER_SELECT_COLOR = { 0.4f, 0.9f, 0.1f, 1.0f };
|
||||
const std::array<float, 4> GLVolume::HOVER_DESELECT_COLOR = { 1.0f, 0.75f, 0.75f, 1.0f };
|
||||
|
@ -359,6 +376,7 @@ const std::array<std::array<float, 4>, 4> GLVolume::MODEL_COLOR = { {
|
|||
{ 0.5f, 1.0f, 0.5f, 1.f },
|
||||
{ 0.5f, 0.5f, 1.0f, 1.f }
|
||||
} };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLVolume::GLVolume(float r, float g, float b, float a)
|
||||
: m_sla_shift_z(0.0)
|
||||
|
@ -388,6 +406,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
|
|||
set_render_color(color);
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
void GLVolume::set_color(const std::array<float, 4>& rgba)
|
||||
{
|
||||
color = rgba;
|
||||
|
@ -402,6 +421,7 @@ void GLVolume::set_render_color(const std::array<float, 4>& rgba)
|
|||
{
|
||||
render_color = rgba;
|
||||
}
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
void GLVolume::set_render_color()
|
||||
{
|
||||
|
@ -433,15 +453,46 @@ void GLVolume::set_render_color()
|
|||
}
|
||||
|
||||
if (!printable) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
render_color = saturate(render_color, 0.25f);
|
||||
#else
|
||||
render_color[0] /= 4;
|
||||
render_color[1] /= 4;
|
||||
render_color[2] /= 4;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
if (force_transparent)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
render_color.a(color.a());
|
||||
#else
|
||||
render_color[3] = color[3];
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color_from_model_volume(const ModelVolume& model_volume)
|
||||
{
|
||||
ColorRGBA color;
|
||||
if (model_volume.is_negative_volume())
|
||||
color = { 0.2f, 0.2f, 0.2f, 1.0f };
|
||||
else if (model_volume.is_modifier())
|
||||
#if ENABLE_MODIFIERS_ALWAYS_TRANSPARENT
|
||||
color = { 1.0, 1.0f, 0.2f, 1.0f };
|
||||
#else
|
||||
color[0] = { 0.2f, 1.0f, 0.2f, 1.0f };
|
||||
#endif // ENABLE_MODIFIERS_ALWAYS_TRANSPARENT
|
||||
else if (model_volume.is_support_blocker())
|
||||
color = { 1.0f, 0.2f, 0.2f, 1.0f };
|
||||
else if (model_volume.is_support_enforcer())
|
||||
color = { 0.2f, 0.2f, 1.0f, 1.0f };
|
||||
|
||||
if (!model_volume.is_model_part())
|
||||
color.a(0.5f);
|
||||
|
||||
return color;
|
||||
}
|
||||
#else
|
||||
std::array<float, 4> color_from_model_volume(const ModelVolume& model_volume)
|
||||
{
|
||||
std::array<float, 4> color;
|
||||
|
@ -474,6 +525,7 @@ std::array<float, 4> color_from_model_volume(const ModelVolume& model_volume)
|
|||
color[3] = model_volume.is_model_part() ? 1.f : 0.5f;
|
||||
return color;
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
Transform3d GLVolume::world_matrix() const
|
||||
{
|
||||
|
@ -631,8 +683,13 @@ int GLVolumeCollection::load_object_volume(
|
|||
const int extruder_id = model_volume->extruder_id();
|
||||
const ModelInstance *instance = model_object->instances[instance_idx];
|
||||
const TriangleMesh &mesh = model_volume->mesh();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color = GLVolume::MODEL_COLOR[((color_by == "volume") ? volume_idx : obj_idx) % 4];
|
||||
color.a(model_volume->is_model_part() ? 1.0f : 0.5f);
|
||||
#else
|
||||
std::array<float, 4> color = GLVolume::MODEL_COLOR[((color_by == "volume") ? volume_idx : obj_idx) % 4];
|
||||
color[3] = model_volume->is_model_part() ? 1.f : 0.5f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
this->volumes.emplace_back(new GLVolume(color));
|
||||
GLVolume& v = *this->volumes.back();
|
||||
v.set_color(color_from_model_volume(*model_volume));
|
||||
|
@ -713,13 +770,22 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||
height = 0.1f;
|
||||
|
||||
TriangleMesh mesh;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color = ColorRGBA::DARK_YELLOW();
|
||||
#else
|
||||
std::array<float, 4> color = { 0.5f, 0.5f, 0.0f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// In case we don't know precise dimensions of the wipe tower yet, we'll draw
|
||||
// the box with different color with one side jagged:
|
||||
if (size_unknown) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
color.r(0.9f);
|
||||
color.g(0.6f);
|
||||
#else
|
||||
color[0] = 0.9f;
|
||||
color[1] = 0.6f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// Too narrow tower would interfere with the teeth. The estimate is not precise anyway.
|
||||
depth = std::max(depth, 10.f);
|
||||
|
@ -775,14 +841,22 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||
return int(volumes.size() - 1);
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
GLVolume* GLVolumeCollection::new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats)
|
||||
#else
|
||||
GLVolume* GLVolumeCollection::new_toolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats)
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
GLVolume *out = new_nontoolpath_volume(rgba, reserve_vbo_floats);
|
||||
out->is_extrusion_path = true;
|
||||
return out;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
GLVolume* GLVolumeCollection::new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats)
|
||||
#else
|
||||
GLVolume* GLVolumeCollection::new_nontoolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats)
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
GLVolume *out = new GLVolume(rgba);
|
||||
out->is_extrusion_path = false;
|
||||
|
@ -799,7 +873,11 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
|
|||
|
||||
for (unsigned int i = 0; i < (unsigned int)volumes.size(); ++i) {
|
||||
GLVolume* volume = volumes[i];
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
bool is_transparent = volume->render_color.is_transparent();
|
||||
#else
|
||||
bool is_transparent = (volume->render_color[3] < 1.0f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (((type == GLVolumeCollection::ERenderType::Opaque && !is_transparent) ||
|
||||
(type == GLVolumeCollection::ERenderType::Transparent && is_transparent) ||
|
||||
type == GLVolumeCollection::ERenderType::All) &&
|
||||
|
@ -991,6 +1069,10 @@ void GLVolumeCollection::reset_outside_state()
|
|||
|
||||
void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* config)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
using ColorItem = std::pair<std::string, ColorRGBA>;
|
||||
std::vector<ColorItem> colors;
|
||||
#else
|
||||
static const float inv_255 = 1.0f / 255.0f;
|
||||
|
||||
struct Color
|
||||
|
@ -1018,19 +1100,24 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
|||
|
||||
unsigned char rgb[3];
|
||||
std::vector<Color> colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (static_cast<PrinterTechnology>(config->opt_int("printer_technology")) == ptSLA)
|
||||
{
|
||||
if (static_cast<PrinterTechnology>(config->opt_int("printer_technology")) == ptSLA) {
|
||||
const std::string& txt_color = config->opt_string("material_colour").empty() ?
|
||||
print_config_def.get("material_colour")->get_default_value<ConfigOptionString>()->value :
|
||||
config->opt_string("material_colour");
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA rgba;
|
||||
if (decode_color(txt_color, rgba))
|
||||
colors.push_back({ txt_color, rgba });
|
||||
#else
|
||||
if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb)) {
|
||||
colors.resize(1);
|
||||
colors[0].set(txt_color, rgb);
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
const ConfigOptionStrings* extruders_opt = dynamic_cast<const ConfigOptionStrings*>(config->option("extruder_colour"));
|
||||
if (extruders_opt == nullptr)
|
||||
return;
|
||||
|
@ -1039,12 +1126,23 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
|||
if (filamemts_opt == nullptr)
|
||||
return;
|
||||
|
||||
unsigned int colors_count = std::max((unsigned int)extruders_opt->values.size(), (unsigned int)filamemts_opt->values.size());
|
||||
size_t colors_count = std::max(extruders_opt->values.size(), filamemts_opt->values.size());
|
||||
if (colors_count == 0)
|
||||
return;
|
||||
colors.resize(colors_count);
|
||||
|
||||
for (unsigned int i = 0; i < colors_count; ++i) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::string& ext_color = config->opt_string("extruder_colour", i);
|
||||
ColorRGBA rgba;
|
||||
if (decode_color(ext_color, rgba))
|
||||
colors[i] = { ext_color, rgba };
|
||||
else {
|
||||
const std::string& fil_color = config->opt_string("filament_colour", i);
|
||||
if (decode_color(fil_color, rgba))
|
||||
colors[i] = { fil_color, rgba };
|
||||
}
|
||||
#else
|
||||
const std::string& txt_color = config->opt_string("extruder_colour", i);
|
||||
if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb))
|
||||
colors[i].set(txt_color, rgb);
|
||||
|
@ -1053,23 +1151,30 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
|||
if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb))
|
||||
colors[i].set(txt_color, rgb);
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
}
|
||||
|
||||
for (GLVolume* volume : volumes) {
|
||||
if (volume == nullptr || volume->is_modifier || volume->is_wipe_tower || (volume->volume_idx() < 0))
|
||||
if (volume == nullptr || volume->is_modifier || volume->is_wipe_tower || volume->volume_idx() < 0)
|
||||
continue;
|
||||
|
||||
int extruder_id = volume->extruder_id - 1;
|
||||
if (extruder_id < 0 || (int)colors.size() <= extruder_id)
|
||||
extruder_id = 0;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorItem& color = colors[extruder_id];
|
||||
if (!color.first.empty())
|
||||
volume->color = color.second;
|
||||
#else
|
||||
const Color& color = colors[extruder_id];
|
||||
if (!color.text.empty()) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
volume->color[i] = (float)color.rgb[i] * inv_255;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#include "libslic3r/TriangleMesh.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Geometry.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "GLModel.hpp"
|
||||
|
||||
|
@ -43,7 +46,11 @@ class ModelVolume;
|
|||
enum ModelInstanceEPrintVolumeState : unsigned char;
|
||||
|
||||
// Return appropriate color based on the ModelVolume.
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
extern ColorRGBA color_from_model_volume(const ModelVolume& model_volume);
|
||||
#else
|
||||
std::array<float, 4> color_from_model_volume(const ModelVolume& model_volume);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// A container for interleaved arrays of 3D vertices and normals,
|
||||
// possibly indexed by triangles and / or quads.
|
||||
|
@ -248,6 +255,18 @@ private:
|
|||
|
||||
class GLVolume {
|
||||
public:
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const ColorRGBA SELECTED_COLOR;
|
||||
static const ColorRGBA HOVER_SELECT_COLOR;
|
||||
static const ColorRGBA HOVER_DESELECT_COLOR;
|
||||
static const ColorRGBA OUTSIDE_COLOR;
|
||||
static const ColorRGBA SELECTED_OUTSIDE_COLOR;
|
||||
static const ColorRGBA DISABLED_COLOR;
|
||||
static const ColorRGBA SLA_SUPPORT_COLOR;
|
||||
static const ColorRGBA SLA_PAD_COLOR;
|
||||
static const ColorRGBA NEUTRAL_COLOR;
|
||||
static const std::array<ColorRGBA, 4> MODEL_COLOR;
|
||||
#else
|
||||
static const std::array<float, 4> SELECTED_COLOR;
|
||||
static const std::array<float, 4> HOVER_SELECT_COLOR;
|
||||
static const std::array<float, 4> HOVER_DESELECT_COLOR;
|
||||
|
@ -258,6 +277,7 @@ public:
|
|||
static const std::array<float, 4> SLA_PAD_COLOR;
|
||||
static const std::array<float, 4> NEUTRAL_COLOR;
|
||||
static const std::array<std::array<float, 4>, 4> MODEL_COLOR;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
enum EHoverState : unsigned char
|
||||
{
|
||||
|
@ -267,8 +287,12 @@ public:
|
|||
HS_Deselect
|
||||
};
|
||||
|
||||
GLVolume(float r = 1.f, float g = 1.f, float b = 1.f, float a = 1.f);
|
||||
GLVolume(float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
GLVolume(const ColorRGBA& color) : GLVolume(color.r(), color.g(), color.b(), color.a()) {}
|
||||
#else
|
||||
GLVolume(const std::array<float, 4>& rgba) : GLVolume(rgba[0], rgba[1], rgba[2], rgba[3]) {}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
private:
|
||||
Geometry::Transformation m_instance_transformation;
|
||||
|
@ -304,10 +328,17 @@ private:
|
|||
SinkingContours m_sinking_contours;
|
||||
|
||||
public:
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
// Color of the triangles / quads held by this volume.
|
||||
ColorRGBA color;
|
||||
// Color used to render this volume.
|
||||
ColorRGBA render_color;
|
||||
#else
|
||||
// Color of the triangles / quads held by this volume.
|
||||
std::array<float, 4> color;
|
||||
// Color used to render this volume.
|
||||
std::array<float, 4> render_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
struct CompositeID {
|
||||
CompositeID(int object_id, int volume_id, int instance_id) : object_id(object_id), volume_id(volume_id), instance_id(instance_id) {}
|
||||
|
@ -393,9 +424,14 @@ public:
|
|||
return out;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_color(const ColorRGBA& rgba) { color = rgba; }
|
||||
void set_render_color(const ColorRGBA& rgba) { render_color = rgba; }
|
||||
#else
|
||||
void set_color(const std::array<float, 4>& rgba);
|
||||
void set_render_color(float r, float g, float b, float a);
|
||||
void set_render_color(const std::array<float, 4>& rgba);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// Sets render color in dependence of current state
|
||||
void set_render_color();
|
||||
// set color according to model volume
|
||||
|
@ -595,8 +631,13 @@ public:
|
|||
int load_wipe_tower_preview(
|
||||
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool size_unknown, float brim_width, bool opengl_initialized);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
GLVolume* new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
|
||||
GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
|
||||
#else
|
||||
GLVolume* new_toolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats = 0);
|
||||
GLVolume* new_nontoolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats = 0);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// Render the volumes by OpenGL.
|
||||
void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#include "I18N.hpp"
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
|
@ -133,12 +136,17 @@ wxString CopyrightsDialog::get_html_text()
|
|||
wxColour bgr_clr = wxGetApp().get_window_default_clr();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();// wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
const auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
const auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
const wxString copyright_str = _(L("Copyright")) + "© ";
|
||||
const wxString copyright_str = _L("Copyright") + "© ";
|
||||
// TRN "Slic3r _is licensed under the_ License"
|
||||
const wxString header_str = _(L("License agreements of all following programs (libraries) are part of application license agreement"));
|
||||
const wxString header_str = _L("License agreements of all following programs (libraries) are part of application license agreement");
|
||||
|
||||
wxString text = wxString::Format(
|
||||
"<html>"
|
||||
|
@ -257,8 +265,13 @@ AboutDialog::AboutDialog()
|
|||
m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
|
||||
wxFont font = get_default_font(this);
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
const int fs = font.GetPointSize()-1;
|
||||
int size[] = {fs,fs,fs,fs,fs,fs,fs};
|
||||
|
|
|
@ -395,6 +395,7 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi
|
|||
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
|
||||
{
|
||||
rgb_out[0] = rgb_out[1] = rgb_out[2] = 0;
|
||||
|
@ -410,6 +411,7 @@ bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -9,9 +9,14 @@
|
|||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
struct NSVGimage;
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class BitmapCache
|
||||
{
|
||||
|
@ -43,10 +48,16 @@ public:
|
|||
wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false, const std::string& new_color = "");
|
||||
|
||||
wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
wxBitmap mksolid(size_t width, size_t height, const ColorRGB& rgb, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
|
||||
#else
|
||||
wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT); }
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static bool parse_color(const std::string& scolor, unsigned char* rgb_out);
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
private:
|
||||
std::map<std::string, wxBitmap*> m_map;
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Time.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "GUI_App.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
@ -31,8 +34,12 @@ static wxString format_reason(const Config::Snapshot::Reason reason)
|
|||
|
||||
static std::string get_color(wxColour colour)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return encode_color(ColorRGB(colour.Red(), colour.Green(), colour.Blue()));
|
||||
#else
|
||||
wxString clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue());
|
||||
return clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
|
@ -746,9 +749,15 @@ void PageMaterials::set_compatible_printers_html_window(const std::vector<std::s
|
|||
wxSystemSettings::GetColour(wxSYS_COLOUR_MENU);
|
||||
#endif
|
||||
#endif
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
#else
|
||||
const auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
const auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
wxString first_line = format_wxstr(_L("%1% marked with <b>*</b> are <b>not</b> compatible with some installed printers."), materials->technology == T_FFF ? _L("Filaments") : _L("SLA materials"));
|
||||
wxString text;
|
||||
if (all_printers) {
|
||||
|
|
|
@ -2557,36 +2557,68 @@ bool Control::check_ticks_changed_event(Type type)
|
|||
|
||||
std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int extruder)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto opposite_one_color = [](const std::string& color) {
|
||||
ColorRGB rgb;
|
||||
decode_color(color, rgb);
|
||||
return encode_color(opposite(rgb));
|
||||
};
|
||||
auto opposite_two_colors = [](const std::string& a, const std::string& b) {
|
||||
ColorRGB rgb1; decode_color(a, rgb1);
|
||||
ColorRGB rgb2; decode_color(b, rgb2);
|
||||
return encode_color(opposite(rgb1, rgb2));
|
||||
};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (mode == SingleExtruder && type == ColorChange && m_use_default_colors) {
|
||||
#if 1
|
||||
if (ticks.empty())
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_one_color((*m_colors)[0]);
|
||||
#else
|
||||
return color_generator.get_opposite_color((*m_colors)[0]);
|
||||
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
auto before_tick_it = std::lower_bound(ticks.begin(), ticks.end(), tick);
|
||||
if (before_tick_it == ticks.end())
|
||||
{
|
||||
if (before_tick_it == ticks.end()) {
|
||||
while (before_tick_it != ticks.begin())
|
||||
if (--before_tick_it; before_tick_it->type == ColorChange)
|
||||
break;
|
||||
if (before_tick_it->type == ColorChange)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_one_color(before_tick_it->color);
|
||||
|
||||
return opposite_one_color((*m_colors)[0]);
|
||||
#else
|
||||
return color_generator.get_opposite_color(before_tick_it->color);
|
||||
|
||||
return color_generator.get_opposite_color((*m_colors)[0]);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
if (before_tick_it == ticks.begin())
|
||||
{
|
||||
if (before_tick_it == ticks.begin()) {
|
||||
const std::string& frst_color = (*m_colors)[0];
|
||||
if (before_tick_it->type == ColorChange)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_two_colors(frst_color, before_tick_it->color);
|
||||
#else
|
||||
return color_generator.get_opposite_color(frst_color, before_tick_it->color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
auto next_tick_it = before_tick_it;
|
||||
while (next_tick_it != ticks.end())
|
||||
if (++next_tick_it; next_tick_it->type == ColorChange)
|
||||
break;
|
||||
if (next_tick_it->type == ColorChange)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_two_colors(frst_color, next_tick_it->color);
|
||||
|
||||
return opposite_one_color(frst_color);
|
||||
#else
|
||||
return color_generator.get_opposite_color(frst_color, next_tick_it->color);
|
||||
|
||||
return color_generator.get_opposite_color(frst_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
std::string frst_color = "";
|
||||
|
@ -2607,13 +2639,27 @@ std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int
|
|||
|
||||
if (before_tick_it->type == ColorChange) {
|
||||
if (frst_color.empty())
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_one_color(before_tick_it->color);
|
||||
|
||||
return opposite_two_colors(before_tick_it->color, frst_color);
|
||||
#else
|
||||
return color_generator.get_opposite_color(before_tick_it->color);
|
||||
|
||||
return color_generator.get_opposite_color(before_tick_it->color, frst_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
if (frst_color.empty())
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_one_color((*m_colors)[0]);
|
||||
|
||||
return opposite_two_colors((*m_colors)[0], frst_color);
|
||||
#else
|
||||
return color_generator.get_opposite_color((*m_colors)[0]);
|
||||
|
||||
return color_generator.get_opposite_color((*m_colors)[0], frst_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#else
|
||||
const std::vector<std::string>& colors = ColorPrintColors::get();
|
||||
if (ticks.empty())
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
#include "libslic3r/CustomGCode.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
#include "DoubleSlider_Utils.hpp"
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
#include <wx/window.h>
|
||||
#include <wx/control.h>
|
||||
|
@ -119,7 +121,9 @@ class TickCodeInfo
|
|||
// int m_default_color_idx = 0;
|
||||
|
||||
std::vector<std::string>* m_colors {nullptr};
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
ColorGenerator color_generator;
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
std::string get_color_for_tick(TickCode tick, Type type, const int extruder);
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#ifndef slic3r_GUI_DoubleSlider_Utils_hpp_
|
||||
#define slic3r_GUI_DoubleSlider_Utils_hpp_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <random>
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "wx/colour.h"
|
||||
|
||||
class ColorGenerator
|
||||
|
@ -158,7 +163,6 @@ public:
|
|||
hsv_clr.h += 65; // 65 instead 60 to avoid circle values
|
||||
hsv_clr.s = rand_val();
|
||||
hsv_clr.v = rand_val();
|
||||
|
||||
rgb rgb_opp_color = hsv2rgb(hsv_clr);
|
||||
|
||||
wxString clr_str = wxString::Format(wxT("#%02X%02X%02X"), (unsigned char)(rgb_opp_color.r * 255), (unsigned char)(rgb_opp_color.g * 255), (unsigned char)(rgb_opp_color.b * 255));
|
||||
|
@ -188,4 +192,8 @@ public:
|
|||
|
||||
return opp_color;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
#endif // slic3r_GUI_DoubleSlider_Utils_hpp_
|
||||
|
|
|
@ -1390,8 +1390,12 @@ boost::any& ColourPicker::get_value()
|
|||
if (colour == wxTransparentColour)
|
||||
m_value = std::string("");
|
||||
else {
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue());
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_value = encode_color(ColorRGB(colour.Red(), colour.Green(), colour.Blue()));
|
||||
#else
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue());
|
||||
m_value = clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
return m_value;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ static EMoveType buffer_type(unsigned char id) {
|
|||
return static_cast<EMoveType>(static_cast<unsigned char>(EMoveType::Retract) + id);
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static std::array<float, 4> decode_color(const std::string& color) {
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
|
@ -72,6 +73,7 @@ static std::vector<std::array<float, 4>> decode_colors(const std::vector<std::st
|
|||
}
|
||||
return output;
|
||||
}
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
static float round_to_nearest_percent(float value)
|
||||
{
|
||||
|
@ -176,7 +178,11 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessorResult::MoveVertex& move
|
|||
move.volumetric_rate(), move.extruder_id, move.cp_color_id, { { endpoint, endpoint } } });
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA GCodeViewer::Extrusions::Range::get_color_at(float value) const
|
||||
#else
|
||||
GCodeViewer::Color GCodeViewer::Extrusions::Range::get_color_at(float value) const
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
// Input value scaled to the colors range
|
||||
const float step = step_size();
|
||||
|
@ -188,6 +194,10 @@ GCodeViewer::Color GCodeViewer::Extrusions::Range::get_color_at(float value) con
|
|||
const size_t color_low_idx = std::clamp<size_t>(static_cast<size_t>(global_t), 0, color_max_idx);
|
||||
const size_t color_high_idx = std::clamp<size_t>(color_low_idx + 1, 0, color_max_idx);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
// Interpolate between the low and high colors to find exactly which color the input value should get
|
||||
return lerp(Range_Colors[color_low_idx], Range_Colors[color_high_idx], global_t - static_cast<float>(color_low_idx));
|
||||
#else
|
||||
// Compute how far the value is between the low and high colors so that they can be interpolated
|
||||
const float local_t = std::clamp(global_t - static_cast<float>(color_low_idx), 0.0f, 1.0f);
|
||||
|
||||
|
@ -197,6 +207,7 @@ GCodeViewer::Color GCodeViewer::Extrusions::Range::get_color_at(float value) con
|
|||
ret[i] = lerp(Range_Colors[color_low_idx][i], Range_Colors[color_high_idx][i], local_t);
|
||||
}
|
||||
return ret;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
GCodeViewer::SequentialRangeCap::~SequentialRangeCap() {
|
||||
|
@ -346,11 +357,11 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, u
|
|||
return ret;
|
||||
};
|
||||
|
||||
static const ImVec4 LINE_NUMBER_COLOR = ImGuiWrapper::COL_ORANGE_LIGHT;
|
||||
static const ImVec4 LINE_NUMBER_COLOR = ImGuiWrapper::COL_ORANGE_LIGHT;
|
||||
static const ImVec4 SELECTION_RECT_COLOR = ImGuiWrapper::COL_ORANGE_DARK;
|
||||
static const ImVec4 COMMAND_COLOR = { 0.8f, 0.8f, 0.0f, 1.0f };
|
||||
static const ImVec4 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 1.0f };
|
||||
static const ImVec4 COMMAND_COLOR = { 0.8f, 0.8f, 0.0f, 1.0f };
|
||||
static const ImVec4 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 1.0f };
|
||||
|
||||
if (!m_visible || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
|
||||
return;
|
||||
|
@ -475,7 +486,11 @@ void GCodeViewer::SequentialView::render(float legend_height) const
|
|||
gcode_window.render(legend_height, bottom, static_cast<uint64_t>(gcode_ids[current.last]));
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Extrusion_Role_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.90f, 0.70f, 0.70f, 1.0f }, // erNone
|
||||
{ 1.00f, 0.90f, 0.30f, 1.0f }, // erPerimeter
|
||||
{ 1.00f, 0.49f, 0.22f, 1.0f }, // erExternalPerimeter
|
||||
|
@ -494,7 +509,11 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
|
|||
{ 0.00f, 0.00f, 0.00f, 1.0f } // erMixed
|
||||
}};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Options_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Options_Colors {{
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.803f, 0.135f, 0.839f, 1.0f }, // Retractions
|
||||
{ 0.287f, 0.679f, 0.810f, 1.0f }, // Unretractions
|
||||
{ 0.900f, 0.900f, 0.900f, 1.0f }, // Seams
|
||||
|
@ -504,7 +523,11 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Options_Colors {{
|
|||
{ 0.886f, 0.825f, 0.262f, 1.0f } // CustomGCodes
|
||||
}};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Travel_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Travel_Colors {{
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.219f, 0.282f, 0.609f, 1.0f }, // Move
|
||||
{ 0.112f, 0.422f, 0.103f, 1.0f }, // Extrude
|
||||
{ 0.505f, 0.064f, 0.028f, 1.0f } // Retract
|
||||
|
@ -512,7 +535,11 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Travel_Colors {{
|
|||
|
||||
#if 1
|
||||
// Normal ranges
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Range_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors {{
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.043f, 0.173f, 0.478f, 1.0f }, // bluish
|
||||
{ 0.075f, 0.349f, 0.522f, 1.0f },
|
||||
{ 0.110f, 0.533f, 0.569f, 1.0f },
|
||||
|
@ -527,7 +554,11 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors {{
|
|||
}};
|
||||
#else
|
||||
// Detailed ranges
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Range_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors{ {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.043f, 0.173f, 0.478f, 1.0f }, // bluish
|
||||
{ 0.5f * (0.043f + 0.075f), 0.5f * (0.173f + 0.349f), 0.5f * (0.478f + 0.522f), 1.0f },
|
||||
{ 0.075f, 0.349f, 0.522f, 1.0f },
|
||||
|
@ -552,8 +583,13 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors{ {
|
|||
} };
|
||||
#endif
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA GCodeViewer::Wipe_Color = ColorRGBA::YELLOW();
|
||||
const ColorRGBA GCodeViewer::Neutral_Color = ColorRGBA::DARK_GRAY();
|
||||
#else
|
||||
const GCodeViewer::Color GCodeViewer::Wipe_Color = { 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
const GCodeViewer::Color GCodeViewer::Neutral_Color = { 0.25f, 0.25f, 0.25f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GCodeViewer::GCodeViewer()
|
||||
{
|
||||
|
@ -724,14 +760,31 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
|
|||
|
||||
if (m_view_type == EViewType::Tool && !gcode_result.extruder_colors.empty())
|
||||
// update tool colors from config stored in the gcode
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
decode_colors(gcode_result.extruder_colors, m_tool_colors);
|
||||
#else
|
||||
m_tool_colors = decode_colors(gcode_result.extruder_colors);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
else
|
||||
// update tool colors
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
decode_colors(str_tool_colors, m_tool_colors);
|
||||
#else
|
||||
m_tool_colors = decode_colors(str_tool_colors);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA default_color;
|
||||
decode_color("#FF8000", default_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// ensure there are enough colors defined
|
||||
while (m_tool_colors.size() < std::max(size_t(1), gcode_result.extruders_count))
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_tool_colors.push_back(default_color);
|
||||
#else
|
||||
m_tool_colors.push_back(decode_color("#FF8000"));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// update ranges for coloring / legend
|
||||
m_extrusions.reset_ranges();
|
||||
|
@ -795,7 +848,11 @@ void GCodeViewer::reset()
|
|||
m_paths_bounding_box = BoundingBoxf3();
|
||||
m_max_bounding_box = BoundingBoxf3();
|
||||
m_max_print_height = 0.0f;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_tool_colors = std::vector<ColorRGBA>();
|
||||
#else
|
||||
m_tool_colors = std::vector<Color>();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_extruders_count = 0;
|
||||
m_extruder_ids = std::vector<unsigned char>();
|
||||
m_filament_diameters = std::vector<float>();
|
||||
|
@ -973,7 +1030,11 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
|
|||
return;
|
||||
|
||||
// collect color information to generate materials
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> colors;
|
||||
#else
|
||||
std::vector<Color> colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
for (const RenderPath& path : t_buffer.render_paths) {
|
||||
colors.push_back(path.color);
|
||||
}
|
||||
|
@ -995,12 +1056,21 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
|
|||
fprintf(fp, "# Generated by %s-%s based on Slic3r\n", SLIC3R_APP_NAME, SLIC3R_VERSION);
|
||||
|
||||
unsigned int colors_count = 1;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
for (const ColorRGBA& color : colors) {
|
||||
fprintf(fp, "\nnewmtl material_%d\n", colors_count++);
|
||||
fprintf(fp, "Ka 1 1 1\n");
|
||||
fprintf(fp, "Kd %g %g %g\n", color.r(), color.g(), color.b());
|
||||
fprintf(fp, "Ks 0 0 0\n");
|
||||
}
|
||||
#else
|
||||
for (const Color& color : colors) {
|
||||
fprintf(fp, "\nnewmtl material_%d\n", colors_count++);
|
||||
fprintf(fp, "Ka 1 1 1\n");
|
||||
fprintf(fp, "Kd %g %g %g\n", color[0], color[1], color[2]);
|
||||
fprintf(fp, "Ks 0 0 0\n");
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
fclose(fp);
|
||||
|
||||
|
@ -1059,7 +1129,11 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
|
|||
}
|
||||
|
||||
size_t i = 0;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
for (const ColorRGBA& color : colors) {
|
||||
#else
|
||||
for (const Color& color : colors) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// save material triangles to file
|
||||
fprintf(fp, "\nusemtl material_%zu\n", i + 1);
|
||||
fprintf(fp, "# triangles material %zu\n", i + 1);
|
||||
|
@ -2111,7 +2185,11 @@ void GCodeViewer::load_shells(const Print& print, bool initialized)
|
|||
|
||||
for (GLVolume* volume : m_shells.volumes.volumes) {
|
||||
volume->zoom_to_volumes = false;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
volume->color.a(0.25f);
|
||||
#else
|
||||
volume->color[3] = 0.25f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
volume->force_native_color = true;
|
||||
volume->set_render_color();
|
||||
}
|
||||
|
@ -2124,7 +2202,11 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
|||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
||||
auto extrusion_color = [this](const Path& path) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
switch (m_view_type)
|
||||
{
|
||||
case EViewType::FeatureType: { color = Extrusion_Role_Colors[static_cast<unsigned int>(path.role)]; break; }
|
||||
|
@ -2137,13 +2219,21 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
|||
case EViewType::Tool: { color = m_tool_colors[path.extruder_id]; break; }
|
||||
case EViewType::ColorPrint: {
|
||||
if (path.cp_color_id >= static_cast<unsigned char>(m_tool_colors.size()))
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
color = ColorRGBA::GRAY();
|
||||
#else
|
||||
color = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
else
|
||||
color = m_tool_colors[path.cp_color_id];
|
||||
|
||||
break;
|
||||
}
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
default: { color = ColorRGBA::WHITE(); break; }
|
||||
#else
|
||||
default: { color = { 1.0f, 1.0f, 1.0f, 1.0f }; break; }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
return color;
|
||||
|
@ -2342,7 +2432,11 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
|||
if (m_sequential_view.current.last < sub_path.first.s_id || sub_path.last.s_id < m_sequential_view.current.first)
|
||||
continue;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
switch (path.type)
|
||||
{
|
||||
case EMoveType::Tool_change:
|
||||
|
@ -2984,7 +3078,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto append_item = [icon_size, percent_bar_size, &imgui, imperial_units](EItemType type, const ColorRGBA& color, const std::string& label,
|
||||
#else
|
||||
auto append_item = [icon_size, percent_bar_size, &imgui, imperial_units](EItemType type, const Color& color, const std::string& label,
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
bool visible = true, const std::string& time = "", float percent = 0.0f, float max_percent = 0.0f, const std::array<float, 4>& offsets = { 0.0f, 0.0f, 0.0f, 0.0f },
|
||||
double used_filament_m = 0.0, double used_filament_g = 0.0,
|
||||
std::function<void()> callback = nullptr) {
|
||||
|
@ -2997,21 +3095,37 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
default:
|
||||
case EItemType::Rect: {
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGuiWrapper::to_ImU32(color));
|
||||
#else
|
||||
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
break;
|
||||
}
|
||||
case EItemType::Circle: {
|
||||
ImVec2 center(0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
draw_list->AddCircleFilled(center, 0.5f * icon_size, ImGuiWrapper::to_ImU32(color), 16);
|
||||
#else
|
||||
draw_list->AddCircleFilled(center, 0.5f * icon_size, ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 16);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
break;
|
||||
}
|
||||
case EItemType::Hexagon: {
|
||||
ImVec2 center(0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
draw_list->AddNgonFilled(center, 0.5f * icon_size, ImGuiWrapper::to_ImU32(color), 6);
|
||||
#else
|
||||
draw_list->AddNgonFilled(center, 0.5f * icon_size, ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 6);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
break;
|
||||
}
|
||||
case EItemType::Line: {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
draw_list->AddLine({ pos.x + 1, pos.y + icon_size - 1 }, { pos.x + icon_size - 1, pos.y + 1 }, ImGuiWrapper::to_ImU32(color), 3.0f);
|
||||
#else
|
||||
draw_list->AddLine({ pos.x + 1, pos.y + icon_size - 1 }, { pos.x + icon_size - 1, pos.y + 1 }, ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 3.0f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3134,7 +3248,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
};
|
||||
|
||||
auto color_print_ranges = [this](unsigned char extruder_id, const std::vector<CustomGCode::Item>& custom_gcode_per_print_z) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<std::pair<ColorRGBA, std::pair<double, double>>> ret;
|
||||
#else
|
||||
std::vector<std::pair<Color, std::pair<double, double>>> ret;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
ret.reserve(custom_gcode_per_print_z.size());
|
||||
|
||||
for (const auto& item : custom_gcode_per_print_z) {
|
||||
|
@ -3154,7 +3272,15 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
|
||||
// to avoid duplicate values, check adding values
|
||||
if (ret.empty() || !(ret.back().second.first == previous_z && ret.back().second.second == current_z))
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
{
|
||||
ColorRGBA color;
|
||||
decode_color(item.color, color);
|
||||
ret.push_back({ color, { previous_z, current_z } });
|
||||
}
|
||||
#else
|
||||
ret.push_back({ decode_color(item.color), { previous_z, current_z } });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -3349,7 +3475,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
if (need_scrollable)
|
||||
ImGui::BeginChild("color_prints", { -1.0f, child_height }, false);
|
||||
if (m_extruders_count == 1) { // single extruder use case
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(0, custom_gcode_per_print_z);
|
||||
#else
|
||||
const std::vector<std::pair<Color, std::pair<double, double>>> cp_values = color_print_ranges(0, custom_gcode_per_print_z);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0) { // There are no color changes, but there are some pause print or custom Gcode
|
||||
append_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default color"));
|
||||
|
@ -3372,11 +3502,15 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
else { // multi extruder use case
|
||||
// shows only extruders actually used
|
||||
for (unsigned char i : m_extruder_ids) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(i, custom_gcode_per_print_z);
|
||||
#else
|
||||
const std::vector<std::pair<Color, std::pair<double, double>>> cp_values = color_print_ranges(i, custom_gcode_per_print_z);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0) { // There are no color changes, but there are some pause print or custom Gcode
|
||||
if (items_cnt == 0)
|
||||
// There are no color changes, but there are some pause print or custom Gcode
|
||||
append_item(EItemType::Rect, m_tool_colors[i], _u8L("Extruder") + " " + std::to_string(i + 1) + " " + _u8L("default color"));
|
||||
}
|
||||
else {
|
||||
for (int j = items_cnt; j >= 0; --j) {
|
||||
// create label for color change item
|
||||
|
@ -3422,10 +3556,15 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
};
|
||||
EType type;
|
||||
int extruder_id;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color1;
|
||||
ColorRGBA color2;
|
||||
#else
|
||||
Color color1;
|
||||
Color color2;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
Times times;
|
||||
std::pair<double, double> used_filament {0.0f, 0.0f};
|
||||
std::pair<double, double> used_filament{ 0.0f, 0.0f };
|
||||
};
|
||||
using PartialTimes = std::vector<PartialTime>;
|
||||
|
||||
|
@ -3434,7 +3573,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
|
||||
std::vector<CustomGCode::Item> custom_gcode_per_print_z = wxGetApp().is_editor() ? wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes : m_custom_gcode_per_print_z;
|
||||
int extruders_count = wxGetApp().extruders_edited_cnt();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> last_color(extruders_count);
|
||||
#else
|
||||
std::vector<Color> last_color(extruders_count);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
for (int i = 0; i < extruders_count; ++i) {
|
||||
last_color[i] = m_tool_colors[i];
|
||||
}
|
||||
|
@ -3446,8 +3589,13 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
case CustomGCode::PausePrint: {
|
||||
auto it = std::find_if(custom_gcode_per_print_z.begin(), custom_gcode_per_print_z.end(), [time_rec](const CustomGCode::Item& item) { return item.type == time_rec.first; });
|
||||
if (it != custom_gcode_per_print_z.end()) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
items.push_back({ PartialTime::EType::Print, it->extruder, last_color[it->extruder - 1], ColorRGBA::BLACK(), time_rec.second });
|
||||
items.push_back({ PartialTime::EType::Pause, it->extruder, ColorRGBA::BLACK(), ColorRGBA::BLACK(), time_rec.second });
|
||||
#else
|
||||
items.push_back({ PartialTime::EType::Print, it->extruder, last_color[it->extruder - 1], Color(), time_rec.second });
|
||||
items.push_back({ PartialTime::EType::Pause, it->extruder, Color(), Color(), time_rec.second });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
custom_gcode_per_print_z.erase(it);
|
||||
}
|
||||
break;
|
||||
|
@ -3455,14 +3603,26 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
case CustomGCode::ColorChange: {
|
||||
auto it = std::find_if(custom_gcode_per_print_z.begin(), custom_gcode_per_print_z.end(), [time_rec](const CustomGCode::Item& item) { return item.type == time_rec.first; });
|
||||
if (it != custom_gcode_per_print_z.end()) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
items.push_back({ PartialTime::EType::Print, it->extruder, last_color[it->extruder - 1], ColorRGBA::BLACK(), time_rec.second, get_used_filament_from_volume(used_filaments[color_change_idx++], it->extruder - 1) });
|
||||
ColorRGBA color;
|
||||
decode_color(it->color, color);
|
||||
items.push_back({ PartialTime::EType::ColorChange, it->extruder, last_color[it->extruder - 1], color, time_rec.second });
|
||||
last_color[it->extruder - 1] = color;
|
||||
#else
|
||||
items.push_back({ PartialTime::EType::Print, it->extruder, last_color[it->extruder - 1], Color(), time_rec.second, get_used_filament_from_volume(used_filaments[color_change_idx++], it->extruder-1) });
|
||||
items.push_back({ PartialTime::EType::ColorChange, it->extruder, last_color[it->extruder - 1], decode_color(it->color), time_rec.second });
|
||||
last_color[it->extruder - 1] = decode_color(it->color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
last_extruder_id = it->extruder;
|
||||
custom_gcode_per_print_z.erase(it);
|
||||
}
|
||||
else
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
items.push_back({ PartialTime::EType::Print, last_extruder_id, last_color[last_extruder_id - 1], ColorRGBA::BLACK(), time_rec.second, get_used_filament_from_volume(used_filaments[color_change_idx++], last_extruder_id - 1) });
|
||||
#else
|
||||
items.push_back({ PartialTime::EType::Print, last_extruder_id, last_color[last_extruder_id - 1], Color(), time_rec.second, get_used_filament_from_volume(used_filaments[color_change_idx++], last_extruder_id -1) });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -3473,7 +3633,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
return items;
|
||||
};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto append_color_change = [&imgui](const ColorRGBA& color1, const ColorRGBA& color2, const std::array<float, 4>& offsets, const Times& times) {
|
||||
#else
|
||||
auto append_color_change = [&imgui](const Color& color1, const Color& color2, const std::array<float, 4>& offsets, const Times& times) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
imgui.text(_u8L("Color change"));
|
||||
ImGui::SameLine();
|
||||
|
||||
|
@ -3483,16 +3647,28 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
pos.x -= 0.5f * ImGui::GetStyle().ItemSpacing.x;
|
||||
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGuiWrapper::to_ImU32(color1));
|
||||
#else
|
||||
ImGui::GetColorU32({ color1[0], color1[1], color1[2], 1.0f }));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
pos.x += icon_size;
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGuiWrapper::to_ImU32(color2));
|
||||
#else
|
||||
ImGui::GetColorU32({ color2[0], color2[1], color2[2], 1.0f }));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
ImGui::SameLine(offsets[0]);
|
||||
imgui.text(short_time(get_time_dhms(times.second - times.first)));
|
||||
};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto append_print = [&imgui, imperial_units](const ColorRGBA& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
|
||||
#else
|
||||
auto append_print = [&imgui, imperial_units](const Color& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
imgui.text(_u8L("Print"));
|
||||
ImGui::SameLine();
|
||||
|
||||
|
@ -3502,7 +3678,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
pos.x -= 0.5f * ImGui::GetStyle().ItemSpacing.x;
|
||||
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGuiWrapper::to_ImU32(color));
|
||||
#else
|
||||
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
ImGui::SameLine(offsets[0]);
|
||||
imgui.text(short_time(get_time_dhms(times.second)));
|
||||
|
@ -3924,7 +4104,11 @@ void GCodeViewer::log_memory_used(const std::string& label, int64_t additional)
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA GCodeViewer::option_color(EMoveType move_type) const
|
||||
#else
|
||||
GCodeViewer::Color GCodeViewer::option_color(EMoveType move_type) const
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
switch (move_type)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,9 @@ namespace GUI {
|
|||
class GCodeViewer
|
||||
{
|
||||
using IBufferType = unsigned short;
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
using Color = std::array<float, 4>;
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
using VertexBuffer = std::vector<float>;
|
||||
using MultiVertexBuffer = std::vector<VertexBuffer>;
|
||||
using IndexBuffer = std::vector<IBufferType>;
|
||||
|
@ -31,12 +33,21 @@ class GCodeViewer
|
|||
using InstanceIdBuffer = std::vector<size_t>;
|
||||
using InstancesOffsets = std::vector<Vec3f>;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const std::vector<ColorRGBA> Extrusion_Role_Colors;
|
||||
static const std::vector<ColorRGBA> Options_Colors;
|
||||
static const std::vector<ColorRGBA> Travel_Colors;
|
||||
static const std::vector<ColorRGBA> Range_Colors;
|
||||
static const ColorRGBA Wipe_Color;
|
||||
static const ColorRGBA Neutral_Color;
|
||||
#else
|
||||
static const std::vector<Color> Extrusion_Role_Colors;
|
||||
static const std::vector<Color> Options_Colors;
|
||||
static const std::vector<Color> Travel_Colors;
|
||||
static const std::vector<Color> Range_Colors;
|
||||
static const Color Wipe_Color;
|
||||
static const Color Neutral_Color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
enum class EOptionsColors : unsigned char
|
||||
{
|
||||
|
@ -121,7 +132,11 @@ class GCodeViewer
|
|||
// vbo id
|
||||
unsigned int vbo{ 0 };
|
||||
// Color to apply to the instances
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
std::vector<Range> ranges;
|
||||
|
@ -243,7 +258,11 @@ class GCodeViewer
|
|||
// Index of the parent tbuffer
|
||||
unsigned char tbuffer_id;
|
||||
// Render path property
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// Index of the buffer in TBuffer::indices
|
||||
unsigned int ibuffer_id;
|
||||
// Render path content
|
||||
|
@ -263,12 +282,19 @@ class GCodeViewer
|
|||
bool operator() (const RenderPath &l, const RenderPath &r) const {
|
||||
if (l.tbuffer_id < r.tbuffer_id)
|
||||
return true;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
if (l.color < r.color)
|
||||
return true;
|
||||
else if (l.color > r.color)
|
||||
return false;
|
||||
#else
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (l.color[i] < r.color[i])
|
||||
return true;
|
||||
else if (l.color[i] > r.color[i])
|
||||
return false;
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
return l.ibuffer_id < r.ibuffer_id;
|
||||
}
|
||||
};
|
||||
|
@ -299,7 +325,11 @@ class GCodeViewer
|
|||
struct Model
|
||||
{
|
||||
GLModel model;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
InstanceVBuffer instances;
|
||||
GLModel::InitializationData data;
|
||||
|
||||
|
@ -399,7 +429,11 @@ class GCodeViewer
|
|||
void reset() { min = FLT_MAX; max = -FLT_MAX; count = 0; }
|
||||
|
||||
float step_size() const { return (max - min) / (static_cast<float>(Range_Colors.size()) - 1.0f); }
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA get_color_at(float value) const;
|
||||
#else
|
||||
Color get_color_at(float value) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
struct Ranges
|
||||
|
@ -493,7 +527,11 @@ class GCodeViewer
|
|||
TBuffer* buffer{ nullptr };
|
||||
unsigned int ibo{ 0 };
|
||||
unsigned int vbo{ 0 };
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
~SequentialRangeCap();
|
||||
bool is_renderable() const { return buffer != nullptr; }
|
||||
|
@ -697,7 +735,11 @@ private:
|
|||
// bounding box of toolpaths + marker tools
|
||||
BoundingBoxf3 m_max_bounding_box;
|
||||
float m_max_print_height{ 0.0f };
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> m_tool_colors;
|
||||
#else
|
||||
std::vector<Color> m_tool_colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
Layers m_layers;
|
||||
std::array<unsigned int, 2> m_layers_z_range;
|
||||
std::vector<ExtrusionRole> m_roles;
|
||||
|
@ -792,7 +834,11 @@ private:
|
|||
}
|
||||
bool is_visible(const Path& path) const { return is_visible(path.role); }
|
||||
void log_memory_used(const std::string& label, int64_t additional = 0) const;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA option_color(EMoveType move_type) const;
|
||||
#else
|
||||
Color option_color(EMoveType move_type) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -72,11 +72,18 @@
|
|||
|
||||
static constexpr const float TRACKBALLSIZE = 0.8f;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const Slic3r::ColorRGB DEFAULT_BG_DARK_COLOR = { 0.478f, 0.478f, 0.478f };
|
||||
static const Slic3r::ColorRGB DEFAULT_BG_LIGHT_COLOR = { 0.753f, 0.753f, 0.753f };
|
||||
static const Slic3r::ColorRGB ERROR_BG_DARK_COLOR = { 0.478f, 0.192f, 0.039f };
|
||||
static const Slic3r::ColorRGB ERROR_BG_LIGHT_COLOR = { 0.753f, 0.192f, 0.039f };
|
||||
#else
|
||||
static constexpr const float DEFAULT_BG_DARK_COLOR[3] = { 0.478f, 0.478f, 0.478f };
|
||||
static constexpr const float DEFAULT_BG_LIGHT_COLOR[3] = { 0.753f, 0.753f, 0.753f };
|
||||
static constexpr const float ERROR_BG_DARK_COLOR[3] = { 0.478f, 0.192f, 0.039f };
|
||||
static constexpr const float ERROR_BG_LIGHT_COLOR[3] = { 0.753f, 0.192f, 0.039f };
|
||||
//static constexpr const float AXES_COLOR[3][3] = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// Number of floats
|
||||
static constexpr const size_t MAX_VERTEX_BUFFER_SIZE = 131072 * 6; // 3.15MB
|
||||
|
@ -859,8 +866,13 @@ void GLCanvas3D::SequentialPrintClearance::set_polygons(const Polygons& polygons
|
|||
|
||||
void GLCanvas3D::SequentialPrintClearance::render()
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA FILL_COLOR = { 1.0f, 0.0f, 0.0f, 0.5f };
|
||||
const ColorRGBA NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f };
|
||||
#else
|
||||
std::array<float, 4> FILL_COLOR = { 1.0f, 0.0f, 0.0f, 0.5f };
|
||||
std::array<float, 4> NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader == nullptr)
|
||||
|
@ -4119,8 +4131,10 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
return ret;
|
||||
};
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static const std::array<float, 4> orange = { 0.923f, 0.504f, 0.264f, 1.0f };
|
||||
static const std::array<float, 4> gray = { 0.64f, 0.64f, 0.64f, 1.0f };
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
GLVolumePtrs visible_volumes;
|
||||
|
||||
|
@ -4176,7 +4190,11 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
shader->set_uniform("emission_factor", 0.0f);
|
||||
|
||||
for (GLVolume* vol : visible_volumes) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : ColorRGBA::ORANGE()) : ColorRGBA::GRAY());
|
||||
#else
|
||||
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : orange) : gray);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// the volume may have been deactivated by an active gizmo
|
||||
bool is_active = vol->is_active;
|
||||
vol->is_active = true;
|
||||
|
@ -4907,19 +4925,34 @@ void GLCanvas3D::_picking_pass()
|
|||
int volume_id = -1;
|
||||
int gizmo_id = -1;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::array<GLubyte, 4> color = { 0, 0, 0, 0 };
|
||||
#else
|
||||
GLubyte color[4] = { 0, 0, 0, 0 };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const Size& cnv_size = get_canvas_size();
|
||||
bool inside = 0 <= m_mouse.position(0) && m_mouse.position(0) < cnv_size.get_width() && 0 <= m_mouse.position(1) && m_mouse.position(1) < cnv_size.get_height();
|
||||
if (inside) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position.y() - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color.data()));
|
||||
#else
|
||||
glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position(1) - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (picking_checksum_alpha_channel(color[0], color[1], color[2]) == color[3]) {
|
||||
// Only non-interpolated colors are valid, those have their lowest three bits zeroed.
|
||||
// we reserve color = (0,0,0) for occluders (as the printbed)
|
||||
// volumes' id are shifted by 1
|
||||
// see: _render_volumes_for_picking()
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
unsigned int id = picking_encode(color[0], color[1], color[2]);
|
||||
volume_id = id - 1;
|
||||
// gizmos' id are instead properly encoded by the color
|
||||
gizmo_id = id;
|
||||
#else
|
||||
volume_id = color[0] + (color[1] << 8) + (color[2] << 16) - 1;
|
||||
// gizmos' id are instead properly encoded by the color
|
||||
gizmo_id = color[0] + (color[1] << 8) + (color[2] << 16);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
}
|
||||
if (0 <= volume_id && volume_id < (int)m_volumes.volumes.size()) {
|
||||
|
@ -5035,18 +5068,26 @@ void GLCanvas3D::_render_background() const
|
|||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor3fv(use_error_color ? ERROR_BG_DARK_COLOR.data(): DEFAULT_BG_DARK_COLOR.data());
|
||||
#else
|
||||
if (use_error_color)
|
||||
::glColor3fv(ERROR_BG_DARK_COLOR);
|
||||
else
|
||||
::glColor3fv(DEFAULT_BG_DARK_COLOR);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
::glVertex2f(-1.0f, -1.0f);
|
||||
::glVertex2f(1.0f, -1.0f);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor3fv(use_error_color ? ERROR_BG_LIGHT_COLOR.data() : DEFAULT_BG_LIGHT_COLOR.data());
|
||||
#else
|
||||
if (use_error_color)
|
||||
::glColor3fv(ERROR_BG_LIGHT_COLOR);
|
||||
else
|
||||
::glColor3fv(DEFAULT_BG_LIGHT_COLOR);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
::glVertex2f(1.0f, 1.0f);
|
||||
::glVertex2f(-1.0f, 1.0f);
|
||||
|
@ -5346,13 +5387,18 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
// Object picking mode. Render the object with a color encoding the object index.
|
||||
// we reserve color = (0,0,0) for occluders (as the printbed)
|
||||
// so we shift volumes' id by 1 to get the proper color
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const unsigned int id = 1 + volume.second.first;
|
||||
glsafe(::glColor4fv(picking_decode(id).data()));
|
||||
#else
|
||||
unsigned int id = 1 + volume.second.first;
|
||||
unsigned int r = (id & (0x000000FF << 0)) << 0;
|
||||
unsigned int g = (id & (0x000000FF << 8)) >> 8;
|
||||
unsigned int b = (id & (0x000000FF << 16)) >> 16;
|
||||
unsigned int a = picking_checksum_alpha_channel(r, g, b);
|
||||
glsafe(::glColor4f((GLfloat)r * INV_255, (GLfloat)g * INV_255, (GLfloat)b * INV_255, (GLfloat)a * INV_255));
|
||||
volume.first->render();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
volume.first->render();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5771,7 +5817,11 @@ void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
|
|||
if (!print->has_skirt() && !print->has_brim())
|
||||
return;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA color = ColorRGBA::GREENISH();
|
||||
#else
|
||||
const std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.0f }; // greenish
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// number of skirt layers
|
||||
size_t total_layer_count = 0;
|
||||
|
@ -5818,7 +5868,12 @@ void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
|
|||
|
||||
void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const BuildVolume& build_volume, const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> tool_colors;
|
||||
decode_colors(str_tool_colors, tool_colors);
|
||||
#else
|
||||
std::vector<std::array<float, 4>> tool_colors = _parse_colors(str_tool_colors);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
struct Ctxt
|
||||
{
|
||||
|
@ -5827,20 +5882,35 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
bool has_perimeters;
|
||||
bool has_infill;
|
||||
bool has_support;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA>* tool_colors;
|
||||
#else
|
||||
const std::vector<std::array<float, 4>>* tool_colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
bool is_single_material_print;
|
||||
int extruders_cnt;
|
||||
const std::vector<CustomGCode::Item>* color_print_values;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ColorRGBA color_perimeters() { return ColorRGBA::YELLOW(); }
|
||||
static ColorRGBA color_infill() { return ColorRGBA::REDISH(); }
|
||||
static ColorRGBA color_support() { return ColorRGBA::GREENISH(); }
|
||||
static ColorRGBA color_pause_or_custom_code() { return ColorRGBA::GRAY(); }
|
||||
#else
|
||||
static const std::array<float, 4>& color_perimeters() { static std::array<float, 4> color = { 1.0f, 1.0f, 0.0f, 1.f }; return color; } // yellow
|
||||
static const std::array<float, 4>& color_infill() { static std::array<float, 4> color = { 1.0f, 0.5f, 0.5f, 1.f }; return color; } // redish
|
||||
static const std::array<float, 4>& color_support() { static std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.f }; return color; } // greenish
|
||||
static const std::array<float, 4>& color_pause_or_custom_code() { static std::array<float, 4> color = { 0.5f, 0.5f, 0.5f, 1.f }; return color; } // gray
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// For cloring by a tool, return a parsed color.
|
||||
bool color_by_tool() const { return tool_colors != nullptr; }
|
||||
size_t number_tools() const { return color_by_tool() ? tool_colors->size() : 0; }
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
#else
|
||||
const std::array<float, 4>& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// For coloring by a color_print(M600), return a parsed color.
|
||||
bool color_by_color_print() const { return color_print_values!=nullptr; }
|
||||
|
@ -5980,7 +6050,11 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
//FIXME Improve the heuristics for a grain size.
|
||||
size_t grain_size = std::max(ctxt.layers.size() / 16, size_t(1));
|
||||
tbb::spin_mutex new_volume_mutex;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) {
|
||||
#else
|
||||
auto new_volume = [this, &new_volume_mutex](const std::array<float, 4>& color) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// Allocate the volume before locking.
|
||||
GLVolume *volume = new GLVolume(color);
|
||||
volume->is_extrusion_path = true;
|
||||
|
@ -6121,21 +6195,38 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
|
|||
if (!print->is_step_done(psWipeTower))
|
||||
return;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> tool_colors;
|
||||
decode_colors(str_tool_colors, tool_colors);
|
||||
#else
|
||||
std::vector<std::array<float, 4>> tool_colors = _parse_colors(str_tool_colors);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
struct Ctxt
|
||||
{
|
||||
const Print *print;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA>* tool_colors;
|
||||
#else
|
||||
const std::vector<std::array<float, 4>>* tool_colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
Vec2f wipe_tower_pos;
|
||||
float wipe_tower_angle;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ColorRGBA color_support() { return ColorRGBA::GREENISH(); }
|
||||
#else
|
||||
static const std::array<float, 4>& color_support() { static std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.f }; return color; } // greenish
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// For cloring by a tool, return a parsed color.
|
||||
bool color_by_tool() const { return tool_colors != nullptr; }
|
||||
size_t number_tools() const { return this->color_by_tool() ? tool_colors->size() : 0; }
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
#else
|
||||
const std::array<float, 4>& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
int volume_idx(int tool, int feature) const {
|
||||
return this->color_by_tool() ? std::min<int>(this->number_tools() - 1, std::max<int>(tool, 0)) : feature;
|
||||
}
|
||||
|
@ -6167,7 +6258,11 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
|
|||
size_t n_items = print->wipe_tower_data().tool_changes.size() + (ctxt.priming.empty() ? 0 : 1);
|
||||
size_t grain_size = std::max(n_items / 128, size_t(1));
|
||||
tbb::spin_mutex new_volume_mutex;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) {
|
||||
#else
|
||||
auto new_volume = [this, &new_volume_mutex](const std::array<float, 4>& color) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
auto *volume = new GLVolume(color);
|
||||
volume->is_extrusion_path = true;
|
||||
tbb::spin_mutex::scoped_lock lock;
|
||||
|
@ -6286,7 +6381,11 @@ void GLCanvas3D::_load_sla_shells()
|
|||
return;
|
||||
|
||||
auto add_volume = [this](const SLAPrintObject &object, int volume_id, const SLAPrintObject::Instance& instance,
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const TriangleMesh& mesh, const ColorRGBA& color, bool outside_printer_detection_enabled) {
|
||||
#else
|
||||
const TriangleMesh& mesh, const std::array<float, 4>& color, bool outside_printer_detection_enabled) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_volumes.volumes.emplace_back(new GLVolume(color));
|
||||
GLVolume& v = *m_volumes.volumes.back();
|
||||
#if ENABLE_SMOOTH_NORMALS
|
||||
|
@ -6348,6 +6447,7 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
|
|||
_set_warning_notification(warning, show);
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
std::vector<std::array<float, 4>> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors)
|
||||
{
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
@ -6369,6 +6469,7 @@ std::vector<std::array<float, 4>> GLCanvas3D::_parse_colors(const std::vector<st
|
|||
}
|
||||
return output;
|
||||
}
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
|
||||
{
|
||||
|
|
|
@ -982,7 +982,9 @@ private:
|
|||
|
||||
float get_overlay_window_width() { return LayersEditing::get_overlay_window_width(); }
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static std::vector<std::array<float, 4>> _parse_colors(const std::vector<std::string>& colors);
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -165,6 +165,15 @@ bool GLModel::init_from_file(const std::string& filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void GLModel::set_color(int entity_id, const ColorRGBA& color)
|
||||
{
|
||||
for (size_t i = 0; i < m_render_data.size(); ++i) {
|
||||
if (entity_id == -1 || static_cast<int>(i) == entity_id)
|
||||
m_render_data[i].color = color;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void GLModel::set_color(int entity_id, const std::array<float, 4>& color)
|
||||
{
|
||||
for (size_t i = 0; i < m_render_data.size(); ++i) {
|
||||
|
@ -172,6 +181,7 @@ void GLModel::set_color(int entity_id, const std::array<float, 4>& color)
|
|||
m_render_data[i].color = color;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void GLModel::reset()
|
||||
{
|
||||
|
@ -216,7 +226,11 @@ void GLModel::render() const
|
|||
if (shader != nullptr)
|
||||
shader->set_uniform("uniform_color", data.color);
|
||||
else
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(data.color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(data.color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.ibo_id));
|
||||
glsafe(::glDrawElements(mode, static_cast<GLsizei>(data.indices_count), GL_UNSIGNED_INT, (const void*)0));
|
||||
|
@ -276,7 +290,11 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
|
|||
if (shader != nullptr)
|
||||
shader->set_uniform("uniform_color", data.color);
|
||||
else
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(data.color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(data.color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, data.vbo_id));
|
||||
if (position_id != -1) {
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "libslic3r/Point.hpp"
|
||||
#include "libslic3r/BoundingBox.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -33,7 +36,11 @@ namespace GUI {
|
|||
unsigned int vbo_id{ 0 };
|
||||
unsigned int ibo_id{ 0 };
|
||||
size_t indices_count{ 0 };
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
std::array<float, 4> color{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
struct InitializationData
|
||||
|
@ -44,7 +51,11 @@ namespace GUI {
|
|||
std::vector<Vec3f> positions;
|
||||
std::vector<Vec3f> normals;
|
||||
std::vector<unsigned int> indices;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
std::array<float, 4> color{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
std::vector<Entity> entities;
|
||||
|
@ -74,7 +85,11 @@ namespace GUI {
|
|||
bool init_from_file(const std::string& filename);
|
||||
|
||||
// if entity_id == -1 set the color of all entities
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_color(int entity_id, const ColorRGBA& color);
|
||||
#else
|
||||
void set_color(int entity_id, const std::array<float, 4>& color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void reset();
|
||||
void render() const;
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#include "3DScene.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/format.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <GL/glew.h>
|
||||
|
@ -306,6 +309,18 @@ void GLShaderProgram::set_uniform(int id, const Vec3d& value) const
|
|||
set_uniform(id, static_cast<Vec3f>(value.cast<float>()));
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void GLShaderProgram::set_uniform(int id, const ColorRGB& value) const
|
||||
{
|
||||
set_uniform(id, value.data(), 3);
|
||||
}
|
||||
|
||||
void GLShaderProgram::set_uniform(int id, const ColorRGBA& value) const
|
||||
{
|
||||
set_uniform(id, value.data(), 4);
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
int GLShaderProgram::get_attrib_location(const char* name) const
|
||||
{
|
||||
assert(m_id > 0);
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
class ColorRGB;
|
||||
class ColorRGBA;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
class GLShaderProgram
|
||||
{
|
||||
public:
|
||||
|
@ -60,6 +65,10 @@ public:
|
|||
void set_uniform(const char* name, const Matrix3f& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
void set_uniform(const char* name, const Vec3f& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
void set_uniform(const char* name, const Vec3d& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_uniform(const char* name, const ColorRGB& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
void set_uniform(const char* name, const ColorRGBA& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void set_uniform(int id, int value) const;
|
||||
void set_uniform(int id, bool value) const;
|
||||
|
@ -77,6 +86,10 @@ public:
|
|||
void set_uniform(int id, const Matrix3f& value) const;
|
||||
void set_uniform(int id, const Vec3f& value) const;
|
||||
void set_uniform(int id, const Vec3d& value) const;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_uniform(int id, const ColorRGB& value) const;
|
||||
void set_uniform(int id, const ColorRGBA& value) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// returns -1 if not found
|
||||
int get_attrib_location(const char* name) const;
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/I18N.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
|
@ -1520,8 +1523,12 @@ void GUI_App::set_label_clr_modified(const wxColour& clr)
|
|||
if (m_color_label_modified == clr)
|
||||
return;
|
||||
m_color_label_modified = clr;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::string str = encode_color(ColorRGB(clr.Red(), clr.Green(), clr.Blue()));
|
||||
#else
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue());
|
||||
std::string str = clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
app_config->set("label_clr_modified", str);
|
||||
app_config->save();
|
||||
}
|
||||
|
@ -1531,8 +1538,12 @@ void GUI_App::set_label_clr_sys(const wxColour& clr)
|
|||
if (m_color_label_sys == clr)
|
||||
return;
|
||||
m_color_label_sys = clr;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::string str = encode_color(ColorRGB(clr.Red(), clr.Green(), clr.Blue()));
|
||||
#else
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue());
|
||||
std::string str = clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
app_config->set("label_clr_sys", str);
|
||||
app_config->save();
|
||||
}
|
||||
|
|
|
@ -406,6 +406,7 @@ public:
|
|||
|
||||
std::ostream& operator<<(std::ostream &os, const WindowMetrics& metrics);
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
inline int hex_digit_to_int(const char c)
|
||||
{
|
||||
return
|
||||
|
@ -413,6 +414,7 @@ inline int hex_digit_to_int(const char c)
|
|||
(c >= 'A' && c <= 'F') ? int(c - 'A') + 10 :
|
||||
(c >= 'a' && c <= 'f') ? int(c - 'a') + 10 : -1;
|
||||
}
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
class TaskTimer
|
||||
{
|
||||
|
|
|
@ -25,6 +25,11 @@ GLGizmoBase::Grabber::Grabber()
|
|||
|
||||
void GLGizmoBase::Grabber::render(bool hover, float size) const
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA render_color = color;
|
||||
if (hover)
|
||||
render_color = complementary(render_color);
|
||||
#else
|
||||
std::array<float, 4> render_color;
|
||||
if (hover) {
|
||||
render_color[0] = (1.0f - color[0]);
|
||||
|
@ -34,6 +39,7 @@ void GLGizmoBase::Grabber::render(bool hover, float size) const
|
|||
}
|
||||
else
|
||||
render_color = color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
render(size, render_color, false);
|
||||
}
|
||||
|
@ -48,7 +54,11 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
|
|||
return get_half_size(size) * DraggingScaleFactor;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking) const
|
||||
#else
|
||||
void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render_color, bool picking) const
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
if (!cube.is_initialized()) {
|
||||
// This cannot be done in constructor, OpenGL is not yet
|
||||
|
@ -99,10 +109,12 @@ void GLGizmoBase::set_hover_id(int id)
|
|||
}
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
void GLGizmoBase::set_highlight_color(const std::array<float, 4>& color)
|
||||
{
|
||||
m_highlight_color = color;
|
||||
}
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
void GLGizmoBase::enable_grabber(unsigned int id)
|
||||
{
|
||||
|
@ -157,15 +169,21 @@ bool GLGizmoBase::update_items_state()
|
|||
return res;
|
||||
};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const
|
||||
{
|
||||
#else
|
||||
std::array<float, 4> GLGizmoBase::picking_color_component(unsigned int id) const
|
||||
{
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
id = BASE_ID - id;
|
||||
|
||||
if (m_group_id > -1)
|
||||
id -= m_group_id;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return picking_decode(id);
|
||||
#else
|
||||
// color components are encoded to match the calculation of volume_id made into GLCanvas3D::_picking_pass()
|
||||
return std::array<float, 4> {
|
||||
float((id >> 0) & 0xff) * INV_255, // red
|
||||
|
@ -173,6 +191,7 @@ std::array<float, 4> GLGizmoBase::picking_color_component(unsigned int id) const
|
|||
float((id >> 16) & 0xff) * INV_255, // blue
|
||||
float(picking_checksum_alpha_channel(id & 0xff, (id >> 8) & 0xff, (id >> 16) & 0xff))* INV_255 // checksum for validating against unwanted alpha blending and multi sampling
|
||||
};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
|
||||
|
@ -200,8 +219,12 @@ void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
|
|||
|
||||
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i) {
|
||||
if (m_grabbers[i].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_grabbers[i].color = picking_color_component(i);
|
||||
#else
|
||||
std::array<float, 4> color = picking_color_component(i);
|
||||
m_grabbers[i].color = color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_grabbers[i].render_for_picking(mean_size);
|
||||
}
|
||||
}
|
||||
|
@ -238,8 +261,7 @@ std::string GLGizmoBase::get_name(bool include_shortcut) const
|
|||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
||||
// were not interpolated by alpha blending or multi sampling.
|
||||
unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue)
|
||||
|
@ -254,7 +276,7 @@ unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char gr
|
|||
b ^= 0x55;
|
||||
return b;
|
||||
}
|
||||
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define slic3r_GLGizmoBase_hpp_
|
||||
|
||||
#include "libslic3r/Point.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/GLModel.hpp"
|
||||
|
@ -18,6 +21,13 @@ class ModelObject;
|
|||
|
||||
namespace GUI {
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const ColorRGBA DEFAULT_BASE_COLOR = { 0.625f, 0.625f, 0.625f, 1.0f };
|
||||
static const ColorRGBA DEFAULT_DRAG_COLOR = ColorRGBA::WHITE();
|
||||
static const ColorRGBA DEFAULT_HIGHLIGHT_COLOR = ColorRGBA::ORANGE();
|
||||
static const std::array<ColorRGBA, 3> AXES_COLOR = {{ ColorRGBA::X(), ColorRGBA::Y(), ColorRGBA::Z() }};
|
||||
static const ColorRGBA CONSTRAINED_COLOR = ColorRGBA::GRAY();
|
||||
#else
|
||||
static const std::array<float, 4> DEFAULT_BASE_COLOR = { 0.625f, 0.625f, 0.625f, 1.0f };
|
||||
static const std::array<float, 4> DEFAULT_DRAG_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static const std::array<float, 4> DEFAULT_HIGHLIGHT_COLOR = { 1.0f, 0.38f, 0.0f, 1.0f };
|
||||
|
@ -27,6 +37,7 @@ static const std::array<std::array<float, 4>, 3> AXES_COLOR = {{
|
|||
{ 0.0f, 0.0f, 0.75f, 1.0f }
|
||||
}};
|
||||
static const std::array<float, 4> CONSTRAINED_COLOR = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
class ImGuiWrapper;
|
||||
class GLCanvas3D;
|
||||
|
@ -50,7 +61,11 @@ protected:
|
|||
|
||||
Vec3d center;
|
||||
Vec3d angles;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
std::array<float, 4> color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
bool enabled;
|
||||
bool dragging;
|
||||
|
||||
|
@ -63,7 +78,11 @@ protected:
|
|||
float get_dragging_half_size(float size) const;
|
||||
|
||||
private:
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void render(float size, const ColorRGBA& render_color, bool picking) const;
|
||||
#else
|
||||
void render(float size, const std::array<float, 4>& render_color, bool picking) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLModel cube;
|
||||
};
|
||||
|
@ -96,9 +115,15 @@ protected:
|
|||
unsigned int m_sprite_id;
|
||||
int m_hover_id;
|
||||
bool m_dragging;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA m_base_color;
|
||||
ColorRGBA m_drag_color;
|
||||
ColorRGBA m_highlight_color;
|
||||
#else
|
||||
std::array<float, 4> m_base_color;
|
||||
std::array<float, 4> m_drag_color;
|
||||
std::array<float, 4> m_highlight_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
mutable std::vector<Grabber> m_grabbers;
|
||||
ImGuiWrapper* m_imgui;
|
||||
bool m_first_input_window_render;
|
||||
|
@ -142,7 +167,11 @@ public:
|
|||
int get_hover_id() const { return m_hover_id; }
|
||||
void set_hover_id(int id);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_highlight_color(const ColorRGBA& color) { m_highlight_color = color; }
|
||||
#else
|
||||
void set_highlight_color(const std::array<float, 4>& color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void enable_grabber(unsigned int id);
|
||||
void disable_grabber(unsigned int id);
|
||||
|
@ -184,7 +213,11 @@ protected:
|
|||
|
||||
// Returns the picking color for the given id, based on the BASE_ID constant
|
||||
// No check is made for clashing with other picking color (i.e. GLVolumes)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA picking_color_component(unsigned int id) const;
|
||||
#else
|
||||
std::array<float, 4> picking_color_component(unsigned int id) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
void render_grabbers(const BoundingBoxf3& box) const;
|
||||
void render_grabbers(float size) const;
|
||||
void render_grabbers_for_picking(const BoundingBoxf3& box) const;
|
||||
|
@ -199,9 +232,11 @@ private:
|
|||
bool m_dirty;
|
||||
};
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
||||
// were not interpolated by alpha blending or multi sampling.
|
||||
extern unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue);
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -23,7 +23,12 @@ namespace GUI {
|
|||
|
||||
const double GLGizmoCut::Offset = 10.0;
|
||||
const double GLGizmoCut::Margin = 20.0;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const ColorRGBA GRABBER_COLOR = ColorRGBA::ORANGE();
|
||||
static const ColorRGBA PLANE_COLOR = { 0.8f, 0.8f, 0.8f, 0.5f };
|
||||
#else
|
||||
const std::array<float, 4> GLGizmoCut::GrabberColor = { 1.0, 0.5, 0.0, 1.0 };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
|
@ -103,7 +108,11 @@ void GLGizmoCut::on_render()
|
|||
|
||||
// Draw the cutting plane
|
||||
::glBegin(GL_QUADS);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor4fv(PLANE_COLOR.data());
|
||||
#else
|
||||
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glVertex3f(min_x, min_y, plane_center.z());
|
||||
::glVertex3f(max_x, min_y, plane_center.z());
|
||||
::glVertex3f(max_x, max_y, plane_center.z());
|
||||
|
@ -134,7 +143,11 @@ void GLGizmoCut::on_render()
|
|||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.1f);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_grabbers[0].color = GRABBER_COLOR;
|
||||
#else
|
||||
m_grabbers[0].color = GrabberColor;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_grabbers[0].render(m_hover_id == 0, (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0));
|
||||
|
||||
shader->stop_using();
|
||||
|
|
|
@ -13,7 +13,9 @@ class GLGizmoCut : public GLGizmoBase
|
|||
{
|
||||
static const double Offset;
|
||||
static const double Margin;
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static const std::array<float, 4> GrabberColor;
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
double m_cut_z{ 0.0 };
|
||||
double m_max_z{ 0.0 };
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const Slic3r::ColorRGBA DEFAULT_PLANE_COLOR = { 0.9f, 0.9f, 0.9f, 0.5f };
|
||||
static const Slic3r::ColorRGBA DEFAULT_HOVER_PLANE_COLOR = { 0.9f, 0.9f, 0.9f, 0.75f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
|
@ -74,10 +78,14 @@ void GLGizmoFlatten::on_render()
|
|||
if (this->is_plane_update_necessary())
|
||||
update_planes();
|
||||
for (int i = 0; i < (int)m_planes.size(); ++i) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(i == m_hover_id ? DEFAULT_HOVER_PLANE_COLOR.data() : DEFAULT_PLANE_COLOR.data()));
|
||||
#else
|
||||
if (i == m_hover_id)
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.75f));
|
||||
else
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.5f));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (m_planes[i].vbo.has_VBOs())
|
||||
m_planes[i].vbo.render();
|
||||
|
@ -104,7 +112,11 @@ void GLGizmoFlatten::on_render_for_picking()
|
|||
if (this->is_plane_update_necessary())
|
||||
update_planes();
|
||||
for (int i = 0; i < (int)m_planes.size(); ++i) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(picking_color_component(i).data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(picking_color_component(i).data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_planes[i].vbo.render();
|
||||
}
|
||||
glsafe(::glPopMatrix());
|
||||
|
|
|
@ -116,7 +116,11 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
|
|||
glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift()));
|
||||
glsafe(::glMultMatrixd(instance_matrix.data()));
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA render_color;
|
||||
#else
|
||||
std::array<float, 4> render_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const sla::DrainHoles& drain_holes = m_c->selection_info()->model_object()->sla_drain_holes;
|
||||
size_t cache_size = drain_holes.size();
|
||||
|
||||
|
@ -129,24 +133,30 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
|
|||
|
||||
// First decide about the color of the point.
|
||||
if (picking) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
render_color = picking_color_component(i);
|
||||
#else
|
||||
std::array<float, 4> color = picking_color_component(i);
|
||||
render_color = color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
else {
|
||||
if (size_t(m_hover_id) == i) {
|
||||
render_color = {0.f, 1.f, 1.f, 1.f};
|
||||
}
|
||||
if (size_t(m_hover_id) == i)
|
||||
render_color = {0.0f, 1.0f, 1.0f, 1.0f};
|
||||
else if (m_c->hollowed_mesh() &&
|
||||
i < m_c->hollowed_mesh()->get_drainholes().size() &&
|
||||
m_c->hollowed_mesh()->get_drainholes()[i].failed) {
|
||||
render_color = {1.f, 0.f, 0.f, .5f};
|
||||
render_color = {1.0f, 0.0f, 0.0f, 0.5f};
|
||||
}
|
||||
else { // neigher hover nor picking
|
||||
|
||||
else { // neither hover nor picking
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
render_color = point_selected ? ColorRGBA(1.0f, 0.3f, 0.3f, 0.5f) : ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
#else
|
||||
render_color[0] = point_selected ? 1.0f : 1.f;
|
||||
render_color[1] = point_selected ? 0.3f : 1.f;
|
||||
render_color[2] = point_selected ? 0.3f : 1.f;
|
||||
render_color[3] = 0.5f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,10 +56,20 @@ bool GLGizmoMmuSegmentation::on_is_activable() const
|
|||
return GLGizmoPainterBase::on_is_activable() && wxGetApp().extruders_edited_cnt() > 1;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static std::vector<ColorRGBA> get_extruders_colors()
|
||||
{
|
||||
#else
|
||||
static std::vector<std::array<float, 4>> get_extruders_colors()
|
||||
{
|
||||
unsigned char rgb_color[3] = {};
|
||||
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> ret;
|
||||
decode_colors(colors, ret);
|
||||
return ret;
|
||||
#else
|
||||
std::vector<std::array<float, 4>> colors_out(colors.size());
|
||||
for (const std::string &color : colors) {
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb_color);
|
||||
|
@ -68,6 +78,7 @@ static std::vector<std::array<float, 4>> get_extruders_colors()
|
|||
}
|
||||
|
||||
return colors_out;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
static std::vector<std::string> get_extruders_names()
|
||||
|
@ -212,17 +223,26 @@ void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static void render_extruders_combo(const std::string& label,
|
||||
const std::vector<std::string>& extruders,
|
||||
const std::vector<ColorRGBA>& extruders_colors,
|
||||
size_t& selection_idx)
|
||||
#else
|
||||
static void render_extruders_combo(const std::string &label,
|
||||
const std::vector<std::string> &extruders,
|
||||
const std::vector<std::array<float, 4>> &extruders_colors,
|
||||
size_t &selection_idx)
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
assert(!extruders_colors.empty());
|
||||
assert(extruders_colors.size() == extruders_colors.size());
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
auto convert_to_imu32 = [](const std::array<float, 4> &color) -> ImU32 {
|
||||
return IM_COL32(uint8_t(color[0] * 255.f), uint8_t(color[1] * 255.f), uint8_t(color[2] * 255.f), uint8_t(color[3] * 255.f));
|
||||
};
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
size_t selection_out = selection_idx;
|
||||
// It is necessary to use BeginGroup(). Otherwise, when using SameLine() is called, then other items will be drawn inside the combobox.
|
||||
|
@ -239,7 +259,11 @@ static void render_extruders_combo(const std::string &labe
|
|||
ImGui::SameLine();
|
||||
ImGuiStyle &style = ImGui::GetStyle();
|
||||
float height = ImGui::GetTextLineHeight();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height), ImGuiWrapper::to_ImU32(extruders_colors[extruder_idx]));
|
||||
#else
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height), convert_to_imu32(extruders_colors[extruder_idx]));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
ImGui::GetWindowDrawList()->AddRect(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height), IM_COL32_BLACK);
|
||||
|
||||
ImGui::SetCursorScreenPos(ImVec2(start_position.x + height + height / 2 + style.FramePadding.x, start_position.y));
|
||||
|
@ -257,7 +281,11 @@ static void render_extruders_combo(const std::string &labe
|
|||
ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
float height = ImGui::GetTextLineHeight();
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + height + height / 2, p.y + height), ImGuiWrapper::to_ImU32(extruders_colors[selection_idx]));
|
||||
#else
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + height + height / 2, p.y + height), convert_to_imu32(extruders_colors[selection_idx]));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
ImGui::GetWindowDrawList()->AddRect(p, ImVec2(p.x + height + height / 2, p.y + height), IM_COL32_BLACK);
|
||||
|
||||
ImGui::SetCursorScreenPos(ImVec2(p.x + height + height / 2 + style.FramePadding.x, p.y));
|
||||
|
@ -343,10 +371,17 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
render_extruders_combo("##first_color_combo", m_original_extruders_names, m_original_extruders_colors, m_first_selected_extruder_idx);
|
||||
ImGui::SameLine();
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& select_first_color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
ImVec4 first_color = ImGuiWrapper::to_ImVec4(select_first_color);
|
||||
if (ImGui::ColorEdit4("First color##color_picker", (float*)&first_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_first_selected_extruder_idx] = ImGuiWrapper::from_ImVec4(first_color);
|
||||
#else
|
||||
const std::array<float, 4> &select_first_color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
ImVec4 first_color = ImVec4(select_first_color[0], select_first_color[1], select_first_color[2], select_first_color[3]);
|
||||
if(ImGui::ColorEdit4("First color##color_picker", (float*)&first_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_first_selected_extruder_idx] = {first_color.x, first_color.y, first_color.z, first_color.w};
|
||||
ImVec4 first_color = ImVec4(select_first_color[0], select_first_color[1], select_first_color[2], select_first_color[3]);
|
||||
if (ImGui::ColorEdit4("First color##color_picker", (float*)&first_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_first_selected_extruder_idx] = { first_color.x, first_color.y, first_color.z, first_color.w };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
m_imgui->text(m_desc.at("second_color"));
|
||||
|
@ -355,10 +390,17 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
render_extruders_combo("##second_color_combo", m_original_extruders_names, m_original_extruders_colors, m_second_selected_extruder_idx);
|
||||
ImGui::SameLine();
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& select_second_color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
ImVec4 second_color = ImGuiWrapper::to_ImVec4(select_second_color);
|
||||
if (ImGui::ColorEdit4("Second color##color_picker", (float*)&second_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_second_selected_extruder_idx] = ImGuiWrapper::from_ImVec4(second_color);
|
||||
#else
|
||||
const std::array<float, 4> &select_second_color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
ImVec4 second_color = ImVec4(select_second_color[0], select_second_color[1], select_second_color[2], select_second_color[3]);
|
||||
if(ImGui::ColorEdit4("Second color##color_picker", (float*)&second_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_second_selected_extruder_idx] = {second_color.x, second_color.y, second_color.z, second_color.w};
|
||||
if (ImGui::ColorEdit4("Second color##color_picker", (float*)&second_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_second_selected_extruder_idx] = { second_color.x, second_color.y, second_color.z, second_color.w };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
|
||||
|
||||
|
@ -595,6 +637,21 @@ PainterGizmoType GLGizmoMmuSegmentation::get_painter_type() const
|
|||
return PainterGizmoType::MMU_SEGMENTATION;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_left_button_color() const
|
||||
{
|
||||
ColorRGBA color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
color.a(0.25f);
|
||||
return color;
|
||||
}
|
||||
|
||||
ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const
|
||||
{
|
||||
ColorRGBA color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
color.a(0.25f);
|
||||
return color;
|
||||
}
|
||||
#else
|
||||
std::array<float, 4> GLGizmoMmuSegmentation::get_cursor_sphere_left_button_color() const
|
||||
{
|
||||
const std::array<float, 4> &color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
|
@ -606,6 +663,7 @@ std::array<float, 4> GLGizmoMmuSegmentation::get_cursor_sphere_right_button_colo
|
|||
const std::array<float, 4> &color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
return {color[0], color[1], color[2], 0.25f};
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
||||
{
|
||||
|
|
|
@ -62,8 +62,13 @@ public:
|
|||
class TriangleSelectorMmGui : public TriangleSelectorGUI {
|
||||
public:
|
||||
// Plus 1 in the initialization of m_gizmo_scene is because the first position is allocated for non-painted triangles, and the indices above colors.size() are allocated for seed fill.
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
TriangleSelectorMmGui(const TriangleMesh& mesh, const std::vector<ColorRGBA>& colors, const ColorRGBA& default_volume_color)
|
||||
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {}
|
||||
#else
|
||||
explicit TriangleSelectorMmGui(const TriangleMesh &mesh, const std::vector<std::array<float, 4>> &colors, const std::array<float, 4> &default_volume_color)
|
||||
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
~TriangleSelectorMmGui() override = default;
|
||||
|
||||
// Render current selection. Transformation matrices are supposed
|
||||
|
@ -73,8 +78,13 @@ public:
|
|||
private:
|
||||
void update_render_data();
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA>& m_colors;
|
||||
const ColorRGBA m_default_volume_color;
|
||||
#else
|
||||
const std::vector<std::array<float, 4>> &m_colors;
|
||||
const std::array<float, 4> m_default_volume_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
GLMmSegmentationGizmo3DScene m_gizmo_scene;
|
||||
};
|
||||
|
||||
|
@ -100,8 +110,13 @@ public:
|
|||
const float get_cursor_radius_min() const override { return CursorRadiusMin; }
|
||||
|
||||
protected:
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA get_cursor_sphere_left_button_color() const override;
|
||||
ColorRGBA get_cursor_sphere_right_button_color() const override;
|
||||
#else
|
||||
std::array<float, 4> get_cursor_sphere_left_button_color() const override;
|
||||
std::array<float, 4> get_cursor_sphere_right_button_color() const override;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
EnforcerBlockerType get_left_button_state_type() const override { return EnforcerBlockerType(m_first_selected_extruder_idx + 1); }
|
||||
EnforcerBlockerType get_right_button_state_type() const override { return EnforcerBlockerType(m_second_selected_extruder_idx + 1); }
|
||||
|
@ -121,8 +136,13 @@ protected:
|
|||
size_t m_first_selected_extruder_idx = 0;
|
||||
size_t m_second_selected_extruder_idx = 1;
|
||||
std::vector<std::string> m_original_extruders_names;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> m_original_extruders_colors;
|
||||
std::vector<ColorRGBA> m_modified_extruders_colors;
|
||||
#else
|
||||
std::vector<std::array<float, 4>> m_original_extruders_colors;
|
||||
std::vector<std::array<float, 4>> m_modified_extruders_colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
std::vector<int> m_original_volumes_extruder_idxs;
|
||||
|
||||
static const constexpr float CursorRadiusMin = 0.1f; // cannot be zero
|
||||
|
|
|
@ -117,7 +117,11 @@ void GLGizmoMove3D::on_render()
|
|||
// draw axes
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
if (m_grabbers[i].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(AXES_COLOR[i].data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(AXES_COLOR[i].data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3dv(center.data());
|
||||
::glVertex3dv(m_grabbers[i].center.data());
|
||||
|
@ -134,7 +138,11 @@ void GLGizmoMove3D::on_render()
|
|||
}
|
||||
else {
|
||||
// draw axis
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3dv(center.data());
|
||||
::glVertex3dv(m_grabbers[m_hover_id].center.data());
|
||||
|
@ -195,6 +203,11 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
|||
float mean_size = (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0);
|
||||
double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size(mean_size) : (double)m_grabbers[axis].get_half_size(mean_size);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color = m_grabbers[axis].color;
|
||||
if (!picking && m_hover_id != -1)
|
||||
color = complementary(color);
|
||||
#else
|
||||
std::array<float, 4> color = m_grabbers[axis].color;
|
||||
if (!picking && m_hover_id != -1) {
|
||||
color[0] = 1.0f - color[0];
|
||||
|
@ -202,6 +215,7 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
|||
color[2] = 1.0f - color[2];
|
||||
color[3] = color[3];
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader == nullptr)
|
||||
|
|
|
@ -207,12 +207,20 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
|||
if (is_left_handed)
|
||||
glFrontFace(GL_CW);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA render_color = { 0.0f, 0.0f, 0.0f, 0.25f };
|
||||
#else
|
||||
std::array<float, 4> render_color = {0.f, 0.f, 0.f, 0.25f};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (m_button_down == Button::Left)
|
||||
render_color = this->get_cursor_sphere_left_button_color();
|
||||
else if (m_button_down == Button::Right)
|
||||
render_color = this->get_cursor_sphere_right_button_color();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(render_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(render_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
assert(s_sphere != nullptr);
|
||||
s_sphere->render();
|
||||
|
@ -709,15 +717,27 @@ TriangleSelector::ClippingPlane GLGizmoPainterBase::get_clipping_plane_in_volume
|
|||
return TriangleSelector::ClippingPlane({float(normal_transformed.x()), float(normal_transformed.y()), float(normal_transformed.z()), offset_transformed});
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA TriangleSelectorGUI::get_seed_fill_color(const ColorRGBA& base_color)
|
||||
{
|
||||
return saturate(base_color, 0.75f);
|
||||
}
|
||||
#else
|
||||
std::array<float, 4> TriangleSelectorGUI::get_seed_fill_color(const std::array<float, 4> &base_color)
|
||||
{
|
||||
return {base_color[0] * 0.75f, base_color[1] * 0.75f, base_color[2] * 0.75f, 1.f};
|
||||
return { base_color[0] * 0.75f, base_color[1] * 0.75f, base_color[2] * 0.75f, 1.f };
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const ColorRGBA enforcers_color = { 0.47f, 0.47f, 1.0f, 1.0f };
|
||||
static const ColorRGBA blockers_color = { 1.0f, 0.44f, 0.44f, 1.0f };
|
||||
#else
|
||||
static constexpr std::array<float, 4> enforcers_color{0.47f, 0.47f, 1.f, 1.f};
|
||||
static constexpr std::array<float, 4> blockers_color{1.f, 0.44f, 0.44f, 1.f};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (m_update_render_data) {
|
||||
update_render_data();
|
||||
|
@ -741,9 +761,15 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||
for (auto &iva : m_iva_seed_fills)
|
||||
if (iva.has_VBOs()) {
|
||||
size_t color_idx = &iva - &m_iva_seed_fills.front();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& color = TriangleSelectorGUI::get_seed_fill_color(color_idx == 1 ? enforcers_color :
|
||||
color_idx == 2 ? blockers_color :
|
||||
GLVolume::NEUTRAL_COLOR);
|
||||
#else
|
||||
const std::array<float, 4> &color = TriangleSelectorGUI::get_seed_fill_color(color_idx == 1 ? enforcers_color :
|
||||
color_idx == 2 ? blockers_color :
|
||||
GLVolume::NEUTRAL_COLOR);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
shader->set_uniform("uniform_color", color);
|
||||
iva.render();
|
||||
}
|
||||
|
|
|
@ -86,7 +86,11 @@ public:
|
|||
protected:
|
||||
bool m_update_render_data = false;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ColorRGBA get_seed_fill_color(const ColorRGBA& base_color);
|
||||
#else
|
||||
static std::array<float, 4> get_seed_fill_color(const std::array<float, 4> &base_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
private:
|
||||
void update_render_data();
|
||||
|
@ -135,8 +139,13 @@ protected:
|
|||
virtual void update_model_object() const = 0;
|
||||
virtual void update_from_model_object() = 0;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
virtual ColorRGBA get_cursor_sphere_left_button_color() const { return { 0.0f, 0.0f, 1.0f, 0.25f }; }
|
||||
virtual ColorRGBA get_cursor_sphere_right_button_color() const { return { 1.0f, 0.0f, 0.0f, 0.25f }; }
|
||||
#else
|
||||
virtual std::array<float, 4> get_cursor_sphere_left_button_color() const { return {0.f, 0.f, 1.f, 0.25f}; }
|
||||
virtual std::array<float, 4> get_cursor_sphere_right_button_color() const { return {1.f, 0.f, 0.f, 0.25f}; }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
virtual EnforcerBlockerType get_left_button_state_type() const { return EnforcerBlockerType::ENFORCER; }
|
||||
virtual EnforcerBlockerType get_right_button_state_type() const { return EnforcerBlockerType::BLOCKER; }
|
||||
|
|
|
@ -137,7 +137,11 @@ void GLGizmoRotate::on_render()
|
|||
transform_to_local(selection);
|
||||
|
||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv((m_hover_id != -1) ? m_drag_color.data() : m_highlight_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv((m_hover_id != -1) ? m_drag_color.data() : m_highlight_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
render_circle();
|
||||
|
||||
|
@ -147,7 +151,11 @@ void GLGizmoRotate::on_render()
|
|||
render_reference_radius();
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_highlight_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_highlight_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (m_hover_id != -1)
|
||||
render_angle();
|
||||
|
@ -298,7 +306,11 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
|
|||
m_grabbers[0].center = Vec3d(::cos(m_angle) * grabber_radius, ::sin(m_angle) * grabber_radius, 0.0);
|
||||
m_grabbers[0].angles(2) = m_angle;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv((m_hover_id != -1) ? m_drag_color.data() : m_highlight_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv((m_hover_id != -1) ? m_drag_color.data() : m_highlight_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
|
@ -314,12 +326,18 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
|||
float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
||||
double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size(mean_size) : (double)m_grabbers[0].get_half_size(mean_size);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color = m_grabbers[0].color;
|
||||
if (!picking && m_hover_id != -1)
|
||||
color = complementary(color);
|
||||
#else
|
||||
std::array<float, 4> color = m_grabbers[0].color;
|
||||
if (!picking && m_hover_id != -1) {
|
||||
color[0] = 1.0f - color[0];
|
||||
color[1] = 1.0f - color[1];
|
||||
color[2] = 1.0f - color[2];
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader == nullptr)
|
||||
|
|
|
@ -209,18 +209,34 @@ void GLGizmoScale3D::on_render()
|
|||
if (m_hover_id == -1) {
|
||||
// draw connections
|
||||
if (m_grabbers[0].enabled && m_grabbers[1].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[0].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[0].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(0, 1);
|
||||
}
|
||||
if (m_grabbers[2].enabled && m_grabbers[3].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(2, 3);
|
||||
}
|
||||
if (m_grabbers[4].enabled && m_grabbers[5].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(4, 5);
|
||||
}
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_base_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_base_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(6, 7);
|
||||
render_grabbers_connection(7, 8);
|
||||
render_grabbers_connection(8, 9);
|
||||
|
@ -230,7 +246,11 @@ void GLGizmoScale3D::on_render()
|
|||
}
|
||||
else if (m_hover_id == 0 || m_hover_id == 1) {
|
||||
// draw connection
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[0].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[0].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(0, 1);
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
|
@ -245,7 +265,11 @@ void GLGizmoScale3D::on_render()
|
|||
}
|
||||
else if (m_hover_id == 2 || m_hover_id == 3) {
|
||||
// draw connection
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(2, 3);
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
|
@ -260,7 +284,11 @@ void GLGizmoScale3D::on_render()
|
|||
}
|
||||
else if (m_hover_id == 4 || m_hover_id == 5) {
|
||||
// draw connection
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(4, 5);
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
|
@ -275,7 +303,11 @@ void GLGizmoScale3D::on_render()
|
|||
}
|
||||
else if (m_hover_id >= 6) {
|
||||
// draw connection
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_drag_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_drag_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(6, 7);
|
||||
render_grabbers_connection(7, 8);
|
||||
render_grabbers_connection(8, 9);
|
||||
|
|
|
@ -144,7 +144,11 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
glsafe(::glTranslated(0.0, 0.0, z_shift));
|
||||
glsafe(::glMultMatrixd(instance_matrix.data()));
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA render_color;
|
||||
#else
|
||||
std::array<float, 4> render_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
for (size_t i = 0; i < cache_size; ++i) {
|
||||
const sla::SupportPoint& support_point = m_editing_mode ? m_editing_cache[i].support_point : m_normal_cache[i];
|
||||
const bool& point_selected = m_editing_mode ? m_editing_cache[i].selected : false;
|
||||
|
@ -226,10 +230,14 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
|
||||
// Now render the drain holes:
|
||||
if (has_holes && ! picking) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
render_color = { 0.7f, 0.7f, 0.7f, 0.7f };
|
||||
#else
|
||||
render_color[0] = 0.7f;
|
||||
render_color[1] = 0.7f;
|
||||
render_color[2] = 0.7f;
|
||||
render_color[3] = 0.7f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const_cast<GLModel*>(&m_cylinder)->set_color(-1, render_color);
|
||||
if (shader)
|
||||
shader->set_uniform("emission_factor", 0.5f);
|
||||
|
|
|
@ -216,8 +216,13 @@ void InstancesHider::render_cut() const
|
|||
if (mv->is_model_part())
|
||||
glsafe(::glColor3f(0.8f, 0.3f, 0.0f));
|
||||
else {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA color = color_from_model_volume(*mv);
|
||||
glsafe(::glColor4fv(color.data()));
|
||||
#else
|
||||
const std::array<float, 4>& c = color_from_model_volume(*mv);
|
||||
glsafe(::glColor4f(c[0], c[1], c[2], c[3]));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
glsafe(::glPushAttrib(GL_DEPTH_TEST));
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "3DScene.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
@ -82,14 +85,25 @@ static const std::map<const wchar_t, std::string> font_icons_extra_large = {
|
|||
|
||||
};
|
||||
|
||||
const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.333f, 0.333f, 0.333f, 1.0f };
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.33f, 0.33f, 0.33f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_GREY_LIGHT = { 0.4f, 0.4f, 0.4f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.757f, 0.404f, 0.216f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = { 1.0f, 0.49f, 0.216f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_WINDOW_BACKGROUND = { 0.133f, 0.133f, 0.133f, 0.8f };
|
||||
const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.67f, 0.36f, 0.19f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = to_ImVec4(ColorRGBA::ORANGE());
|
||||
const ImVec4 ImGuiWrapper::COL_WINDOW_BACKGROUND = { 0.13f, 0.13f, 0.13f, 0.8f };
|
||||
const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_ORANGE_DARK;
|
||||
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
|
||||
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = ImGuiWrapper::COL_BUTTON_HOVERED;
|
||||
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = COL_BUTTON_HOVERED;
|
||||
#else
|
||||
const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.333f, 0.333f, 0.333f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_GREY_LIGHT = { 0.4f, 0.4f, 0.4f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.757f, 0.404f, 0.216f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = { 1.0f, 0.49f, 0.216f, 1.0f };
|
||||
const ImVec4 ImGuiWrapper::COL_WINDOW_BACKGROUND = { 0.133f, 0.133f, 0.133f, 0.8f };
|
||||
const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_ORANGE_DARK;
|
||||
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
|
||||
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = ImGuiWrapper::COL_BUTTON_HOVERED;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
ImGuiWrapper::ImGuiWrapper()
|
||||
{
|
||||
|
@ -1035,6 +1049,28 @@ bool ImGuiWrapper::want_any_input() const
|
|||
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImU32 ImGuiWrapper::to_ImU32(const ColorRGBA& color)
|
||||
{
|
||||
return ImGui::GetColorU32({ color.r(), color.g(), color.b(), color.a() });
|
||||
}
|
||||
|
||||
ImVec4 ImGuiWrapper::to_ImVec4(const ColorRGBA& color)
|
||||
{
|
||||
return { color.r(), color.g(), color.b(), color.a() };
|
||||
}
|
||||
|
||||
ColorRGBA ImGuiWrapper::from_ImU32(const ImU32& color)
|
||||
{
|
||||
return from_ImVec4(ImGui::ColorConvertU32ToFloat4(color));
|
||||
}
|
||||
|
||||
ColorRGBA ImGuiWrapper::from_ImVec4(const ImVec4& color)
|
||||
{
|
||||
return { color.x, color.y, color.z, color.w };
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#ifdef __APPLE__
|
||||
static const ImWchar ranges_keyboard_shortcuts[] =
|
||||
{
|
||||
|
|
|
@ -10,9 +10,14 @@
|
|||
|
||||
#include "libslic3r/Point.hpp"
|
||||
|
||||
namespace Slic3r {namespace Search {
|
||||
namespace Slic3r {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
class ColorRGBA;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
namespace Search {
|
||||
struct OptionViewParameters;
|
||||
}}
|
||||
} // namespace Search
|
||||
} // namespace Slic3r
|
||||
|
||||
class wxString;
|
||||
class wxMouseEvent;
|
||||
|
@ -134,6 +139,13 @@ public:
|
|||
void reset_requires_extra_frame() { m_requires_extra_frame = false; }
|
||||
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ImU32 to_ImU32(const ColorRGBA& color);
|
||||
static ImVec4 to_ImVec4(const ColorRGBA& color);
|
||||
static ColorRGBA from_ImU32(const ImU32& color);
|
||||
static ColorRGBA from_ImVec4(const ImVec4& color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
static const ImVec4 COL_GREY_DARK;
|
||||
static const ImVec4 COL_GREY_LIGHT;
|
||||
static const ImVec4 COL_ORANGE_DARK;
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "GUI.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
|
@ -137,8 +140,13 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin
|
|||
wxColour text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
#endif
|
||||
wxColour bgr_clr = parent->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const int font_size = font.GetPointSize();
|
||||
int size[] = { font_size, font_size, font_size, font_size, font_size, font_size, font_size };
|
||||
html->SetFonts(font.GetFaceName(), monospace.GetFaceName(), size);
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
@ -441,15 +444,26 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con
|
|||
// Paint a red flag for incompatible presets.
|
||||
bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp());
|
||||
|
||||
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty())
|
||||
{
|
||||
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty()) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
// Paint the color bars.
|
||||
ColorRGB color;
|
||||
decode_color(filament_rgb, color);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, color, false, 1, dark_mode));
|
||||
#else
|
||||
unsigned char rgb[3];
|
||||
// Paint the color bars.
|
||||
bitmap_cache().parse_color(filament_rgb, rgb);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, rgb, false, 1, dark_mode));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (!is_single_bar) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
decode_color(extruder_rgb, color);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(thin_icon_width, icon_height, color, false, 1, dark_mode));
|
||||
#else
|
||||
bitmap_cache().parse_color(extruder_rgb, rgb);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(thin_icon_width, icon_height, rgb, false, 1, dark_mode));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
// Paint a lock at the system presets.
|
||||
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
|
||||
|
@ -767,11 +781,16 @@ void PlaterPresetComboBox::update()
|
|||
|
||||
const Preset* selected_filament_preset = nullptr;
|
||||
std::string extruder_color;
|
||||
if (m_type == Preset::TYPE_FILAMENT)
|
||||
{
|
||||
if (m_type == Preset::TYPE_FILAMENT) {
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
unsigned char rgb[3];
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
extruder_color = m_preset_bundle->printers.get_edited_preset().config.opt_string("extruder_colour", (unsigned int)m_extruder_idx);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
if (!can_decode_color(extruder_color))
|
||||
#else
|
||||
if (!bitmap_cache().parse_color(extruder_color, rgb))
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// Extruder color is not defined.
|
||||
extruder_color.clear();
|
||||
selected_filament_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_extruder_idx]);
|
||||
|
|
|
@ -24,7 +24,13 @@
|
|||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const Slic3r::ColorRGBA UNIFORM_SCALE_COLOR = Slic3r::ColorRGBA::ORANGE();
|
||||
static const Slic3r::ColorRGBA SOLID_PLANE_COLOR = Slic3r::ColorRGBA::ORANGE();
|
||||
static const Slic3r::ColorRGBA TRANSPARENT_PLANE_COLOR = { 0.8f, 0.8f, 0.8f, 0.5f };
|
||||
#else
|
||||
static const std::array<float, 4> UNIFORM_SCALE_COLOR = { 0.923f, 0.504f, 0.264f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -453,11 +459,15 @@ void Selection::clear()
|
|||
for (unsigned int i : m_list) {
|
||||
GLVolume& volume = *(*m_volumes)[i];
|
||||
volume.selected = false;
|
||||
bool transparent = volume.color[3] < 1.0f;
|
||||
if (transparent)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
bool is_transparent = volume.color.is_transparent();
|
||||
#else
|
||||
bool is_transparent = volume.color[3] < 1.0f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (is_transparent)
|
||||
volume.force_transparent = true;
|
||||
volume.set_render_color();
|
||||
if (transparent)
|
||||
if (is_transparent)
|
||||
volume.force_transparent = false;
|
||||
}
|
||||
#else
|
||||
|
@ -1919,10 +1929,17 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, float* color) cons
|
|||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ColorRGBA get_color(Axis axis)
|
||||
{
|
||||
return AXES_COLOR[axis];
|
||||
};
|
||||
#else
|
||||
static std::array<float, 4> get_color(Axis axis)
|
||||
{
|
||||
return { AXES_COLOR[axis][0], AXES_COLOR[axis][1], AXES_COLOR[axis][2], AXES_COLOR[axis][3] };
|
||||
};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void Selection::render_sidebar_position_hints(const std::string& sidebar_field) const
|
||||
{
|
||||
|
@ -2052,10 +2069,15 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co
|
|||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor4fv((camera_on_top && type == 1) || (!camera_on_top && type == 2) ?
|
||||
SOLID_PLANE_COLOR.data() : TRANSPARENT_PLANE_COLOR.data());
|
||||
#else
|
||||
if ((camera_on_top && type == 1) || (!camera_on_top && type == 2))
|
||||
::glColor4f(1.0f, 0.38f, 0.0f, 1.0f);
|
||||
else
|
||||
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glVertex3f(min_x, min_y, z1);
|
||||
::glVertex3f(max_x, min_y, z1);
|
||||
::glVertex3f(max_x, max_y, z1);
|
||||
|
@ -2063,10 +2085,15 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co
|
|||
glsafe(::glEnd());
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor4fv((camera_on_top && type == 2) || (!camera_on_top && type == 1) ?
|
||||
SOLID_PLANE_COLOR.data() : TRANSPARENT_PLANE_COLOR.data());
|
||||
#else
|
||||
if ((camera_on_top && type == 2) || (!camera_on_top && type == 1))
|
||||
::glColor4f(1.0f, 0.38f, 0.0f, 1.0f);
|
||||
else
|
||||
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glVertex3f(min_x, min_y, z2);
|
||||
::glVertex3f(max_x, min_y, z2);
|
||||
::glVertex3f(max_x, max_y, z2);
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#include "libslic3r/BlacklistedLibraryCheck.hpp"
|
||||
#include "libslic3r/Platform.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "slic3r/GUI/format.hpp"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
|
@ -571,9 +574,13 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
|
|||
wxColour bgr_clr = wxGetApp().get_window_default_clr();
|
||||
SetBackgroundColour(bgr_clr);
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
auto *topSizer = new wxBoxSizer(wxVERTICAL);
|
||||
auto *vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include "MainFrame.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "../libslic3r/BlacklistedLibraryCheck.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "../libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "format.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -114,8 +117,13 @@ SysInfoDialog::SysInfoDialog()
|
|||
// main_info_text
|
||||
wxFont font = get_default_font(this);
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
const int fs = font.GetPointSize() - 1;
|
||||
int size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs };
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "format.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "Plater.hpp"
|
||||
|
@ -58,8 +61,12 @@ static std::string get_icon_name(Preset::Type type, PrinterTechnology pt) {
|
|||
static std::string def_text_color()
|
||||
{
|
||||
wxColour def_colour = wxGetApp().get_label_clr_default();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return encode_color(ColorRGB(def_colour.Red(), def_colour.Green(), def_colour.Blue()));
|
||||
#else
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), def_colour.Red(), def_colour.Green(), def_colour.Blue());
|
||||
return clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
static std::string grey = "#808080";
|
||||
static std::string orange = "#ed6b21";
|
||||
|
@ -124,8 +131,13 @@ wxBitmap ModelNode::get_bitmap(const wxString& color)
|
|||
const int icon_height = lround(1.6 * em);
|
||||
|
||||
BitmapCache bmp_cache;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGB rgb;
|
||||
decode_color(into_u8(color), rgb);
|
||||
#else
|
||||
unsigned char rgb[3];
|
||||
BitmapCache::parse_color(into_u8(color), rgb);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// there is no need to scale created solid bitmap
|
||||
#ifndef __linux__
|
||||
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
#include "GUI_App.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include <wx/sizer.h>
|
||||
|
||||
int scale(const int val) { return val * Slic3r::GUI::wxGetApp().em_unit(); }
|
||||
|
@ -226,9 +230,15 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
m_number_of_extruders = (int)(sqrt(matrix.size())+0.001);
|
||||
|
||||
for (const std::string& color : extruder_colours) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
Slic3r::ColorRGB rgb;
|
||||
Slic3r::decode_color(color, rgb);
|
||||
m_colours.push_back(wxColor(rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar()));
|
||||
#else
|
||||
unsigned char rgb[3];
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb);
|
||||
m_colours.push_back(wxColor(rgb[0], rgb[1], rgb[2]));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
// Create two switched panels with their own sizers
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
#include "../Utils/MacDarkMode.hpp"
|
||||
#include "BitmapComboBox.hpp"
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#ifndef __linux__
|
||||
// msw_menuitem_bitmaps is used for MSW and OSX
|
||||
static std::map<int, std::string> msw_menuitem_bitmaps;
|
||||
|
@ -471,7 +475,9 @@ std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
|
|||
if (colors.empty())
|
||||
return bmps;
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
unsigned char rgb[3];
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
/* It's supposed that standard size of an icon is 36px*16px for 100% scaled display.
|
||||
* So set sizes for solid_colored icons used for filament preset
|
||||
|
@ -489,10 +495,18 @@ std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
|
|||
|
||||
wxBitmap* bitmap = bmp_cache.find(bitmap_key);
|
||||
if (bitmap == nullptr) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
// Paint the color icon.
|
||||
Slic3r::ColorRGB rgb;
|
||||
Slic3r::decode_color(color, rgb);
|
||||
// there is no neede to scale created solid bitmap
|
||||
bitmap = bmp_cache.insert(bitmap_key, bmp_cache.mksolid(icon_width, icon_height, rgb, true, 1, dark_mode));
|
||||
#else
|
||||
// Paint the color icon.
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb);
|
||||
// there is no neede to scale created solid bitmap
|
||||
bitmap = bmp_cache.insert(bitmap_key, bmp_cache.mksolid(icon_width, icon_height, rgb, true, 1, dark_mode));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
bmps.emplace_back(bitmap);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ add_executable(${_TEST_NAME}_tests
|
|||
test_aabbindirect.cpp
|
||||
test_clipper_offset.cpp
|
||||
test_clipper_utils.cpp
|
||||
test_color.cpp
|
||||
test_config.cpp
|
||||
test_elephant_foot_compensation.cpp
|
||||
test_geometry.cpp
|
||||
|
|
41
tests/libslic3r/test_color.cpp
Normal file
41
tests/libslic3r/test_color.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <catch2/catch.hpp>
|
||||
#include "libslic3r/libslic3r.h"
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "libslic3r/Color.hpp"
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
SCENARIO("Color encoding/decoding cycle", "[Color]") {
|
||||
GIVEN("Color") {
|
||||
const ColorRGB src_rgb(unsigned char(255), unsigned char(127), unsigned char(63));
|
||||
WHEN("apply encode/decode cycle") {
|
||||
const std::string encoded = encode_color(src_rgb);
|
||||
ColorRGB res_rgb;
|
||||
decode_color(encoded, res_rgb);
|
||||
const bool ret = res_rgb.r_uchar() == src_rgb.r_uchar() && res_rgb.g_uchar() == src_rgb.g_uchar() && res_rgb.b_uchar() == src_rgb.b_uchar();
|
||||
THEN("result matches source") {
|
||||
REQUIRE(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("Color picking encoding/decoding cycle", "[Color]") {
|
||||
GIVEN("Picking color") {
|
||||
const ColorRGB src_rgb(unsigned char(255), unsigned char(127), unsigned char(63));
|
||||
WHEN("apply encode/decode cycle") {
|
||||
const unsigned int encoded = picking_encode(src_rgb.r_uchar(), src_rgb.g_uchar(), src_rgb.b_uchar());
|
||||
const ColorRGBA res_rgba = picking_decode(encoded);
|
||||
const bool ret = res_rgba.r_uchar() == src_rgb.r_uchar() && res_rgba.g_uchar() == src_rgb.g_uchar() && res_rgba.b_uchar() == src_rgb.b_uchar();
|
||||
THEN("result matches source") {
|
||||
REQUIRE(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
|
Loading…
Reference in a new issue