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 */
75  ~ColorScheme();
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  */
135  ColorSchemeGroup* getParent() const;
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  */
151  ColorScheme(const ColorScheme& rhs);
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  */
160  ColorScheme& operator=(const ColorScheme& rhs);
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  */
176  void setParent(ColorSchemeGroup* parent);
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 
ColorSchemeGroup * m_parent
A pointer to the parent group.
Definition: ColorScheme.h:182
It models the concept of color scheme.
Definition: ColorScheme.h:58
A helper class for 24-bit RGBA (Red-Green-Blue-Alpha channel) color.
URI C++ Library.
This class represents a group of color schemes.
std::string m_name
Color scheme name.
Definition: ColorScheme.h:183
#define TECOLOREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:73
std::vector< std::vector< RGBAColor > * > m_colorSet
A set of color list.
Definition: ColorScheme.h:184