Tech ENABLE_COLOR_CLASSES - 1st installment -> Introduction of classes ColorRGB and ColorRGBA to unify color data definition and manipulation

This commit is contained in:
enricoturri1966 2021-12-22 10:45:35 +01:00
parent 48098fbaff
commit cd4094743e
53 changed files with 1810 additions and 60 deletions

View file

@ -62,8 +62,13 @@ public:
class TriangleSelectorMmGui : public TriangleSelectorGUI {
public:
// Plus 1 in the initialization of m_gizmo_scene is because the first position is allocated for non-painted triangles, and the indices above colors.size() are allocated for seed fill.
#if ENABLE_COLOR_CLASSES
TriangleSelectorMmGui(const TriangleMesh& mesh, const std::vector<ColorRGBA>& colors, const ColorRGBA& default_volume_color)
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {}
#else
explicit TriangleSelectorMmGui(const TriangleMesh &mesh, const std::vector<std::array<float, 4>> &colors, const std::array<float, 4> &default_volume_color)
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {}
#endif // ENABLE_COLOR_CLASSES
~TriangleSelectorMmGui() override = default;
// Render current selection. Transformation matrices are supposed
@ -73,8 +78,13 @@ public:
private:
void update_render_data();
#if ENABLE_COLOR_CLASSES
const std::vector<ColorRGBA>& m_colors;
const ColorRGBA m_default_volume_color;
#else
const std::vector<std::array<float, 4>> &m_colors;
const std::array<float, 4> m_default_volume_color;
#endif // ENABLE_COLOR_CLASSES
GLMmSegmentationGizmo3DScene m_gizmo_scene;
};
@ -100,8 +110,13 @@ public:
const float get_cursor_radius_min() const override { return CursorRadiusMin; }
protected:
#if ENABLE_COLOR_CLASSES
ColorRGBA get_cursor_sphere_left_button_color() const override;
ColorRGBA get_cursor_sphere_right_button_color() const override;
#else
std::array<float, 4> get_cursor_sphere_left_button_color() const override;
std::array<float, 4> get_cursor_sphere_right_button_color() const override;
#endif // ENABLE_COLOR_CLASSES
EnforcerBlockerType get_left_button_state_type() const override { return EnforcerBlockerType(m_first_selected_extruder_idx + 1); }
EnforcerBlockerType get_right_button_state_type() const override { return EnforcerBlockerType(m_second_selected_extruder_idx + 1); }
@ -121,8 +136,13 @@ protected:
size_t m_first_selected_extruder_idx = 0;
size_t m_second_selected_extruder_idx = 1;
std::vector<std::string> m_original_extruders_names;
#if ENABLE_COLOR_CLASSES
std::vector<ColorRGBA> m_original_extruders_colors;
std::vector<ColorRGBA> m_modified_extruders_colors;
#else
std::vector<std::array<float, 4>> m_original_extruders_colors;
std::vector<std::array<float, 4>> m_modified_extruders_colors;
#endif // ENABLE_COLOR_CLASSES
std::vector<int> m_original_volumes_extruder_idxs;
static const constexpr float CursorRadiusMin = 0.1f; // cannot be zero