All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rule.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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/se/Rule.cpp
22 
23  \brief A Rule is used to attach property/scale conditions to and group the individual symbols used for rendering.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../fe/Filter.h"
29 #include "Description.h"
30 #include "Graphic.h"
31 #include "Rule.h"
32 #include "Symbolizer.h"
33 
34 // STL
35 #include <cassert>
36 #include <limits>
37 
39  : m_name(0),
40  m_description(0),
41  m_legendGraphic(0),
42  m_filter(0),
43  m_elseFilter(false),
44  m_minScaleDenominator(0.0),
45  m_maxScaleDenominator(std::numeric_limits<double>::infinity())
46 {
47 }
48 
50 {
51  delete m_name;
52  delete m_description;
53  delete m_legendGraphic;
54  delete m_filter;
55  te::common::FreeContents(m_symbolizers);
56 }
57 
58 void te::se::Rule::setName(std::string* name)
59 {
60  delete m_name;
61  m_name = name;
62 }
63 
64 const std::string* te::se::Rule::getName() const
65 {
66  return m_name;
67 }
68 
70 {
71  delete m_description;
72  m_description = d;
73 }
74 
76 {
77  return m_description;
78 }
79 
81 {
82  delete m_legendGraphic;
83  m_legendGraphic = legendGraphic;
84 }
85 
87 {
88  return m_legendGraphic;
89 }
90 
92 {
93  delete m_filter;
94  m_filter = f;
95 }
96 
98 {
99  return m_filter;
100 }
101 
103 {
104  assert(m_filter == 0);
105  m_elseFilter = true;
106 }
107 
109 {
110  m_elseFilter = false;
111 }
112 
114 {
115  return m_elseFilter;
116 }
117 
118 void te::se::Rule::setMinScaleDenominator(const double& minScaleDenominator)
119 {
120  m_minScaleDenominator = minScaleDenominator;
121 }
122 
124 {
125  return m_minScaleDenominator;
126 }
127 
128 void te::se::Rule::setMaxScaleDenominator(const double& maxScaleDenominator)
129 {
130  m_maxScaleDenominator = maxScaleDenominator;
131 }
132 
134 {
135  return m_maxScaleDenominator;
136 }
137 
139 {
140  assert(s);
141  m_symbolizers.push_back(s);
142 }
143 
145 {
146  assert(s);
147  assert(i < m_symbolizers.size());
148  delete m_symbolizers[i];
149  m_symbolizers[i] = s;
150 }
151 
152 const std::vector<te::se::Symbolizer*>& te::se::Rule::getSymbolizers() const
153 {
154  return m_symbolizers;
155 }
156 
158 {
159  assert(i < m_symbolizers.size());
160  return m_symbolizers[i];
161 }
162 
164 {
165  assert(i < m_symbolizers.size());
166 
167  delete m_symbolizers[i];
168 
169  m_symbolizers.erase(m_symbolizers.begin() + i);
170 }
const std::string * getName() const
Definition: Rule.cpp:64
void setLegendGraphic(Graphic *legendGraphic)
Definition: Rule.cpp:80
void push_back(Symbolizer *s)
Definition: Rule.cpp:138
const Symbolizer * getSymbolizer(std::size_t i) const
Definition: Rule.cpp:157
void setName(std::string *name)
Definition: Rule.cpp:58
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
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
void setMinScaleDenominator(const double &minScaleDenominator)
Definition: Rule.cpp:118
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
~Rule()
Destructor.
Definition: Rule.cpp:49
const std::vector< Symbolizer * > & getSymbolizers() const
Definition: Rule.cpp:152
void removeSymbolizer(std::size_t i)
Definition: Rule.cpp:163
const Graphic * getLegendGraphic() const
Definition: Rule.cpp:86
A filter is any valid predicate expression.
Definition: Filter.h:52
A Symbolizer describes how a Feature is to appear on a map.
A Description gives human-readable descriptive information for the object it is included within...
void setMaxScaleDenominator(const double &maxScaleDenominator)
Definition: Rule.cpp:128
void setFilter(te::fe::Filter *f)
Definition: Rule.cpp:91
const Description * getDescription() const
Definition: Rule.cpp:75
void disableElseFilter()
Definition: Rule.cpp:108
void enableElseFilter()
Definition: Rule.cpp:102
void setDescription(Description *d)
Definition: Rule.cpp:69
Rule()
It initializes a new Rule.
Definition: Rule.cpp:38
const te::fe::Filter * getFilter() const
Definition: Rule.cpp:97
void setSymbolizer(std::size_t i, Symbolizer *s)
Definition: Rule.cpp:144
bool hasElseFilter() const
Definition: Rule.cpp:113
const double & getMinScaleDenominator() const
Definition: Rule.cpp:123
A Description gives human-readable descriptive information for the object it is included within...
Definition: Description.h:56
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
const double & getMaxScaleDenominator() const
Definition: Rule.cpp:133
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66