Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ColorProperty Class Reference

Property for storing RGB color values. More...

#include <mitkColorProperty.h>

Inheritance diagram for mitk::ColorProperty:
Collaboration diagram for mitk::ColorProperty:

Public Types

typedef mitk::Color ValueType
 The type of the value stored by this property. More...
 

Public Member Functions

 mitkClassMacro (ColorProperty, BaseProperty)
 
Pointer Clone () const
 
 mitkNewMacro1Param (ColorProperty, const float *)
 
 mitkNewMacro1Param (ColorProperty, const mitk::Color &)
 
 mitkNewMacro3Param (ColorProperty, const float, const float, const float)
 
const mitk::Color & GetColor () const
 Get the color value. More...
 
const mitk::Color & GetValue () const
 Get the color value (alias for GetColor()). More...
 
std::string GetValueAsString () const override
 Return the color as a human-readable string. More...
 
void SetColor (const mitk::Color &color)
 Set the color value. More...
 
void SetValue (const mitk::Color &color)
 Set the color value (alias for SetColor()). More...
 
void SetColor (float red, float green, float blue)
 Set the color from individual RGB components. More...
 
bool ToJSON (nlohmann::json &j) const override
 Serialize the color to JSON as a three-element array [r, g, b]. More...
 
bool FromJSON (const nlohmann::json &j) override
 Deserialize the color from a JSON three-element array [r, g, b]. More...
 
BaseProperty & operator= (const BaseProperty &property)
 Assign a property value to this instance. More...
 
- Public Member Functions inherited from mitk::BaseProperty
 mitkClassMacroItkParent (BaseProperty, itk::Object)
 
Pointer Clone () const
 
bool operator== (const BaseProperty &property) const
 Compare two properties for equality. More...
 
BaseProperty & operator= (const BaseProperty &property)
 Assign a property value to this instance. More...
 
bool AssignProperty (const BaseProperty &property)
 Assign a property value to this instance and report success. More...
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 ColorProperty ()
 
 ColorProperty (const ColorProperty &other)
 
 ColorProperty (const float red, const float green, const float blue)
 
 ColorProperty (const float color[3])
 
 ColorProperty (const mitk::Color &color)
 
 mitkCloneMacro (ColorProperty)
 
- Protected Member Functions inherited from mitk::BaseProperty
 BaseProperty ()
 
 BaseProperty (const BaseProperty &other)
 
 ~BaseProperty () override
 

Protected Attributes

mitk::Color m_Color
 

Additional Inherited Members

- Static Public Attributes inherited from mitk::BaseProperty
static const std::string VALUE_CANNOT_BE_CONVERTED_TO_STRING
 Default return value for properties that cannot be converted to a string. More...
 

Detailed Description

Property for storing RGB color values.

Stores an RGB color with float precision (each component 0.0f to 1.0f). Used to associate a rendering color with a DataNode.

Note
If you want to apply the mitk::ColorProperty to an mitk::Image, make sure to set the mitk::RenderingModeProperty to a mode which supports color (e.g. LOOKUPTABLE_LEVELWINDOW_COLOR). For an example, see mitkImageVtkMapper2DColorTest.cpp in Core/Code/Rendering.
See also
BaseProperty
RenderingModeProperty

Definition at line 61 of file mitkColorProperty.h.

Member Typedef Documentation

◆ ValueType

The type of the value stored by this property.

Definition at line 86 of file mitkColorProperty.h.

Constructor & Destructor Documentation

◆ ColorProperty() [1/5]

mitk::ColorProperty::ColorProperty ( )
protected

◆ ColorProperty() [2/5]

mitk::ColorProperty::ColorProperty ( const ColorProperty &  other)
protected

◆ ColorProperty() [3/5]

mitk::ColorProperty::ColorProperty ( const float  red,
const float  green,
const float  blue 
)
protected

◆ ColorProperty() [4/5]

mitk::ColorProperty::ColorProperty ( const float  color[3])
protected

◆ ColorProperty() [5/5]

mitk::ColorProperty::ColorProperty ( const mitk::Color &  color)
protected

Member Function Documentation

◆ Clone()

Pointer mitk::ColorProperty::Clone ( ) const

◆ FromJSON()

bool mitk::ColorProperty::FromJSON ( const nlohmann::json &  j)
overridevirtual

Deserialize the color from a JSON three-element array [r, g, b].

Parameters
[in]jThe JSON array containing the RGB values.
Returns
Always true.

Implements mitk::BaseProperty.

◆ GetColor()

const mitk::Color& mitk::ColorProperty::GetColor ( ) const

Get the color value.

Returns
A const reference to the stored color.

◆ GetValue()

const mitk::Color& mitk::ColorProperty::GetValue ( ) const

Get the color value (alias for GetColor()).

Returns
A const reference to the stored color.

◆ GetValueAsString()

std::string mitk::ColorProperty::GetValueAsString ( ) const
overridevirtual

Return the color as a human-readable string.

Returns
A string representation of the RGB values.

Reimplemented from mitk::BaseProperty.

◆ mitkClassMacro()

mitk::ColorProperty::mitkClassMacro ( ColorProperty  ,
BaseProperty   
)

◆ mitkCloneMacro()

mitk::ColorProperty::mitkCloneMacro ( ColorProperty  )
protected

◆ mitkNewMacro1Param() [1/2]

mitk::ColorProperty::mitkNewMacro1Param ( ColorProperty  ,
const float *   
)

◆ mitkNewMacro1Param() [2/2]

mitk::ColorProperty::mitkNewMacro1Param ( ColorProperty  ,
const mitk::Color &   
)

◆ mitkNewMacro3Param()

mitk::ColorProperty::mitkNewMacro3Param ( ColorProperty  ,
const float  ,
const float  ,
const float   
)

◆ New()

static Pointer mitk::ColorProperty::New ( )
static

◆ operator=()

BaseProperty& mitk::BaseProperty::operator=

Assign a property value to this instance.

Performs a polymorphic assignment from the given property. The assignment succeeds only if the source and target properties are of the same type. The subclass-specific Assign() method is called to perform the actual value copy.

Subclasses must implement Assign(const BaseProperty&) and call the superclass Assign method for proper handling. The copy assignment operator of the subclass should be disabled and the base class operator should be made visible using "using" statements.

Parameters
[in]propertyThe property whose value should be assigned to this instance.
Returns
A reference to this property.
See also
AssignProperty
Assign

◆ SetColor() [1/2]

void mitk::ColorProperty::SetColor ( const mitk::Color &  color)

Set the color value.

Marks the property as modified if the new color differs from the current one.

Parameters
[in]colorThe new color to set.

◆ SetColor() [2/2]

void mitk::ColorProperty::SetColor ( float  red,
float  green,
float  blue 
)

Set the color from individual RGB components.

Parameters
[in]redRed component (0.0f to 1.0f).
[in]greenGreen component (0.0f to 1.0f).
[in]blueBlue component (0.0f to 1.0f).

◆ SetValue()

void mitk::ColorProperty::SetValue ( const mitk::Color &  color)

Set the color value (alias for SetColor()).

Parameters
[in]colorThe new color to set.

◆ ToJSON()

bool mitk::ColorProperty::ToJSON ( nlohmann::json &  j) const
overridevirtual

Serialize the color to JSON as a three-element array [r, g, b].

Parameters
[out]jThe JSON object to write the value into.
Returns
Always true.

Implements mitk::BaseProperty.

Member Data Documentation

◆ m_Color

mitk::Color mitk::ColorProperty::m_Color
protected

Definition at line 64 of file mitkColorProperty.h.


The documentation for this class was generated from the following file: