ColorScheme.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/color/ColorScheme.h
22 
23  \brief The concept of color scheme.
24 */
25 
26 #ifndef __TERRALIB_COLOR_INTERNAL_COLORSCHEME_H
27 #define __TERRALIB_COLOR_INTERNAL_COLORSCHEME_H
28 
29 // TerraLib
30 #include "RGBAColor.h"
31 
32 // STL
33 #include <string>
34 #include <vector>
35 
36 namespace te
37 {
38  namespace color
39  {
40 // Forward declarations
41  class ColorSchemeGroup;
42 
43  /*!
44  \class ColorScheme
45 
46  \brief It models the concept of color scheme.
47 
48  It is used to construct color scheme catalogs,
49  that helps the user to decide the right colors
50  to use in a map. A color scheme has a name
51  and a set of list colors. Each list can have a
52  certain number of colors.
53 
54  \ingroup color
55 
56  \sa ColorSchemeGroup, ColorSchemeCatalog, ColorSchemeCatalogManager
57  */
59  {
60  public:
61 
62  /** @name Initializer Methods
63  * Methods related to instantiation and destruction.
64  */
65  //@{
66 
67  /*!
68  \brief It initializes a new ColorScheme and adds it to the parent group of schemes.
69 
70  \param name Color schema name.
71  */
72  ColorScheme(const std::string& name);
73 
74  /*! \brief Destructor */
76 
77  //@}
78 
79  /** @name Accessor methods
80  * Methods used to get or set properties.
81  */
82  //@{
83 
84  /*!
85  \brief It returns the color schema name.
86 
87  \return The color schema name.
88  */
89  const std::string& getName() const;
90 
91  /*!
92  \brief It sets the color schema name and adjust its entry in the scheme group if needed.
93 
94  \param name The new color schema name.
95  */
96  void setName(const std::string& name);
97 
98  /*!
99  \brief It adds a new list of colors to the color scheme.
100 
101  \param colors The new list of colors to be added to the scheme.
102 
103  \note The color scheme will take the ownership of the color list.
104 
105  \note Don't inform a NULL pointer.
106  */
107  void push_back(std::vector<RGBAColor>* colors);
108 
109  /*!
110  \brief It returns all color lists.
111 
112  \return All color lists.
113  */
114  const std::vector<std::vector<RGBAColor>* >& getColors() const;
115 
116  /*!
117  \brief It returns a color list having the specified number of elements or NULL if none is found.
118 
119  This method will look up a list of color in the scheme that has the choosen
120  number of colors. If it can not find one, it will return NULL.
121 
122  \param size The number of elements needed for the color scheme.
123 
124  \return A color list having the specified number of elements or NULL if none is found.
125 
126  \note size must be a value greater than 0.
127  */
128  std::vector<RGBAColor>* getColors(size_t size) const;
129 
130  /*!
131  \brief It returns the parent scheme group or NULL if it doesn't belong to a group.
132 
133  \return The parent scheme group or NULL if it doesn't belong to a group.
134  */
136 
137  //@}
138 
139  private:
140 
141  /** @name Copy Constructor and Assignment Operator
142  * Copy constructor and assignment operator not allowed.
143  */
144  //@{
145 
146  /*!
147  \brief Copy constructor not allowed.
148 
149  \param rhs The right-hand-side copy that would be used to copy from.
150  */
152 
153  /*!
154  \brief Assignment operator not allowed.
155 
156  \param rhs The right-hand-side copy that would be used to copy from.
157 
158  \return A reference to this object.
159  */
161 
162  //@}
163 
164  /** @name Auxiliary Methods
165  * Auxiliary methods.
166  */
167  //@{
168 
169  /*!
170  \brief It sets the parent color scheme group for this scheme.
171 
172  \param parent The parent color scheme group.
173 
174  \note This method is intended to be used by a ColorSchemeGroup object.
175  */
177 
178  //@}
179 
180  private:
181 
182  ColorSchemeGroup* m_parent; //!< A pointer to the parent group.
183  std::string m_name; //!< Color scheme name.
184  std::vector<std::vector<RGBAColor>* > m_colorSet; //!< A set of color list.
185 
186  friend class ColorSchemeGroup;
187  };
188 
189  } // end namespace color
190 } // end namespace te
191 
192 #endif // __TERRALIB_COLOR_INTERNAL_COLORSCHEME_H
193 
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::color::ColorScheme::getColors
std::vector< RGBAColor > * getColors(size_t size) const
It returns a color list having the specified number of elements or NULL if none is found.
te::color::ColorScheme::setParent
void setParent(ColorSchemeGroup *parent)
It sets the parent color scheme group for this scheme.
te::color::ColorScheme::m_colorSet
std::vector< std::vector< RGBAColor > * > m_colorSet
A set of color list.
Definition: ColorScheme.h:184
te::color::ColorScheme::setName
void setName(const std::string &name)
It sets the color schema name and adjust its entry in the scheme group if needed.
te::color::ColorScheme::ColorScheme
ColorScheme(const std::string &name)
It initializes a new ColorScheme and adds it to the parent group of schemes.
te::color::ColorScheme::getName
const std::string & getName() const
It returns the color schema name.
te::color::ColorScheme::getParent
ColorSchemeGroup * getParent() const
It returns the parent scheme group or NULL if it doesn't belong to a group.
RGBAColor.h
A helper class for 24-bit RGBA (Red-Green-Blue-Alpha channel) color.
te::color::ColorScheme
It models the concept of color scheme.
Definition: ColorScheme.h:59
te::color::ColorScheme::m_parent
ColorSchemeGroup * m_parent
A pointer to the parent group.
Definition: ColorScheme.h:182
te::color::ColorScheme::getColors
const std::vector< std::vector< RGBAColor > * > & getColors() const
It returns all color lists.
TECOLOREXPORT
#define TECOLOREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:73
te::color::ColorScheme::m_name
std::string m_name
Color scheme name.
Definition: ColorScheme.h:183
te::color::ColorScheme::ColorScheme
ColorScheme(const ColorScheme &rhs)
Copy constructor not allowed.
te::color::ColorScheme::~ColorScheme
~ColorScheme()
Destructor.
te::color::ColorSchemeGroup
This class represents a group of color schemes.
Definition: ColorSchemeGroup.h:56
te::color::ColorScheme::push_back
void push_back(std::vector< RGBAColor > *colors)
It adds a new list of colors to the color scheme.
te::color::ColorScheme::operator=
ColorScheme & operator=(const ColorScheme &rhs)
Assignment operator not allowed.