Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkColorProperty.h"
18 #include <sstream>
19 
21 {
22 }
23 
24 mitk::ColorProperty::ColorProperty(const mitk::ColorProperty &other) : BaseProperty(other), m_Color(other.m_Color)
25 {
26 }
27 
28 mitk::ColorProperty::ColorProperty(const float color[3]) : m_Color(color)
29 {
30 }
31 
32 mitk::ColorProperty::ColorProperty(const float red, const float green, const float blue)
33 {
34  m_Color.Set(red, green, blue);
35 }
36 
37 mitk::ColorProperty::ColorProperty(const mitk::Color &color) : m_Color(color)
38 {
39 }
40 
41 bool mitk::ColorProperty::IsEqual(const BaseProperty &property) const
42 {
43  return this->m_Color == static_cast<const Self &>(property).m_Color;
44 }
45 
46 bool mitk::ColorProperty::Assign(const BaseProperty &property)
47 {
48  this->m_Color = static_cast<const Self &>(property).m_Color;
49  return true;
50 }
51 
53 {
54  return m_Color;
55 }
56 
58 {
59  if (m_Color != color)
60  {
61  m_Color = color;
62  Modified();
63  }
64 }
65 
67 {
68  SetColor(color);
69 }
70 
71 void mitk::ColorProperty::SetColor(float red, float green, float blue)
72 {
73  float tmp[3] = {red, green, blue};
74  SetColor(mitk::Color(tmp));
75 }
76 
78 {
79  std::stringstream myStr;
80  myStr.imbue(std::locale::classic());
81  myStr << GetValue();
82  return myStr.str();
83 }
85 {
86  return GetColor();
87 }
88 
89 itk::LightObject::Pointer mitk::ColorProperty::InternalClone() const
90 {
91  itk::LightObject::Pointer result(new Self(*this));
92  result->UnRegister();
93  return result;
94 }
itk::SmartPointer< Self > Pointer
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)
const mitk::Color & GetValue() const