Tech ENABLE_COLOR_CLASSES set as default
This commit is contained in:
parent
fab35e8aa4
commit
6201dad245
@ -3,7 +3,6 @@
|
||||
|
||||
#include <random>
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
namespace Slic3r {
|
||||
@ -399,4 +398,3 @@ unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char gr
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
@ -1,8 +1,6 @@
|
||||
#ifndef slic3r_Color_hpp_
|
||||
#define slic3r_Color_hpp_
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
@ -169,6 +167,4 @@ extern unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#endif /* slic3r_Color_hpp_ */
|
||||
|
@ -45,13 +45,4 @@
|
||||
#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_
|
||||
|
@ -19,15 +19,10 @@
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
static const float GROUND_Z = -0.02f;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const Slic3r::ColorRGBA DEFAULT_MODEL_COLOR = Slic3r::ColorRGBA::DARK_GRAY();
|
||||
static const Slic3r::ColorRGBA PICKING_MODEL_COLOR = Slic3r::ColorRGBA::BLACK();
|
||||
static const Slic3r::ColorRGBA DEFAULT_SOLID_GRID_COLOR = { 0.9f, 0.9f, 0.9f, 1.0f };
|
||||
static const Slic3r::ColorRGBA DEFAULT_TRANSPARENT_GRID_COLOR = { 0.9f, 0.9f, 0.9f, 0.6f };
|
||||
#else
|
||||
static const std::array<float, 4> DEFAULT_MODEL_COLOR = { 0.235f, 0.235f, 0.235f, 1.0f };
|
||||
static const std::array<float, 4> PICKING_MODEL_COLOR = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
@ -128,27 +123,15 @@ void Bed3D::Axes::render() const
|
||||
shader->set_uniform("emission_factor", 0.0f);
|
||||
|
||||
// x axis
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::X());
|
||||
#else
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.75f, 0.0f, 0.0f, 1.0f });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }).cast<float>());
|
||||
|
||||
// y axis
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::Y());
|
||||
#else
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.0f, 0.75f, 0.0f, 1.0f });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }).cast<float>());
|
||||
|
||||
// z axis
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, ColorRGBA::Z());
|
||||
#else
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.0f, 0.0f, 0.75f, 1.0f });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_axis(Geometry::assemble_transform(m_origin).cast<float>());
|
||||
|
||||
shader->stop_using();
|
||||
@ -559,11 +542,7 @@ void Bed3D::render_default(bool bottom, bool picking) const
|
||||
if (!has_model && !bottom) {
|
||||
// draw background
|
||||
glsafe(::glDepthMask(GL_FALSE));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(picking ? PICKING_MODEL_COLOR.data() : DEFAULT_MODEL_COLOR.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(picking ? PICKING_MODEL_COLOR.data() : DEFAULT_MODEL_COLOR.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
glsafe(::glNormal3d(0.0f, 0.0f, 1.0f));
|
||||
glsafe(::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_vertices_data()));
|
||||
glsafe(::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount));
|
||||
@ -573,14 +552,7 @@ void Bed3D::render_default(bool bottom, bool picking) const
|
||||
if (!picking) {
|
||||
// draw grid
|
||||
glsafe(::glLineWidth(1.5f * m_scale_factor));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(has_model && !bottom ? DEFAULT_SOLID_GRID_COLOR.data() : DEFAULT_TRANSPARENT_GRID_COLOR.data()));
|
||||
#else
|
||||
if (has_model && !bottom)
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 1.0f));
|
||||
else
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.6f));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
glsafe(::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_gridlines.get_vertices_data()));
|
||||
glsafe(::glDrawArrays(GL_LINES, 0, (GLsizei)m_gridlines.get_vertices_count()));
|
||||
}
|
||||
|
@ -344,7 +344,6 @@ void GLVolume::SinkingContours::update()
|
||||
m_model.reset();
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA GLVolume::SELECTED_COLOR = ColorRGBA::GREEN();
|
||||
const ColorRGBA GLVolume::HOVER_SELECT_COLOR = { 0.4f, 0.9f, 0.1f, 1.0f };
|
||||
const ColorRGBA GLVolume::HOVER_DESELECT_COLOR = { 1.0f, 0.75f, 0.75f, 1.0f };
|
||||
@ -360,23 +359,6 @@ const std::array<ColorRGBA, 4> GLVolume::MODEL_COLOR = { {
|
||||
{ 0.5f, 1.0f, 0.5f, 1.0f },
|
||||
{ 0.5f, 0.5f, 1.0f, 1.0f }
|
||||
} };
|
||||
#else
|
||||
const std::array<float, 4> GLVolume::SELECTED_COLOR = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
const std::array<float, 4> GLVolume::HOVER_SELECT_COLOR = { 0.4f, 0.9f, 0.1f, 1.0f };
|
||||
const std::array<float, 4> GLVolume::HOVER_DESELECT_COLOR = { 1.0f, 0.75f, 0.75f, 1.0f };
|
||||
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)
|
||||
: m_sla_shift_z(0.0)
|
||||
@ -406,23 +388,6 @@ GLVolume::GLVolume(float r, float g, float b, float a)
|
||||
set_render_color(color);
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
void GLVolume::set_color(const std::array<float, 4>& rgba)
|
||||
{
|
||||
color = rgba;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
bool outside = is_outside || is_below_printbed();
|
||||
@ -452,25 +417,13 @@ void GLVolume::set_render_color()
|
||||
set_render_color(color);
|
||||
}
|
||||
|
||||
if (!printable) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
if (!printable)
|
||||
render_color = saturate(render_color, 0.25f);
|
||||
#else
|
||||
render_color[0] /= 4;
|
||||
render_color[1] /= 4;
|
||||
render_color[2] /= 4;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
if (force_transparent)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
render_color.a(color.a());
|
||||
#else
|
||||
render_color[3] = color[3];
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color_from_model_volume(const ModelVolume& model_volume)
|
||||
{
|
||||
ColorRGBA color;
|
||||
@ -488,34 +441,6 @@ ColorRGBA color_from_model_volume(const ModelVolume& model_volume)
|
||||
|
||||
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
|
||||
{
|
||||
@ -673,13 +598,8 @@ int GLVolumeCollection::load_object_volume(
|
||||
const int extruder_id = model_volume->extruder_id();
|
||||
const ModelInstance *instance = model_object->instances[instance_idx];
|
||||
const TriangleMesh &mesh = model_volume->mesh();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color = GLVolume::MODEL_COLOR[((color_by == "volume") ? volume_idx : obj_idx) % 4];
|
||||
color.a(model_volume->is_model_part() ? 1.0f : 0.5f);
|
||||
#else
|
||||
std::array<float, 4> color = GLVolume::MODEL_COLOR[((color_by == "volume") ? volume_idx : obj_idx) % 4];
|
||||
color[3] = model_volume->is_model_part() ? 1.f : 0.5f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
this->volumes.emplace_back(new GLVolume(color));
|
||||
GLVolume& v = *this->volumes.back();
|
||||
v.set_color(color_from_model_volume(*model_volume));
|
||||
@ -760,22 +680,13 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
||||
height = 0.1f;
|
||||
|
||||
TriangleMesh mesh;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color = ColorRGBA::DARK_YELLOW();
|
||||
#else
|
||||
std::array<float, 4> color = { 0.5f, 0.5f, 0.0f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// In case we don't know precise dimensions of the wipe tower yet, we'll draw
|
||||
// the box with different color with one side jagged:
|
||||
if (size_unknown) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
color.r(0.9f);
|
||||
color.g(0.6f);
|
||||
#else
|
||||
color[0] = 0.9f;
|
||||
color[1] = 0.6f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// Too narrow tower would interfere with the teeth. The estimate is not precise anyway.
|
||||
depth = std::max(depth, 10.f);
|
||||
@ -831,22 +742,14 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
||||
return int(volumes.size() - 1);
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
GLVolume* GLVolumeCollection::new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats)
|
||||
#else
|
||||
GLVolume* GLVolumeCollection::new_toolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats)
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
GLVolume *out = new_nontoolpath_volume(rgba, reserve_vbo_floats);
|
||||
out->is_extrusion_path = true;
|
||||
return out;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
GLVolume* GLVolumeCollection::new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats)
|
||||
#else
|
||||
GLVolume* GLVolumeCollection::new_nontoolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats)
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
GLVolume *out = new GLVolume(rgba);
|
||||
out->is_extrusion_path = false;
|
||||
@ -863,11 +766,7 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
|
||||
|
||||
for (unsigned int i = 0; i < (unsigned int)volumes.size(); ++i) {
|
||||
GLVolume* volume = volumes[i];
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
bool is_transparent = volume->render_color.is_transparent();
|
||||
#else
|
||||
bool is_transparent = (volume->render_color[3] < 1.0f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (((type == GLVolumeCollection::ERenderType::Opaque && !is_transparent) ||
|
||||
(type == GLVolumeCollection::ERenderType::Transparent && is_transparent) ||
|
||||
type == GLVolumeCollection::ERenderType::All) &&
|
||||
@ -1046,8 +945,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
|
||||
|
||||
void GLVolumeCollection::reset_outside_state()
|
||||
{
|
||||
for (GLVolume* volume : this->volumes)
|
||||
{
|
||||
for (GLVolume* volume : this->volumes) {
|
||||
if (volume != nullptr)
|
||||
volume->is_outside = false;
|
||||
}
|
||||
@ -1055,54 +953,17 @@ void GLVolumeCollection::reset_outside_state()
|
||||
|
||||
void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* config)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
using ColorItem = std::pair<std::string, ColorRGBA>;
|
||||
std::vector<ColorItem> colors;
|
||||
#else
|
||||
static const float inv_255 = 1.0f / 255.0f;
|
||||
|
||||
struct Color
|
||||
{
|
||||
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) {
|
||||
const std::string& txt_color = config->opt_string("material_colour").empty() ?
|
||||
print_config_def.get("material_colour")->get_default_value<ConfigOptionString>()->value :
|
||||
config->opt_string("material_colour");
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA rgba;
|
||||
if (decode_color(txt_color, rgba))
|
||||
colors.push_back({ txt_color, rgba });
|
||||
#else
|
||||
if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb)) {
|
||||
colors.resize(1);
|
||||
colors[0].set(txt_color, rgb);
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
}
|
||||
else {
|
||||
const ConfigOptionStrings* extruders_opt = dynamic_cast<const ConfigOptionStrings*>(config->option("extruder_colour"));
|
||||
if (extruders_opt == nullptr)
|
||||
@ -1118,7 +979,6 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
||||
colors.resize(colors_count);
|
||||
|
||||
for (unsigned int i = 0; i < colors_count; ++i) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::string& ext_color = config->opt_string("extruder_colour", i);
|
||||
ColorRGBA rgba;
|
||||
if (decode_color(ext_color, rgba))
|
||||
@ -1128,16 +988,6 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
||||
if (decode_color(fil_color, rgba))
|
||||
colors[i] = { fil_color, rgba };
|
||||
}
|
||||
#else
|
||||
const std::string& txt_color = config->opt_string("extruder_colour", i);
|
||||
if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb))
|
||||
colors[i].set(txt_color, rgb);
|
||||
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)
|
||||
extruder_id = 0;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorItem& color = colors[extruder_id];
|
||||
if (!color.first.empty())
|
||||
volume->color = color.second;
|
||||
#else
|
||||
const Color& color = colors[extruder_id];
|
||||
if (!color.text.empty()) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
volume->color[i] = (float)color.rgb[i] * inv_255;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,7 @@
|
||||
#include "libslic3r/TriangleMesh.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Geometry.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "GLModel.hpp"
|
||||
|
||||
@ -46,11 +44,7 @@ class ModelVolume;
|
||||
enum ModelInstanceEPrintVolumeState : unsigned char;
|
||||
|
||||
// Return appropriate color based on the ModelVolume.
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
extern ColorRGBA color_from_model_volume(const ModelVolume& model_volume);
|
||||
#else
|
||||
std::array<float, 4> color_from_model_volume(const ModelVolume& model_volume);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// A container for interleaved arrays of 3D vertices and normals,
|
||||
// possibly indexed by triangles and / or quads.
|
||||
@ -255,7 +249,6 @@ private:
|
||||
|
||||
class GLVolume {
|
||||
public:
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const ColorRGBA SELECTED_COLOR;
|
||||
static const ColorRGBA HOVER_SELECT_COLOR;
|
||||
static const ColorRGBA HOVER_DESELECT_COLOR;
|
||||
@ -266,18 +259,6 @@ public:
|
||||
static const ColorRGBA SLA_PAD_COLOR;
|
||||
static const ColorRGBA NEUTRAL_COLOR;
|
||||
static const std::array<ColorRGBA, 4> MODEL_COLOR;
|
||||
#else
|
||||
static const std::array<float, 4> SELECTED_COLOR;
|
||||
static const std::array<float, 4> HOVER_SELECT_COLOR;
|
||||
static const std::array<float, 4> HOVER_DESELECT_COLOR;
|
||||
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
|
||||
{
|
||||
@ -288,11 +269,7 @@ public:
|
||||
};
|
||||
|
||||
GLVolume(float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
GLVolume(const ColorRGBA& color) : GLVolume(color.r(), color.g(), color.b(), color.a()) {}
|
||||
#else
|
||||
GLVolume(const std::array<float, 4>& rgba) : GLVolume(rgba[0], rgba[1], rgba[2], rgba[3]) {}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
private:
|
||||
Geometry::Transformation m_instance_transformation;
|
||||
@ -328,17 +305,10 @@ private:
|
||||
SinkingContours m_sinking_contours;
|
||||
|
||||
public:
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
// Color of the triangles / quads held by this volume.
|
||||
ColorRGBA color;
|
||||
// Color used to render this volume.
|
||||
ColorRGBA render_color;
|
||||
#else
|
||||
// Color of the triangles / quads held by this volume.
|
||||
std::array<float, 4> color;
|
||||
// Color used to render this volume.
|
||||
std::array<float, 4> render_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
struct CompositeID {
|
||||
CompositeID(int object_id, int volume_id, int instance_id) : object_id(object_id), volume_id(volume_id), instance_id(instance_id) {}
|
||||
@ -424,14 +394,8 @@ public:
|
||||
return out;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_color(const ColorRGBA& rgba) { color = rgba; }
|
||||
void set_render_color(const ColorRGBA& rgba) { render_color = rgba; }
|
||||
#else
|
||||
void set_color(const std::array<float, 4>& rgba);
|
||||
void set_render_color(float r, float g, float b, float a);
|
||||
void set_render_color(const std::array<float, 4>& rgba);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// Sets render color in dependence of current state
|
||||
void set_render_color();
|
||||
// set color according to model volume
|
||||
@ -631,13 +595,8 @@ public:
|
||||
int load_wipe_tower_preview(
|
||||
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool size_unknown, float brim_width, bool opengl_initialized);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
GLVolume* new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
|
||||
GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
|
||||
#else
|
||||
GLVolume* new_toolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats = 0);
|
||||
GLVolume* new_nontoolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats = 0);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// Render the volumes by OpenGL.
|
||||
void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;
|
||||
|
@ -2,9 +2,7 @@
|
||||
#include "I18N.hpp"
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
@ -136,13 +134,8 @@ wxString CopyrightsDialog::get_html_text()
|
||||
wxColour bgr_clr = wxGetApp().get_window_default_clr();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
const auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
const auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
const wxString copyright_str = _L("Copyright") + "© ";
|
||||
// TRN "Slic3r _is licensed under the_ License"
|
||||
@ -265,13 +258,8 @@ AboutDialog::AboutDialog()
|
||||
m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
|
||||
wxFont font = get_default_font(this);
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
const int fs = font.GetPointSize()-1;
|
||||
int size[] = {fs,fs,fs,fs,fs,fs,fs};
|
||||
|
@ -395,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);
|
||||
}
|
||||
|
||||
#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 Slic3r
|
||||
|
@ -9,9 +9,7 @@
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
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 mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
wxBitmap mksolid(size_t width, size_t height, const ColorRGB& rgb, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
|
||||
#else
|
||||
wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT); }
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static bool parse_color(const std::string& scolor, unsigned char* rgb_out);
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
private:
|
||||
std::map<std::string, wxBitmap*> m_map;
|
||||
double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs)
|
||||
|
@ -5,9 +5,7 @@
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Time.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "GUI_App.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
@ -34,15 +32,9 @@ static wxString format_reason(const Config::Snapshot::Reason reason)
|
||||
|
||||
static std::string get_color(wxColour colour)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return encode_color(ColorRGB(colour.Red(), colour.Green(), colour.Blue()));
|
||||
#else
|
||||
wxString clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue());
|
||||
return clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
|
||||
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.
|
||||
|
@ -36,9 +36,7 @@
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
@ -749,15 +747,9 @@ void PageMaterials::set_compatible_printers_html_window(const std::vector<std::s
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_MENU);
|
||||
#endif
|
||||
#endif
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();
|
||||
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
#else
|
||||
const auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();
|
||||
const auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
wxString first_line = format_wxstr(_L("%1% marked with <b>*</b> are <b>not</b> compatible with some installed printers."), materials->technology == T_FFF ? _L("Filaments") : _L("SLA materials"));
|
||||
wxString text;
|
||||
if (all_printers) {
|
||||
|
@ -2557,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)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto opposite_one_color = [](const std::string& color) {
|
||||
ColorRGB 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);
|
||||
return encode_color(opposite(rgb1, rgb2));
|
||||
};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (mode == SingleExtruder && type == ColorChange && m_use_default_colors) {
|
||||
#if 1
|
||||
if (ticks.empty())
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_one_color((*m_colors)[0]);
|
||||
#else
|
||||
return color_generator.get_opposite_color((*m_colors)[0]);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
auto before_tick_it = std::lower_bound(ticks.begin(), ticks.end(), tick);
|
||||
if (before_tick_it == ticks.end()) {
|
||||
@ -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)
|
||||
break;
|
||||
if (before_tick_it->type == ColorChange)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_one_color(before_tick_it->color);
|
||||
|
||||
return opposite_one_color((*m_colors)[0]);
|
||||
#else
|
||||
return color_generator.get_opposite_color(before_tick_it->color);
|
||||
|
||||
return color_generator.get_opposite_color((*m_colors)[0]);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
if (before_tick_it == ticks.begin()) {
|
||||
const std::string& frst_color = (*m_colors)[0];
|
||||
if (before_tick_it->type == ColorChange)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_two_colors(frst_color, before_tick_it->color);
|
||||
#else
|
||||
return color_generator.get_opposite_color(frst_color, before_tick_it->color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
auto next_tick_it = before_tick_it;
|
||||
while (next_tick_it != ticks.end())
|
||||
if (++next_tick_it; next_tick_it->type == ColorChange)
|
||||
break;
|
||||
if (next_tick_it->type == ColorChange)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_two_colors(frst_color, next_tick_it->color);
|
||||
|
||||
return opposite_one_color(frst_color);
|
||||
#else
|
||||
return color_generator.get_opposite_color(frst_color, next_tick_it->color);
|
||||
|
||||
return color_generator.get_opposite_color(frst_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
std::string frst_color = "";
|
||||
@ -2639,27 +2617,15 @@ std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int
|
||||
|
||||
if (before_tick_it->type == ColorChange) {
|
||||
if (frst_color.empty())
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_one_color(before_tick_it->color);
|
||||
|
||||
return opposite_two_colors(before_tick_it->color, frst_color);
|
||||
#else
|
||||
return color_generator.get_opposite_color(before_tick_it->color);
|
||||
|
||||
return color_generator.get_opposite_color(before_tick_it->color, frst_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
if (frst_color.empty())
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return opposite_one_color((*m_colors)[0]);
|
||||
|
||||
return opposite_two_colors((*m_colors)[0], frst_color);
|
||||
#else
|
||||
return color_generator.get_opposite_color((*m_colors)[0]);
|
||||
|
||||
return color_generator.get_opposite_color((*m_colors)[0], frst_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#else
|
||||
const std::vector<std::string>& colors = ColorPrintColors::get();
|
||||
if (ticks.empty())
|
||||
|
@ -3,9 +3,6 @@
|
||||
|
||||
#include "libslic3r/CustomGCode.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
#include "DoubleSlider_Utils.hpp"
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
#include <wx/window.h>
|
||||
#include <wx/control.h>
|
||||
@ -121,9 +118,6 @@ class TickCodeInfo
|
||||
// int m_default_color_idx = 0;
|
||||
|
||||
std::vector<std::string>* m_colors {nullptr};
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
ColorGenerator color_generator;
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
std::string get_color_for_tick(TickCode tick, Type type, const int extruder);
|
||||
|
||||
|
@ -4,196 +4,5 @@
|
||||
#include <stdio.h>
|
||||
#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_
|
||||
|
@ -1389,14 +1389,8 @@ boost::any& ColourPicker::get_value()
|
||||
auto colour = static_cast<wxColourPickerCtrl*>(window)->GetColour();
|
||||
if (colour == wxTransparentColour)
|
||||
m_value = std::string("");
|
||||
else {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
else
|
||||
m_value = encode_color(ColorRGB(colour.Red(), colour.Green(), colour.Blue()));
|
||||
#else
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue());
|
||||
m_value = clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
@ -47,34 +47,6 @@ static EMoveType buffer_type(unsigned char id) {
|
||||
return static_cast<EMoveType>(static_cast<unsigned char>(EMoveType::Retract) + id);
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static std::array<float, 4> decode_color(const std::string& color) {
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
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.
|
||||
// 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)
|
||||
@ -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 } } });
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA GCodeViewer::Extrusions::Range::get_color_at(float value) const
|
||||
#else
|
||||
GCodeViewer::Color GCodeViewer::Extrusions::Range::get_color_at(float value) const
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
// Input value scaled to the colors range
|
||||
const float step = step_size();
|
||||
@ -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_high_idx = std::clamp<size_t>(color_low_idx + 1, 0, color_max_idx);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
// Interpolate between the low and high colors to find exactly which color the input value should get
|
||||
return lerp(Range_Colors[color_low_idx], Range_Colors[color_high_idx], global_t - static_cast<float>(color_low_idx));
|
||||
#else
|
||||
// Compute how far the value is between the low and high colors so that they can be interpolated
|
||||
const float local_t = std::clamp(global_t - static_cast<float>(color_low_idx), 0.0f, 1.0f);
|
||||
|
||||
// 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() {
|
||||
@ -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]));
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Extrusion_Role_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.90f, 0.70f, 0.70f, 1.0f }, // erNone
|
||||
{ 1.00f, 0.90f, 0.30f, 1.0f }, // erPerimeter
|
||||
{ 1.00f, 0.49f, 0.22f, 1.0f }, // erExternalPerimeter
|
||||
@ -514,11 +466,7 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
|
||||
{ 0.00f, 0.00f, 0.00f, 1.0f } // erMixed
|
||||
}};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Options_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Options_Colors {{
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.803f, 0.135f, 0.839f, 1.0f }, // Retractions
|
||||
{ 0.287f, 0.679f, 0.810f, 1.0f }, // Unretractions
|
||||
{ 0.900f, 0.900f, 0.900f, 1.0f }, // Seams
|
||||
@ -528,11 +476,7 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Options_Colors {{
|
||||
{ 0.886f, 0.825f, 0.262f, 1.0f } // CustomGCodes
|
||||
}};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Travel_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Travel_Colors {{
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.219f, 0.282f, 0.609f, 1.0f }, // Move
|
||||
{ 0.112f, 0.422f, 0.103f, 1.0f }, // Extrude
|
||||
{ 0.505f, 0.064f, 0.028f, 1.0f } // Retract
|
||||
@ -540,11 +484,7 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Travel_Colors {{
|
||||
|
||||
#if 1
|
||||
// Normal ranges
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Range_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors {{
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.043f, 0.173f, 0.478f, 1.0f }, // bluish
|
||||
{ 0.075f, 0.349f, 0.522f, 1.0f },
|
||||
{ 0.110f, 0.533f, 0.569f, 1.0f },
|
||||
@ -559,11 +499,7 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors {{
|
||||
}};
|
||||
#else
|
||||
// Detailed ranges
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA> GCodeViewer::Range_Colors{ {
|
||||
#else
|
||||
const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors{ {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{ 0.043f, 0.173f, 0.478f, 1.0f }, // bluish
|
||||
{ 0.5f * (0.043f + 0.075f), 0.5f * (0.173f + 0.349f), 0.5f * (0.478f + 0.522f), 1.0f },
|
||||
{ 0.075f, 0.349f, 0.522f, 1.0f },
|
||||
@ -588,13 +524,8 @@ const std::vector<GCodeViewer::Color> GCodeViewer::Range_Colors{ {
|
||||
} };
|
||||
#endif
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA GCodeViewer::Wipe_Color = ColorRGBA::YELLOW();
|
||||
const ColorRGBA GCodeViewer::Neutral_Color = ColorRGBA::DARK_GRAY();
|
||||
#else
|
||||
const GCodeViewer::Color GCodeViewer::Wipe_Color = { 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
const GCodeViewer::Color GCodeViewer::Neutral_Color = { 0.25f, 0.25f, 0.25f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GCodeViewer::GCodeViewer()
|
||||
{
|
||||
@ -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())
|
||||
// update tool colors from config stored in the gcode
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
decode_colors(gcode_result.extruder_colors, m_tool_colors);
|
||||
#else
|
||||
m_tool_colors = decode_colors(gcode_result.extruder_colors);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
else
|
||||
// update tool colors
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
decode_colors(str_tool_colors, m_tool_colors);
|
||||
#else
|
||||
m_tool_colors = decode_colors(str_tool_colors);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA default_color;
|
||||
decode_color("#FF8000", default_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// ensure there are enough colors defined
|
||||
while (m_tool_colors.size() < std::max(size_t(1), gcode_result.extruders_count))
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_tool_colors.push_back(default_color);
|
||||
#else
|
||||
m_tool_colors.push_back(decode_color("#FF8000"));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// update ranges for coloring / legend
|
||||
m_extrusions.reset_ranges();
|
||||
@ -853,11 +770,7 @@ void GCodeViewer::reset()
|
||||
m_paths_bounding_box = BoundingBoxf3();
|
||||
m_max_bounding_box = BoundingBoxf3();
|
||||
m_max_print_height = 0.0f;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_tool_colors = std::vector<ColorRGBA>();
|
||||
#else
|
||||
m_tool_colors = std::vector<Color>();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_extruders_count = 0;
|
||||
m_extruder_ids = std::vector<unsigned char>();
|
||||
m_filament_diameters = std::vector<float>();
|
||||
@ -1035,11 +948,7 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
|
||||
return;
|
||||
|
||||
// collect color information to generate materials
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> colors;
|
||||
#else
|
||||
std::vector<Color> colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
for (const RenderPath& path : t_buffer.render_paths) {
|
||||
colors.push_back(path.color);
|
||||
}
|
||||
@ -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);
|
||||
|
||||
unsigned int colors_count = 1;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
for (const ColorRGBA& color : colors) {
|
||||
fprintf(fp, "\nnewmtl material_%d\n", colors_count++);
|
||||
fprintf(fp, "Ka 1 1 1\n");
|
||||
fprintf(fp, "Kd %g %g %g\n", color.r(), color.g(), color.b());
|
||||
fprintf(fp, "Ks 0 0 0\n");
|
||||
}
|
||||
#else
|
||||
for (const Color& color : colors) {
|
||||
fprintf(fp, "\nnewmtl material_%d\n", colors_count++);
|
||||
fprintf(fp, "Ka 1 1 1\n");
|
||||
fprintf(fp, "Kd %g %g %g\n", color[0], color[1], color[2]);
|
||||
fprintf(fp, "Ks 0 0 0\n");
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
fclose(fp);
|
||||
|
||||
@ -1134,11 +1034,7 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
for (const ColorRGBA& color : colors) {
|
||||
#else
|
||||
for (const Color& color : colors) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// save material triangles to file
|
||||
fprintf(fp, "\nusemtl material_%zu\n", i + 1);
|
||||
fprintf(fp, "# triangles material %zu\n", i + 1);
|
||||
@ -2200,11 +2096,7 @@ void GCodeViewer::load_shells(const Print& print, bool initialized)
|
||||
|
||||
for (GLVolume* volume : m_shells.volumes.volumes) {
|
||||
volume->zoom_to_volumes = false;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
volume->color.a(0.25f);
|
||||
#else
|
||||
volume->color[3] = 0.25f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
volume->force_native_color = true;
|
||||
volume->set_render_color();
|
||||
}
|
||||
@ -2217,11 +2109,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
||||
auto extrusion_color = [this](const Path& path) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
switch (m_view_type)
|
||||
{
|
||||
case EViewType::FeatureType: { color = Extrusion_Role_Colors[static_cast<unsigned int>(path.role)]; break; }
|
||||
@ -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::ColorPrint: {
|
||||
if (path.cp_color_id >= static_cast<unsigned char>(m_tool_colors.size()))
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
color = ColorRGBA::GRAY();
|
||||
#else
|
||||
color = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
else
|
||||
color = m_tool_colors[path.cp_color_id];
|
||||
|
||||
break;
|
||||
}
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
default: { color = ColorRGBA::WHITE(); break; }
|
||||
#else
|
||||
default: { color = { 1.0f, 1.0f, 1.0f, 1.0f }; break; }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
return color;
|
||||
@ -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)
|
||||
continue;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
switch (path.type)
|
||||
{
|
||||
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";
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto append_item = [icon_size, percent_bar_size, &imgui, imperial_units](EItemType type, const ColorRGBA& color, const std::string& label,
|
||||
#else
|
||||
auto append_item = [icon_size, percent_bar_size, &imgui, imperial_units](EItemType type, const Color& color, const std::string& label,
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
bool visible = true, const std::string& time = "", float percent = 0.0f, float max_percent = 0.0f, const std::array<float, 4>& offsets = { 0.0f, 0.0f, 0.0f, 0.0f },
|
||||
double used_filament_m = 0.0, double used_filament_g = 0.0,
|
||||
std::function<void()> callback = nullptr) {
|
||||
@ -3110,37 +2982,21 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
default:
|
||||
case EItemType::Rect: {
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGuiWrapper::to_ImU32(color));
|
||||
#else
|
||||
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
break;
|
||||
}
|
||||
case EItemType::Circle: {
|
||||
ImVec2 center(0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
draw_list->AddCircleFilled(center, 0.5f * icon_size, ImGuiWrapper::to_ImU32(color), 16);
|
||||
#else
|
||||
draw_list->AddCircleFilled(center, 0.5f * icon_size, ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 16);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
break;
|
||||
}
|
||||
case EItemType::Hexagon: {
|
||||
ImVec2 center(0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
draw_list->AddNgonFilled(center, 0.5f * icon_size, ImGuiWrapper::to_ImU32(color), 6);
|
||||
#else
|
||||
draw_list->AddNgonFilled(center, 0.5f * icon_size, ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 6);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
break;
|
||||
}
|
||||
case EItemType::Line: {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
draw_list->AddLine({ pos.x + 1, pos.y + icon_size - 1 }, { pos.x + icon_size - 1, pos.y + 1 }, ImGuiWrapper::to_ImU32(color), 3.0f);
|
||||
#else
|
||||
draw_list->AddLine({ pos.x + 1, pos.y + icon_size - 1 }, { pos.x + icon_size - 1, pos.y + 1 }, ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 3.0f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -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) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<std::pair<ColorRGBA, std::pair<double, double>>> ret;
|
||||
#else
|
||||
std::vector<std::pair<Color, std::pair<double, double>>> ret;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
ret.reserve(custom_gcode_per_print_z.size());
|
||||
|
||||
for (const auto& item : custom_gcode_per_print_z) {
|
||||
@ -3281,16 +3133,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
const double previous_z = (lower_b == zs.begin()) ? 0.0 : *(--lower_b);
|
||||
|
||||
// to avoid duplicate values, check adding values
|
||||
if (ret.empty() || !(ret.back().second.first == previous_z && ret.back().second.second == current_z))
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
{
|
||||
if (ret.empty() || !(ret.back().second.first == previous_z && ret.back().second.second == current_z)) {
|
||||
ColorRGBA color;
|
||||
decode_color(item.color, color);
|
||||
ret.push_back({ color, { previous_z, current_z } });
|
||||
}
|
||||
#else
|
||||
ret.push_back({ decode_color(item.color), { previous_z, current_z } });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -3485,15 +3332,10 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
if (need_scrollable)
|
||||
ImGui::BeginChild("color_prints", { -1.0f, child_height }, false);
|
||||
if (m_extruders_count == 1) { // single extruder use case
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(0, custom_gcode_per_print_z);
|
||||
#else
|
||||
const std::vector<std::pair<Color, std::pair<double, double>>> cp_values = color_print_ranges(0, custom_gcode_per_print_z);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0) { // There are no color changes, but there are some pause print or custom Gcode
|
||||
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"));
|
||||
}
|
||||
else {
|
||||
for (int i = items_cnt; i >= 0; --i) {
|
||||
// create label for color change item
|
||||
@ -3512,11 +3354,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
else { // multi extruder use case
|
||||
// shows only extruders actually used
|
||||
for (unsigned char i : m_extruder_ids) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(i, custom_gcode_per_print_z);
|
||||
#else
|
||||
const std::vector<std::pair<Color, std::pair<double, double>>> cp_values = color_print_ranges(i, custom_gcode_per_print_z);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0)
|
||||
// There are no color changes, but there are some pause print or custom Gcode
|
||||
@ -3566,13 +3404,8 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
};
|
||||
EType type;
|
||||
int extruder_id;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color1;
|
||||
ColorRGBA color2;
|
||||
#else
|
||||
Color color1;
|
||||
Color color2;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
Times times;
|
||||
std::pair<double, double> used_filament{ 0.0f, 0.0f };
|
||||
};
|
||||
@ -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;
|
||||
int extruders_count = wxGetApp().extruders_edited_cnt();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> last_color(extruders_count);
|
||||
#else
|
||||
std::vector<Color> last_color(extruders_count);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
for (int i = 0; i < extruders_count; ++i) {
|
||||
last_color[i] = m_tool_colors[i];
|
||||
}
|
||||
@ -3599,13 +3428,8 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
case CustomGCode::PausePrint: {
|
||||
auto it = std::find_if(custom_gcode_per_print_z.begin(), custom_gcode_per_print_z.end(), [time_rec](const CustomGCode::Item& item) { return item.type == time_rec.first; });
|
||||
if (it != custom_gcode_per_print_z.end()) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
items.push_back({ PartialTime::EType::Print, it->extruder, last_color[it->extruder - 1], ColorRGBA::BLACK(), time_rec.second });
|
||||
items.push_back({ PartialTime::EType::Pause, it->extruder, ColorRGBA::BLACK(), ColorRGBA::BLACK(), time_rec.second });
|
||||
#else
|
||||
items.push_back({ PartialTime::EType::Print, it->extruder, last_color[it->extruder - 1], Color(), time_rec.second });
|
||||
items.push_back({ PartialTime::EType::Pause, it->extruder, Color(), Color(), time_rec.second });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
custom_gcode_per_print_z.erase(it);
|
||||
}
|
||||
break;
|
||||
@ -3613,26 +3437,16 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
case CustomGCode::ColorChange: {
|
||||
auto it = std::find_if(custom_gcode_per_print_z.begin(), custom_gcode_per_print_z.end(), [time_rec](const CustomGCode::Item& item) { return item.type == time_rec.first; });
|
||||
if (it != custom_gcode_per_print_z.end()) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
items.push_back({ PartialTime::EType::Print, it->extruder, last_color[it->extruder - 1], ColorRGBA::BLACK(), time_rec.second, get_used_filament_from_volume(used_filaments[color_change_idx++], it->extruder - 1) });
|
||||
ColorRGBA color;
|
||||
decode_color(it->color, color);
|
||||
items.push_back({ PartialTime::EType::ColorChange, it->extruder, last_color[it->extruder - 1], color, time_rec.second });
|
||||
last_color[it->extruder - 1] = color;
|
||||
#else
|
||||
items.push_back({ PartialTime::EType::Print, it->extruder, last_color[it->extruder - 1], Color(), time_rec.second, get_used_filament_from_volume(used_filaments[color_change_idx++], it->extruder-1) });
|
||||
items.push_back({ PartialTime::EType::ColorChange, it->extruder, last_color[it->extruder - 1], decode_color(it->color), time_rec.second });
|
||||
last_color[it->extruder - 1] = decode_color(it->color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
last_extruder_id = it->extruder;
|
||||
custom_gcode_per_print_z.erase(it);
|
||||
}
|
||||
else
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
items.push_back({ PartialTime::EType::Print, last_extruder_id, last_color[last_extruder_id - 1], ColorRGBA::BLACK(), time_rec.second, get_used_filament_from_volume(used_filaments[color_change_idx++], last_extruder_id - 1) });
|
||||
#else
|
||||
items.push_back({ PartialTime::EType::Print, last_extruder_id, last_color[last_extruder_id - 1], Color(), time_rec.second, get_used_filament_from_volume(used_filaments[color_change_idx++], last_extruder_id -1) });
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
break;
|
||||
}
|
||||
@ -3643,11 +3457,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
return items;
|
||||
};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto append_color_change = [&imgui](const ColorRGBA& color1, const ColorRGBA& color2, const std::array<float, 4>& offsets, const Times& times) {
|
||||
#else
|
||||
auto append_color_change = [&imgui](const Color& color1, const Color& color2, const std::array<float, 4>& offsets, const Times& times) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
imgui.text(_u8L("Color change"));
|
||||
ImGui::SameLine();
|
||||
|
||||
@ -3657,28 +3467,16 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
pos.x -= 0.5f * ImGui::GetStyle().ItemSpacing.x;
|
||||
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGuiWrapper::to_ImU32(color1));
|
||||
#else
|
||||
ImGui::GetColorU32({ color1[0], color1[1], color1[2], 1.0f }));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
pos.x += icon_size;
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGuiWrapper::to_ImU32(color2));
|
||||
#else
|
||||
ImGui::GetColorU32({ color2[0], color2[1], color2[2], 1.0f }));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
ImGui::SameLine(offsets[0]);
|
||||
imgui.text(short_time(get_time_dhms(times.second - times.first)));
|
||||
};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto append_print = [&imgui, imperial_units](const ColorRGBA& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
|
||||
#else
|
||||
auto append_print = [&imgui, imperial_units](const Color& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
imgui.text(_u8L("Print"));
|
||||
ImGui::SameLine();
|
||||
|
||||
@ -3688,11 +3486,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
pos.x -= 0.5f * ImGui::GetStyle().ItemSpacing.x;
|
||||
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGuiWrapper::to_ImU32(color));
|
||||
#else
|
||||
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
ImGui::SameLine(offsets[0]);
|
||||
imgui.text(short_time(get_time_dhms(times.second)));
|
||||
@ -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
|
||||
#else
|
||||
GCodeViewer::Color GCodeViewer::option_color(EMoveType move_type) const
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
switch (move_type)
|
||||
{
|
||||
|
@ -22,9 +22,6 @@ namespace GUI {
|
||||
class GCodeViewer
|
||||
{
|
||||
using IBufferType = unsigned short;
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
using Color = std::array<float, 4>;
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
using VertexBuffer = std::vector<float>;
|
||||
using MultiVertexBuffer = std::vector<VertexBuffer>;
|
||||
using IndexBuffer = std::vector<IBufferType>;
|
||||
@ -33,21 +30,12 @@ class GCodeViewer
|
||||
using InstanceIdBuffer = std::vector<size_t>;
|
||||
using InstancesOffsets = std::vector<Vec3f>;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const std::vector<ColorRGBA> Extrusion_Role_Colors;
|
||||
static const std::vector<ColorRGBA> Options_Colors;
|
||||
static const std::vector<ColorRGBA> Travel_Colors;
|
||||
static const std::vector<ColorRGBA> Range_Colors;
|
||||
static const ColorRGBA Wipe_Color;
|
||||
static const ColorRGBA Neutral_Color;
|
||||
#else
|
||||
static const std::vector<Color> Extrusion_Role_Colors;
|
||||
static const std::vector<Color> Options_Colors;
|
||||
static const std::vector<Color> Travel_Colors;
|
||||
static const std::vector<Color> Range_Colors;
|
||||
static const Color Wipe_Color;
|
||||
static const Color Neutral_Color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
enum class EOptionsColors : unsigned char
|
||||
{
|
||||
@ -132,11 +120,7 @@ class GCodeViewer
|
||||
// vbo id
|
||||
unsigned int vbo{ 0 };
|
||||
// Color to apply to the instances
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
std::vector<Range> ranges;
|
||||
@ -258,11 +242,7 @@ class GCodeViewer
|
||||
// Index of the parent tbuffer
|
||||
unsigned char tbuffer_id;
|
||||
// Render path property
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// Index of the buffer in TBuffer::indices
|
||||
unsigned int ibuffer_id;
|
||||
// Render path content
|
||||
@ -282,19 +262,10 @@ class GCodeViewer
|
||||
bool operator() (const RenderPath &l, const RenderPath &r) const {
|
||||
if (l.tbuffer_id < r.tbuffer_id)
|
||||
return true;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
if (l.color < r.color)
|
||||
return true;
|
||||
else if (l.color > r.color)
|
||||
return false;
|
||||
#else
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (l.color[i] < r.color[i])
|
||||
return true;
|
||||
else if (l.color[i] > r.color[i])
|
||||
return false;
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
return l.ibuffer_id < r.ibuffer_id;
|
||||
}
|
||||
};
|
||||
@ -325,11 +296,7 @@ class GCodeViewer
|
||||
struct Model
|
||||
{
|
||||
GLModel model;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
InstanceVBuffer instances;
|
||||
GLModel::InitializationData data;
|
||||
|
||||
@ -429,11 +396,7 @@ class GCodeViewer
|
||||
void reset() { min = FLT_MAX; max = -FLT_MAX; count = 0; }
|
||||
|
||||
float step_size() const { return (max - min) / (static_cast<float>(Range_Colors.size()) - 1.0f); }
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA get_color_at(float value) const;
|
||||
#else
|
||||
Color get_color_at(float value) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
struct Ranges
|
||||
@ -525,11 +488,7 @@ class GCodeViewer
|
||||
TBuffer* buffer{ nullptr };
|
||||
unsigned int ibo{ 0 };
|
||||
unsigned int vbo{ 0 };
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
Color color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
~SequentialRangeCap();
|
||||
bool is_renderable() const { return buffer != nullptr; }
|
||||
@ -733,11 +692,7 @@ private:
|
||||
// bounding box of toolpaths + marker tools
|
||||
BoundingBoxf3 m_max_bounding_box;
|
||||
float m_max_print_height{ 0.0f };
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> m_tool_colors;
|
||||
#else
|
||||
std::vector<Color> m_tool_colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
Layers m_layers;
|
||||
std::array<unsigned int, 2> m_layers_z_range;
|
||||
std::vector<ExtrusionRole> m_roles;
|
||||
@ -832,11 +787,7 @@ private:
|
||||
}
|
||||
bool is_visible(const Path& path) const { return is_visible(path.role); }
|
||||
void log_memory_used(const std::string& label, int64_t additional = 0) const;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA option_color(EMoveType move_type) const;
|
||||
#else
|
||||
Color option_color(EMoveType move_type) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
@ -72,18 +72,10 @@
|
||||
|
||||
static constexpr const float TRACKBALLSIZE = 0.8f;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const Slic3r::ColorRGB DEFAULT_BG_DARK_COLOR = { 0.478f, 0.478f, 0.478f };
|
||||
static const Slic3r::ColorRGB DEFAULT_BG_LIGHT_COLOR = { 0.753f, 0.753f, 0.753f };
|
||||
static const Slic3r::ColorRGB ERROR_BG_DARK_COLOR = { 0.478f, 0.192f, 0.039f };
|
||||
static const Slic3r::ColorRGB ERROR_BG_LIGHT_COLOR = { 0.753f, 0.192f, 0.039f };
|
||||
#else
|
||||
static constexpr const float DEFAULT_BG_DARK_COLOR[3] = { 0.478f, 0.478f, 0.478f };
|
||||
static constexpr const float DEFAULT_BG_LIGHT_COLOR[3] = { 0.753f, 0.753f, 0.753f };
|
||||
static constexpr const float ERROR_BG_DARK_COLOR[3] = { 0.478f, 0.192f, 0.039f };
|
||||
static constexpr const float ERROR_BG_LIGHT_COLOR[3] = { 0.753f, 0.192f, 0.039f };
|
||||
//static constexpr const float AXES_COLOR[3][3] = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// Number of floats
|
||||
static constexpr const size_t MAX_VERTEX_BUFFER_SIZE = 131072 * 6; // 3.15MB
|
||||
@ -856,13 +848,8 @@ void GLCanvas3D::SequentialPrintClearance::set_polygons(const Polygons& polygons
|
||||
|
||||
void GLCanvas3D::SequentialPrintClearance::render()
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA FILL_COLOR = { 1.0f, 0.0f, 0.0f, 0.5f };
|
||||
const ColorRGBA NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f };
|
||||
#else
|
||||
std::array<float, 4> FILL_COLOR = { 1.0f, 0.0f, 0.0f, 0.5f };
|
||||
std::array<float, 4> NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader == nullptr)
|
||||
@ -4111,11 +4098,6 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
||||
return ret;
|
||||
};
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static const std::array<float, 4> orange = { 0.923f, 0.504f, 0.264f, 1.0f };
|
||||
static const std::array<float, 4> gray = { 0.64f, 0.64f, 0.64f, 1.0f };
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
GLVolumePtrs visible_volumes;
|
||||
|
||||
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);
|
||||
|
||||
for (GLVolume* vol : visible_volumes) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : ColorRGBA::ORANGE()) : ColorRGBA::GRAY());
|
||||
#else
|
||||
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : orange) : gray);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// the volume may have been deactivated by an active gizmo
|
||||
bool is_active = vol->is_active;
|
||||
vol->is_active = true;
|
||||
@ -4905,34 +4883,20 @@ void GLCanvas3D::_picking_pass()
|
||||
int volume_id = -1;
|
||||
int gizmo_id = -1;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::array<GLubyte, 4> color = { 0, 0, 0, 0 };
|
||||
#else
|
||||
GLubyte color[4] = { 0, 0, 0, 0 };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const Size& cnv_size = get_canvas_size();
|
||||
bool inside = 0 <= m_mouse.position(0) && m_mouse.position(0) < cnv_size.get_width() && 0 <= m_mouse.position(1) && m_mouse.position(1) < cnv_size.get_height();
|
||||
if (inside) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position.y() - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color.data()));
|
||||
#else
|
||||
glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position(1) - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (picking_checksum_alpha_channel(color[0], color[1], color[2]) == color[3]) {
|
||||
// Only non-interpolated colors are valid, those have their lowest three bits zeroed.
|
||||
// we reserve color = (0,0,0) for occluders (as the printbed)
|
||||
// volumes' id are shifted by 1
|
||||
// see: _render_volumes_for_picking()
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
unsigned int id = picking_encode(color[0], color[1], color[2]);
|
||||
volume_id = id - 1;
|
||||
// gizmos' id are instead properly encoded by the color
|
||||
gizmo_id = id;
|
||||
#else
|
||||
volume_id = color[0] + (color[1] << 8) + (color[2] << 16) - 1;
|
||||
// gizmos' id are instead properly encoded by the color
|
||||
gizmo_id = color[0] + (color[1] << 8) + (color[2] << 16);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
}
|
||||
if (0 <= volume_id && volume_id < (int)m_volumes.volumes.size()) {
|
||||
@ -5048,27 +5012,11 @@ void GLCanvas3D::_render_background() const
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor3fv(use_error_color ? ERROR_BG_DARK_COLOR.data(): DEFAULT_BG_DARK_COLOR.data());
|
||||
#else
|
||||
if (use_error_color)
|
||||
::glColor3fv(ERROR_BG_DARK_COLOR);
|
||||
else
|
||||
::glColor3fv(DEFAULT_BG_DARK_COLOR);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
::glVertex2f(-1.0f, -1.0f);
|
||||
::glVertex2f(1.0f, -1.0f);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor3fv(use_error_color ? ERROR_BG_LIGHT_COLOR.data() : DEFAULT_BG_LIGHT_COLOR.data());
|
||||
#else
|
||||
if (use_error_color)
|
||||
::glColor3fv(ERROR_BG_LIGHT_COLOR);
|
||||
else
|
||||
::glColor3fv(DEFAULT_BG_LIGHT_COLOR);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
::glVertex2f(1.0f, 1.0f);
|
||||
::glVertex2f(-1.0f, 1.0f);
|
||||
glsafe(::glEnd());
|
||||
@ -5351,10 +5299,6 @@ void GLCanvas3D::_render_overlays()
|
||||
|
||||
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
|
||||
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.
|
||||
// we reserve color = (0,0,0) for occluders (as the printbed)
|
||||
// so we shift volumes' id by 1 to get the proper color
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const unsigned int id = 1 + volume.second.first;
|
||||
glsafe(::glColor4fv(picking_decode(id).data()));
|
||||
#else
|
||||
unsigned int id = 1 + volume.second.first;
|
||||
unsigned int r = (id & (0x000000FF << 0)) << 0;
|
||||
unsigned int g = (id & (0x000000FF << 8)) >> 8;
|
||||
unsigned int b = (id & (0x000000FF << 16)) >> 16;
|
||||
unsigned int a = picking_checksum_alpha_channel(r, g, b);
|
||||
glsafe(::glColor4f((GLfloat)r * INV_255, (GLfloat)g * INV_255, (GLfloat)b * INV_255, (GLfloat)a * INV_255));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
volume.first->render();
|
||||
}
|
||||
}
|
||||
@ -5799,11 +5734,7 @@ void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
|
||||
if (!print->has_skirt() && !print->has_brim())
|
||||
return;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA color = ColorRGBA::GREENISH();
|
||||
#else
|
||||
const std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.0f }; // greenish
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// number of skirt layers
|
||||
size_t total_layer_count = 0;
|
||||
@ -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)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> tool_colors;
|
||||
decode_colors(str_tool_colors, tool_colors);
|
||||
#else
|
||||
std::vector<std::array<float, 4>> tool_colors = _parse_colors(str_tool_colors);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
struct Ctxt
|
||||
{
|
||||
@ -5864,35 +5791,20 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
||||
bool has_perimeters;
|
||||
bool has_infill;
|
||||
bool has_support;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA>* tool_colors;
|
||||
#else
|
||||
const std::vector<std::array<float, 4>>* tool_colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
bool is_single_material_print;
|
||||
int extruders_cnt;
|
||||
const std::vector<CustomGCode::Item>* color_print_values;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ColorRGBA color_perimeters() { return ColorRGBA::YELLOW(); }
|
||||
static ColorRGBA color_infill() { return ColorRGBA::REDISH(); }
|
||||
static ColorRGBA color_support() { return ColorRGBA::GREENISH(); }
|
||||
static ColorRGBA color_pause_or_custom_code() { return ColorRGBA::GRAY(); }
|
||||
#else
|
||||
static const std::array<float, 4>& color_perimeters() { static std::array<float, 4> color = { 1.0f, 1.0f, 0.0f, 1.f }; return color; } // yellow
|
||||
static const std::array<float, 4>& color_infill() { static std::array<float, 4> color = { 1.0f, 0.5f, 0.5f, 1.f }; return color; } // redish
|
||||
static const std::array<float, 4>& color_support() { static std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.f }; return color; } // greenish
|
||||
static const std::array<float, 4>& color_pause_or_custom_code() { static std::array<float, 4> color = { 0.5f, 0.5f, 0.5f, 1.f }; return color; } // gray
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// For cloring by a tool, return a parsed color.
|
||||
bool color_by_tool() const { return tool_colors != nullptr; }
|
||||
size_t number_tools() const { return color_by_tool() ? tool_colors->size() : 0; }
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
#else
|
||||
const std::array<float, 4>& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// For coloring by a color_print(M600), return a parsed color.
|
||||
bool color_by_color_print() const { return color_print_values!=nullptr; }
|
||||
@ -6032,11 +5944,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
||||
//FIXME Improve the heuristics for a grain size.
|
||||
size_t grain_size = std::max(ctxt.layers.size() / 16, size_t(1));
|
||||
tbb::spin_mutex new_volume_mutex;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) {
|
||||
#else
|
||||
auto new_volume = [this, &new_volume_mutex](const std::array<float, 4>& color) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// Allocate the volume before locking.
|
||||
GLVolume *volume = new GLVolume(color);
|
||||
volume->is_extrusion_path = true;
|
||||
@ -6177,38 +6085,22 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
|
||||
if (!print->is_step_done(psWipeTower))
|
||||
return;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> tool_colors;
|
||||
decode_colors(str_tool_colors, tool_colors);
|
||||
#else
|
||||
std::vector<std::array<float, 4>> tool_colors = _parse_colors(str_tool_colors);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
struct Ctxt
|
||||
{
|
||||
const Print *print;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA>* tool_colors;
|
||||
#else
|
||||
const std::vector<std::array<float, 4>>* tool_colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
Vec2f wipe_tower_pos;
|
||||
float wipe_tower_angle;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ColorRGBA color_support() { return ColorRGBA::GREENISH(); }
|
||||
#else
|
||||
static const std::array<float, 4>& color_support() { static std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.f }; return color; } // greenish
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// For cloring by a tool, return a parsed color.
|
||||
bool color_by_tool() const { return tool_colors != nullptr; }
|
||||
size_t number_tools() const { return this->color_by_tool() ? tool_colors->size() : 0; }
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
#else
|
||||
const std::array<float, 4>& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
int volume_idx(int tool, int feature) const {
|
||||
return this->color_by_tool() ? std::min<int>(this->number_tools() - 1, std::max<int>(tool, 0)) : feature;
|
||||
}
|
||||
@ -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 grain_size = std::max(n_items / 128, size_t(1));
|
||||
tbb::spin_mutex new_volume_mutex;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) {
|
||||
#else
|
||||
auto new_volume = [this, &new_volume_mutex](const std::array<float, 4>& color) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
auto *volume = new GLVolume(color);
|
||||
volume->is_extrusion_path = true;
|
||||
tbb::spin_mutex::scoped_lock lock;
|
||||
@ -6363,11 +6251,7 @@ void GLCanvas3D::_load_sla_shells()
|
||||
return;
|
||||
|
||||
auto add_volume = [this](const SLAPrintObject &object, int volume_id, const SLAPrintObject::Instance& instance,
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const TriangleMesh& mesh, const ColorRGBA& color, bool outside_printer_detection_enabled) {
|
||||
#else
|
||||
const TriangleMesh& mesh, const std::array<float, 4>& color, bool outside_printer_detection_enabled) {
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_volumes.volumes.emplace_back(new GLVolume(color));
|
||||
GLVolume& v = *m_volumes.volumes.back();
|
||||
#if ENABLE_SMOOTH_NORMALS
|
||||
@ -6429,30 +6313,6 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
|
||||
_set_warning_notification(warning, show);
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
std::vector<std::array<float, 4>> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors)
|
||||
{
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
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)
|
||||
{
|
||||
enum ErrorType{
|
||||
|
@ -981,10 +981,6 @@ private:
|
||||
bool _deactivate_arrange_menu();
|
||||
|
||||
float get_overlay_window_width() { return LayersEditing::get_overlay_window_width(); }
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static std::vector<std::array<float, 4>> _parse_colors(const std::vector<std::string>& colors);
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
@ -165,7 +165,6 @@ bool GLModel::init_from_file(const std::string& filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void GLModel::set_color(int entity_id, const ColorRGBA& color)
|
||||
{
|
||||
for (size_t i = 0; i < m_render_data.size(); ++i) {
|
||||
@ -173,15 +172,6 @@ void GLModel::set_color(int entity_id, const ColorRGBA& 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()
|
||||
{
|
||||
@ -226,11 +216,7 @@ void GLModel::render() const
|
||||
if (shader != nullptr)
|
||||
shader->set_uniform("uniform_color", data.color);
|
||||
else
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(data.color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(data.color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.ibo_id));
|
||||
glsafe(::glDrawElements(mode, static_cast<GLsizei>(data.indices_count), GL_UNSIGNED_INT, (const void*)0));
|
||||
@ -290,11 +276,7 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
|
||||
if (shader != nullptr)
|
||||
shader->set_uniform("uniform_color", data.color);
|
||||
else
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(data.color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(data.color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, data.vbo_id));
|
||||
if (position_id != -1) {
|
||||
|
@ -3,9 +3,7 @@
|
||||
|
||||
#include "libslic3r/Point.hpp"
|
||||
#include "libslic3r/BoundingBox.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@ -36,11 +34,7 @@ namespace GUI {
|
||||
unsigned int vbo_id{ 0 };
|
||||
unsigned int ibo_id{ 0 };
|
||||
size_t indices_count{ 0 };
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
std::array<float, 4> color{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
struct InitializationData
|
||||
@ -51,11 +45,7 @@ namespace GUI {
|
||||
std::vector<Vec3f> positions;
|
||||
std::vector<Vec3f> normals;
|
||||
std::vector<unsigned int> indices;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
std::array<float, 4> color{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
};
|
||||
|
||||
std::vector<Entity> entities;
|
||||
@ -85,11 +75,7 @@ namespace GUI {
|
||||
bool init_from_file(const std::string& filename);
|
||||
|
||||
// if entity_id == -1 set the color of all entities
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_color(int entity_id, const ColorRGBA& color);
|
||||
#else
|
||||
void set_color(int entity_id, const std::array<float, 4>& color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void reset();
|
||||
void render() const;
|
||||
|
@ -4,9 +4,7 @@
|
||||
#include "3DScene.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/format.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <GL/glew.h>
|
||||
@ -309,7 +307,6 @@ void GLShaderProgram::set_uniform(int id, const Vec3d& value) const
|
||||
set_uniform(id, static_cast<Vec3f>(value.cast<float>()));
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void GLShaderProgram::set_uniform(int id, const ColorRGB& value) const
|
||||
{
|
||||
set_uniform(id, value.data(), 3);
|
||||
@ -319,7 +316,6 @@ void GLShaderProgram::set_uniform(int id, const ColorRGBA& value) const
|
||||
{
|
||||
set_uniform(id, value.data(), 4);
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
int GLShaderProgram::get_attrib_location(const char* name) const
|
||||
{
|
||||
|
@ -9,10 +9,8 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
class ColorRGB;
|
||||
class ColorRGBA;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
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 Vec3f& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
void set_uniform(const char* name, const Vec3d& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_uniform(const char* name, const ColorRGB& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
void set_uniform(const char* name, const ColorRGBA& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void set_uniform(int id, int value) const;
|
||||
void set_uniform(int id, bool value) const;
|
||||
@ -86,10 +82,8 @@ public:
|
||||
void set_uniform(int id, const Matrix3f& value) const;
|
||||
void set_uniform(int id, const Vec3f& value) const;
|
||||
void set_uniform(int id, const Vec3d& value) const;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_uniform(int id, const ColorRGB& value) const;
|
||||
void set_uniform(int id, const ColorRGBA& value) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
// returns -1 if not found
|
||||
int get_attrib_location(const char* name) const;
|
||||
|
@ -44,9 +44,7 @@
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/I18N.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
@ -1583,12 +1581,7 @@ void GUI_App::set_label_clr_modified(const wxColour& clr)
|
||||
if (m_color_label_modified == clr)
|
||||
return;
|
||||
m_color_label_modified = clr;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::string str = encode_color(ColorRGB(clr.Red(), clr.Green(), clr.Blue()));
|
||||
#else
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue());
|
||||
std::string str = clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
app_config->set("label_clr_modified", str);
|
||||
app_config->save();
|
||||
}
|
||||
@ -1598,12 +1591,7 @@ void GUI_App::set_label_clr_sys(const wxColour& clr)
|
||||
if (m_color_label_sys == clr)
|
||||
return;
|
||||
m_color_label_sys = clr;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::string str = encode_color(ColorRGB(clr.Red(), clr.Green(), clr.Blue()));
|
||||
#else
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue());
|
||||
std::string str = clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
app_config->set("label_clr_sys", str);
|
||||
app_config->save();
|
||||
}
|
||||
|
@ -406,16 +406,6 @@ public:
|
||||
|
||||
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
|
||||
{
|
||||
std::chrono::milliseconds start_timer;
|
||||
|
@ -25,21 +25,9 @@ GLGizmoBase::Grabber::Grabber()
|
||||
|
||||
void GLGizmoBase::Grabber::render(bool hover, float size) const
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA render_color = color;
|
||||
if (hover)
|
||||
render_color = complementary(render_color);
|
||||
#else
|
||||
std::array<float, 4> render_color;
|
||||
if (hover) {
|
||||
render_color[0] = (1.0f - color[0]);
|
||||
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);
|
||||
}
|
||||
@ -54,11 +42,7 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
|
||||
return get_half_size(size) * DraggingScaleFactor;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking) const
|
||||
#else
|
||||
void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render_color, bool picking) const
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
if (!cube.is_initialized()) {
|
||||
// This cannot be done in constructor, OpenGL is not yet
|
||||
@ -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)
|
||||
{
|
||||
if (id < m_grabbers.size())
|
||||
@ -169,29 +146,13 @@ bool GLGizmoBase::update_items_state()
|
||||
return res;
|
||||
};
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const
|
||||
{
|
||||
#else
|
||||
std::array<float, 4> GLGizmoBase::picking_color_component(unsigned int id) const
|
||||
{
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
id = BASE_ID - id;
|
||||
if (m_group_id > -1)
|
||||
id -= m_group_id;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return picking_decode(id);
|
||||
#else
|
||||
// color components are encoded to match the calculation of volume_id made into GLCanvas3D::_picking_pass()
|
||||
return std::array<float, 4> {
|
||||
float((id >> 0) & 0xff) * INV_255, // red
|
||||
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
|
||||
@ -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) {
|
||||
if (m_grabbers[i].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_grabbers[i].color = picking_color_component(i);
|
||||
#else
|
||||
std::array<float, 4> color = picking_color_component(i);
|
||||
m_grabbers[i].color = color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_grabbers[i].render_for_picking(mean_size);
|
||||
}
|
||||
}
|
||||
@ -261,22 +217,6 @@ std::string GLGizmoBase::get_name(bool include_shortcut) const
|
||||
return out;
|
||||
}
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
||||
// were not interpolated by alpha blending or multi sampling.
|
||||
unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
// 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 Slic3r
|
||||
|
@ -2,9 +2,7 @@
|
||||
#define slic3r_GLGizmoBase_hpp_
|
||||
|
||||
#include "libslic3r/Point.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/GLModel.hpp"
|
||||
@ -21,23 +19,11 @@ class ModelObject;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const ColorRGBA DEFAULT_BASE_COLOR = { 0.625f, 0.625f, 0.625f, 1.0f };
|
||||
static const ColorRGBA DEFAULT_DRAG_COLOR = ColorRGBA::WHITE();
|
||||
static const ColorRGBA DEFAULT_HIGHLIGHT_COLOR = ColorRGBA::ORANGE();
|
||||
static const std::array<ColorRGBA, 3> AXES_COLOR = {{ ColorRGBA::X(), ColorRGBA::Y(), ColorRGBA::Z() }};
|
||||
static const ColorRGBA CONSTRAINED_COLOR = ColorRGBA::GRAY();
|
||||
#else
|
||||
static const std::array<float, 4> DEFAULT_BASE_COLOR = { 0.625f, 0.625f, 0.625f, 1.0f };
|
||||
static const std::array<float, 4> DEFAULT_DRAG_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static const std::array<float, 4> DEFAULT_HIGHLIGHT_COLOR = { 1.0f, 0.38f, 0.0f, 1.0f };
|
||||
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
|
||||
static const ColorRGBA DEFAULT_BASE_COLOR = { 0.625f, 0.625f, 0.625f, 1.0f };
|
||||
static const ColorRGBA DEFAULT_DRAG_COLOR = ColorRGBA::WHITE();
|
||||
static const ColorRGBA DEFAULT_HIGHLIGHT_COLOR = ColorRGBA::ORANGE();
|
||||
static const std::array<ColorRGBA, 3> AXES_COLOR = {{ ColorRGBA::X(), ColorRGBA::Y(), ColorRGBA::Z() }};
|
||||
static const ColorRGBA CONSTRAINED_COLOR = ColorRGBA::GRAY();
|
||||
|
||||
class ImGuiWrapper;
|
||||
class GLCanvas3D;
|
||||
@ -61,11 +47,7 @@ protected:
|
||||
|
||||
Vec3d center;
|
||||
Vec3d angles;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color;
|
||||
#else
|
||||
std::array<float, 4> color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
bool enabled;
|
||||
bool dragging;
|
||||
|
||||
@ -78,11 +60,7 @@ protected:
|
||||
float get_dragging_half_size(float size) const;
|
||||
|
||||
private:
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void render(float size, const ColorRGBA& render_color, bool picking) const;
|
||||
#else
|
||||
void render(float size, const std::array<float, 4>& render_color, bool picking) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLModel cube;
|
||||
};
|
||||
@ -115,15 +93,9 @@ protected:
|
||||
unsigned int m_sprite_id;
|
||||
int m_hover_id;
|
||||
bool m_dragging;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA m_base_color;
|
||||
ColorRGBA m_drag_color;
|
||||
ColorRGBA m_highlight_color;
|
||||
#else
|
||||
std::array<float, 4> m_base_color;
|
||||
std::array<float, 4> m_drag_color;
|
||||
std::array<float, 4> m_highlight_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
mutable std::vector<Grabber> m_grabbers;
|
||||
ImGuiWrapper* m_imgui;
|
||||
bool m_first_input_window_render;
|
||||
@ -167,11 +139,7 @@ public:
|
||||
int get_hover_id() const { return m_hover_id; }
|
||||
void set_hover_id(int id);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
void set_highlight_color(const ColorRGBA& color) { m_highlight_color = color; }
|
||||
#else
|
||||
void set_highlight_color(const std::array<float, 4>& color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void enable_grabber(unsigned int id);
|
||||
void disable_grabber(unsigned int id);
|
||||
@ -213,11 +181,8 @@ protected:
|
||||
|
||||
// Returns the picking color for the given id, based on the BASE_ID constant
|
||||
// No check is made for clashing with other picking color (i.e. GLVolumes)
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA picking_color_component(unsigned int id) const;
|
||||
#else
|
||||
std::array<float, 4> picking_color_component(unsigned int id) const;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void render_grabbers(const BoundingBoxf3& box) const;
|
||||
void render_grabbers(float size) const;
|
||||
void render_grabbers_for_picking(const BoundingBoxf3& box) const;
|
||||
@ -232,12 +197,6 @@ private:
|
||||
bool m_dirty;
|
||||
};
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
||||
// were not interpolated by alpha blending or multi sampling.
|
||||
extern unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue);
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
|
@ -23,12 +23,8 @@ namespace GUI {
|
||||
|
||||
const double GLGizmoCut::Offset = 10.0;
|
||||
const double GLGizmoCut::Margin = 20.0;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const ColorRGBA GRABBER_COLOR = ColorRGBA::ORANGE();
|
||||
static const ColorRGBA PLANE_COLOR = { 0.8f, 0.8f, 0.8f, 0.5f };
|
||||
#else
|
||||
const std::array<float, 4> GLGizmoCut::GrabberColor = { 1.0, 0.5, 0.0, 1.0 };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
@ -108,11 +104,7 @@ void GLGizmoCut::on_render()
|
||||
|
||||
// Draw the cutting plane
|
||||
::glBegin(GL_QUADS);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor4fv(PLANE_COLOR.data());
|
||||
#else
|
||||
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glVertex3f(min_x, min_y, plane_center.z());
|
||||
::glVertex3f(max_x, min_y, plane_center.z());
|
||||
::glVertex3f(max_x, max_y, plane_center.z());
|
||||
@ -143,11 +135,7 @@ void GLGizmoCut::on_render()
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.1f);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
m_grabbers[0].color = GRABBER_COLOR;
|
||||
#else
|
||||
m_grabbers[0].color = GrabberColor;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_grabbers[0].render(m_hover_id == 0, (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0));
|
||||
|
||||
shader->stop_using();
|
||||
|
@ -13,9 +13,6 @@ class GLGizmoCut : public GLGizmoBase
|
||||
{
|
||||
static const double Offset;
|
||||
static const double Margin;
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
static const std::array<float, 4> GrabberColor;
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
double m_cut_z{ 0.0 };
|
||||
double m_max_z{ 0.0 };
|
||||
|
@ -13,10 +13,8 @@
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const Slic3r::ColorRGBA DEFAULT_PLANE_COLOR = { 0.9f, 0.9f, 0.9f, 0.5f };
|
||||
static const Slic3r::ColorRGBA DEFAULT_HOVER_PLANE_COLOR = { 0.9f, 0.9f, 0.9f, 0.75f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
@ -78,15 +76,7 @@ void GLGizmoFlatten::on_render()
|
||||
if (this->is_plane_update_necessary())
|
||||
update_planes();
|
||||
for (int i = 0; i < (int)m_planes.size(); ++i) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(i == m_hover_id ? DEFAULT_HOVER_PLANE_COLOR.data() : DEFAULT_PLANE_COLOR.data()));
|
||||
#else
|
||||
if (i == m_hover_id)
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.75f));
|
||||
else
|
||||
glsafe(::glColor4f(0.9f, 0.9f, 0.9f, 0.5f));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (m_planes[i].vbo.has_VBOs())
|
||||
m_planes[i].vbo.render();
|
||||
}
|
||||
@ -112,11 +102,7 @@ void GLGizmoFlatten::on_render_for_picking()
|
||||
if (this->is_plane_update_necessary())
|
||||
update_planes();
|
||||
for (int i = 0; i < (int)m_planes.size(); ++i) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(picking_color_component(i).data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(picking_color_component(i).data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
m_planes[i].vbo.render();
|
||||
}
|
||||
glsafe(::glPopMatrix());
|
||||
|
@ -116,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(::glMultMatrixd(instance_matrix.data()));
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA render_color;
|
||||
#else
|
||||
std::array<float, 4> render_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const sla::DrainHoles& drain_holes = m_c->selection_info()->model_object()->sla_drain_holes;
|
||||
size_t cache_size = drain_holes.size();
|
||||
|
||||
@ -132,14 +128,8 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
|
||||
continue;
|
||||
|
||||
// First decide about the color of the point.
|
||||
if (picking) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
if (picking)
|
||||
render_color = picking_color_component(i);
|
||||
#else
|
||||
std::array<float, 4> color = picking_color_component(i);
|
||||
render_color = color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
else {
|
||||
if (size_t(m_hover_id) == i)
|
||||
render_color = {0.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) {
|
||||
render_color = {1.0f, 0.0f, 0.0f, 0.5f};
|
||||
}
|
||||
else { // neither hover nor picking
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
else // neither hover nor picking
|
||||
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);
|
||||
|
@ -56,29 +56,12 @@ bool GLGizmoMmuSegmentation::on_is_activable() const
|
||||
return GLGizmoPainterBase::on_is_activable() && wxGetApp().extruders_edited_cnt() > 1;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static std::vector<ColorRGBA> get_extruders_colors()
|
||||
{
|
||||
#else
|
||||
static std::vector<std::array<float, 4>> get_extruders_colors()
|
||||
{
|
||||
unsigned char rgb_color[3] = {};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> ret;
|
||||
decode_colors(colors, ret);
|
||||
return ret;
|
||||
#else
|
||||
std::vector<std::array<float, 4>> colors_out(colors.size());
|
||||
for (const std::string &color : colors) {
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb_color);
|
||||
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()
|
||||
@ -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,
|
||||
const std::vector<std::string>& extruders,
|
||||
const std::vector<ColorRGBA>& extruders_colors,
|
||||
size_t& selection_idx)
|
||||
#else
|
||||
static void render_extruders_combo(const std::string &label,
|
||||
const std::vector<std::string> &extruders,
|
||||
const std::vector<std::array<float, 4>> &extruders_colors,
|
||||
size_t &selection_idx)
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
{
|
||||
assert(!extruders_colors.empty());
|
||||
assert(extruders_colors.size() == extruders_colors.size());
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
auto convert_to_imu32 = [](const std::array<float, 4> &color) -> ImU32 {
|
||||
return IM_COL32(uint8_t(color[0] * 255.f), uint8_t(color[1] * 255.f), uint8_t(color[2] * 255.f), uint8_t(color[3] * 255.f));
|
||||
};
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
size_t selection_out = selection_idx;
|
||||
// It is necessary to use BeginGroup(). Otherwise, when using SameLine() is called, then other items will be drawn inside the combobox.
|
||||
ImGui::BeginGroup();
|
||||
@ -259,11 +229,7 @@ static void render_extruders_combo(const std::string &labe
|
||||
ImGui::SameLine();
|
||||
ImGuiStyle &style = ImGui::GetStyle();
|
||||
float height = ImGui::GetTextLineHeight();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height), ImGuiWrapper::to_ImU32(extruders_colors[extruder_idx]));
|
||||
#else
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height), convert_to_imu32(extruders_colors[extruder_idx]));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
ImGui::GetWindowDrawList()->AddRect(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height), IM_COL32_BLACK);
|
||||
|
||||
ImGui::SetCursorScreenPos(ImVec2(start_position.x + height + height / 2 + style.FramePadding.x, start_position.y));
|
||||
@ -281,11 +247,7 @@ static void render_extruders_combo(const std::string &labe
|
||||
ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
float height = ImGui::GetTextLineHeight();
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + height + height / 2, p.y + height), ImGuiWrapper::to_ImU32(extruders_colors[selection_idx]));
|
||||
#else
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + height + height / 2, p.y + height), convert_to_imu32(extruders_colors[selection_idx]));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
ImGui::GetWindowDrawList()->AddRect(p, ImVec2(p.x + height + height / 2, p.y + height), IM_COL32_BLACK);
|
||||
|
||||
ImGui::SetCursorScreenPos(ImVec2(p.x + height + height / 2 + style.FramePadding.x, p.y));
|
||||
@ -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);
|
||||
ImGui::SameLine();
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& select_first_color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
ImVec4 first_color = ImGuiWrapper::to_ImVec4(select_first_color);
|
||||
if (ImGui::ColorEdit4("First color##color_picker", (float*)&first_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_first_selected_extruder_idx] = ImGuiWrapper::from_ImVec4(first_color);
|
||||
#else
|
||||
const std::array<float, 4> &select_first_color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
ImVec4 first_color = ImVec4(select_first_color[0], select_first_color[1], select_first_color[2], select_first_color[3]);
|
||||
if (ImGui::ColorEdit4("First color##color_picker", (float*)&first_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_first_selected_extruder_idx] = { first_color.x, first_color.y, first_color.z, first_color.w };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
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);
|
||||
ImGui::SameLine();
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& select_second_color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
ImVec4 second_color = ImGuiWrapper::to_ImVec4(select_second_color);
|
||||
if (ImGui::ColorEdit4("Second color##color_picker", (float*)&second_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_second_selected_extruder_idx] = ImGuiWrapper::from_ImVec4(second_color);
|
||||
#else
|
||||
const std::array<float, 4> &select_second_color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
ImVec4 second_color = ImVec4(select_second_color[0], select_second_color[1], select_second_color[2], select_second_color[3]);
|
||||
if (ImGui::ColorEdit4("Second color##color_picker", (float*)&second_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_second_selected_extruder_idx] = { second_color.x, second_color.y, second_color.z, second_color.w };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
|
||||
|
||||
@ -607,7 +555,6 @@ PainterGizmoType GLGizmoMmuSegmentation::get_painter_type() const
|
||||
return PainterGizmoType::MMU_SEGMENTATION;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_left_button_color() const
|
||||
{
|
||||
ColorRGBA color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
@ -621,19 +568,6 @@ ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const
|
||||
color.a(0.25f);
|
||||
return color;
|
||||
}
|
||||
#else
|
||||
std::array<float, 4> GLGizmoMmuSegmentation::get_cursor_sphere_left_button_color() const
|
||||
{
|
||||
const std::array<float, 4> &color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
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)
|
||||
{
|
||||
|
@ -62,13 +62,8 @@ public:
|
||||
class TriangleSelectorMmGui : public TriangleSelectorGUI {
|
||||
public:
|
||||
// Plus 1 in the initialization of m_gizmo_scene is because the first position is allocated for non-painted triangles, and the indices above colors.size() are allocated for seed fill.
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
TriangleSelectorMmGui(const TriangleMesh& mesh, const std::vector<ColorRGBA>& colors, const ColorRGBA& default_volume_color)
|
||||
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {}
|
||||
#else
|
||||
explicit TriangleSelectorMmGui(const TriangleMesh &mesh, const std::vector<std::array<float, 4>> &colors, const std::array<float, 4> &default_volume_color)
|
||||
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
~TriangleSelectorMmGui() override = default;
|
||||
|
||||
// Render current selection. Transformation matrices are supposed
|
||||
@ -78,13 +73,8 @@ public:
|
||||
private:
|
||||
void update_render_data();
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const std::vector<ColorRGBA>& m_colors;
|
||||
const ColorRGBA m_default_volume_color;
|
||||
#else
|
||||
const std::vector<std::array<float, 4>> &m_colors;
|
||||
const std::array<float, 4> m_default_volume_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
GLMmSegmentationGizmo3DScene m_gizmo_scene;
|
||||
};
|
||||
|
||||
@ -110,13 +100,8 @@ public:
|
||||
const float get_cursor_radius_min() const override { return CursorRadiusMin; }
|
||||
|
||||
protected:
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA get_cursor_sphere_left_button_color() const override;
|
||||
ColorRGBA get_cursor_sphere_right_button_color() const override;
|
||||
#else
|
||||
std::array<float, 4> get_cursor_sphere_left_button_color() const override;
|
||||
std::array<float, 4> get_cursor_sphere_right_button_color() const override;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
EnforcerBlockerType get_left_button_state_type() const override { return EnforcerBlockerType(m_first_selected_extruder_idx + 1); }
|
||||
EnforcerBlockerType get_right_button_state_type() const override { return EnforcerBlockerType(m_second_selected_extruder_idx + 1); }
|
||||
@ -136,13 +121,8 @@ protected:
|
||||
size_t m_first_selected_extruder_idx = 0;
|
||||
size_t m_second_selected_extruder_idx = 1;
|
||||
std::vector<std::string> m_original_extruders_names;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
std::vector<ColorRGBA> m_original_extruders_colors;
|
||||
std::vector<ColorRGBA> m_modified_extruders_colors;
|
||||
#else
|
||||
std::vector<std::array<float, 4>> m_original_extruders_colors;
|
||||
std::vector<std::array<float, 4>> m_modified_extruders_colors;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
std::vector<int> m_original_volumes_extruder_idxs;
|
||||
|
||||
static const constexpr float CursorRadiusMin = 0.1f; // cannot be zero
|
||||
|
@ -117,11 +117,7 @@ void GLGizmoMove3D::on_render()
|
||||
// draw axes
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
if (m_grabbers[i].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(AXES_COLOR[i].data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(AXES_COLOR[i].data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3dv(center.data());
|
||||
::glVertex3dv(m_grabbers[i].center.data());
|
||||
@ -138,11 +134,7 @@ void GLGizmoMove3D::on_render()
|
||||
}
|
||||
else {
|
||||
// draw axis
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3dv(center.data());
|
||||
::glVertex3dv(m_grabbers[m_hover_id].center.data());
|
||||
@ -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);
|
||||
double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size(mean_size) : (double)m_grabbers[axis].get_half_size(mean_size);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color = m_grabbers[axis].color;
|
||||
if (!picking && m_hover_id != -1)
|
||||
color = complementary(color);
|
||||
#else
|
||||
std::array<float, 4> color = m_grabbers[axis].color;
|
||||
if (!picking && m_hover_id != -1) {
|
||||
color[0] = 1.0f - color[0];
|
||||
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");
|
||||
if (shader == nullptr)
|
||||
|
@ -207,20 +207,12 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
||||
if (is_left_handed)
|
||||
glFrontFace(GL_CW);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA render_color = { 0.0f, 0.0f, 0.0f, 0.25f };
|
||||
#else
|
||||
std::array<float, 4> render_color = {0.f, 0.f, 0.f, 0.25f};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (m_button_down == Button::Left)
|
||||
render_color = this->get_cursor_sphere_left_button_color();
|
||||
else if (m_button_down == Button::Right)
|
||||
render_color = this->get_cursor_sphere_right_button_color();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(render_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(render_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
assert(s_sphere != nullptr);
|
||||
s_sphere->render();
|
||||
@ -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});
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA TriangleSelectorGUI::get_seed_fill_color(const ColorRGBA& base_color)
|
||||
{
|
||||
return saturate(base_color, 0.75f);
|
||||
}
|
||||
#else
|
||||
std::array<float, 4> TriangleSelectorGUI::get_seed_fill_color(const std::array<float, 4> &base_color)
|
||||
{
|
||||
return { base_color[0] * 0.75f, base_color[1] * 0.75f, base_color[2] * 0.75f, 1.f };
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
||||
{
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const ColorRGBA enforcers_color = { 0.47f, 0.47f, 1.0f, 1.0f };
|
||||
static const ColorRGBA blockers_color = { 1.0f, 0.44f, 0.44f, 1.0f };
|
||||
#else
|
||||
static constexpr std::array<float, 4> enforcers_color{0.47f, 0.47f, 1.f, 1.f};
|
||||
static constexpr std::array<float, 4> blockers_color{1.f, 0.44f, 0.44f, 1.f};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (m_update_render_data) {
|
||||
update_render_data();
|
||||
@ -761,15 +741,9 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
||||
for (auto &iva : m_iva_seed_fills)
|
||||
if (iva.has_VBOs()) {
|
||||
size_t color_idx = &iva - &m_iva_seed_fills.front();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA& color = TriangleSelectorGUI::get_seed_fill_color(color_idx == 1 ? enforcers_color :
|
||||
color_idx == 2 ? blockers_color :
|
||||
GLVolume::NEUTRAL_COLOR);
|
||||
#else
|
||||
const std::array<float, 4> &color = TriangleSelectorGUI::get_seed_fill_color(color_idx == 1 ? enforcers_color :
|
||||
color_idx == 2 ? blockers_color :
|
||||
GLVolume::NEUTRAL_COLOR);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
shader->set_uniform("uniform_color", color);
|
||||
iva.render();
|
||||
}
|
||||
|
@ -86,11 +86,7 @@ public:
|
||||
protected:
|
||||
bool m_update_render_data = false;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ColorRGBA get_seed_fill_color(const ColorRGBA& base_color);
|
||||
#else
|
||||
static std::array<float, 4> get_seed_fill_color(const std::array<float, 4> &base_color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
private:
|
||||
void update_render_data();
|
||||
@ -139,13 +135,8 @@ protected:
|
||||
virtual void update_model_object() const = 0;
|
||||
virtual void update_from_model_object() = 0;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
virtual ColorRGBA get_cursor_sphere_left_button_color() const { return { 0.0f, 0.0f, 1.0f, 0.25f }; }
|
||||
virtual ColorRGBA get_cursor_sphere_right_button_color() const { return { 1.0f, 0.0f, 0.0f, 0.25f }; }
|
||||
#else
|
||||
virtual std::array<float, 4> get_cursor_sphere_left_button_color() const { return {0.f, 0.f, 1.f, 0.25f}; }
|
||||
virtual std::array<float, 4> get_cursor_sphere_right_button_color() const { return {1.f, 0.f, 0.f, 0.25f}; }
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
virtual EnforcerBlockerType get_left_button_state_type() const { return EnforcerBlockerType::ENFORCER; }
|
||||
virtual EnforcerBlockerType get_right_button_state_type() const { return EnforcerBlockerType::BLOCKER; }
|
||||
|
@ -137,11 +137,7 @@ void GLGizmoRotate::on_render()
|
||||
transform_to_local(selection);
|
||||
|
||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv((m_hover_id != -1) ? m_drag_color.data() : m_highlight_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv((m_hover_id != -1) ? m_drag_color.data() : m_highlight_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
render_circle();
|
||||
|
||||
@ -151,11 +147,7 @@ void GLGizmoRotate::on_render()
|
||||
render_reference_radius();
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_highlight_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_highlight_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
if (m_hover_id != -1)
|
||||
render_angle();
|
||||
@ -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].angles(2) = m_angle;
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv((m_hover_id != -1) ? m_drag_color.data() : m_highlight_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv((m_hover_id != -1) ? m_drag_color.data() : m_highlight_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
@ -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);
|
||||
double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size(mean_size) : (double)m_grabbers[0].get_half_size(mean_size);
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA color = m_grabbers[0].color;
|
||||
if (!picking && m_hover_id != -1)
|
||||
color = complementary(color);
|
||||
#else
|
||||
std::array<float, 4> color = m_grabbers[0].color;
|
||||
if (!picking && m_hover_id != -1) {
|
||||
color[0] = 1.0f - color[0];
|
||||
color[1] = 1.0f - color[1];
|
||||
color[2] = 1.0f - color[2];
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader == nullptr)
|
||||
|
@ -209,34 +209,18 @@ void GLGizmoScale3D::on_render()
|
||||
if (m_hover_id == -1) {
|
||||
// draw connections
|
||||
if (m_grabbers[0].enabled && m_grabbers[1].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[0].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[0].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(0, 1);
|
||||
}
|
||||
if (m_grabbers[2].enabled && m_grabbers[3].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(2, 3);
|
||||
}
|
||||
if (m_grabbers[4].enabled && m_grabbers[5].enabled) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(4, 5);
|
||||
}
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_base_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_base_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(6, 7);
|
||||
render_grabbers_connection(7, 8);
|
||||
render_grabbers_connection(8, 9);
|
||||
@ -246,11 +230,7 @@ void GLGizmoScale3D::on_render()
|
||||
}
|
||||
else if (m_hover_id == 0 || m_hover_id == 1) {
|
||||
// draw connection
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[0].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[0].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(0, 1);
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
@ -265,11 +245,7 @@ void GLGizmoScale3D::on_render()
|
||||
}
|
||||
else if (m_hover_id == 2 || m_hover_id == 3) {
|
||||
// draw connection
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(2, 3);
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
@ -284,11 +260,7 @@ void GLGizmoScale3D::on_render()
|
||||
}
|
||||
else if (m_hover_id == 4 || m_hover_id == 5) {
|
||||
// draw connection
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(4, 5);
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
@ -303,11 +275,7 @@ void GLGizmoScale3D::on_render()
|
||||
}
|
||||
else if (m_hover_id >= 6) {
|
||||
// draw connection
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
glsafe(::glColor4fv(m_drag_color.data()));
|
||||
#else
|
||||
glsafe(::glColor4fv(m_drag_color.data()));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
render_grabbers_connection(6, 7);
|
||||
render_grabbers_connection(7, 8);
|
||||
render_grabbers_connection(8, 9);
|
||||
|
@ -144,11 +144,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
||||
glsafe(::glTranslated(0.0, 0.0, z_shift));
|
||||
glsafe(::glMultMatrixd(instance_matrix.data()));
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGBA render_color;
|
||||
#else
|
||||
std::array<float, 4> render_color;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
for (size_t i = 0; i < cache_size; ++i) {
|
||||
const sla::SupportPoint& support_point = m_editing_mode ? m_editing_cache[i].support_point : m_normal_cache[i];
|
||||
const bool& point_selected = m_editing_mode ? m_editing_cache[i].selected : false;
|
||||
@ -230,14 +226,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
||||
|
||||
// Now render the drain holes:
|
||||
if (has_holes && ! picking) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
render_color = { 0.7f, 0.7f, 0.7f, 0.7f };
|
||||
#else
|
||||
render_color[0] = 0.7f;
|
||||
render_color[1] = 0.7f;
|
||||
render_color[2] = 0.7f;
|
||||
render_color[3] = 0.7f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const_cast<GLModel*>(&m_cylinder)->set_color(-1, render_color);
|
||||
if (shader)
|
||||
shader->set_uniform("emission_factor", 0.5f);
|
||||
|
@ -216,13 +216,8 @@ void InstancesHider::render_cut() const
|
||||
if (mv->is_model_part())
|
||||
glsafe(::glColor3f(0.8f, 0.3f, 0.0f));
|
||||
else {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
const ColorRGBA color = color_from_model_volume(*mv);
|
||||
glsafe(::glColor4fv(color.data()));
|
||||
#else
|
||||
const std::array<float, 4>& c = color_from_model_volume(*mv);
|
||||
glsafe(::glColor4f(c[0], c[1], c[2], c[3]));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
glsafe(::glPushAttrib(GL_DEPTH_TEST));
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
@ -25,9 +25,7 @@
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "3DScene.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "I18N.hpp"
|
||||
@ -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_LIGHT = { 0.4f, 0.4f, 0.4f, 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_HOVERED = COL_ORANGE_LIGHT;
|
||||
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()
|
||||
{
|
||||
@ -1024,7 +1011,6 @@ bool ImGuiWrapper::want_any_input() const
|
||||
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ImU32 ImGuiWrapper::to_ImU32(const ColorRGBA& color)
|
||||
{
|
||||
return ImGui::GetColorU32({ color.r(), color.g(), color.b(), color.a() });
|
||||
@ -1044,7 +1030,6 @@ ColorRGBA ImGuiWrapper::from_ImVec4(const ImVec4& color)
|
||||
{
|
||||
return { color.x, color.y, color.z, color.w };
|
||||
}
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#ifdef __APPLE__
|
||||
static const ImWchar ranges_keyboard_shortcuts[] =
|
||||
|
@ -9,11 +9,9 @@
|
||||
#include <wx/string.h>
|
||||
|
||||
#include "libslic3r/Point.hpp"
|
||||
#include "libslic3r/Color.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
class ColorRGBA;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
namespace Search {
|
||||
struct OptionViewParameters;
|
||||
} // namespace Search
|
||||
@ -129,12 +127,10 @@ public:
|
||||
void set_requires_extra_frame() { m_requires_extra_frame = true; }
|
||||
void reset_requires_extra_frame() { m_requires_extra_frame = false; }
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ImU32 to_ImU32(const ColorRGBA& color);
|
||||
static ImVec4 to_ImVec4(const ColorRGBA& color);
|
||||
static ColorRGBA from_ImU32(const ImU32& color);
|
||||
static ColorRGBA from_ImVec4(const ImVec4& color);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
static const ImVec4 COL_GREY_DARK;
|
||||
static const ImVec4 COL_GREY_LIGHT;
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "GUI.hpp"
|
||||
#include "format.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 monospace = wxGetApp().code_font();
|
||||
wxColour text_clr = wxGetApp().get_label_clr_default();
|
||||
wxColour bgr_clr = parent->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
wxColour bgr_clr = parent->GetBackgroundColour();
|
||||
auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
const int font_size = font.GetPointSize();
|
||||
int size[] = { font_size, font_size, font_size, font_size, font_size, font_size, font_size };
|
||||
html->SetFonts(font.GetFaceName(), monospace.GetFaceName(), size);
|
||||
|
@ -24,9 +24,7 @@
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
@ -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());
|
||||
|
||||
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty()) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
// Paint the color bars.
|
||||
ColorRGB color;
|
||||
decode_color(filament_rgb, color);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, color, false, 1, dark_mode));
|
||||
#else
|
||||
unsigned char rgb[3];
|
||||
// Paint the color bars.
|
||||
bitmap_cache().parse_color(filament_rgb, rgb);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, rgb, false, 1, dark_mode));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (!is_single_bar) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
decode_color(extruder_rgb, color);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(thin_icon_width, icon_height, color, false, 1, dark_mode));
|
||||
#else
|
||||
bitmap_cache().parse_color(extruder_rgb, rgb);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(thin_icon_width, icon_height, rgb, false, 1, dark_mode));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
// Paint a lock at the system presets.
|
||||
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
|
||||
@ -782,15 +768,8 @@ void PlaterPresetComboBox::update()
|
||||
const Preset* selected_filament_preset = nullptr;
|
||||
std::string extruder_color;
|
||||
if (m_type == Preset::TYPE_FILAMENT) {
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
unsigned char rgb[3];
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
extruder_color = m_preset_bundle->printers.get_edited_preset().config.opt_string("extruder_colour", (unsigned int)m_extruder_idx);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
if (!can_decode_color(extruder_color))
|
||||
#else
|
||||
if (!bitmap_cache().parse_color(extruder_color, rgb))
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// Extruder color is not defined.
|
||||
extruder_color.clear();
|
||||
selected_filament_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_extruder_idx]);
|
||||
|
@ -22,13 +22,9 @@
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static const Slic3r::ColorRGBA UNIFORM_SCALE_COLOR = Slic3r::ColorRGBA::ORANGE();
|
||||
static const Slic3r::ColorRGBA SOLID_PLANE_COLOR = Slic3r::ColorRGBA::ORANGE();
|
||||
static const Slic3r::ColorRGBA TRANSPARENT_PLANE_COLOR = { 0.8f, 0.8f, 0.8f, 0.5f };
|
||||
#else
|
||||
static const std::array<float, 4> UNIFORM_SCALE_COLOR = { 0.923f, 0.504f, 0.264f, 1.0f };
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
@ -456,11 +452,7 @@ void Selection::clear()
|
||||
for (unsigned int i : m_list) {
|
||||
GLVolume& volume = *(*m_volumes)[i];
|
||||
volume.selected = false;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
bool is_transparent = volume.color.is_transparent();
|
||||
#else
|
||||
bool is_transparent = volume.color[3] < 1.0f;
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
if (is_transparent)
|
||||
volume.force_transparent = true;
|
||||
volume.set_render_color();
|
||||
@ -1874,17 +1866,10 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, float* color) cons
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
static ColorRGBA get_color(Axis axis)
|
||||
{
|
||||
return AXES_COLOR[axis];
|
||||
};
|
||||
#else
|
||||
static std::array<float, 4> get_color(Axis axis)
|
||||
{
|
||||
return { AXES_COLOR[axis][0], AXES_COLOR[axis][1], AXES_COLOR[axis][2], AXES_COLOR[axis][3] };
|
||||
};
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
void Selection::render_sidebar_position_hints(const std::string& sidebar_field) const
|
||||
{
|
||||
@ -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));
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor4fv((camera_on_top && type == 1) || (!camera_on_top && type == 2) ?
|
||||
SOLID_PLANE_COLOR.data() : TRANSPARENT_PLANE_COLOR.data());
|
||||
#else
|
||||
if ((camera_on_top && type == 1) || (!camera_on_top && type == 2))
|
||||
::glColor4f(1.0f, 0.38f, 0.0f, 1.0f);
|
||||
else
|
||||
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glVertex3f(min_x, min_y, z1);
|
||||
::glVertex3f(max_x, min_y, z1);
|
||||
::glVertex3f(max_x, max_y, z1);
|
||||
@ -2030,15 +2008,8 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co
|
||||
glsafe(::glEnd());
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
::glColor4fv((camera_on_top && type == 2) || (!camera_on_top && type == 1) ?
|
||||
SOLID_PLANE_COLOR.data() : TRANSPARENT_PLANE_COLOR.data());
|
||||
#else
|
||||
if ((camera_on_top && type == 2) || (!camera_on_top && type == 1))
|
||||
::glColor4f(1.0f, 0.38f, 0.0f, 1.0f);
|
||||
else
|
||||
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
::glVertex3f(min_x, min_y, z2);
|
||||
::glVertex3f(max_x, min_y, z2);
|
||||
::glVertex3f(max_x, max_y, z2);
|
||||
|
@ -4,9 +4,7 @@
|
||||
#include "libslic3r/BlacklistedLibraryCheck.hpp"
|
||||
#include "libslic3r/Platform.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#include "slic3r/GUI/format.hpp"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
@ -574,13 +572,8 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
|
||||
wxColour bgr_clr = wxGetApp().get_window_default_clr();
|
||||
SetBackgroundColour(bgr_clr);
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
auto *topSizer = new wxBoxSizer(wxVERTICAL);
|
||||
auto *vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -15,9 +15,7 @@
|
||||
#include "MainFrame.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "../libslic3r/BlacklistedLibraryCheck.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "../libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "format.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -117,13 +115,8 @@ SysInfoDialog::SysInfoDialog()
|
||||
// main_info_text
|
||||
wxFont font = get_default_font(this);
|
||||
const auto text_clr = wxGetApp().get_label_clr_default();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||
auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||
#else
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
const int fs = font.GetPointSize() - 1;
|
||||
int size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs };
|
||||
|
@ -11,9 +11,7 @@
|
||||
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
#include "format.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "Plater.hpp"
|
||||
@ -61,12 +59,7 @@ static std::string get_icon_name(Preset::Type type, PrinterTechnology pt) {
|
||||
static std::string def_text_color()
|
||||
{
|
||||
wxColour def_colour = wxGetApp().get_label_clr_default();
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
return encode_color(ColorRGB(def_colour.Red(), def_colour.Green(), def_colour.Blue()));
|
||||
#else
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), def_colour.Red(), def_colour.Green(), def_colour.Blue());
|
||||
return clr_str.ToStdString();
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
static std::string grey = "#808080";
|
||||
static std::string orange = "#ed6b21";
|
||||
@ -131,13 +124,8 @@ wxBitmap ModelNode::get_bitmap(const wxString& color)
|
||||
const int icon_height = lround(1.6 * em);
|
||||
|
||||
BitmapCache bmp_cache;
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
ColorRGB rgb;
|
||||
decode_color(into_u8(color), rgb);
|
||||
#else
|
||||
unsigned char rgb[3];
|
||||
BitmapCache::parse_color(into_u8(color), rgb);
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
// there is no need to scale created solid bitmap
|
||||
#ifndef __linux__
|
||||
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
|
||||
|
@ -7,9 +7,7 @@
|
||||
#include "GUI_App.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#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);
|
||||
|
||||
for (const std::string& color : extruder_colours) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
Slic3r::ColorRGB rgb;
|
||||
Slic3r::decode_color(color, rgb);
|
||||
m_colours.push_back(wxColor(rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar()));
|
||||
#else
|
||||
unsigned char rgb[3];
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb);
|
||||
m_colours.push_back(wxColor(rgb[0], rgb[1], rgb[2]));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
|
||||
// Create two switched panels with their own sizers
|
||||
|
@ -18,9 +18,7 @@
|
||||
#include "BitmapComboBox.hpp"
|
||||
#include "OG_CustomCtrl.hpp"
|
||||
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
#include "libslic3r/Color.hpp"
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
|
||||
#ifndef __linux__
|
||||
// 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())
|
||||
return bmps;
|
||||
|
||||
#if !ENABLE_COLOR_CLASSES
|
||||
unsigned char rgb[3];
|
||||
#endif // !ENABLE_COLOR_CLASSES
|
||||
|
||||
/* It's supposed that standard size of an icon is 36px*16px for 100% scaled display.
|
||||
* So set sizes for solid_colored icons used for filament preset
|
||||
* 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);
|
||||
if (bitmap == nullptr) {
|
||||
#if ENABLE_COLOR_CLASSES
|
||||
// Paint the color icon.
|
||||
Slic3r::ColorRGB rgb;
|
||||
Slic3r::decode_color(color, rgb);
|
||||
// there is no neede to scale created solid bitmap
|
||||
bitmap = bmp_cache.insert(bitmap_key, bmp_cache.mksolid(icon_width, icon_height, rgb, true, 1, dark_mode));
|
||||
#else
|
||||
// Paint the color icon.
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb);
|
||||
// there is no neede to scale created solid bitmap
|
||||
bitmap = bmp_cache.insert(bitmap_key, bmp_cache.mksolid(icon_width, icon_height, rgb, true, 1, dark_mode));
|
||||
#endif // ENABLE_COLOR_CLASSES
|
||||
}
|
||||
bmps.emplace_back(bitmap);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user