1 /*=========================================================================
2  *
3  *  Copyright Insight Software Consortium
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *         http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkSpatialObjectProperty_h
19 #define itkSpatialObjectProperty_h
20 
21 #include <string>
22 #include <map>
23 
24 #include "itkLightObject.h"
25 #include "itkRGBAPixel.h"
26 #include "itkTimeStamp.h"
27 #include "itkObjectFactory.h"
28 
29 #include "ITKSpatialObjectsExport.h"
30 
31 namespace itk
32 {
33 /**
34  * This class contains the objects properties such as colors, opacity, etc...
35  * it's templated over the representation to use for each color component.
36  */
37 
38 class ITKSpatialObjects_EXPORT SpatialObjectProperty
39 {
40 public:
41 
42   SpatialObjectProperty();
43 
44   virtual ~SpatialObjectProperty() = default;
45 
46   using Self = SpatialObjectProperty;
47 
48   using ColorType = RGBAPixel< double >;
49 
50   virtual void Clear( void );
51 
SetColor(const ColorType & color)52   void SetColor( const ColorType & color )
53   { m_Color = color; }
54 
GetColor()55   ColorType & GetColor()
56   { return m_Color; }
57 
GetColor()58   const ColorType & GetColor() const
59   { return m_Color; }
60 
61   void SetColor(double r, double g, double b);
62 
63   void SetRed(double r);
64   double GetRed() const;
65 
66   void SetGreen(double g);
67   double GetGreen() const;
68 
69   void SetBlue(double b);
70   double GetBlue() const;
71 
72   void SetAlpha(double a);
73   double GetAlpha() const;
74 
SetName(const std::string & name)75   void SetName( const std::string & name )
76   { m_Name = name; }
77 
GetName()78   std::string & GetName()
79   { return m_Name; }
80 
GetName()81   const std::string & GetName() const
82   { return m_Name; }
83 
84   void SetTagScalarValue( const std::string & tag, double value );
85   void SetTagStringValue( const std::string & tag, const std::string & value );
86 
87   bool GetTagScalarValue( const std::string & tag, double & value ) const;
88   bool GetTagStringValue( const std::string & tag, std::string & value ) const;
89 
90   std::map< std::string, double > &            GetTagScalarDictionary();
91   const std::map< std::string, double > &      GetTagScalarDictionary() const;
92   std::map< std::string, std::string > &       GetTagStringDictionary();
93   const std::map< std::string, std::string > & GetTagStringDictionary() const;
94 
95   void SetTagScalarDictionary( const std::map< std::string, double > & dict );
96   void SetTagStringDictionary( const std::map< std::string,
97     std::string > & dict );
98 
Print(std::ostream & os)99   void Print(std::ostream & os) const
100   { this->PrintSelf( os, 3 ); }
101 
102   Self & operator=(const SpatialObjectProperty & rhs );
103 
104 protected:
105 
106   void PrintSelf(std::ostream & os, Indent indent) const;
107 
108 private:
109 
110   ColorType        m_Color;
111 
112   std::string      m_Name;
113 
114   std::map< std::string, double >      m_ScalarDictionary;
115   std::map< std::string, std::string > m_StringDictionary;
116 };
117 
118 }
119 
120 #endif // __SpatialObjectProperty_h
121