All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ColorSchemeGroup.cpp
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/ColorSchemeGroup.cpp
22 
23  \brief Implementation of the color scheme group class.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "ColorScheme.h"
29 #include "ColorSchemeCatalog.h"
30 #include "ColorSchemeGroup.h"
31 
32 // STL
33 #include <algorithm>
34 #include <cassert>
35 
37  : m_parent(0),
38  m_name(name)
39 {
40 }
41 
43 {
44  te::common::FreeContents(m_colorSchemes);
45 }
46 
47 const std::string& te::color::ColorSchemeGroup::getName() const
48 {
49  return m_name;
50 }
51 
52 void te::color::ColorSchemeGroup::setName(const std::string& name)
53 {
54  assert(name.empty() == false);
55 
56  if(m_parent == 0)
57  {
58  m_name = name;
59  return;
60  }
61 // disconnect from the parent, change name and re-connect
62  m_parent->disconnect(this);
63  m_name = name;
64  m_parent->push_back(this);
65 }
66 
68 {
69  return m_description;
70 }
71 
73 {
74  m_description = d;
75 }
76 
78 {
79  assert(colorScheme && (colorScheme->getParent() == 0));
80  m_colorSchemes.push_back(colorScheme);
81  colorScheme->setParent(this);
82 }
83 
85 {
86  std::vector<ColorScheme*>::iterator it = std::find(m_colorSchemes.begin(), m_colorSchemes.end(), colorScheme);
87 
88  if(it != m_colorSchemes.end())
89  m_colorSchemes.erase(it);
90 }
91 
92 const std::vector<te::color::ColorScheme*>& te::color::ColorSchemeGroup::getColorSchemes() const
93 {
94  return m_colorSchemes;
95 }
96 
98 {
99  return m_parent;
100 }
101 
103 {
104  m_parent = parent;
105 }
106 
void disconnect(ColorScheme *colorScheme)
It just remove the reference to the informed color scheme.
const std::vector< ColorScheme * > & getColorSchemes() const
It returns a reference to the list of color schemes belonging to this group.
This class represents a group of color schemes.
const std::string & getName() const
It returns the group name.
It models the concept of color scheme.
Definition: ColorScheme.h:58
void setParent(ColorSchemeGroup *parent)
It sets the parent color scheme group for this scheme.
Definition: ColorScheme.cpp:89
ColorSchemeGroup(const std::string &name)
It initializes a new ColorSchemeGroup and adds it to the parent catalog.
void setName(const std::string &name)
It sets the group name and adjust its entry in its the catalog if needed.
void push_back(ColorScheme *colorScheme)
It adds a new color scheme to the group and sets its relationship.
const std::string & getDescription() const
It returns the group description.
The concept of color scheme.
ColorSchemeGroup * getParent() const
It returns the parent scheme group or NULL if it doesn't belong to a group.
Definition: ColorScheme.cpp:84
A catalog for color schemes.
void setParent(ColorSchemeCatalog *parent)
It sets the parent color catalog for this group.
ColorSchemeCatalog * getParent() const
It returns the parent catalog or NULL if it doesn't belong to a catalog.
void setDescription(const std::string &d)
It sets the group description.
A catalog for color schemes groups.
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55