Tech ENABLE_COLOR_CLASSES set as default

This commit is contained in:
enricoturri1966 2022-01-14 08:19:00 +01:00
parent fab35e8aa4
commit 6201dad245
50 changed files with 18 additions and 1500 deletions

View File

@ -3,7 +3,6 @@
#include <random> #include <random>
#if ENABLE_COLOR_CLASSES
static const float INV_255 = 1.0f / 255.0f; static const float INV_255 = 1.0f / 255.0f;
namespace Slic3r { namespace Slic3r {
@ -399,4 +398,3 @@ unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char gr
} // namespace Slic3r } // namespace Slic3r
#endif // ENABLE_COLOR_CLASSES

View File

@ -1,8 +1,6 @@
#ifndef slic3r_Color_hpp_ #ifndef slic3r_Color_hpp_
#define slic3r_Color_hpp_ #define slic3r_Color_hpp_
#if ENABLE_COLOR_CLASSES
#include <array> #include <array>
#include <algorithm> #include <algorithm>
@ -169,6 +167,4 @@ extern unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned
} // namespace Slic3r } // namespace Slic3r
#endif // ENABLE_COLOR_CLASSES
#endif /* slic3r_Color_hpp_ */ #endif /* slic3r_Color_hpp_ */

View File

@ -45,13 +45,4 @@
#define ENABLE_SPIRAL_VASE_LAYERS (1 && ENABLE_2_4_1_RC) #define ENABLE_SPIRAL_VASE_LAYERS (1 && ENABLE_2_4_1_RC)
//====================
// 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_ #endif // _prusaslicer_technologies_h_

View File

@ -19,15 +19,10 @@
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
static const float GROUND_Z = -0.02f; 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 DEFAULT_MODEL_COLOR = Slic3r::ColorRGBA::DARK_GRAY();
static const Slic3r::ColorRGBA PICKING_MODEL_COLOR = Slic3r::ColorRGBA::BLACK(); 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_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 }; 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 Slic3r {
namespace GUI { namespace GUI {
@ -128,27 +123,15 @@ void Bed3D::Axes::render() const
shader->set_uniform("emission_factor", 0.0f); shader->set_uniform("emission_factor", 0.0f);
// x axis // x axis
#if ENABLE_COLOR_CLASSES
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::X()); 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>()); render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }).cast<float>());
// y axis // y axis
#if ENABLE_COLOR_CLASSES
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::Y()); 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>()); render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }).cast<float>());
// z axis // z axis
#if ENABLE_COLOR_CLASSES
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::Z()); 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>()); render_axis(Geometry::assemble_transform(m_origin).cast<float>());
shader->stop_using(); shader->stop_using();
@ -559,11 +542,7 @@ void Bed3D::render_default(bool bottom, bool picking) const
if (!has_model && !bottom) { if (!has_model && !bottom) {
// draw background // draw background
glsafe(::glDepthMask(GL_FALSE)); glsafe(::glDepthMask(GL_FALSE));
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(picking ? PICKING_MODEL_COLOR.data() : DEFAULT_MODEL_COLOR.data())); 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(::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(::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_vertices_data()));
glsafe(::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount)); glsafe(::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount));
@ -573,14 +552,7 @@ void Bed3D::render_default(bool bottom, bool picking) const
if (!picking) { if (!picking) {
// draw grid // draw grid
glsafe(::glLineWidth(1.5f * m_scale_factor)); 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())); 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(::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())); glsafe(::glDrawArrays(GL_LINES, 0, (GLsizei)m_gridlines.get_vertices_count()));
} }

View File

@ -344,7 +344,6 @@ void GLVolume::SinkingContours::update()
m_model.reset(); m_model.reset();
} }
#if ENABLE_COLOR_CLASSES
const ColorRGBA GLVolume::SELECTED_COLOR = ColorRGBA::GREEN(); 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_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::HOVER_DESELECT_COLOR = { 1.0f, 0.75f, 0.75f, 1.0f };
@ -360,23 +359,6 @@ const std::array<ColorRGBA, 4> GLVolume::MODEL_COLOR = { {
{ 0.5f, 1.0f, 0.5f, 1.0f }, { 0.5f, 1.0f, 0.5f, 1.0f },
{ 0.5f, 0.5f, 1.0f, 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 };
const std::array<float, 4> GLVolume::OUTSIDE_COLOR = { 0.0f, 0.38f, 0.8f, 1.0f };
const std::array<float, 4> GLVolume::SELECTED_OUTSIDE_COLOR = { 0.19f, 0.58f, 1.0f, 1.0f };
const std::array<float, 4> GLVolume::DISABLED_COLOR = { 0.25f, 0.25f, 0.25f, 1.0f };
const std::array<float, 4> GLVolume::SLA_SUPPORT_COLOR = { 0.75f, 0.75f, 0.75f, 1.0f };
const std::array<float, 4> GLVolume::SLA_PAD_COLOR = { 0.0f, 0.2f, 0.0f, 1.0f };
const std::array<float, 4> GLVolume::NEUTRAL_COLOR = { 0.9f, 0.9f, 0.9f, 1.0f };
const std::array<std::array<float, 4>, 4> GLVolume::MODEL_COLOR = { {
{ 1.0f, 1.0f, 0.0f, 1.f },
{ 1.0f, 0.5f, 0.5f, 1.f },
{ 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) GLVolume::GLVolume(float r, float g, float b, float a)
: m_sla_shift_z(0.0) : m_sla_shift_z(0.0)
@ -406,23 +388,6 @@ GLVolume::GLVolume(float r, float g, float b, float a)
set_render_color(color); set_render_color(color);
} }
#if !ENABLE_COLOR_CLASSES
void GLVolume::set_color(const std::array<float, 4>& rgba)
{
color = rgba;
}
void GLVolume::set_render_color(float r, float g, float b, float a)
{
render_color = { r, g, b, a };
}
void GLVolume::set_render_color(const std::array<float, 4>& rgba)
{
render_color = rgba;
}
#endif // !ENABLE_COLOR_CLASSES
void GLVolume::set_render_color() void GLVolume::set_render_color()
{ {
bool outside = is_outside || is_below_printbed(); bool outside = is_outside || is_below_printbed();
@ -452,25 +417,13 @@ void GLVolume::set_render_color()
set_render_color(color); set_render_color(color);
} }
if (!printable) { if (!printable)
#if ENABLE_COLOR_CLASSES
render_color = saturate(render_color, 0.25f); 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 (force_transparent)
#if ENABLE_COLOR_CLASSES
render_color.a(color.a()); 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_from_model_volume(const ModelVolume& model_volume)
{ {
ColorRGBA color; ColorRGBA color;
@ -488,34 +441,6 @@ ColorRGBA color_from_model_volume(const ModelVolume& model_volume)
return color; return color;
} }
#else
std::array<float, 4> color_from_model_volume(const ModelVolume& model_volume)
{
std::array<float, 4> color;
if (model_volume.is_negative_volume()) {
color[0] = 0.2f;
color[1] = 0.2f;
color[2] = 0.2f;
}
else if (model_volume.is_modifier()) {
color[0] = 1.0f;
color[1] = 1.0f;
color[2] = 0.2f;
}
else if (model_volume.is_support_blocker()) {
color[0] = 1.0f;
color[1] = 0.2f;
color[2] = 0.2f;
}
else if (model_volume.is_support_enforcer()) {
color[0] = 0.2f;
color[1] = 0.2f;
color[2] = 1.0f;
}
color[3] = model_volume.is_model_part() ? 1.f : 0.5f;
return color;
}
#endif // ENABLE_COLOR_CLASSES
Transform3d GLVolume::world_matrix() const Transform3d GLVolume::world_matrix() const
{ {
@ -673,13 +598,8 @@ int GLVolumeCollection::load_object_volume(
const int extruder_id = model_volume->extruder_id(); const int extruder_id = model_volume->extruder_id();
const ModelInstance *instance = model_object->instances[instance_idx]; const ModelInstance *instance = model_object->instances[instance_idx];
const TriangleMesh &mesh = model_volume->mesh(); const TriangleMesh &mesh = model_volume->mesh();
#if ENABLE_COLOR_CLASSES
ColorRGBA color = GLVolume::MODEL_COLOR[((color_by == "volume") ? volume_idx : obj_idx) % 4]; ColorRGBA color = GLVolume::MODEL_COLOR[((color_by == "volume") ? volume_idx : obj_idx) % 4];
color.a(model_volume->is_model_part() ? 1.0f : 0.5f); 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)); this->volumes.emplace_back(new GLVolume(color));
GLVolume& v = *this->volumes.back(); GLVolume& v = *this->volumes.back();
v.set_color(color_from_model_volume(*model_volume)); v.set_color(color_from_model_volume(*model_volume));
@ -760,22 +680,13 @@ int GLVolumeCollection::load_wipe_tower_preview(
height = 0.1f; height = 0.1f;
TriangleMesh mesh; TriangleMesh mesh;
#if ENABLE_COLOR_CLASSES
ColorRGBA color = ColorRGBA::DARK_YELLOW(); 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 // 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: // the box with different color with one side jagged:
if (size_unknown) { if (size_unknown) {
#if ENABLE_COLOR_CLASSES
color.r(0.9f); color.r(0.9f);
color.g(0.6f); 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. // Too narrow tower would interfere with the teeth. The estimate is not precise anyway.
depth = std::max(depth, 10.f); depth = std::max(depth, 10.f);
@ -831,22 +742,14 @@ int GLVolumeCollection::load_wipe_tower_preview(
return int(volumes.size() - 1); return int(volumes.size() - 1);
} }
#if ENABLE_COLOR_CLASSES
GLVolume* GLVolumeCollection::new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats) 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); GLVolume *out = new_nontoolpath_volume(rgba, reserve_vbo_floats);
out->is_extrusion_path = true; out->is_extrusion_path = true;
return out; return out;
} }
#if ENABLE_COLOR_CLASSES
GLVolume* GLVolumeCollection::new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats) 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); GLVolume *out = new GLVolume(rgba);
out->is_extrusion_path = false; out->is_extrusion_path = false;
@ -863,11 +766,7 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
for (unsigned int i = 0; i < (unsigned int)volumes.size(); ++i) { for (unsigned int i = 0; i < (unsigned int)volumes.size(); ++i) {
GLVolume* volume = volumes[i]; GLVolume* volume = volumes[i];
#if ENABLE_COLOR_CLASSES
bool is_transparent = volume->render_color.is_transparent(); 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) || if (((type == GLVolumeCollection::ERenderType::Opaque && !is_transparent) ||
(type == GLVolumeCollection::ERenderType::Transparent && is_transparent) || (type == GLVolumeCollection::ERenderType::Transparent && is_transparent) ||
type == GLVolumeCollection::ERenderType::All) && type == GLVolumeCollection::ERenderType::All) &&
@ -1046,8 +945,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
void GLVolumeCollection::reset_outside_state() void GLVolumeCollection::reset_outside_state()
{ {
for (GLVolume* volume : this->volumes) for (GLVolume* volume : this->volumes) {
{
if (volume != nullptr) if (volume != nullptr)
volume->is_outside = false; volume->is_outside = false;
} }
@ -1055,54 +953,17 @@ void GLVolumeCollection::reset_outside_state()
void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* config) void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* config)
{ {
#if ENABLE_COLOR_CLASSES
using ColorItem = std::pair<std::string, ColorRGBA>; using ColorItem = std::pair<std::string, ColorRGBA>;
std::vector<ColorItem> colors; std::vector<ColorItem> colors;
#else
static const float inv_255 = 1.0f / 255.0f;
struct Color
{
std::string text;
unsigned char rgb[3];
Color()
: text("")
{
rgb[0] = 255;
rgb[1] = 255;
rgb[2] = 255;
}
void set(const std::string& text, unsigned char* rgb)
{
this->text = text;
::memcpy((void*)this->rgb, (const void*)rgb, 3 * sizeof(unsigned char));
}
};
if (config == nullptr)
return;
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() ? const std::string& txt_color = config->opt_string("material_colour").empty() ?
print_config_def.get("material_colour")->get_default_value<ConfigOptionString>()->value : print_config_def.get("material_colour")->get_default_value<ConfigOptionString>()->value :
config->opt_string("material_colour"); config->opt_string("material_colour");
#if ENABLE_COLOR_CLASSES
ColorRGBA rgba; ColorRGBA rgba;
if (decode_color(txt_color, rgba)) if (decode_color(txt_color, rgba))
colors.push_back({ 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")); const ConfigOptionStrings* extruders_opt = dynamic_cast<const ConfigOptionStrings*>(config->option("extruder_colour"));
if (extruders_opt == nullptr) if (extruders_opt == nullptr)
@ -1118,7 +979,6 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
colors.resize(colors_count); colors.resize(colors_count);
for (unsigned int i = 0; i < colors_count; ++i) { for (unsigned int i = 0; i < colors_count; ++i) {
#if ENABLE_COLOR_CLASSES
const std::string& ext_color = config->opt_string("extruder_colour", i); const std::string& ext_color = config->opt_string("extruder_colour", i);
ColorRGBA rgba; ColorRGBA rgba;
if (decode_color(ext_color, rgba)) if (decode_color(ext_color, rgba))
@ -1128,16 +988,6 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
if (decode_color(fil_color, rgba)) if (decode_color(fil_color, rgba))
colors[i] = { 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);
else {
const std::string& txt_color = config->opt_string("filament_colour", i);
if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb))
colors[i].set(txt_color, rgb);
}
#endif // ENABLE_COLOR_CLASSES
} }
} }
@ -1149,18 +999,9 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
if (extruder_id < 0 || (int)colors.size() <= extruder_id) if (extruder_id < 0 || (int)colors.size() <= extruder_id)
extruder_id = 0; extruder_id = 0;
#if ENABLE_COLOR_CLASSES
const ColorItem& color = colors[extruder_id]; const ColorItem& color = colors[extruder_id];
if (!color.first.empty()) if (!color.first.empty())
volume->color = color.second; 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
} }
} }

View File

@ -7,9 +7,7 @@
#include "libslic3r/TriangleMesh.hpp" #include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "libslic3r/Geometry.hpp" #include "libslic3r/Geometry.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "GLModel.hpp" #include "GLModel.hpp"
@ -46,11 +44,7 @@ class ModelVolume;
enum ModelInstanceEPrintVolumeState : unsigned char; enum ModelInstanceEPrintVolumeState : unsigned char;
// Return appropriate color based on the ModelVolume. // Return appropriate color based on the ModelVolume.
#if ENABLE_COLOR_CLASSES
extern ColorRGBA color_from_model_volume(const ModelVolume& model_volume); 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, // A container for interleaved arrays of 3D vertices and normals,
// possibly indexed by triangles and / or quads. // possibly indexed by triangles and / or quads.
@ -255,7 +249,6 @@ private:
class GLVolume { class GLVolume {
public: public:
#if ENABLE_COLOR_CLASSES
static const ColorRGBA SELECTED_COLOR; static const ColorRGBA SELECTED_COLOR;
static const ColorRGBA HOVER_SELECT_COLOR; static const ColorRGBA HOVER_SELECT_COLOR;
static const ColorRGBA HOVER_DESELECT_COLOR; static const ColorRGBA HOVER_DESELECT_COLOR;
@ -266,18 +259,6 @@ public:
static const ColorRGBA SLA_PAD_COLOR; static const ColorRGBA SLA_PAD_COLOR;
static const ColorRGBA NEUTRAL_COLOR; static const ColorRGBA NEUTRAL_COLOR;
static const std::array<ColorRGBA, 4> MODEL_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;
static const std::array<float, 4> OUTSIDE_COLOR;
static const std::array<float, 4> SELECTED_OUTSIDE_COLOR;
static const std::array<float, 4> DISABLED_COLOR;
static const std::array<float, 4> SLA_SUPPORT_COLOR;
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 enum EHoverState : unsigned char
{ {
@ -288,11 +269,7 @@ public:
}; };
GLVolume(float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f); 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()) {} 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: private:
Geometry::Transformation m_instance_transformation; Geometry::Transformation m_instance_transformation;
@ -328,17 +305,10 @@ private:
SinkingContours m_sinking_contours; SinkingContours m_sinking_contours;
public: public:
#if ENABLE_COLOR_CLASSES
// Color of the triangles / quads held by this volume. // Color of the triangles / quads held by this volume.
ColorRGBA color; ColorRGBA color;
// Color used to render this volume. // Color used to render this volume.
ColorRGBA render_color; 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 { struct CompositeID {
CompositeID(int object_id, int volume_id, int instance_id) : object_id(object_id), volume_id(volume_id), instance_id(instance_id) {} CompositeID(int object_id, int volume_id, int instance_id) : object_id(object_id), volume_id(volume_id), instance_id(instance_id) {}
@ -424,14 +394,8 @@ public:
return out; return out;
} }
#if ENABLE_COLOR_CLASSES
void set_color(const ColorRGBA& rgba) { color = rgba; } void set_color(const ColorRGBA& rgba) { color = rgba; }
void set_render_color(const ColorRGBA& rgba) { render_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 // Sets render color in dependence of current state
void set_render_color(); void set_render_color();
// set color according to model volume // set color according to model volume
@ -631,13 +595,8 @@ public:
int load_wipe_tower_preview( 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); 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_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
GLVolume* new_nontoolpath_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. // 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; void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;

View File

@ -2,9 +2,7 @@
#include "I18N.hpp" #include "I18N.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "GUI.hpp" #include "GUI.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "MainFrame.hpp" #include "MainFrame.hpp"
@ -136,13 +134,8 @@ wxString CopyrightsDialog::get_html_text()
wxColour bgr_clr = wxGetApp().get_window_default_clr();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxColour bgr_clr = wxGetApp().get_window_default_clr();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
const auto text_clr = wxGetApp().get_label_clr_default(); const auto text_clr = wxGetApp().get_label_clr_default();
#if ENABLE_COLOR_CLASSES
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue())); 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())); 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") + "&copy; "; const wxString copyright_str = _L("Copyright") + "&copy; ";
// TRN "Slic3r _is licensed under the_ License" // TRN "Slic3r _is licensed under the_ License"
@ -265,13 +258,8 @@ AboutDialog::AboutDialog()
m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit())); m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
wxFont font = get_default_font(this); wxFont font = get_default_font(this);
const auto text_clr = wxGetApp().get_label_clr_default(); const auto text_clr = wxGetApp().get_label_clr_default();
#if ENABLE_COLOR_CLASSES
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue())); 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())); 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; const int fs = font.GetPointSize()-1;
int size[] = {fs,fs,fs,fs,fs,fs,fs}; int size[] = {fs,fs,fs,fs,fs,fs,fs};

View File

@ -395,23 +395,5 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale); 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;
if (scolor.size() != 7 || scolor.front() != '#')
return false;
const char* c = scolor.data() + 1;
for (size_t i = 0; i < 3; ++i) {
int digit1 = hex_digit_to_int(*c++);
int digit2 = hex_digit_to_int(*c++);
if (digit1 == -1 || digit2 == -1)
return false;
rgb_out[i] = (unsigned char)(digit1 * 16 + digit2);
}
return true;
}
#endif // !ENABLE_COLOR_CLASSES
} // namespace GUI } // namespace GUI
} // namespace Slic3r } // namespace Slic3r

View File

@ -9,9 +9,7 @@
#include <wx/wx.h> #include <wx/wx.h>
#endif #endif
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
struct NSVGimage; struct NSVGimage;
@ -48,17 +46,9 @@ 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* 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); 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); } 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); } 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: private:
std::map<std::string, wxBitmap*> m_map; std::map<std::string, wxBitmap*> m_map;
double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs) double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs)

View File

@ -5,9 +5,7 @@
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "libslic3r/Time.hpp" #include "libslic3r/Time.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "MainFrame.hpp" #include "MainFrame.hpp"
#include "wxExtensions.hpp" #include "wxExtensions.hpp"
@ -34,15 +32,9 @@ static wxString format_reason(const Config::Snapshot::Reason reason)
static std::string get_color(wxColour colour) static std::string get_color(wxColour colour)
{ {
#if ENABLE_COLOR_CLASSES
return encode_color(ColorRGB(colour.Red(), colour.Green(), colour.Blue())); 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
}; };
static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_even, bool snapshot_active, bool dark_mode) static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_even, bool snapshot_active, bool dark_mode)
{ {
// Start by declaring a row with an alternating background color. // Start by declaring a row with an alternating background color.

View File

@ -36,9 +36,7 @@
#include "libslic3r/Config.hpp" #include "libslic3r/Config.hpp"
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
#include "libslic3r/Model.hpp" #include "libslic3r/Model.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "GUI.hpp" #include "GUI.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "GUI_Utils.hpp" #include "GUI_Utils.hpp"
@ -749,15 +747,9 @@ void PageMaterials::set_compatible_printers_html_window(const std::vector<std::s
wxSystemSettings::GetColour(wxSYS_COLOUR_MENU); wxSystemSettings::GetColour(wxSYS_COLOUR_MENU);
#endif #endif
#endif #endif
#if ENABLE_COLOR_CLASSES const auto text_clr = wxGetApp().get_label_clr_default();
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 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())); 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();
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 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; wxString text;
if (all_printers) { if (all_printers) {

View File

@ -2557,7 +2557,6 @@ bool Control::check_ticks_changed_event(Type type)
std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int extruder) 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) { auto opposite_one_color = [](const std::string& color) {
ColorRGB rgb; ColorRGB rgb;
decode_color(color, rgb); decode_color(color, rgb);
@ -2568,16 +2567,11 @@ std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int
ColorRGB rgb2; decode_color(b, rgb2); ColorRGB rgb2; decode_color(b, rgb2);
return encode_color(opposite(rgb1, rgb2)); return encode_color(opposite(rgb1, rgb2));
}; };
#endif // ENABLE_COLOR_CLASSES
if (mode == SingleExtruder && type == ColorChange && m_use_default_colors) { if (mode == SingleExtruder && type == ColorChange && m_use_default_colors) {
#if 1 #if 1
if (ticks.empty()) if (ticks.empty())
#if ENABLE_COLOR_CLASSES
return opposite_one_color((*m_colors)[0]); 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); auto before_tick_it = std::lower_bound(ticks.begin(), ticks.end(), tick);
if (before_tick_it == ticks.end()) { if (before_tick_it == ticks.end()) {
@ -2585,40 +2579,24 @@ std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int
if (--before_tick_it; before_tick_it->type == ColorChange) if (--before_tick_it; before_tick_it->type == ColorChange)
break; break;
if (before_tick_it->type == ColorChange) if (before_tick_it->type == ColorChange)
#if ENABLE_COLOR_CLASSES
return opposite_one_color(before_tick_it->color); return opposite_one_color(before_tick_it->color);
return opposite_one_color((*m_colors)[0]); 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]; const std::string& frst_color = (*m_colors)[0];
if (before_tick_it->type == ColorChange) if (before_tick_it->type == ColorChange)
#if ENABLE_COLOR_CLASSES
return opposite_two_colors(frst_color, before_tick_it->color); 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; auto next_tick_it = before_tick_it;
while (next_tick_it != ticks.end()) while (next_tick_it != ticks.end())
if (++next_tick_it; next_tick_it->type == ColorChange) if (++next_tick_it; next_tick_it->type == ColorChange)
break; break;
if (next_tick_it->type == ColorChange) if (next_tick_it->type == ColorChange)
#if ENABLE_COLOR_CLASSES
return opposite_two_colors(frst_color, next_tick_it->color); return opposite_two_colors(frst_color, next_tick_it->color);
return opposite_one_color(frst_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 = ""; std::string frst_color = "";
@ -2639,27 +2617,15 @@ std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int
if (before_tick_it->type == ColorChange) { if (before_tick_it->type == ColorChange) {
if (frst_color.empty()) if (frst_color.empty())
#if ENABLE_COLOR_CLASSES
return opposite_one_color(before_tick_it->color); return opposite_one_color(before_tick_it->color);
return opposite_two_colors(before_tick_it->color, frst_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 (frst_color.empty())
#if ENABLE_COLOR_CLASSES
return opposite_one_color((*m_colors)[0]); return opposite_one_color((*m_colors)[0]);
return opposite_two_colors((*m_colors)[0], frst_color); 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 #else
const std::vector<std::string>& colors = ColorPrintColors::get(); const std::vector<std::string>& colors = ColorPrintColors::get();
if (ticks.empty()) if (ticks.empty())

View File

@ -3,9 +3,6 @@
#include "libslic3r/CustomGCode.hpp" #include "libslic3r/CustomGCode.hpp"
#include "wxExtensions.hpp" #include "wxExtensions.hpp"
#if !ENABLE_COLOR_CLASSES
#include "DoubleSlider_Utils.hpp"
#endif // !ENABLE_COLOR_CLASSES
#include <wx/window.h> #include <wx/window.h>
#include <wx/control.h> #include <wx/control.h>
@ -121,9 +118,6 @@ class TickCodeInfo
// int m_default_color_idx = 0; // int m_default_color_idx = 0;
std::vector<std::string>* m_colors {nullptr}; 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); std::string get_color_for_tick(TickCode tick, Type type, const int extruder);

View File

@ -4,196 +4,5 @@
#include <stdio.h> #include <stdio.h>
#include <random> #include <random>
#if !ENABLE_COLOR_CLASSES
#include "wx/colour.h"
class ColorGenerator
{
// Some of next code is borrowed from https://stackoverflow.com/questions/3018313/algorithm-to-convert-rgb-to-hsv-and-hsv-to-rgb-in-range-0-255-for-both
typedef struct {
double r; // a fraction between 0 and 1
double g; // a fraction between 0 and 1
double b; // a fraction between 0 and 1
} rgb;
typedef struct {
double h; // angle in degrees
double s; // a fraction between 0 and 1
double v; // a fraction between 0 and 1
} hsv;
//static hsv rgb2hsv(rgb in);
//static rgb hsv2rgb(hsv in);
hsv rgb2hsv(rgb in)
{
hsv out;
double min, max, delta;
min = in.r < in.g ? in.r : in.g;
min = min < in.b ? min : in.b;
max = in.r > in.g ? in.r : in.g;
max = max > in.b ? max : in.b;
out.v = max; // v
delta = max - min;
if (delta < 0.00001)
{
out.s = 0;
out.h = 0; // undefined, maybe nan?
return out;
}
if (max > 0.0) { // NOTE: if Max is == 0, this divide would cause a crash
out.s = (delta / max); // s
}
else {
// if max is 0, then r = g = b = 0
// s = 0, h is undefined
out.s = 0.0;
out.h = NAN; // its now undefined
return out;
}
if (in.r >= max) // > is bogus, just keeps compilor happy
out.h = (in.g - in.b) / delta; // between yellow & magenta
else
if (in.g >= max)
out.h = 2.0 + (in.b - in.r) / delta; // between cyan & yellow
else
out.h = 4.0 + (in.r - in.g) / delta; // between magenta & cyan
out.h *= 60.0; // degrees
if (out.h < 0.0)
out.h += 360.0;
return out;
}
hsv rgb2hsv(const std::string& str_clr_in)
{
wxColour clr(str_clr_in);
rgb in = { clr.Red() / 255.0, clr.Green() / 255.0, clr.Blue() / 255.0 };
return rgb2hsv(in);
}
rgb hsv2rgb(hsv in)
{
double hh, p, q, t, ff;
long i;
rgb out;
if (in.s <= 0.0) { // < is bogus, just shuts up warnings
out.r = in.v;
out.g = in.v;
out.b = in.v;
return out;
}
hh = in.h;
if (hh >= 360.0) hh -= 360.0;//hh = 0.0;
hh /= 60.0;
i = (long)hh;
ff = hh - i;
p = in.v * (1.0 - in.s);
q = in.v * (1.0 - (in.s * ff));
t = in.v * (1.0 - (in.s * (1.0 - ff)));
switch (i) {
case 0:
out.r = in.v;
out.g = t;
out.b = p;
break;
case 1:
out.r = q;
out.g = in.v;
out.b = p;
break;
case 2:
out.r = p;
out.g = in.v;
out.b = t;
break;
case 3:
out.r = p;
out.g = q;
out.b = in.v;
break;
case 4:
out.r = t;
out.g = p;
out.b = in.v;
break;
case 5:
default:
out.r = in.v;
out.g = p;
out.b = q;
break;
}
return out;
}
std::random_device rd;
public:
ColorGenerator() {}
~ColorGenerator() {}
double rand_val()
{
std::mt19937 rand_generator(rd());
// this value will be used for Saturation and Value
// to avoid extremely light/dark colors, take this value from range [0.65; 1.0]
std::uniform_real_distribution<double> distrib(0.65, 1.0);
return distrib(rand_generator);
}
std::string get_opposite_color(const std::string& color)
{
std::string opp_color = "";
hsv hsv_clr = rgb2hsv(color);
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));
opp_color = clr_str.ToStdString();
return opp_color;
}
std::string get_opposite_color(const std::string& color_frst, const std::string& color_scnd)
{
std::string opp_color = "";
hsv hsv_frst = rgb2hsv(color_frst);
hsv hsv_scnd = rgb2hsv(color_scnd);
double delta_h = fabs(hsv_frst.h - hsv_scnd.h);
double start_h = delta_h > 180 ? std::min<double>(hsv_scnd.h, hsv_frst.h) : std::max<double>(hsv_scnd.h, hsv_frst.h);
start_h += 5; // to avoid circle change of colors for 120 deg
if (delta_h < 180)
delta_h = 360 - delta_h;
hsv hsv_opp = hsv{ start_h + 0.5 * delta_h, rand_val(), rand_val() };
rgb rgb_opp_color = hsv2rgb(hsv_opp);
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));
opp_color = clr_str.ToStdString();
return opp_color;
}
};
#endif // !ENABLE_COLOR_CLASSES
#endif // slic3r_GUI_DoubleSlider_Utils_hpp_ #endif // slic3r_GUI_DoubleSlider_Utils_hpp_

View File

@ -1389,14 +1389,8 @@ boost::any& ColourPicker::get_value()
auto colour = static_cast<wxColourPickerCtrl*>(window)->GetColour(); auto colour = static_cast<wxColourPickerCtrl*>(window)->GetColour();
if (colour == wxTransparentColour) if (colour == wxTransparentColour)
m_value = std::string(""); m_value = std::string("");
else { else
#if ENABLE_COLOR_CLASSES
m_value = encode_color(ColorRGB(colour.Red(), colour.Green(), colour.Blue())); 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; return m_value;
} }

View File

@ -47,34 +47,6 @@ static EMoveType buffer_type(unsigned char id) {
return static_cast<EMoveType>(static_cast<unsigned char>(EMoveType::Retract) + 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;
std::array<float, 4> ret = { 0.0f, 0.0f, 0.0f, 1.0f };
const char* c = color.data() + 1;
if (color.size() == 7 && color.front() == '#') {
for (size_t j = 0; j < 3; ++j) {
int digit1 = hex_digit_to_int(*c++);
int digit2 = hex_digit_to_int(*c++);
if (digit1 == -1 || digit2 == -1)
break;
ret[j] = float(digit1 * 16 + digit2) * INV_255;
}
}
return ret;
}
static std::vector<std::array<float, 4>> decode_colors(const std::vector<std::string>& colors) {
std::vector<std::array<float, 4>> output(colors.size(), { 0.0f, 0.0f, 0.0f, 1.0f });
for (size_t i = 0; i < colors.size(); ++i) {
output[i] = decode_color(colors[i]);
}
return output;
}
#endif // !ENABLE_COLOR_CLASSES
// Round to a bin with minimum two digits resolution. // Round to a bin with minimum two digits resolution.
// Equivalent to conversion to string with sprintf(buf, "%.2g", value) and conversion back to float, but faster. // Equivalent to conversion to string with sprintf(buf, "%.2g", value) and conversion back to float, but faster.
static float round_to_bin(const float value) static float round_to_bin(const float value)
@ -188,11 +160,7 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessorResult::MoveVertex& move
move.volumetric_rate(), move.extruder_id, move.cp_color_id, { { endpoint, endpoint } } }); 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 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 // Input value scaled to the colors range
const float step = step_size(); const float step = step_size();
@ -204,20 +172,8 @@ 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_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); 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 // 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)); 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);
// Interpolate between the low and high colors to find exactly which color the input value should get
Color ret = { 0.0f, 0.0f, 0.0f, 1.0f };
for (unsigned int i = 0; i < 3; ++i) {
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() { GCodeViewer::SequentialRangeCap::~SequentialRangeCap() {
@ -491,11 +447,7 @@ void GCodeViewer::SequentialView::render(float legend_height) const
gcode_window.render(legend_height, bottom, static_cast<uint64_t>(gcode_ids[current.last])); 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{ { 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 { 0.90f, 0.70f, 0.70f, 1.0f }, // erNone
{ 1.00f, 0.90f, 0.30f, 1.0f }, // erPerimeter { 1.00f, 0.90f, 0.30f, 1.0f }, // erPerimeter
{ 1.00f, 0.49f, 0.22f, 1.0f }, // erExternalPerimeter { 1.00f, 0.49f, 0.22f, 1.0f }, // erExternalPerimeter
@ -514,11 +466,7 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
{ 0.00f, 0.00f, 0.00f, 1.0f } // erMixed { 0.00f, 0.00f, 0.00f, 1.0f } // erMixed
}}; }};
#if ENABLE_COLOR_CLASSES
const std::vector<ColorRGBA> GCodeViewer::Options_Colors{ { 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.803f, 0.135f, 0.839f, 1.0f }, // Retractions
{ 0.287f, 0.679f, 0.810f, 1.0f }, // Unretractions { 0.287f, 0.679f, 0.810f, 1.0f }, // Unretractions
{ 0.900f, 0.900f, 0.900f, 1.0f }, // Seams { 0.900f, 0.900f, 0.900f, 1.0f }, // Seams
@ -528,11 +476,7 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Options_Colors {{
{ 0.886f, 0.825f, 0.262f, 1.0f } // CustomGCodes { 0.886f, 0.825f, 0.262f, 1.0f } // CustomGCodes
}}; }};
#if ENABLE_COLOR_CLASSES
const std::vector<ColorRGBA> GCodeViewer::Travel_Colors{ { 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.219f, 0.282f, 0.609f, 1.0f }, // Move
{ 0.112f, 0.422f, 0.103f, 1.0f }, // Extrude { 0.112f, 0.422f, 0.103f, 1.0f }, // Extrude
{ 0.505f, 0.064f, 0.028f, 1.0f } // Retract { 0.505f, 0.064f, 0.028f, 1.0f } // Retract
@ -540,11 +484,7 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Travel_Colors {{
#if 1 #if 1
// Normal ranges // Normal ranges
#if ENABLE_COLOR_CLASSES
const std::vector<ColorRGBA> GCodeViewer::Range_Colors{ { 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.043f, 0.173f, 0.478f, 1.0f }, // bluish
{ 0.075f, 0.349f, 0.522f, 1.0f }, { 0.075f, 0.349f, 0.522f, 1.0f },
{ 0.110f, 0.533f, 0.569f, 1.0f }, { 0.110f, 0.533f, 0.569f, 1.0f },
@ -559,11 +499,7 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors {{
}}; }};
#else #else
// Detailed ranges // Detailed ranges
#if ENABLE_COLOR_CLASSES
const std::vector<ColorRGBA> GCodeViewer::Range_Colors{ { 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.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.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 }, { 0.075f, 0.349f, 0.522f, 1.0f },
@ -588,13 +524,8 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors{ {
} }; } };
#endif #endif
#if ENABLE_COLOR_CLASSES
const ColorRGBA GCodeViewer::Wipe_Color = ColorRGBA::YELLOW(); const ColorRGBA GCodeViewer::Wipe_Color = ColorRGBA::YELLOW();
const ColorRGBA GCodeViewer::Neutral_Color = ColorRGBA::DARK_GRAY(); 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() GCodeViewer::GCodeViewer()
{ {
@ -765,31 +696,17 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
if (m_view_type == EViewType::Tool && !gcode_result.extruder_colors.empty()) if (m_view_type == EViewType::Tool && !gcode_result.extruder_colors.empty())
// update tool colors from config stored in the gcode // update tool colors from config stored in the gcode
#if ENABLE_COLOR_CLASSES
decode_colors(gcode_result.extruder_colors, m_tool_colors); decode_colors(gcode_result.extruder_colors, m_tool_colors);
#else
m_tool_colors = decode_colors(gcode_result.extruder_colors);
#endif // ENABLE_COLOR_CLASSES
else else
// update tool colors // update tool colors
#if ENABLE_COLOR_CLASSES
decode_colors(str_tool_colors, m_tool_colors); 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; ColorRGBA default_color;
decode_color("#FF8000", default_color); decode_color("#FF8000", default_color);
#endif // ENABLE_COLOR_CLASSES
// ensure there are enough colors defined // ensure there are enough colors defined
while (m_tool_colors.size() < std::max(size_t(1), gcode_result.extruders_count)) 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); 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 // update ranges for coloring / legend
m_extrusions.reset_ranges(); m_extrusions.reset_ranges();
@ -853,11 +770,7 @@ void GCodeViewer::reset()
m_paths_bounding_box = BoundingBoxf3(); m_paths_bounding_box = BoundingBoxf3();
m_max_bounding_box = BoundingBoxf3(); m_max_bounding_box = BoundingBoxf3();
m_max_print_height = 0.0f; m_max_print_height = 0.0f;
#if ENABLE_COLOR_CLASSES
m_tool_colors = std::vector<ColorRGBA>(); m_tool_colors = std::vector<ColorRGBA>();
#else
m_tool_colors = std::vector<Color>();
#endif // ENABLE_COLOR_CLASSES
m_extruders_count = 0; m_extruders_count = 0;
m_extruder_ids = std::vector<unsigned char>(); m_extruder_ids = std::vector<unsigned char>();
m_filament_diameters = std::vector<float>(); m_filament_diameters = std::vector<float>();
@ -1035,11 +948,7 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
return; return;
// collect color information to generate materials // collect color information to generate materials
#if ENABLE_COLOR_CLASSES
std::vector<ColorRGBA> colors; std::vector<ColorRGBA> colors;
#else
std::vector<Color> colors;
#endif // ENABLE_COLOR_CLASSES
for (const RenderPath& path : t_buffer.render_paths) { for (const RenderPath& path : t_buffer.render_paths) {
colors.push_back(path.color); colors.push_back(path.color);
} }
@ -1061,21 +970,12 @@ 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); fprintf(fp, "# Generated by %s-%s based on Slic3r\n", SLIC3R_APP_NAME, SLIC3R_VERSION);
unsigned int colors_count = 1; unsigned int colors_count = 1;
#if ENABLE_COLOR_CLASSES
for (const ColorRGBA& color : colors) { for (const ColorRGBA& color : colors) {
fprintf(fp, "\nnewmtl material_%d\n", colors_count++); fprintf(fp, "\nnewmtl material_%d\n", colors_count++);
fprintf(fp, "Ka 1 1 1\n"); fprintf(fp, "Ka 1 1 1\n");
fprintf(fp, "Kd %g %g %g\n", color.r(), color.g(), color.b()); fprintf(fp, "Kd %g %g %g\n", color.r(), color.g(), color.b());
fprintf(fp, "Ks 0 0 0\n"); 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); fclose(fp);
@ -1134,11 +1034,7 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
} }
size_t i = 0; size_t i = 0;
#if ENABLE_COLOR_CLASSES
for (const ColorRGBA& color : colors) { for (const ColorRGBA& color : colors) {
#else
for (const Color& color : colors) {
#endif // ENABLE_COLOR_CLASSES
// save material triangles to file // save material triangles to file
fprintf(fp, "\nusemtl material_%zu\n", i + 1); fprintf(fp, "\nusemtl material_%zu\n", i + 1);
fprintf(fp, "# triangles material %zu\n", i + 1); fprintf(fp, "# triangles material %zu\n", i + 1);
@ -2200,11 +2096,7 @@ void GCodeViewer::load_shells(const Print& print, bool initialized)
for (GLVolume* volume : m_shells.volumes.volumes) { for (GLVolume* volume : m_shells.volumes.volumes) {
volume->zoom_to_volumes = false; volume->zoom_to_volumes = false;
#if ENABLE_COLOR_CLASSES
volume->color.a(0.25f); volume->color.a(0.25f);
#else
volume->color[3] = 0.25f;
#endif // ENABLE_COLOR_CLASSES
volume->force_native_color = true; volume->force_native_color = true;
volume->set_render_color(); volume->set_render_color();
} }
@ -2217,11 +2109,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
auto extrusion_color = [this](const Path& path) { auto extrusion_color = [this](const Path& path) {
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
Color color;
#endif // ENABLE_COLOR_CLASSES
switch (m_view_type) switch (m_view_type)
{ {
case EViewType::FeatureType: { color = Extrusion_Role_Colors[static_cast<unsigned int>(path.role)]; break; } case EViewType::FeatureType: { color = Extrusion_Role_Colors[static_cast<unsigned int>(path.role)]; break; }
@ -2234,21 +2122,13 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
case EViewType::Tool: { color = m_tool_colors[path.extruder_id]; break; } case EViewType::Tool: { color = m_tool_colors[path.extruder_id]; break; }
case EViewType::ColorPrint: { case EViewType::ColorPrint: {
if (path.cp_color_id >= static_cast<unsigned char>(m_tool_colors.size())) if (path.cp_color_id >= static_cast<unsigned char>(m_tool_colors.size()))
#if ENABLE_COLOR_CLASSES
color = ColorRGBA::GRAY(); color = ColorRGBA::GRAY();
#else
color = { 0.5f, 0.5f, 0.5f, 1.0f };
#endif // ENABLE_COLOR_CLASSES
else else
color = m_tool_colors[path.cp_color_id]; color = m_tool_colors[path.cp_color_id];
break; break;
} }
#if ENABLE_COLOR_CLASSES
default: { color = ColorRGBA::WHITE(); break; } default: { color = ColorRGBA::WHITE(); break; }
#else
default: { color = { 1.0f, 1.0f, 1.0f, 1.0f }; break; }
#endif // ENABLE_COLOR_CLASSES
} }
return color; return color;
@ -2447,11 +2327,7 @@ 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) if (m_sequential_view.current.last < sub_path.first.s_id || sub_path.last.s_id < m_sequential_view.current.first)
continue; continue;
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
Color color;
#endif // ENABLE_COLOR_CLASSES
switch (path.type) switch (path.type)
{ {
case EMoveType::Tool_change: case EMoveType::Tool_change:
@ -3093,11 +2969,7 @@ void GCodeViewer::render_legend(float& legend_height)
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1"; 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, 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 }, 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, double used_filament_m = 0.0, double used_filament_g = 0.0,
std::function<void()> callback = nullptr) { std::function<void()> callback = nullptr) {
@ -3110,37 +2982,21 @@ void GCodeViewer::render_legend(float& legend_height)
default: default:
case EItemType::Rect: { 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 }, 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)); ImGuiWrapper::to_ImU32(color));
#else
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
#endif // ENABLE_COLOR_CLASSES
break; break;
} }
case EItemType::Circle: { case EItemType::Circle: {
ImVec2 center(0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size)); 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); 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; break;
} }
case EItemType::Hexagon: { case EItemType::Hexagon: {
ImVec2 center(0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size)); 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); 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; break;
} }
case EItemType::Line: { 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); 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; break;
} }
} }
@ -3258,11 +3114,7 @@ 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) { 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; 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()); ret.reserve(custom_gcode_per_print_z.size());
for (const auto& item : custom_gcode_per_print_z) { for (const auto& item : custom_gcode_per_print_z) {
@ -3281,16 +3133,11 @@ void GCodeViewer::render_legend(float& legend_height)
const double previous_z = (lower_b == zs.begin()) ? 0.0 : *(--lower_b); const double previous_z = (lower_b == zs.begin()) ? 0.0 : *(--lower_b);
// to avoid duplicate values, check adding values // to avoid duplicate values, check adding values
if (ret.empty() || !(ret.back().second.first == previous_z && ret.back().second.second == current_z)) if (ret.empty() || !(ret.back().second.first == previous_z && ret.back().second.second == current_z)) {
#if ENABLE_COLOR_CLASSES
{
ColorRGBA color; ColorRGBA color;
decode_color(item.color, color); decode_color(item.color, color);
ret.push_back({ color, { previous_z, current_z } }); 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; return ret;
@ -3485,15 +3332,10 @@ void GCodeViewer::render_legend(float& legend_height)
if (need_scrollable) if (need_scrollable)
ImGui::BeginChild("color_prints", { -1.0f, child_height }, false); ImGui::BeginChild("color_prints", { -1.0f, child_height }, false);
if (m_extruders_count == 1) { // single extruder use case 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); 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()); 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.front(), _u8L("Default color")); append_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default color"));
}
else { else {
for (int i = items_cnt; i >= 0; --i) { for (int i = items_cnt; i >= 0; --i) {
// create label for color change item // create label for color change item
@ -3512,11 +3354,7 @@ void GCodeViewer::render_legend(float& legend_height)
else { // multi extruder use case else { // multi extruder use case
// shows only extruders actually used // shows only extruders actually used
for (unsigned char i : m_extruder_ids) { 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); 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()); const int items_cnt = static_cast<int>(cp_values.size());
if (items_cnt == 0) if (items_cnt == 0)
// There are no color changes, but there are some pause print or custom Gcode // There are no color changes, but there are some pause print or custom Gcode
@ -3566,13 +3404,8 @@ void GCodeViewer::render_legend(float& legend_height)
}; };
EType type; EType type;
int extruder_id; int extruder_id;
#if ENABLE_COLOR_CLASSES
ColorRGBA color1; ColorRGBA color1;
ColorRGBA color2; ColorRGBA color2;
#else
Color color1;
Color color2;
#endif // ENABLE_COLOR_CLASSES
Times times; Times times;
std::pair<double, double> used_filament{ 0.0f, 0.0f }; std::pair<double, double> used_filament{ 0.0f, 0.0f };
}; };
@ -3583,11 +3416,7 @@ 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; 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(); int extruders_count = wxGetApp().extruders_edited_cnt();
#if ENABLE_COLOR_CLASSES
std::vector<ColorRGBA> last_color(extruders_count); 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) { for (int i = 0; i < extruders_count; ++i) {
last_color[i] = m_tool_colors[i]; last_color[i] = m_tool_colors[i];
} }
@ -3599,13 +3428,8 @@ void GCodeViewer::render_legend(float& legend_height)
case CustomGCode::PausePrint: { 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; }); 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 (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::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 }); 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); custom_gcode_per_print_z.erase(it);
} }
break; break;
@ -3613,26 +3437,16 @@ void GCodeViewer::render_legend(float& legend_height)
case CustomGCode::ColorChange: { 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; }); 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 (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) }); 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; ColorRGBA color;
decode_color(it->color, color); decode_color(it->color, color);
items.push_back({ PartialTime::EType::ColorChange, it->extruder, last_color[it->extruder - 1], color, time_rec.second }); items.push_back({ PartialTime::EType::ColorChange, it->extruder, last_color[it->extruder - 1], color, time_rec.second });
last_color[it->extruder - 1] = color; 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; last_extruder_id = it->extruder;
custom_gcode_per_print_z.erase(it); custom_gcode_per_print_z.erase(it);
} }
else 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) }); 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; break;
} }
@ -3643,11 +3457,7 @@ void GCodeViewer::render_legend(float& legend_height)
return items; 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) { 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.text(_u8L("Color change"));
ImGui::SameLine(); ImGui::SameLine();
@ -3657,28 +3467,16 @@ void GCodeViewer::render_legend(float& legend_height)
pos.x -= 0.5f * ImGui::GetStyle().ItemSpacing.x; 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 }, 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)); ImGuiWrapper::to_ImU32(color1));
#else
ImGui::GetColorU32({ color1[0], color1[1], color1[2], 1.0f }));
#endif // ENABLE_COLOR_CLASSES
pos.x += icon_size; 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 }, 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)); ImGuiWrapper::to_ImU32(color2));
#else
ImGui::GetColorU32({ color2[0], color2[1], color2[2], 1.0f }));
#endif // ENABLE_COLOR_CLASSES
ImGui::SameLine(offsets[0]); ImGui::SameLine(offsets[0]);
imgui.text(short_time(get_time_dhms(times.second - times.first))); 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) { 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.text(_u8L("Print"));
ImGui::SameLine(); ImGui::SameLine();
@ -3688,11 +3486,7 @@ void GCodeViewer::render_legend(float& legend_height)
pos.x -= 0.5f * ImGui::GetStyle().ItemSpacing.x; 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 }, 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)); ImGuiWrapper::to_ImU32(color));
#else
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
#endif // ENABLE_COLOR_CLASSES
ImGui::SameLine(offsets[0]); ImGui::SameLine(offsets[0]);
imgui.text(short_time(get_time_dhms(times.second))); imgui.text(short_time(get_time_dhms(times.second)));
@ -4109,11 +3903,7 @@ void GCodeViewer::log_memory_used(const std::string& label, int64_t additional)
} }
} }
#if ENABLE_COLOR_CLASSES
ColorRGBA GCodeViewer::option_color(EMoveType move_type) const 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) switch (move_type)
{ {

View File

@ -22,9 +22,6 @@ namespace GUI {
class GCodeViewer class GCodeViewer
{ {
using IBufferType = unsigned short; using IBufferType = unsigned short;
#if !ENABLE_COLOR_CLASSES
using Color = std::array<float, 4>;
#endif // !ENABLE_COLOR_CLASSES
using VertexBuffer = std::vector<float>; using VertexBuffer = std::vector<float>;
using MultiVertexBuffer = std::vector<VertexBuffer>; using MultiVertexBuffer = std::vector<VertexBuffer>;
using IndexBuffer = std::vector<IBufferType>; using IndexBuffer = std::vector<IBufferType>;
@ -33,21 +30,12 @@ class GCodeViewer
using InstanceIdBuffer = std::vector<size_t>; using InstanceIdBuffer = std::vector<size_t>;
using InstancesOffsets = std::vector<Vec3f>; using InstancesOffsets = std::vector<Vec3f>;
#if ENABLE_COLOR_CLASSES
static const std::vector<ColorRGBA> Extrusion_Role_Colors; static const std::vector<ColorRGBA> Extrusion_Role_Colors;
static const std::vector<ColorRGBA> Options_Colors; static const std::vector<ColorRGBA> Options_Colors;
static const std::vector<ColorRGBA> Travel_Colors; static const std::vector<ColorRGBA> Travel_Colors;
static const std::vector<ColorRGBA> Range_Colors; static const std::vector<ColorRGBA> Range_Colors;
static const ColorRGBA Wipe_Color; static const ColorRGBA Wipe_Color;
static const ColorRGBA Neutral_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 enum class EOptionsColors : unsigned char
{ {
@ -132,11 +120,7 @@ class GCodeViewer
// vbo id // vbo id
unsigned int vbo{ 0 }; unsigned int vbo{ 0 };
// Color to apply to the instances // Color to apply to the instances
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
Color color;
#endif // ENABLE_COLOR_CLASSES
}; };
std::vector<Range> ranges; std::vector<Range> ranges;
@ -258,11 +242,7 @@ class GCodeViewer
// Index of the parent tbuffer // Index of the parent tbuffer
unsigned char tbuffer_id; unsigned char tbuffer_id;
// Render path property // Render path property
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
Color color;
#endif // ENABLE_COLOR_CLASSES
// Index of the buffer in TBuffer::indices // Index of the buffer in TBuffer::indices
unsigned int ibuffer_id; unsigned int ibuffer_id;
// Render path content // Render path content
@ -282,19 +262,10 @@ class GCodeViewer
bool operator() (const RenderPath &l, const RenderPath &r) const { bool operator() (const RenderPath &l, const RenderPath &r) const {
if (l.tbuffer_id < r.tbuffer_id) if (l.tbuffer_id < r.tbuffer_id)
return true; return true;
#if ENABLE_COLOR_CLASSES
if (l.color < r.color) if (l.color < r.color)
return true; return true;
else if (l.color > r.color) else if (l.color > r.color)
return false; 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; return l.ibuffer_id < r.ibuffer_id;
} }
}; };
@ -325,11 +296,7 @@ class GCodeViewer
struct Model struct Model
{ {
GLModel model; GLModel model;
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
Color color;
#endif // ENABLE_COLOR_CLASSES
InstanceVBuffer instances; InstanceVBuffer instances;
GLModel::InitializationData data; GLModel::InitializationData data;
@ -429,11 +396,7 @@ class GCodeViewer
void reset() { min = FLT_MAX; max = -FLT_MAX; count = 0; } 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); } 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; ColorRGBA get_color_at(float value) const;
#else
Color get_color_at(float value) const;
#endif // ENABLE_COLOR_CLASSES
}; };
struct Ranges struct Ranges
@ -525,11 +488,7 @@ class GCodeViewer
TBuffer* buffer{ nullptr }; TBuffer* buffer{ nullptr };
unsigned int ibo{ 0 }; unsigned int ibo{ 0 };
unsigned int vbo{ 0 }; unsigned int vbo{ 0 };
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
Color color;
#endif // ENABLE_COLOR_CLASSES
~SequentialRangeCap(); ~SequentialRangeCap();
bool is_renderable() const { return buffer != nullptr; } bool is_renderable() const { return buffer != nullptr; }
@ -733,11 +692,7 @@ private:
// bounding box of toolpaths + marker tools // bounding box of toolpaths + marker tools
BoundingBoxf3 m_max_bounding_box; BoundingBoxf3 m_max_bounding_box;
float m_max_print_height{ 0.0f }; float m_max_print_height{ 0.0f };
#if ENABLE_COLOR_CLASSES
std::vector<ColorRGBA> m_tool_colors; std::vector<ColorRGBA> m_tool_colors;
#else
std::vector<Color> m_tool_colors;
#endif // ENABLE_COLOR_CLASSES
Layers m_layers; Layers m_layers;
std::array<unsigned int, 2> m_layers_z_range; std::array<unsigned int, 2> m_layers_z_range;
std::vector<ExtrusionRole> m_roles; std::vector<ExtrusionRole> m_roles;
@ -832,11 +787,7 @@ private:
} }
bool is_visible(const Path& path) const { return is_visible(path.role); } 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; void log_memory_used(const std::string& label, int64_t additional = 0) const;
#if ENABLE_COLOR_CLASSES
ColorRGBA option_color(EMoveType move_type) const; ColorRGBA option_color(EMoveType move_type) const;
#else
Color option_color(EMoveType move_type) const;
#endif // ENABLE_COLOR_CLASSES
}; };
} // namespace GUI } // namespace GUI

View File

@ -72,18 +72,10 @@
static constexpr const float TRACKBALLSIZE = 0.8f; 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_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 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_DARK_COLOR = { 0.478f, 0.192f, 0.039f };
static const Slic3r::ColorRGB ERROR_BG_LIGHT_COLOR = { 0.753f, 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 // Number of floats
static constexpr const size_t MAX_VERTEX_BUFFER_SIZE = 131072 * 6; // 3.15MB static constexpr const size_t MAX_VERTEX_BUFFER_SIZE = 131072 * 6; // 3.15MB
@ -856,13 +848,8 @@ void GLCanvas3D::SequentialPrintClearance::set_polygons(const Polygons& polygons
void GLCanvas3D::SequentialPrintClearance::render() void GLCanvas3D::SequentialPrintClearance::render()
{ {
#if ENABLE_COLOR_CLASSES
const ColorRGBA FILL_COLOR = { 1.0f, 0.0f, 0.0f, 0.5f }; 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 }; 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"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr) if (shader == nullptr)
@ -4111,11 +4098,6 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
return ret; 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; GLVolumePtrs visible_volumes;
for (GLVolume* vol : volumes.volumes) { for (GLVolume* vol : volumes.volumes) {
@ -4170,11 +4152,7 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
shader->set_uniform("emission_factor", 0.0f); shader->set_uniform("emission_factor", 0.0f);
for (GLVolume* vol : visible_volumes) { 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()); 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 // the volume may have been deactivated by an active gizmo
bool is_active = vol->is_active; bool is_active = vol->is_active;
vol->is_active = true; vol->is_active = true;
@ -4905,34 +4883,20 @@ void GLCanvas3D::_picking_pass()
int volume_id = -1; int volume_id = -1;
int gizmo_id = -1; int gizmo_id = -1;
#if ENABLE_COLOR_CLASSES
std::array<GLubyte, 4> color = { 0, 0, 0, 0 }; 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(); 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(); 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 (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())); 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]) { 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. // Only non-interpolated colors are valid, those have their lowest three bits zeroed.
// we reserve color = (0,0,0) for occluders (as the printbed) // we reserve color = (0,0,0) for occluders (as the printbed)
// volumes' id are shifted by 1 // volumes' id are shifted by 1
// see: _render_volumes_for_picking() // see: _render_volumes_for_picking()
#if ENABLE_COLOR_CLASSES
unsigned int id = picking_encode(color[0], color[1], color[2]); unsigned int id = picking_encode(color[0], color[1], color[2]);
volume_id = id - 1; volume_id = id - 1;
// gizmos' id are instead properly encoded by the color // gizmos' id are instead properly encoded by the color
gizmo_id = id; 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()) { if (0 <= volume_id && volume_id < (int)m_volumes.volumes.size()) {
@ -5048,27 +5012,11 @@ void GLCanvas3D::_render_background() const
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
::glBegin(GL_QUADS); ::glBegin(GL_QUADS);
#if ENABLE_COLOR_CLASSES
::glColor3fv(use_error_color ? ERROR_BG_DARK_COLOR.data(): DEFAULT_BG_DARK_COLOR.data()); ::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);
::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()); ::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);
::glVertex2f(-1.0f, 1.0f); ::glVertex2f(-1.0f, 1.0f);
glsafe(::glEnd()); glsafe(::glEnd());
@ -5351,10 +5299,6 @@ void GLCanvas3D::_render_overlays()
void GLCanvas3D::_render_volumes_for_picking() const void GLCanvas3D::_render_volumes_for_picking() const
{ {
#if !ENABLE_COLOR_CLASSES
static const GLfloat INV_255 = 1.0f / 255.0f;
#endif // !ENABLE_COLOR_CLASSES
// do not cull backfaces to show broken geometry, if any // do not cull backfaces to show broken geometry, if any
glsafe(::glDisable(GL_CULL_FACE)); glsafe(::glDisable(GL_CULL_FACE));
@ -5369,17 +5313,8 @@ void GLCanvas3D::_render_volumes_for_picking() const
// Object picking mode. Render the object with a color encoding the object index. // Object picking mode. Render the object with a color encoding the object index.
// we reserve color = (0,0,0) for occluders (as the printbed) // we reserve color = (0,0,0) for occluders (as the printbed)
// so we shift volumes' id by 1 to get the proper color // so we shift volumes' id by 1 to get the proper color
#if ENABLE_COLOR_CLASSES
const unsigned int id = 1 + volume.second.first; const unsigned int id = 1 + volume.second.first;
glsafe(::glColor4fv(picking_decode(id).data())); 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));
#endif // ENABLE_COLOR_CLASSES
volume.first->render(); volume.first->render();
} }
} }
@ -5799,11 +5734,7 @@ void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
if (!print->has_skirt() && !print->has_brim()) if (!print->has_skirt() && !print->has_brim())
return; return;
#if ENABLE_COLOR_CLASSES
const ColorRGBA color = ColorRGBA::GREENISH(); 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 // number of skirt layers
size_t total_layer_count = 0; size_t total_layer_count = 0;
@ -5850,12 +5781,8 @@ 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) 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; std::vector<ColorRGBA> tool_colors;
decode_colors(str_tool_colors, 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 struct Ctxt
{ {
@ -5864,35 +5791,20 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
bool has_perimeters; bool has_perimeters;
bool has_infill; bool has_infill;
bool has_support; bool has_support;
#if ENABLE_COLOR_CLASSES
const std::vector<ColorRGBA>* tool_colors; 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; bool is_single_material_print;
int extruders_cnt; int extruders_cnt;
const std::vector<CustomGCode::Item>* color_print_values; const std::vector<CustomGCode::Item>* color_print_values;
#if ENABLE_COLOR_CLASSES
static ColorRGBA color_perimeters() { return ColorRGBA::YELLOW(); } static ColorRGBA color_perimeters() { return ColorRGBA::YELLOW(); }
static ColorRGBA color_infill() { return ColorRGBA::REDISH(); } static ColorRGBA color_infill() { return ColorRGBA::REDISH(); }
static ColorRGBA color_support() { return ColorRGBA::GREENISH(); } static ColorRGBA color_support() { return ColorRGBA::GREENISH(); }
static ColorRGBA color_pause_or_custom_code() { return ColorRGBA::GRAY(); } 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. // For cloring by a tool, return a parsed color.
bool color_by_tool() const { return tool_colors != nullptr; } bool color_by_tool() const { return tool_colors != nullptr; }
size_t number_tools() const { return color_by_tool() ? tool_colors->size() : 0; } 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]; } 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. // For coloring by a color_print(M600), return a parsed color.
bool color_by_color_print() const { return color_print_values!=nullptr; } bool color_by_color_print() const { return color_print_values!=nullptr; }
@ -6032,11 +5944,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
//FIXME Improve the heuristics for a grain size. //FIXME Improve the heuristics for a grain size.
size_t grain_size = std::max(ctxt.layers.size() / 16, size_t(1)); size_t grain_size = std::max(ctxt.layers.size() / 16, size_t(1));
tbb::spin_mutex new_volume_mutex; tbb::spin_mutex new_volume_mutex;
#if ENABLE_COLOR_CLASSES
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) { 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. // Allocate the volume before locking.
GLVolume *volume = new GLVolume(color); GLVolume *volume = new GLVolume(color);
volume->is_extrusion_path = true; volume->is_extrusion_path = true;
@ -6177,38 +6085,22 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
if (!print->is_step_done(psWipeTower)) if (!print->is_step_done(psWipeTower))
return; return;
#if ENABLE_COLOR_CLASSES
std::vector<ColorRGBA> tool_colors; std::vector<ColorRGBA> tool_colors;
decode_colors(str_tool_colors, 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 struct Ctxt
{ {
const Print *print; const Print *print;
#if ENABLE_COLOR_CLASSES
const std::vector<ColorRGBA>* tool_colors; const std::vector<ColorRGBA>* tool_colors;
#else
const std::vector<std::array<float, 4>>* tool_colors;
#endif // ENABLE_COLOR_CLASSES
Vec2f wipe_tower_pos; Vec2f wipe_tower_pos;
float wipe_tower_angle; float wipe_tower_angle;
#if ENABLE_COLOR_CLASSES
static ColorRGBA color_support() { return ColorRGBA::GREENISH(); } 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. // For cloring by a tool, return a parsed color.
bool color_by_tool() const { return tool_colors != nullptr; } bool color_by_tool() const { return tool_colors != nullptr; }
size_t number_tools() const { return this->color_by_tool() ? tool_colors->size() : 0; } 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]; } 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 { 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; return this->color_by_tool() ? std::min<int>(this->number_tools() - 1, std::max<int>(tool, 0)) : feature;
} }
@ -6240,11 +6132,7 @@ 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 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)); size_t grain_size = std::max(n_items / 128, size_t(1));
tbb::spin_mutex new_volume_mutex; tbb::spin_mutex new_volume_mutex;
#if ENABLE_COLOR_CLASSES
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) { 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); auto *volume = new GLVolume(color);
volume->is_extrusion_path = true; volume->is_extrusion_path = true;
tbb::spin_mutex::scoped_lock lock; tbb::spin_mutex::scoped_lock lock;
@ -6363,11 +6251,7 @@ void GLCanvas3D::_load_sla_shells()
return; return;
auto add_volume = [this](const SLAPrintObject &object, int volume_id, const SLAPrintObject::Instance& instance, 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) { 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)); m_volumes.volumes.emplace_back(new GLVolume(color));
GLVolume& v = *m_volumes.volumes.back(); GLVolume& v = *m_volumes.volumes.back();
#if ENABLE_SMOOTH_NORMALS #if ENABLE_SMOOTH_NORMALS
@ -6429,30 +6313,6 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
_set_warning_notification(warning, show); _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;
std::vector<std::array<float, 4>> output(colors.size(), { 1.0f, 1.0f, 1.0f, 1.0f });
for (size_t i = 0; i < colors.size(); ++i) {
const std::string& color = colors[i];
const char* c = color.data() + 1;
if (color.size() == 7 && color.front() == '#') {
for (size_t j = 0; j < 3; ++j) {
int digit1 = hex_digit_to_int(*c++);
int digit2 = hex_digit_to_int(*c++);
if (digit1 == -1 || digit2 == -1)
break;
output[i][j] = float(digit1 * 16 + digit2) * INV_255;
}
}
}
return output;
}
#endif // !ENABLE_COLOR_CLASSES
void GLCanvas3D::_set_warning_notification(EWarning warning, bool state) void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
{ {
enum ErrorType{ enum ErrorType{

View File

@ -981,10 +981,6 @@ private:
bool _deactivate_arrange_menu(); bool _deactivate_arrange_menu();
float get_overlay_window_width() { return LayersEditing::get_overlay_window_width(); } 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 } // namespace GUI

View File

@ -165,7 +165,6 @@ bool GLModel::init_from_file(const std::string& filename)
return true; return true;
} }
#if ENABLE_COLOR_CLASSES
void GLModel::set_color(int entity_id, const ColorRGBA& color) void GLModel::set_color(int entity_id, const ColorRGBA& color)
{ {
for (size_t i = 0; i < m_render_data.size(); ++i) { for (size_t i = 0; i < m_render_data.size(); ++i) {
@ -173,15 +172,6 @@ void GLModel::set_color(int entity_id, const ColorRGBA& color)
m_render_data[i].color = color; 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) {
if (entity_id == -1 || static_cast<int>(i) == entity_id)
m_render_data[i].color = color;
}
}
#endif // ENABLE_COLOR_CLASSES
void GLModel::reset() void GLModel::reset()
{ {
@ -226,11 +216,7 @@ void GLModel::render() const
if (shader != nullptr) if (shader != nullptr)
shader->set_uniform("uniform_color", data.color); shader->set_uniform("uniform_color", data.color);
else else
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(data.color.data())); 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(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.ibo_id));
glsafe(::glDrawElements(mode, static_cast<GLsizei>(data.indices_count), GL_UNSIGNED_INT, (const void*)0)); glsafe(::glDrawElements(mode, static_cast<GLsizei>(data.indices_count), GL_UNSIGNED_INT, (const void*)0));
@ -290,11 +276,7 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
if (shader != nullptr) if (shader != nullptr)
shader->set_uniform("uniform_color", data.color); shader->set_uniform("uniform_color", data.color);
else else
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(data.color.data())); glsafe(::glColor4fv(data.color.data()));
#else
glsafe(::glColor4fv(data.color.data()));
#endif // ENABLE_COLOR_CLASSES
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, data.vbo_id)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, data.vbo_id));
if (position_id != -1) { if (position_id != -1) {

View File

@ -3,9 +3,7 @@
#include "libslic3r/Point.hpp" #include "libslic3r/Point.hpp"
#include "libslic3r/BoundingBox.hpp" #include "libslic3r/BoundingBox.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include <vector> #include <vector>
#include <string> #include <string>
@ -36,11 +34,7 @@ namespace GUI {
unsigned int vbo_id{ 0 }; unsigned int vbo_id{ 0 };
unsigned int ibo_id{ 0 }; unsigned int ibo_id{ 0 };
size_t indices_count{ 0 }; size_t indices_count{ 0 };
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
std::array<float, 4> color{ 1.0f, 1.0f, 1.0f, 1.0f };
#endif // ENABLE_COLOR_CLASSES
}; };
struct InitializationData struct InitializationData
@ -51,11 +45,7 @@ namespace GUI {
std::vector<Vec3f> positions; std::vector<Vec3f> positions;
std::vector<Vec3f> normals; std::vector<Vec3f> normals;
std::vector<unsigned int> indices; std::vector<unsigned int> indices;
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
std::array<float, 4> color{ 1.0f, 1.0f, 1.0f, 1.0f };
#endif // ENABLE_COLOR_CLASSES
}; };
std::vector<Entity> entities; std::vector<Entity> entities;
@ -85,11 +75,7 @@ namespace GUI {
bool init_from_file(const std::string& filename); bool init_from_file(const std::string& filename);
// if entity_id == -1 set the color of all entities // if entity_id == -1 set the color of all entities
#if ENABLE_COLOR_CLASSES
void set_color(int entity_id, const ColorRGBA& color); 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 reset();
void render() const; void render() const;

View File

@ -4,9 +4,7 @@
#include "3DScene.hpp" #include "3DScene.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "libslic3r/format.hpp" #include "libslic3r/format.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include <boost/nowide/fstream.hpp> #include <boost/nowide/fstream.hpp>
#include <GL/glew.h> #include <GL/glew.h>
@ -309,7 +307,6 @@ void GLShaderProgram::set_uniform(int id, const Vec3d& value) const
set_uniform(id, static_cast<Vec3f>(value.cast<float>())); set_uniform(id, static_cast<Vec3f>(value.cast<float>()));
} }
#if ENABLE_COLOR_CLASSES
void GLShaderProgram::set_uniform(int id, const ColorRGB& value) const void GLShaderProgram::set_uniform(int id, const ColorRGB& value) const
{ {
set_uniform(id, value.data(), 3); set_uniform(id, value.data(), 3);
@ -319,7 +316,6 @@ void GLShaderProgram::set_uniform(int id, const ColorRGBA& value) const
{ {
set_uniform(id, value.data(), 4); set_uniform(id, value.data(), 4);
} }
#endif // ENABLE_COLOR_CLASSES
int GLShaderProgram::get_attrib_location(const char* name) const int GLShaderProgram::get_attrib_location(const char* name) const
{ {

View File

@ -9,10 +9,8 @@
namespace Slic3r { namespace Slic3r {
#if ENABLE_COLOR_CLASSES
class ColorRGB; class ColorRGB;
class ColorRGBA; class ColorRGBA;
#endif // ENABLE_COLOR_CLASSES
class GLShaderProgram class GLShaderProgram
{ {
@ -65,10 +63,8 @@ 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 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 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); } 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 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); } 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, int value) const;
void set_uniform(int id, bool value) const; void set_uniform(int id, bool value) const;
@ -86,10 +82,8 @@ public:
void set_uniform(int id, const Matrix3f& value) const; void set_uniform(int id, const Matrix3f& value) const;
void set_uniform(int id, const Vec3f& value) const; void set_uniform(int id, const Vec3f& value) const;
void set_uniform(int id, const Vec3d& 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 ColorRGB& value) const;
void set_uniform(int id, const ColorRGBA& value) const; void set_uniform(int id, const ColorRGBA& value) const;
#endif // ENABLE_COLOR_CLASSES
// returns -1 if not found // returns -1 if not found
int get_attrib_location(const char* name) const; int get_attrib_location(const char* name) const;

View File

@ -44,9 +44,7 @@
#include "libslic3r/Model.hpp" #include "libslic3r/Model.hpp"
#include "libslic3r/I18N.hpp" #include "libslic3r/I18N.hpp"
#include "libslic3r/PresetBundle.hpp" #include "libslic3r/PresetBundle.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "GUI.hpp" #include "GUI.hpp"
#include "GUI_Utils.hpp" #include "GUI_Utils.hpp"
@ -1583,12 +1581,7 @@ void GUI_App::set_label_clr_modified(const wxColour& clr)
if (m_color_label_modified == clr) if (m_color_label_modified == clr)
return; return;
m_color_label_modified = clr; m_color_label_modified = clr;
#if ENABLE_COLOR_CLASSES
const std::string str = encode_color(ColorRGB(clr.Red(), clr.Green(), clr.Blue())); 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->set("label_clr_modified", str);
app_config->save(); app_config->save();
} }
@ -1598,12 +1591,7 @@ void GUI_App::set_label_clr_sys(const wxColour& clr)
if (m_color_label_sys == clr) if (m_color_label_sys == clr)
return; return;
m_color_label_sys = clr; m_color_label_sys = clr;
#if ENABLE_COLOR_CLASSES
const std::string str = encode_color(ColorRGB(clr.Red(), clr.Green(), clr.Blue())); 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->set("label_clr_sys", str);
app_config->save(); app_config->save();
} }

View File

@ -406,16 +406,6 @@ public:
std::ostream& operator<<(std::ostream &os, const WindowMetrics& metrics); std::ostream& operator<<(std::ostream &os, const WindowMetrics& metrics);
#if !ENABLE_COLOR_CLASSES
inline int 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;
}
#endif // !ENABLE_COLOR_CLASSES
class TaskTimer class TaskTimer
{ {
std::chrono::milliseconds start_timer; std::chrono::milliseconds start_timer;

View File

@ -25,21 +25,9 @@ GLGizmoBase::Grabber::Grabber()
void GLGizmoBase::Grabber::render(bool hover, float size) const void GLGizmoBase::Grabber::render(bool hover, float size) const
{ {
#if ENABLE_COLOR_CLASSES
ColorRGBA render_color = color; ColorRGBA render_color = color;
if (hover) if (hover)
render_color = complementary(render_color); render_color = complementary(render_color);
#else
std::array<float, 4> render_color;
if (hover) {
render_color[0] = (1.0f - color[0]);
render_color[1] = (1.0f - color[1]);
render_color[2] = (1.0f - color[2]);
render_color[3] = color[3];
}
else
render_color = color;
#endif // ENABLE_COLOR_CLASSES
render(size, render_color, false); render(size, render_color, false);
} }
@ -54,11 +42,7 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
return get_half_size(size) * DraggingScaleFactor; return get_half_size(size) * DraggingScaleFactor;
} }
#if ENABLE_COLOR_CLASSES
void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking) const 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()) { if (!cube.is_initialized()) {
// This cannot be done in constructor, OpenGL is not yet // This cannot be done in constructor, OpenGL is not yet
@ -109,13 +93,6 @@ 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) void GLGizmoBase::enable_grabber(unsigned int id)
{ {
if (id < m_grabbers.size()) if (id < m_grabbers.size())
@ -169,29 +146,13 @@ bool GLGizmoBase::update_items_state()
return res; return res;
}; };
#if ENABLE_COLOR_CLASSES
ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const 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; id = BASE_ID - id;
if (m_group_id > -1) if (m_group_id > -1)
id -= m_group_id; id -= m_group_id;
#if ENABLE_COLOR_CLASSES
return picking_decode(id); 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
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
};
#endif // ENABLE_COLOR_CLASSES
} }
void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
@ -219,12 +180,7 @@ void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i) { for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i) {
if (m_grabbers[i].enabled) { if (m_grabbers[i].enabled) {
#if ENABLE_COLOR_CLASSES
m_grabbers[i].color = picking_color_component(i); 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); m_grabbers[i].render_for_picking(mean_size);
} }
} }
@ -261,22 +217,6 @@ std::string GLGizmoBase::get_name(bool include_shortcut) const
return out; 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)
{
// 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;
}
#endif // !ENABLE_COLOR_CLASSES
} // namespace GUI } // namespace GUI
} // namespace Slic3r } // namespace Slic3r

View File

@ -2,9 +2,7 @@
#define slic3r_GLGizmoBase_hpp_ #define slic3r_GLGizmoBase_hpp_
#include "libslic3r/Point.hpp" #include "libslic3r/Point.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "slic3r/GUI/I18N.hpp" #include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/GLModel.hpp" #include "slic3r/GUI/GLModel.hpp"
@ -21,23 +19,11 @@ class ModelObject;
namespace GUI { namespace GUI {
#if ENABLE_COLOR_CLASSES static const ColorRGBA DEFAULT_BASE_COLOR = { 0.625f, 0.625f, 0.625f, 1.0f };
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_DRAG_COLOR = ColorRGBA::WHITE(); static const ColorRGBA DEFAULT_HIGHLIGHT_COLOR = ColorRGBA::ORANGE();
static const ColorRGBA DEFAULT_HIGHLIGHT_COLOR = ColorRGBA::ORANGE(); static const std::array<ColorRGBA, 3> AXES_COLOR = {{ ColorRGBA::X(), ColorRGBA::Y(), ColorRGBA::Z() }};
static const std::array<ColorRGBA, 3> AXES_COLOR = {{ ColorRGBA::X(), ColorRGBA::Y(), ColorRGBA::Z() }}; static const ColorRGBA CONSTRAINED_COLOR = ColorRGBA::GRAY();
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 };
static const std::array<std::array<float, 4>, 3> AXES_COLOR = {{
{ 0.75f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.75f, 0.0f, 1.0f },
{ 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 ImGuiWrapper;
class GLCanvas3D; class GLCanvas3D;
@ -61,11 +47,7 @@ protected:
Vec3d center; Vec3d center;
Vec3d angles; Vec3d angles;
#if ENABLE_COLOR_CLASSES
ColorRGBA color; ColorRGBA color;
#else
std::array<float, 4> color;
#endif // ENABLE_COLOR_CLASSES
bool enabled; bool enabled;
bool dragging; bool dragging;
@ -78,11 +60,7 @@ protected:
float get_dragging_half_size(float size) const; float get_dragging_half_size(float size) const;
private: private:
#if ENABLE_COLOR_CLASSES
void render(float size, const ColorRGBA& render_color, bool picking) const; 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; GLModel cube;
}; };
@ -115,15 +93,9 @@ protected:
unsigned int m_sprite_id; unsigned int m_sprite_id;
int m_hover_id; int m_hover_id;
bool m_dragging; bool m_dragging;
#if ENABLE_COLOR_CLASSES
ColorRGBA m_base_color; ColorRGBA m_base_color;
ColorRGBA m_drag_color; ColorRGBA m_drag_color;
ColorRGBA m_highlight_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; mutable std::vector<Grabber> m_grabbers;
ImGuiWrapper* m_imgui; ImGuiWrapper* m_imgui;
bool m_first_input_window_render; bool m_first_input_window_render;
@ -167,11 +139,7 @@ public:
int get_hover_id() const { return m_hover_id; } int get_hover_id() const { return m_hover_id; }
void set_hover_id(int id); void set_hover_id(int id);
#if ENABLE_COLOR_CLASSES
void set_highlight_color(const ColorRGBA& color) { m_highlight_color = color; } 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 enable_grabber(unsigned int id);
void disable_grabber(unsigned int id); void disable_grabber(unsigned int id);
@ -213,11 +181,8 @@ protected:
// Returns the picking color for the given id, based on the BASE_ID constant // 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) // 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; 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(const BoundingBoxf3& box) const;
void render_grabbers(float size) const; void render_grabbers(float size) const;
void render_grabbers_for_picking(const BoundingBoxf3& box) const; void render_grabbers_for_picking(const BoundingBoxf3& box) const;
@ -232,12 +197,6 @@ private:
bool m_dirty; 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 GUI
} // namespace Slic3r } // namespace Slic3r

View File

@ -23,12 +23,8 @@ namespace GUI {
const double GLGizmoCut::Offset = 10.0; const double GLGizmoCut::Offset = 10.0;
const double GLGizmoCut::Margin = 20.0; const double GLGizmoCut::Margin = 20.0;
#if ENABLE_COLOR_CLASSES
static const ColorRGBA GRABBER_COLOR = ColorRGBA::ORANGE(); static const ColorRGBA GRABBER_COLOR = ColorRGBA::ORANGE();
static const ColorRGBA PLANE_COLOR = { 0.8f, 0.8f, 0.8f, 0.5f }; 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) GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
: GLGizmoBase(parent, icon_filename, sprite_id) : GLGizmoBase(parent, icon_filename, sprite_id)
@ -108,11 +104,7 @@ void GLGizmoCut::on_render()
// Draw the cutting plane // Draw the cutting plane
::glBegin(GL_QUADS); ::glBegin(GL_QUADS);
#if ENABLE_COLOR_CLASSES
::glColor4fv(PLANE_COLOR.data()); ::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(min_x, min_y, plane_center.z());
::glVertex3f(max_x, min_y, plane_center.z()); ::glVertex3f(max_x, min_y, plane_center.z());
::glVertex3f(max_x, max_y, plane_center.z()); ::glVertex3f(max_x, max_y, plane_center.z());
@ -143,11 +135,7 @@ void GLGizmoCut::on_render()
shader->start_using(); shader->start_using();
shader->set_uniform("emission_factor", 0.1f); shader->set_uniform("emission_factor", 0.1f);
#if ENABLE_COLOR_CLASSES
m_grabbers[0].color = GRABBER_COLOR; 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)); m_grabbers[0].render(m_hover_id == 0, (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0));
shader->stop_using(); shader->stop_using();

View File

@ -13,9 +13,6 @@ class GLGizmoCut : public GLGizmoBase
{ {
static const double Offset; static const double Offset;
static const double Margin; 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_cut_z{ 0.0 };
double m_max_z{ 0.0 }; double m_max_z{ 0.0 };

View File

@ -13,10 +13,8 @@
namespace Slic3r { namespace Slic3r {
namespace GUI { 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_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 }; 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) GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
: GLGizmoBase(parent, icon_filename, sprite_id) : GLGizmoBase(parent, icon_filename, sprite_id)
@ -78,15 +76,7 @@ void GLGizmoFlatten::on_render()
if (this->is_plane_update_necessary()) if (this->is_plane_update_necessary())
update_planes(); update_planes();
for (int i = 0; i < (int)m_planes.size(); ++i) { 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())); 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()) if (m_planes[i].vbo.has_VBOs())
m_planes[i].vbo.render(); m_planes[i].vbo.render();
} }
@ -112,11 +102,7 @@ void GLGizmoFlatten::on_render_for_picking()
if (this->is_plane_update_necessary()) if (this->is_plane_update_necessary())
update_planes(); update_planes();
for (int i = 0; i < (int)m_planes.size(); ++i) { for (int i = 0; i < (int)m_planes.size(); ++i) {
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(picking_color_component(i).data())); glsafe(::glColor4fv(picking_color_component(i).data()));
#else
glsafe(::glColor4fv(picking_color_component(i).data()));
#endif // ENABLE_COLOR_CLASSES
m_planes[i].vbo.render(); m_planes[i].vbo.render();
} }
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());

View File

@ -116,11 +116,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift())); glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift()));
glsafe(::glMultMatrixd(instance_matrix.data())); glsafe(::glMultMatrixd(instance_matrix.data()));
#if ENABLE_COLOR_CLASSES
ColorRGBA render_color; 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; const sla::DrainHoles& drain_holes = m_c->selection_info()->model_object()->sla_drain_holes;
size_t cache_size = drain_holes.size(); size_t cache_size = drain_holes.size();
@ -132,14 +128,8 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
continue; continue;
// First decide about the color of the point. // First decide about the color of the point.
if (picking) { if (picking)
#if ENABLE_COLOR_CLASSES
render_color = picking_color_component(i); render_color = picking_color_component(i);
#else
std::array<float, 4> color = picking_color_component(i);
render_color = color;
#endif // ENABLE_COLOR_CLASSES
}
else { else {
if (size_t(m_hover_id) == i) if (size_t(m_hover_id) == i)
render_color = {0.0f, 1.0f, 1.0f, 1.0f}; render_color = {0.0f, 1.0f, 1.0f, 1.0f};
@ -148,16 +138,8 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
m_c->hollowed_mesh()->get_drainholes()[i].failed) { m_c->hollowed_mesh()->get_drainholes()[i].failed) {
render_color = {1.0f, 0.0f, 0.0f, 0.5f}; render_color = {1.0f, 0.0f, 0.0f, 0.5f};
} }
else { // neither 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); 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
}
} }
const_cast<GLModel*>(&m_cylinder)->set_color(-1, render_color); const_cast<GLModel*>(&m_cylinder)->set_color(-1, render_color);

View File

@ -56,29 +56,12 @@ bool GLGizmoMmuSegmentation::on_is_activable() const
return GLGizmoPainterBase::on_is_activable() && wxGetApp().extruders_edited_cnt() > 1; return GLGizmoPainterBase::on_is_activable() && wxGetApp().extruders_edited_cnt() > 1;
} }
#if ENABLE_COLOR_CLASSES
static std::vector<ColorRGBA> get_extruders_colors() static std::vector<ColorRGBA> get_extruders_colors()
{ {
#else
static std::vector<std::array<float, 4>> get_extruders_colors()
{
unsigned char rgb_color[3] = {};
#endif // ENABLE_COLOR_CLASSES
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config(); std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
#if ENABLE_COLOR_CLASSES
std::vector<ColorRGBA> ret; std::vector<ColorRGBA> ret;
decode_colors(colors, ret); decode_colors(colors, ret);
return 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);
size_t color_idx = &color - &colors.front();
colors_out[color_idx] = {float(rgb_color[0]) / 255.f, float(rgb_color[1]) / 255.f, float(rgb_color[2]) / 255.f, 1.f};
}
return colors_out;
#endif // ENABLE_COLOR_CLASSES
} }
static std::vector<std::string> get_extruders_names() static std::vector<std::string> get_extruders_names()
@ -223,27 +206,14 @@ void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
} }
} }
#if ENABLE_COLOR_CLASSES
static void render_extruders_combo(const std::string& label, static void render_extruders_combo(const std::string& label,
const std::vector<std::string>& extruders, const std::vector<std::string>& extruders,
const std::vector<ColorRGBA>& extruders_colors, const std::vector<ColorRGBA>& extruders_colors,
size_t& selection_idx) 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.empty());
assert(extruders_colors.size() == extruders_colors.size()); 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; 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. // It is necessary to use BeginGroup(). Otherwise, when using SameLine() is called, then other items will be drawn inside the combobox.
ImGui::BeginGroup(); ImGui::BeginGroup();
@ -259,11 +229,7 @@ static void render_extruders_combo(const std::string &labe
ImGui::SameLine(); ImGui::SameLine();
ImGuiStyle &style = ImGui::GetStyle(); ImGuiStyle &style = ImGui::GetStyle();
float height = ImGui::GetTextLineHeight(); 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])); 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::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)); ImGui::SetCursorScreenPos(ImVec2(start_position.x + height + height / 2 + style.FramePadding.x, start_position.y));
@ -281,11 +247,7 @@ static void render_extruders_combo(const std::string &labe
ImVec2 p = ImGui::GetCursorScreenPos(); ImVec2 p = ImGui::GetCursorScreenPos();
float height = ImGui::GetTextLineHeight(); 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])); 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::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)); ImGui::SetCursorScreenPos(ImVec2(p.x + height + height / 2 + style.FramePadding.x, p.y));
@ -367,17 +329,10 @@ 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); render_extruders_combo("##first_color_combo", m_original_extruders_names, m_original_extruders_colors, m_first_selected_extruder_idx);
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_COLOR_CLASSES
const ColorRGBA& select_first_color = m_modified_extruders_colors[m_first_selected_extruder_idx]; const ColorRGBA& select_first_color = m_modified_extruders_colors[m_first_selected_extruder_idx];
ImVec4 first_color = ImGuiWrapper::to_ImVec4(select_first_color); 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)) 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); 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 };
#endif // ENABLE_COLOR_CLASSES
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc.at("second_color")); m_imgui->text(m_desc.at("second_color"));
@ -386,17 +341,10 @@ 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); render_extruders_combo("##second_color_combo", m_original_extruders_names, m_original_extruders_colors, m_second_selected_extruder_idx);
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_COLOR_CLASSES
const ColorRGBA& select_second_color = m_modified_extruders_colors[m_second_selected_extruder_idx]; const ColorRGBA& select_second_color = m_modified_extruders_colors[m_second_selected_extruder_idx];
ImVec4 second_color = ImGuiWrapper::to_ImVec4(select_second_color); 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)) 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); 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 };
#endif // ENABLE_COLOR_CLASSES
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f; const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
@ -607,7 +555,6 @@ PainterGizmoType GLGizmoMmuSegmentation::get_painter_type() const
return PainterGizmoType::MMU_SEGMENTATION; return PainterGizmoType::MMU_SEGMENTATION;
} }
#if ENABLE_COLOR_CLASSES
ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_left_button_color() const ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_left_button_color() const
{ {
ColorRGBA color = m_modified_extruders_colors[m_first_selected_extruder_idx]; ColorRGBA color = m_modified_extruders_colors[m_first_selected_extruder_idx];
@ -621,19 +568,6 @@ ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const
color.a(0.25f); color.a(0.25f);
return color; 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];
return {color[0], color[1], color[2], 0.25f};
}
std::array<float, 4> GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const
{
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) void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
{ {

View File

@ -62,13 +62,8 @@ public:
class TriangleSelectorMmGui : public TriangleSelectorGUI { class TriangleSelectorMmGui : public TriangleSelectorGUI {
public: 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. // 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) 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)) {} : 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; ~TriangleSelectorMmGui() override = default;
// Render current selection. Transformation matrices are supposed // Render current selection. Transformation matrices are supposed
@ -78,13 +73,8 @@ public:
private: private:
void update_render_data(); void update_render_data();
#if ENABLE_COLOR_CLASSES
const std::vector<ColorRGBA>& m_colors; const std::vector<ColorRGBA>& m_colors;
const ColorRGBA m_default_volume_color; 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; GLMmSegmentationGizmo3DScene m_gizmo_scene;
}; };
@ -110,13 +100,8 @@ public:
const float get_cursor_radius_min() const override { return CursorRadiusMin; } const float get_cursor_radius_min() const override { return CursorRadiusMin; }
protected: protected:
#if ENABLE_COLOR_CLASSES
ColorRGBA get_cursor_sphere_left_button_color() const override; ColorRGBA get_cursor_sphere_left_button_color() const override;
ColorRGBA get_cursor_sphere_right_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_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); } EnforcerBlockerType get_right_button_state_type() const override { return EnforcerBlockerType(m_second_selected_extruder_idx + 1); }
@ -136,13 +121,8 @@ protected:
size_t m_first_selected_extruder_idx = 0; size_t m_first_selected_extruder_idx = 0;
size_t m_second_selected_extruder_idx = 1; size_t m_second_selected_extruder_idx = 1;
std::vector<std::string> m_original_extruders_names; std::vector<std::string> m_original_extruders_names;
#if ENABLE_COLOR_CLASSES
std::vector<ColorRGBA> m_original_extruders_colors; std::vector<ColorRGBA> m_original_extruders_colors;
std::vector<ColorRGBA> m_modified_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; std::vector<int> m_original_volumes_extruder_idxs;
static const constexpr float CursorRadiusMin = 0.1f; // cannot be zero static const constexpr float CursorRadiusMin = 0.1f; // cannot be zero

View File

@ -117,11 +117,7 @@ void GLGizmoMove3D::on_render()
// draw axes // draw axes
for (unsigned int i = 0; i < 3; ++i) { for (unsigned int i = 0; i < 3; ++i) {
if (m_grabbers[i].enabled) { if (m_grabbers[i].enabled) {
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(AXES_COLOR[i].data())); glsafe(::glColor4fv(AXES_COLOR[i].data()));
#else
glsafe(::glColor4fv(AXES_COLOR[i].data()));
#endif // ENABLE_COLOR_CLASSES
::glBegin(GL_LINES); ::glBegin(GL_LINES);
::glVertex3dv(center.data()); ::glVertex3dv(center.data());
::glVertex3dv(m_grabbers[i].center.data()); ::glVertex3dv(m_grabbers[i].center.data());
@ -138,11 +134,7 @@ void GLGizmoMove3D::on_render()
} }
else { else {
// draw axis // draw axis
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data())); glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data()));
#else
glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data()));
#endif // ENABLE_COLOR_CLASSES
::glBegin(GL_LINES); ::glBegin(GL_LINES);
::glVertex3dv(center.data()); ::glVertex3dv(center.data());
::glVertex3dv(m_grabbers[m_hover_id].center.data()); ::glVertex3dv(m_grabbers[m_hover_id].center.data());
@ -203,19 +195,9 @@ 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); 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); 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; ColorRGBA color = m_grabbers[axis].color;
if (!picking && m_hover_id != -1) if (!picking && m_hover_id != -1)
color = complementary(color); 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];
color[1] = 1.0f - color[1];
color[2] = 1.0f - color[2];
color[3] = color[3];
}
#endif // ENABLE_COLOR_CLASSES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr) if (shader == nullptr)

View File

@ -207,20 +207,12 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
if (is_left_handed) if (is_left_handed)
glFrontFace(GL_CW); glFrontFace(GL_CW);
#if ENABLE_COLOR_CLASSES
ColorRGBA render_color = { 0.0f, 0.0f, 0.0f, 0.25f }; 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) if (m_button_down == Button::Left)
render_color = this->get_cursor_sphere_left_button_color(); render_color = this->get_cursor_sphere_left_button_color();
else if (m_button_down == Button::Right) else if (m_button_down == Button::Right)
render_color = this->get_cursor_sphere_right_button_color(); render_color = this->get_cursor_sphere_right_button_color();
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(render_color.data())); glsafe(::glColor4fv(render_color.data()));
#else
glsafe(::glColor4fv(render_color.data()));
#endif // ENABLE_COLOR_CLASSES
assert(s_sphere != nullptr); assert(s_sphere != nullptr);
s_sphere->render(); s_sphere->render();
@ -717,27 +709,15 @@ 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}); 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) ColorRGBA TriangleSelectorGUI::get_seed_fill_color(const ColorRGBA& base_color)
{ {
return saturate(base_color, 0.75f); 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 };
}
#endif // ENABLE_COLOR_CLASSES
void TriangleSelectorGUI::render(ImGuiWrapper* imgui) 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 enforcers_color = { 0.47f, 0.47f, 1.0f, 1.0f };
static const ColorRGBA blockers_color = { 1.0f, 0.44f, 0.44f, 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) { if (m_update_render_data) {
update_render_data(); update_render_data();
@ -761,15 +741,9 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
for (auto &iva : m_iva_seed_fills) for (auto &iva : m_iva_seed_fills)
if (iva.has_VBOs()) { if (iva.has_VBOs()) {
size_t color_idx = &iva - &m_iva_seed_fills.front(); 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 : const ColorRGBA& color = TriangleSelectorGUI::get_seed_fill_color(color_idx == 1 ? enforcers_color :
color_idx == 2 ? blockers_color : color_idx == 2 ? blockers_color :
GLVolume::NEUTRAL_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); shader->set_uniform("uniform_color", color);
iva.render(); iva.render();
} }

View File

@ -86,11 +86,7 @@ public:
protected: protected:
bool m_update_render_data = false; bool m_update_render_data = false;
#if ENABLE_COLOR_CLASSES
static ColorRGBA get_seed_fill_color(const ColorRGBA& base_color); 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: private:
void update_render_data(); void update_render_data();
@ -139,13 +135,8 @@ protected:
virtual void update_model_object() const = 0; virtual void update_model_object() const = 0;
virtual void update_from_model_object() = 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_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 }; } 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_left_button_state_type() const { return EnforcerBlockerType::ENFORCER; }
virtual EnforcerBlockerType get_right_button_state_type() const { return EnforcerBlockerType::BLOCKER; } virtual EnforcerBlockerType get_right_button_state_type() const { return EnforcerBlockerType::BLOCKER; }

View File

@ -137,11 +137,7 @@ void GLGizmoRotate::on_render()
transform_to_local(selection); transform_to_local(selection);
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f)); 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())); 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(); render_circle();
@ -151,11 +147,7 @@ void GLGizmoRotate::on_render()
render_reference_radius(); render_reference_radius();
} }
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_highlight_color.data())); glsafe(::glColor4fv(m_highlight_color.data()));
#else
glsafe(::glColor4fv(m_highlight_color.data()));
#endif // ENABLE_COLOR_CLASSES
if (m_hover_id != -1) if (m_hover_id != -1)
render_angle(); render_angle();
@ -306,11 +298,7 @@ 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].center = Vec3d(::cos(m_angle) * grabber_radius, ::sin(m_angle) * grabber_radius, 0.0);
m_grabbers[0].angles(2) = m_angle; 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())); 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); ::glBegin(GL_LINES);
::glVertex3f(0.0f, 0.0f, 0.0f); ::glVertex3f(0.0f, 0.0f, 0.0f);
@ -326,18 +314,9 @@ 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); 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); 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; ColorRGBA color = m_grabbers[0].color;
if (!picking && m_hover_id != -1) if (!picking && m_hover_id != -1)
color = complementary(color); 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"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr) if (shader == nullptr)

View File

@ -209,34 +209,18 @@ void GLGizmoScale3D::on_render()
if (m_hover_id == -1) { if (m_hover_id == -1) {
// draw connections // draw connections
if (m_grabbers[0].enabled && m_grabbers[1].enabled) { if (m_grabbers[0].enabled && m_grabbers[1].enabled) {
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_grabbers[0].color.data())); glsafe(::glColor4fv(m_grabbers[0].color.data()));
#else
glsafe(::glColor4fv(m_grabbers[0].color.data()));
#endif // ENABLE_COLOR_CLASSES
render_grabbers_connection(0, 1); render_grabbers_connection(0, 1);
} }
if (m_grabbers[2].enabled && m_grabbers[3].enabled) { if (m_grabbers[2].enabled && m_grabbers[3].enabled) {
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_grabbers[2].color.data())); glsafe(::glColor4fv(m_grabbers[2].color.data()));
#else
glsafe(::glColor4fv(m_grabbers[2].color.data()));
#endif // ENABLE_COLOR_CLASSES
render_grabbers_connection(2, 3); render_grabbers_connection(2, 3);
} }
if (m_grabbers[4].enabled && m_grabbers[5].enabled) { if (m_grabbers[4].enabled && m_grabbers[5].enabled) {
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_grabbers[4].color.data())); glsafe(::glColor4fv(m_grabbers[4].color.data()));
#else
glsafe(::glColor4fv(m_grabbers[4].color.data()));
#endif // ENABLE_COLOR_CLASSES
render_grabbers_connection(4, 5); render_grabbers_connection(4, 5);
} }
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_base_color.data())); 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(6, 7);
render_grabbers_connection(7, 8); render_grabbers_connection(7, 8);
render_grabbers_connection(8, 9); render_grabbers_connection(8, 9);
@ -246,11 +230,7 @@ void GLGizmoScale3D::on_render()
} }
else if (m_hover_id == 0 || m_hover_id == 1) { else if (m_hover_id == 0 || m_hover_id == 1) {
// draw connection // draw connection
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_grabbers[0].color.data())); glsafe(::glColor4fv(m_grabbers[0].color.data()));
#else
glsafe(::glColor4fv(m_grabbers[0].color.data()));
#endif // ENABLE_COLOR_CLASSES
render_grabbers_connection(0, 1); render_grabbers_connection(0, 1);
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
@ -265,11 +245,7 @@ void GLGizmoScale3D::on_render()
} }
else if (m_hover_id == 2 || m_hover_id == 3) { else if (m_hover_id == 2 || m_hover_id == 3) {
// draw connection // draw connection
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_grabbers[2].color.data())); glsafe(::glColor4fv(m_grabbers[2].color.data()));
#else
glsafe(::glColor4fv(m_grabbers[2].color.data()));
#endif // ENABLE_COLOR_CLASSES
render_grabbers_connection(2, 3); render_grabbers_connection(2, 3);
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
@ -284,11 +260,7 @@ void GLGizmoScale3D::on_render()
} }
else if (m_hover_id == 4 || m_hover_id == 5) { else if (m_hover_id == 4 || m_hover_id == 5) {
// draw connection // draw connection
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_grabbers[4].color.data())); glsafe(::glColor4fv(m_grabbers[4].color.data()));
#else
glsafe(::glColor4fv(m_grabbers[4].color.data()));
#endif // ENABLE_COLOR_CLASSES
render_grabbers_connection(4, 5); render_grabbers_connection(4, 5);
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
@ -303,11 +275,7 @@ void GLGizmoScale3D::on_render()
} }
else if (m_hover_id >= 6) { else if (m_hover_id >= 6) {
// draw connection // draw connection
#if ENABLE_COLOR_CLASSES
glsafe(::glColor4fv(m_drag_color.data())); 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(6, 7);
render_grabbers_connection(7, 8); render_grabbers_connection(7, 8);
render_grabbers_connection(8, 9); render_grabbers_connection(8, 9);

View File

@ -144,11 +144,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glsafe(::glTranslated(0.0, 0.0, z_shift)); glsafe(::glTranslated(0.0, 0.0, z_shift));
glsafe(::glMultMatrixd(instance_matrix.data())); glsafe(::glMultMatrixd(instance_matrix.data()));
#if ENABLE_COLOR_CLASSES
ColorRGBA render_color; ColorRGBA render_color;
#else
std::array<float, 4> render_color;
#endif // ENABLE_COLOR_CLASSES
for (size_t i = 0; i < cache_size; ++i) { 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 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; const bool& point_selected = m_editing_mode ? m_editing_cache[i].selected : false;
@ -230,14 +226,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
// Now render the drain holes: // Now render the drain holes:
if (has_holes && ! picking) { if (has_holes && ! picking) {
#if ENABLE_COLOR_CLASSES
render_color = { 0.7f, 0.7f, 0.7f, 0.7f }; 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); const_cast<GLModel*>(&m_cylinder)->set_color(-1, render_color);
if (shader) if (shader)
shader->set_uniform("emission_factor", 0.5f); shader->set_uniform("emission_factor", 0.5f);

View File

@ -216,13 +216,8 @@ void InstancesHider::render_cut() const
if (mv->is_model_part()) if (mv->is_model_part())
glsafe(::glColor3f(0.8f, 0.3f, 0.0f)); glsafe(::glColor3f(0.8f, 0.3f, 0.0f));
else { else {
#if ENABLE_COLOR_CLASSES
const ColorRGBA color = color_from_model_volume(*mv); const ColorRGBA color = color_from_model_volume(*mv);
glsafe(::glColor4fv(color.data())); 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(::glPushAttrib(GL_DEPTH_TEST));
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));

View File

@ -25,9 +25,7 @@
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "3DScene.hpp" #include "3DScene.hpp"
#include "GUI.hpp" #include "GUI.hpp"
#include "I18N.hpp" #include "I18N.hpp"
@ -81,7 +79,6 @@ static const std::map<const wchar_t, std::string> font_icons_extra_large = {
}; };
#if ENABLE_COLOR_CLASSES
const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.33f, 0.33f, 0.33f, 1.0f }; 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_GREY_LIGHT = { 0.4f, 0.4f, 0.4f, 1.0f };
const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.67f, 0.36f, 0.19f, 1.0f }; const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.67f, 0.36f, 0.19f, 1.0f };
@ -90,16 +87,6 @@ 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_BACKGROUND = COL_ORANGE_DARK;
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT; const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = 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() ImGuiWrapper::ImGuiWrapper()
{ {
@ -1024,7 +1011,6 @@ bool ImGuiWrapper::want_any_input() const
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput; return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
} }
#if ENABLE_COLOR_CLASSES
ImU32 ImGuiWrapper::to_ImU32(const ColorRGBA& color) ImU32 ImGuiWrapper::to_ImU32(const ColorRGBA& color)
{ {
return ImGui::GetColorU32({ color.r(), color.g(), color.b(), color.a() }); return ImGui::GetColorU32({ color.r(), color.g(), color.b(), color.a() });
@ -1044,7 +1030,6 @@ ColorRGBA ImGuiWrapper::from_ImVec4(const ImVec4& color)
{ {
return { color.x, color.y, color.z, color.w }; return { color.x, color.y, color.z, color.w };
} }
#endif // ENABLE_COLOR_CLASSES
#ifdef __APPLE__ #ifdef __APPLE__
static const ImWchar ranges_keyboard_shortcuts[] = static const ImWchar ranges_keyboard_shortcuts[] =

View File

@ -9,11 +9,9 @@
#include <wx/string.h> #include <wx/string.h>
#include "libslic3r/Point.hpp" #include "libslic3r/Point.hpp"
#include "libslic3r/Color.hpp"
namespace Slic3r { namespace Slic3r {
#if ENABLE_COLOR_CLASSES
class ColorRGBA;
#endif // ENABLE_COLOR_CLASSES
namespace Search { namespace Search {
struct OptionViewParameters; struct OptionViewParameters;
} // namespace Search } // namespace Search
@ -129,12 +127,10 @@ public:
void set_requires_extra_frame() { m_requires_extra_frame = true; } void set_requires_extra_frame() { m_requires_extra_frame = true; }
void reset_requires_extra_frame() { m_requires_extra_frame = false; } void reset_requires_extra_frame() { m_requires_extra_frame = false; }
#if ENABLE_COLOR_CLASSES
static ImU32 to_ImU32(const ColorRGBA& color); static ImU32 to_ImU32(const ColorRGBA& color);
static ImVec4 to_ImVec4(const ColorRGBA& color); static ImVec4 to_ImVec4(const ColorRGBA& color);
static ColorRGBA from_ImU32(const ImU32& color); static ColorRGBA from_ImU32(const ImU32& color);
static ColorRGBA from_ImVec4(const ImVec4& color); static ColorRGBA from_ImVec4(const ImVec4& color);
#endif // ENABLE_COLOR_CLASSES
static const ImVec4 COL_GREY_DARK; static const ImVec4 COL_GREY_DARK;
static const ImVec4 COL_GREY_LIGHT; static const ImVec4 COL_GREY_LIGHT;

View File

@ -14,9 +14,7 @@
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "GUI.hpp" #include "GUI.hpp"
#include "format.hpp" #include "format.hpp"
#include "I18N.hpp" #include "I18N.hpp"
@ -140,14 +138,9 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont monospace = wxGetApp().code_font(); wxFont monospace = wxGetApp().code_font();
wxColour text_clr = wxGetApp().get_label_clr_default(); wxColour text_clr = wxGetApp().get_label_clr_default();
wxColour bgr_clr = parent->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxColour bgr_clr = parent->GetBackgroundColour();
#if ENABLE_COLOR_CLASSES
auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue())); 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())); 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(); const int font_size = font.GetPointSize();
int size[] = { font_size, font_size, font_size, font_size, font_size, font_size, font_size }; int size[] = { font_size, font_size, font_size, font_size, font_size, font_size, font_size };
html->SetFonts(font.GetFaceName(), monospace.GetFaceName(), size); html->SetFonts(font.GetFaceName(), monospace.GetFaceName(), size);

View File

@ -24,9 +24,7 @@
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
#include "libslic3r/PrintConfig.hpp" #include "libslic3r/PrintConfig.hpp"
#include "libslic3r/PresetBundle.hpp" #include "libslic3r/PresetBundle.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "GUI.hpp" #include "GUI.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
@ -445,25 +443,13 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con
bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp()); 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. // Paint the color bars.
ColorRGB color; ColorRGB color;
decode_color(filament_rgb, 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)); 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 (!is_single_bar) {
#if ENABLE_COLOR_CLASSES
decode_color(extruder_rgb, color); decode_color(extruder_rgb, color);
bmps.emplace_back(bitmap_cache().mksolid(thin_icon_width, icon_height, color, false, 1, dark_mode)); 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. // Paint a lock at the system presets.
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height)); bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
@ -782,15 +768,8 @@ void PlaterPresetComboBox::update()
const Preset* selected_filament_preset = nullptr; const Preset* selected_filament_preset = nullptr;
std::string extruder_color; 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); 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)) 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 is not defined.
extruder_color.clear(); extruder_color.clear();
selected_filament_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_extruder_idx]); selected_filament_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_extruder_idx]);

View File

@ -22,13 +22,9 @@
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
#if ENABLE_COLOR_CLASSES
static const Slic3r::ColorRGBA UNIFORM_SCALE_COLOR = Slic3r::ColorRGBA::ORANGE(); static const Slic3r::ColorRGBA UNIFORM_SCALE_COLOR = Slic3r::ColorRGBA::ORANGE();
static const Slic3r::ColorRGBA SOLID_PLANE_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 }; 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 Slic3r {
namespace GUI { namespace GUI {
@ -456,11 +452,7 @@ void Selection::clear()
for (unsigned int i : m_list) { for (unsigned int i : m_list) {
GLVolume& volume = *(*m_volumes)[i]; GLVolume& volume = *(*m_volumes)[i];
volume.selected = false; volume.selected = false;
#if ENABLE_COLOR_CLASSES
bool is_transparent = volume.color.is_transparent(); bool is_transparent = volume.color.is_transparent();
#else
bool is_transparent = volume.color[3] < 1.0f;
#endif // ENABLE_COLOR_CLASSES
if (is_transparent) if (is_transparent)
volume.force_transparent = true; volume.force_transparent = true;
volume.set_render_color(); volume.set_render_color();
@ -1874,17 +1866,10 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, float* color) cons
glsafe(::glEnd()); glsafe(::glEnd());
} }
#if ENABLE_COLOR_CLASSES
static ColorRGBA get_color(Axis axis) static ColorRGBA get_color(Axis axis)
{ {
return AXES_COLOR[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 void Selection::render_sidebar_position_hints(const std::string& sidebar_field) const
{ {
@ -2014,15 +1999,8 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
::glBegin(GL_QUADS); ::glBegin(GL_QUADS);
#if ENABLE_COLOR_CLASSES
::glColor4fv((camera_on_top && type == 1) || (!camera_on_top && type == 2) ? ::glColor4fv((camera_on_top && type == 1) || (!camera_on_top && type == 2) ?
SOLID_PLANE_COLOR.data() : TRANSPARENT_PLANE_COLOR.data()); 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(min_x, min_y, z1);
::glVertex3f(max_x, min_y, z1); ::glVertex3f(max_x, min_y, z1);
::glVertex3f(max_x, max_y, z1); ::glVertex3f(max_x, max_y, z1);
@ -2030,15 +2008,8 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co
glsafe(::glEnd()); glsafe(::glEnd());
::glBegin(GL_QUADS); ::glBegin(GL_QUADS);
#if ENABLE_COLOR_CLASSES
::glColor4fv((camera_on_top && type == 2) || (!camera_on_top && type == 1) ? ::glColor4fv((camera_on_top && type == 2) || (!camera_on_top && type == 1) ?
SOLID_PLANE_COLOR.data() : TRANSPARENT_PLANE_COLOR.data()); 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(min_x, min_y, z2);
::glVertex3f(max_x, min_y, z2); ::glVertex3f(max_x, min_y, z2);
::glVertex3f(max_x, max_y, z2); ::glVertex3f(max_x, max_y, z2);

View File

@ -4,9 +4,7 @@
#include "libslic3r/BlacklistedLibraryCheck.hpp" #include "libslic3r/BlacklistedLibraryCheck.hpp"
#include "libslic3r/Platform.hpp" #include "libslic3r/Platform.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "slic3r/GUI/format.hpp" #include "slic3r/GUI/format.hpp"
#include "slic3r/Utils/Http.hpp" #include "slic3r/Utils/Http.hpp"
@ -574,13 +572,8 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
wxColour bgr_clr = wxGetApp().get_window_default_clr(); wxColour bgr_clr = wxGetApp().get_window_default_clr();
SetBackgroundColour(bgr_clr); SetBackgroundColour(bgr_clr);
const auto text_clr = wxGetApp().get_label_clr_default(); 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 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())); 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 *topSizer = new wxBoxSizer(wxVERTICAL);
auto *vsizer = new wxBoxSizer(wxVERTICAL); auto *vsizer = new wxBoxSizer(wxVERTICAL);

View File

@ -15,9 +15,7 @@
#include "MainFrame.hpp" #include "MainFrame.hpp"
#include "wxExtensions.hpp" #include "wxExtensions.hpp"
#include "../libslic3r/BlacklistedLibraryCheck.hpp" #include "../libslic3r/BlacklistedLibraryCheck.hpp"
#if ENABLE_COLOR_CLASSES
#include "../libslic3r/Color.hpp" #include "../libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "format.hpp" #include "format.hpp"
#ifdef _WIN32 #ifdef _WIN32
@ -117,13 +115,8 @@ SysInfoDialog::SysInfoDialog()
// main_info_text // main_info_text
wxFont font = get_default_font(this); wxFont font = get_default_font(this);
const auto text_clr = wxGetApp().get_label_clr_default(); 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 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())); 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; 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 }; int size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs };

View File

@ -11,9 +11,7 @@
#include "libslic3r/PrintConfig.hpp" #include "libslic3r/PrintConfig.hpp"
#include "libslic3r/PresetBundle.hpp" #include "libslic3r/PresetBundle.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "format.hpp" #include "format.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "Plater.hpp" #include "Plater.hpp"
@ -61,12 +59,7 @@ static std::string get_icon_name(Preset::Type type, PrinterTechnology pt) {
static std::string def_text_color() static std::string def_text_color()
{ {
wxColour def_colour = wxGetApp().get_label_clr_default(); wxColour def_colour = wxGetApp().get_label_clr_default();
#if ENABLE_COLOR_CLASSES
return encode_color(ColorRGB(def_colour.Red(), def_colour.Green(), def_colour.Blue())); 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 grey = "#808080";
static std::string orange = "#ed6b21"; static std::string orange = "#ed6b21";
@ -131,13 +124,8 @@ wxBitmap ModelNode::get_bitmap(const wxString& color)
const int icon_height = lround(1.6 * em); const int icon_height = lround(1.6 * em);
BitmapCache bmp_cache; BitmapCache bmp_cache;
#if ENABLE_COLOR_CLASSES
ColorRGB rgb; ColorRGB rgb;
decode_color(into_u8(color), 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 // there is no need to scale created solid bitmap
#ifndef __linux__ #ifndef __linux__
return bmp_cache.mksolid(icon_width, icon_height, rgb, true); return bmp_cache.mksolid(icon_width, icon_height, rgb, true);

View File

@ -7,9 +7,7 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "MsgDialog.hpp" #include "MsgDialog.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include <wx/sizer.h> #include <wx/sizer.h>
@ -230,15 +228,9 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
m_number_of_extruders = (int)(sqrt(matrix.size())+0.001); m_number_of_extruders = (int)(sqrt(matrix.size())+0.001);
for (const std::string& color : extruder_colours) { for (const std::string& color : extruder_colours) {
#if ENABLE_COLOR_CLASSES
Slic3r::ColorRGB rgb; Slic3r::ColorRGB rgb;
Slic3r::decode_color(color, rgb); Slic3r::decode_color(color, rgb);
m_colours.push_back(wxColor(rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar())); 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 // Create two switched panels with their own sizers

View File

@ -18,9 +18,7 @@
#include "BitmapComboBox.hpp" #include "BitmapComboBox.hpp"
#include "OG_CustomCtrl.hpp" #include "OG_CustomCtrl.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp" #include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#ifndef __linux__ #ifndef __linux__
// msw_menuitem_bitmaps is used for MSW and OSX // msw_menuitem_bitmaps is used for MSW and OSX
@ -476,10 +474,6 @@ std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
if (colors.empty()) if (colors.empty())
return bmps; 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. /* 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 * So set sizes for solid_colored icons used for filament preset
* and scale them in respect to em_unit value * and scale them in respect to em_unit value
@ -496,18 +490,11 @@ std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
wxBitmap* bitmap = bmp_cache.find(bitmap_key); wxBitmap* bitmap = bmp_cache.find(bitmap_key);
if (bitmap == nullptr) { if (bitmap == nullptr) {
#if ENABLE_COLOR_CLASSES
// Paint the color icon. // Paint the color icon.
Slic3r::ColorRGB rgb; Slic3r::ColorRGB rgb;
Slic3r::decode_color(color, rgb); Slic3r::decode_color(color, rgb);
// there is no neede to scale created solid bitmap // 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)); 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); bmps.emplace_back(bitmap);
} }