13 #ifndef mitkColorProperty_h
14 #define mitkColorProperty_h
19 #include <itkRGBPixel.h>
21 #include <nlohmann/json.hpp>
30 typedef itk::RGBPixel<float>
Color;
80 itkFactorylessNewMacro(Self);
146 using BaseProperty::operator=;
152 bool IsEqual(
const BaseProperty &property)
const override;
161 template <
typename TComponent>
164 j = nlohmann::json::array();
166 for (
size_t i = 0; i < 3; ++i)
170 template <
typename TComponent>
173 for (
size_t i = 0; i < 3; ++i)
174 j.at(i).get_to(c[i]);
Abstract base class for properties.
Property for storing RGB color values.
const mitk::Color & GetColor() const
Get the color value.
mitkNewMacro3Param(ColorProperty, const float, const float, const float)
ColorProperty(const float color[3])
void SetColor(float red, float green, float blue)
Set the color from individual RGB components.
std::string GetValueAsString() const override
Return the color as a human-readable string.
mitkCloneMacro(ColorProperty)
void SetValue(const mitk::Color &color)
Set the color value (alias for SetColor()).
ColorProperty(const ColorProperty &other)
mitk::Color ValueType
The type of the value stored by this property.
mitkClassMacro(ColorProperty, BaseProperty)
bool FromJSON(const nlohmann::json &j) override
Deserialize the color from a JSON three-element array [r, g, b].
bool ToJSON(nlohmann::json &j) const override
Serialize the color to JSON as a three-element array [r, g, b].
void SetColor(const mitk::Color &color)
Set the color value.
ColorProperty(const float red, const float green, const float blue)
ColorProperty(const mitk::Color &color)
mitkNewMacro1Param(ColorProperty, const mitk::Color &)
const mitk::Color & GetValue() const
Get the color value (alias for GetColor()).
#define mitkNewMacro1Param(classname, type)
void from_json(const nlohmann::json &j, RGBPixel< TComponent > &c)
void to_json(nlohmann::json &j, const RGBPixel< TComponent > &c)
Find image slices visible on a given plane.
itk::RGBPixel< float > Color
Standard RGB color typedef using float components.
Color MakeColor(float r, float g, float b)
Convenience function to create a Color from individual RGB components.