All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GroupingItem.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 GroupingItem.cpp
22 
23  \brief This class contains information about a grouping item associated to a layer.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../se/Symbolizer.h"
29 #include "GroupingItem.h"
30 
31 
32 te::map::GroupingItem::GroupingItem(const std::string& from, const std::string& to)
33  : m_from(from), m_to(to), m_count(0), m_title("")
34 {
35 
36 }
37 
39 {
40  te::common::FreeContents(m_symbolizers);
41  m_symbolizers.clear();
42 }
43 
45  : m_from(rhs.m_from), m_to(rhs.m_to), m_value(rhs.m_value),
46  m_count(rhs.m_count), m_title(rhs.m_title)
47 {
48  for(size_t t = 0; t < rhs.m_symbolizers.size(); ++t)
49  {
50  m_symbolizers.push_back(rhs.m_symbolizers[t]->clone());
51  }
52 }
53 
55 {
56  if(this != &rhs)
57  {
58  m_from = rhs.m_from;
59  m_to = rhs.m_to;
60  m_value = rhs.m_value;
61  m_count = rhs.m_count;
62  m_title = rhs.m_title;
63 
64  for(size_t t = 0; t < rhs.m_symbolizers.size(); ++t)
65  {
66  m_symbolizers.push_back(rhs.m_symbolizers[t]->clone());
67  }
68  }
69 
70  return *this;
71 }
72 
73 const std::string& te::map::GroupingItem::getValue() const
74 {
75  return m_value;
76 }
77 
78 void te::map::GroupingItem::setValue(const std::string& value)
79 {
80  m_value = value;
81 }
82 
83 const std::string& te::map::GroupingItem::getLowerLimit() const
84 {
85  return m_from;
86 }
87 
88 void te::map::GroupingItem::setLowerLimit(const std::string& from)
89 {
90  m_from = from;
91 }
92 
93 const std::string& te::map::GroupingItem::getUpperLimit() const
94 {
95  return m_to;
96 }
97 
98 void te::map::GroupingItem::setUpperLimit(const std::string& to)
99 {
100  m_to = to;
101 }
102 
104 {
105  if(m_title.empty())
106  {
107  if(!m_value.empty())
108  m_title = m_value;
109  else if(!m_from.empty() && !m_to.empty())
110  m_title = m_from + " - " + m_to;
111  else
112  m_title = "No Value";
113  }
114 
115  return m_title;
116 }
117 
118 void te::map::GroupingItem::setTitle(const std::string& title)
119 {
120  m_title = title;
121 }
122 
124 {
125  return m_count;
126 }
127 
128 void te::map::GroupingItem::setCount(std::size_t count)
129 {
130  m_count = count;
131 }
132 
133 const std::vector<te::se::Symbolizer*>& te::map::GroupingItem::getSymbolizers() const
134 {
135  return m_symbolizers;
136 }
137 
138 void te::map::GroupingItem::setSymbolizers(const std::vector<te::se::Symbolizer*>& symbolizers)
139 {
140  te::common::FreeContents(m_symbolizers);
141  m_symbolizers.clear();
142 
143  m_symbolizers = symbolizers;
144 }
std::string m_from
The value of the lower limit of the legend item.
Definition: GroupingItem.h:155
void setValue(const std::string &value)
It sets value of the legend item.
std::size_t m_count
The number of objects whose values are between the lower and upper limits.
Definition: GroupingItem.h:158
const std::string & getValue() const
It gets the value of the legend item.
GroupingItem & operator=(const GroupingItem &rhs)
void setTitle(const std::string &title)
It sets the title of the legend item.
A GroupingItem contains information about a grouping item associated to a layer.
Definition: GroupingItem.h:48
~GroupingItem()
Destructor.
const std::string & getUpperLimit() const
It gets the upper limit value of the legend item.
std::string m_value
The value of the legend item.
Definition: GroupingItem.h:157
void setCount(std::size_t count)
It It sets the number of objects whose values are between the lower and upper limits.
void setUpperLimit(const std::string &to)
It sets the upper limit value of the legend item.
GroupingItem(const std::string &from="", const std::string &to="")
It initializes a new GroupingItem.
std::string m_to
The value of the upper limit of the legend item.
Definition: GroupingItem.h:156
std::size_t getCount() const
It gets the number of objects whose values are between the lower and upper limits.
std::string getTitle()
It gets the title of the legend item.
const std::string & getLowerLimit() const
It gets the lower limit value of the legend item.
std::string m_title
A text that can be used to identify this legend item.
Definition: GroupingItem.h:159
const std::vector< te::se::Symbolizer * > & getSymbolizers() const
It gets the symbolizer of the legend item.
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
std::vector< te::se::Symbolizer * > m_symbolizers
The color of the legend item.
Definition: GroupingItem.h:160
void setSymbolizers(const std::vector< te::se::Symbolizer * > &symbolizers)
It sets the symbolizers of the legend item.
void setLowerLimit(const std::string &from)
It sets the lower limit value of the legend item.