mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
Introduction of classes ColorRGB and ColorRGBA to unify color data definition and manipulation
(cherry picked from commit prusa3d/PrusaSlicer@d0bff2d996 )
This commit is contained in:
parent
36ffb18059
commit
28d0147d09
60 changed files with 1290 additions and 1174 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "libslic3r/TriangleMesh.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Geometry.hpp"
|
||||
#include "libslic3r/Color.hpp"
|
||||
// BBS
|
||||
#include "libslic3r/ObjectID.hpp"
|
||||
|
||||
|
@ -30,10 +31,10 @@
|
|||
#define glsafe(cmd) cmd
|
||||
#define glcheck()
|
||||
#endif // HAS_GLSAFE
|
||||
extern std::vector<std::array<float, 4>> get_extruders_colors();
|
||||
extern float FullyTransparentMaterialThreshold;
|
||||
extern float FullTransparentModdifiedToFixAlpha;
|
||||
extern std::array<float, 4> adjust_color_for_rendering(const std::array<float, 4> &colors);
|
||||
extern std::vector<Slic3r::ColorRGBA> get_extruders_colors();
|
||||
extern float FullyTransparentMaterialThreshold;
|
||||
extern float FullTransparentModdifiedToFixAlpha;
|
||||
extern Slic3r::ColorRGBA adjust_color_for_rendering(const Slic3r::ColorRGBA &colors);
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
@ -54,7 +55,7 @@ enum ModelInstanceEPrintVolumeState : unsigned char;
|
|||
using ModelObjectPtrs = std::vector<ModelObject*>;
|
||||
|
||||
// Return appropriate color based on the ModelVolume.
|
||||
std::array<float, 4> color_from_model_volume(const ModelVolume& model_volume);
|
||||
extern ColorRGBA color_from_model_volume(const ModelVolume& model_volume);
|
||||
|
||||
// A container for interleaved arrays of 3D vertices and normals,
|
||||
// possibly indexed by triangles and / or quads.
|
||||
|
@ -261,17 +262,17 @@ class GLVolume {
|
|||
public:
|
||||
std::string name;
|
||||
|
||||
static std::array<float, 4> DISABLED_COLOR;
|
||||
static std::array<float, 4> SLA_SUPPORT_COLOR;
|
||||
static std::array<float, 4> SLA_PAD_COLOR;
|
||||
static std::array<float, 4> NEUTRAL_COLOR;
|
||||
static std::array<float, 4> UNPRINTABLE_COLOR;
|
||||
static std::array<std::array<float, 4>, 5> MODEL_COLOR;
|
||||
static std::array<float, 4> MODEL_MIDIFIER_COL;
|
||||
static std::array<float, 4> MODEL_NEGTIVE_COL;
|
||||
static std::array<float, 4> SUPPORT_ENFORCER_COL;
|
||||
static std::array<float, 4> SUPPORT_BLOCKER_COL;
|
||||
static std::array<float, 4> MODEL_HIDDEN_COL;
|
||||
static ColorRGBA DISABLED_COLOR;
|
||||
static ColorRGBA SLA_SUPPORT_COLOR;
|
||||
static ColorRGBA SLA_PAD_COLOR;
|
||||
static ColorRGBA NEUTRAL_COLOR;
|
||||
static ColorRGBA UNPRINTABLE_COLOR;
|
||||
static std::array<ColorRGBA, 5> MODEL_COLOR;
|
||||
static ColorRGBA MODEL_MIDIFIER_COL;
|
||||
static ColorRGBA MODEL_NEGTIVE_COL;
|
||||
static ColorRGBA SUPPORT_ENFORCER_COL;
|
||||
static ColorRGBA SUPPORT_BLOCKER_COL;
|
||||
static ColorRGBA MODEL_HIDDEN_COL;
|
||||
|
||||
static void update_render_colors();
|
||||
static void load_render_colors();
|
||||
|
@ -288,7 +289,7 @@ public:
|
|||
};
|
||||
|
||||
GLVolume(float r = 1.f, float g = 1.f, float b = 1.f, float a = 1.f);
|
||||
GLVolume(const std::array<float, 4>& rgba) : GLVolume(rgba[0], rgba[1], rgba[2], rgba[3]) {}
|
||||
GLVolume(const ColorRGBA& color) : GLVolume(color.r(), color.g(), color.b(), color.a()) {}
|
||||
virtual ~GLVolume() = default;
|
||||
|
||||
// BBS
|
||||
|
@ -329,9 +330,9 @@ protected:
|
|||
|
||||
public:
|
||||
// Color of the triangles / quads held by this volume.
|
||||
std::array<float, 4> color;
|
||||
ColorRGBA color;
|
||||
// Color used to render this volume.
|
||||
std::array<float, 4> render_color;
|
||||
ColorRGBA render_color;
|
||||
|
||||
struct CompositeID {
|
||||
CompositeID(int object_id, int volume_id, int instance_id) : object_id(object_id), volume_id(volume_id), instance_id(instance_id) {}
|
||||
|
@ -426,9 +427,8 @@ public:
|
|||
return out;
|
||||
}
|
||||
|
||||
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);
|
||||
void set_color(const ColorRGBA& rgba) { color = rgba; }
|
||||
void set_render_color(const ColorRGBA& rgba) { render_color = rgba; }
|
||||
// Sets render color in dependence of current state
|
||||
void set_render_color();
|
||||
// set color according to model volume
|
||||
|
@ -525,7 +525,7 @@ public:
|
|||
virtual void render(bool with_outline = false) const;
|
||||
|
||||
//BBS: add simple render function for thumbnail
|
||||
void simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_objects, std::vector<std::array<float, 4>>& extruder_colors) const;
|
||||
void simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_objects, std::vector<ColorRGBA>& extruder_colors) const;
|
||||
|
||||
void finalize_geometry(bool opengl_initialized) { this->indexed_vertex_array.finalize_geometry(opengl_initialized); }
|
||||
void release_geometry() { this->indexed_vertex_array.release_geometry(); }
|
||||
|
@ -556,14 +556,14 @@ public:
|
|||
// BBS
|
||||
class GLWipeTowerVolume : public GLVolume {
|
||||
public:
|
||||
GLWipeTowerVolume(const std::vector<std::array<float, 4>>& colors);
|
||||
GLWipeTowerVolume(const std::vector<ColorRGBA>& colors);
|
||||
virtual void render(bool with_outline = false) const;
|
||||
|
||||
std::vector<GLIndexedVertexArray> iva_per_colors;
|
||||
bool IsTransparent();
|
||||
|
||||
private:
|
||||
std::vector<std::array<float, 4>> m_colors;
|
||||
std::vector<ColorRGBA> m_colors;
|
||||
};
|
||||
|
||||
typedef std::vector<GLVolume*> GLVolumePtrs;
|
||||
|
@ -657,8 +657,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);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
int get_selection_support_threshold_angle(bool&) const;
|
||||
// Render the volumes by OpenGL.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue