fw4spl
include/fwData/Color.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #pragma once
8 
9 #include "fwData/config.hpp"
10 #include "fwData/factory/new.hpp"
11 #include "fwData/Object.hpp"
12 
13 #include <array>
14 
15 fwCampAutoDeclareDataMacro((fwData)(Color), FWDATA_API);
16 
17 namespace fwData
18 {
23 class FWDATA_CLASS_API Color : public Object
24 {
25 
26 public:
27 
28  typedef float ColorType;
29  typedef std::array<ColorType, 4> ColorArray;
30 
32  ((::fwData::factory::New< Color >, () ))
33  ((ColorFactory,
34  ((ColorType))((ColorType)(1.0)) ((ColorType) (1.0)) ((ColorType)(
35  1.0)) ))
36  );
37 
38  fwCampMakeFriendDataMacro((fwData)(Color));
39 
44  FWDATA_API Color( ::fwData::Object::Key key );
45 
47  FWDATA_API virtual ~Color();
48 
50  FWDATA_API void shallowCopy( const Object::csptr& _source ) override;
51 
53  FWDATA_API void cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) override;
54 
58  ColorArray& getRGBA();
59  const ColorArray& getRGBA() const;
60  void setRGBA(const ColorArray& _vRGBA);
63  FWDATA_API void setRGBA( const ColorType red, const ColorType green, const ColorType blue,
66  const ColorType alpha = 1.0 );
67 
70  FWDATA_API void setRGBA( std::string hexaColor );
72 
77  FWDATA_API ColorType& red();
78  FWDATA_API ColorType& green();
79  FWDATA_API ColorType& blue();
80  FWDATA_API ColorType& alpha();
82 
86  FWDATA_API const ColorType& red() const;
87  FWDATA_API const ColorType& green() const;
88  FWDATA_API const ColorType& blue() const;
89  FWDATA_API const ColorType& alpha() const;
91 
92 protected:
93 
94  FWDATA_API static sptr ColorFactory(ColorType red, ColorType green, ColorType blue, ColorType alpha);
95 
97  ColorArray m_vRGBA;
98 
99 }; // end class Color
100 
101 //-----------------------------------------------------------------------------
102 
103 inline Color::ColorArray& Color::getRGBA()
104 {
105  return this->m_vRGBA;
106 }
107 
108 //-----------------------------------------------------------------------------
109 
110 inline const Color::ColorArray& Color::getRGBA() const
111 {
112  return this->m_vRGBA;
113 }
114 
115 //-----------------------------------------------------------------------------
116 
117 inline void Color::setRGBA(const Color::ColorArray& _vRGBA)
118 {
119  this->m_vRGBA = _vRGBA;
120 }
121 
122 //-----------------------------------------------------------------------------
123 
124 } // end namespace fwData
#define fwCoreClassDefinitionsWithNFactoriesMacro(_classinfo_, _factories_args_)
Generate common construction methods for classes with several factories.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
ColorArray m_vRGBA
RGBA of the image (in terms of points)
ColorArray & getRGBA()
This class defines color object.
void setRGBA(const ColorArray &_vRGBA)
Base class for each data object.
Contains the representation of the data objects used in the framework.