Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkColorProperty.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkColorProperty.h"
14 #include <sstream>
15 
17 {
18 }
19 
21 {
22 }
23 
24 mitk::ColorProperty::ColorProperty(const float color[3]) : m_Color(color)
25 {
26 }
27 
28 mitk::ColorProperty::ColorProperty(const float red, const float green, const float blue)
29 {
30  m_Color.Set(red, green, blue);
31 }
32 
34 {
35 }
36 
37 bool mitk::ColorProperty::IsEqual(const BaseProperty &property) const
38 {
39  return this->m_Color == static_cast<const Self &>(property).m_Color;
40 }
41 
42 bool mitk::ColorProperty::Assign(const BaseProperty &property)
43 {
44  this->m_Color = static_cast<const Self &>(property).m_Color;
45  return true;
46 }
47 
49 {
50  return m_Color;
51 }
52 
54 {
55  if (m_Color != color)
56  {
57  m_Color = color;
58  Modified();
59  }
60 }
61 
63 {
64  SetColor(color);
65 }
66 
67 void mitk::ColorProperty::SetColor(float red, float green, float blue)
68 {
69  float tmp[3] = {red, green, blue};
70  SetColor(mitk::Color(tmp));
71 }
72 
74 {
75  std::stringstream myStr;
76  myStr.imbue(std::locale::classic());
77  myStr << GetValue();
78  return myStr.str();
79 }
81 {
82  return GetColor();
83 }
84 
85 itk::LightObject::Pointer mitk::ColorProperty::InternalClone() const
86 {
87  itk::LightObject::Pointer result(new Self(*this));
88  result->UnRegister();
89  return result;
90 }
const mitk::Color & GetValue() const
void SetColor(const mitk::Color &color)
std::string GetValueAsString() const override
void SetValue(const mitk::Color &color)
The ColorProperty class RGB color property.
Abstract base class for properties.
const mitk::Color & GetColor() const
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)