Rule.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/se/Rule.h
22 
23  \brief A Rule is used to attach property/scale conditions to and group the individual symbols used for rendering.
24 */
25 
26 #ifndef __TERRALIB_SE_INTERNAL_RULE_H
27 #define __TERRALIB_SE_INTERNAL_RULE_H
28 
29 // TerraLib
30 #include "../fe/Filter.h"
31 #include "Config.h"
32 
33 // STL
34 #include <string>
35 #include <vector>
36 
37 // Boost
38 #include <boost/noncopyable.hpp>
39 
40 namespace te
41 {
42  namespace se
43  {
44 // Forward declaration
45  class Description;
46  class Graphic;
47  class Symbolizer;
48 
49  /*!
50  \class Rule
51 
52  \brief A Rule is used to attach property/scale conditions to and group the individual symbols used for rendering.
53 
54  Rules are used to group rendering instructions by
55  feature-property conditions and map scales. Rule
56  definitions are placed immediately inside of
57  featuretype- or coverage-style definitions.
58  If a rule has no Filter element, the
59  interpretation is that the rule condition is
60  always true, i.e., all features are accepted
61  and styled by the rule.
62  The ElseFilter has a more complicated interpretation
63  than the Filter element, and is interpreted as follows.
64  The nominal scale of the map to be portrayed is
65  computed (as described in the previous subclause) and
66  all rules for scale ranges that do not include the computed
67  nominal scale are discarded from further processing. Then, the
68  specific condition for the ElseFilter is computed by "or-ing"
69  together all of the other filter conditions and take the
70  global "not" of that condition.
71 
72  \ingroup se
73 
74  \sa FeatureTypeStyle, CoverageStyle, Description, Graphic, Symbolizer, te::fe::Filter
75  */
76  class TESEEXPORT Rule : public boost::noncopyable
77  {
78  public:
79 
80  /** @name Initializer Methods
81  * Methods related to instantiation and destruction.
82  */
83  //@{
84 
85  /*! \brief It initializes a new Rule. */
86  Rule();
87 
88  /*! \brief Destructor. */
89  ~Rule();
90 
91  //@}
92 
93  /** @name Accessor methods
94  * Methods used to get or set properties.
95  */
96  //@{
97 
98  void setName(std::string* name);
99 
100  const std::string* getName() const;
101 
103 
104  const Description* getDescription() const;
105 
106  void setLegendGraphic(Graphic* legendGraphic);
107 
108  const Graphic* getLegendGraphic() const;
109 
111 
112  /*!
113  \brief
114 
115  \note The ElseFilter must be false in order to set a filter.
116  */
118 
119  const te::fe::Filter* getFilter() const;
120 
121  /*!
122  \brief
123 
124  \note The filter must be NULL in order to call this method.
125  */
127 
129 
130  bool hasElseFilter() const;
131 
132  void setMinScaleDenominator(const double& minScaleDenominator);
133 
134  const double& getMinScaleDenominator() const;
135 
136  void setMaxScaleDenominator(const double& maxScaleDenominator);
137 
138  const double& getMaxScaleDenominator() const;
139 
141 
142  void setSymbolizer(std::size_t i, Symbolizer* s);
143 
144  void setSymbolizers(const std::vector<Symbolizer*>& symbs);
145 
146  const std::vector<Symbolizer*>& getSymbolizers() const;
147 
148  const Symbolizer* getSymbolizer(std::size_t i) const;
149 
150  void removeSymbolizer(std::size_t i);
151 
153 
154  //@}
155 
156  /*! \brief It creates a new copy of this object. */
157  Rule* clone() const;
158 
159  private:
160 
161  std::string* m_name; //!< It allows the rule to be referenced externally, which is needed in some methods of SE usage. (Optional)
162  Description* m_description; //!< It gives the familiar short title for display lists and longer description for the rule. (Optional)
163  Graphic* m_legendGraphic; //!< It allows an optional explicit Graphic Symbolizer to be displayed in a legend for this rule. (Optional)
164  te::fe::Filter* m_filter; //!< It allows the selection of features in rules to be controlled by attribute conditions. (Optional)
165  bool m_elseFilter; //!< It allows rules to be specified that are activated for features that are not selected by any other rule in a feature-type style. Default: false. If true, this is a Else filter rule. (Optional)
166  double m_minScaleDenominator; //!< It defines the range of map-rendering scales for which the rule should be applied. Default: 0.0. (Optional)
167  double m_maxScaleDenominator; //!< It defines the range of map-rendering scales for which the rule should be applied. Default: TE_DOUBLE_INFINITY. (Optional)
168  std::vector<Symbolizer*> m_symbolizers; //!< A Symbolizer describes how a feature/coverage is to appear on a map. (Mandatory)
169  };
170 
171  } // end namespace se
172 } // end namespace te
173 
174 #endif // __TERRALIB_SE_INTERNAL_RULE_H
te::se::Rule::getMinScaleDenominator
const double & getMinScaleDenominator() const
te::se::Rule::setMinScaleDenominator
void setMinScaleDenominator(const double &minScaleDenominator)
te::se::Rule::m_maxScaleDenominator
double m_maxScaleDenominator
It defines the range of map-rendering scales for which the rule should be applied....
Definition: Rule.h:167
te::se::Rule::getLegendGraphic
const Graphic * getLegendGraphic() const
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::se::Rule::setFilter
void setFilter(te::fe::Filter *f)
te::se::Rule::getMaxScaleDenominator
const double & getMaxScaleDenominator() const
te::se::Rule::getSymbolizer
const Symbolizer * getSymbolizer(std::size_t i) const
te::se::Rule::getName
const std::string * getName() const
te::se::Rule::Rule
Rule()
It initializes a new Rule.
te::se::Rule::hasElseFilter
bool hasElseFilter() const
te::se::Rule::m_elseFilter
bool m_elseFilter
It allows rules to be specified that are activated for features that are not selected by any other ru...
Definition: Rule.h:165
te::se::Rule::m_name
std::string * m_name
It allows the rule to be referenced externally, which is needed in some methods of SE usage....
Definition: Rule.h:161
te::se::Rule::m_legendGraphic
Graphic * m_legendGraphic
It allows an optional explicit Graphic Symbolizer to be displayed in a legend for this rule....
Definition: Rule.h:163
te::se::Rule::removeSymbolizer
void removeSymbolizer(std::size_t i)
te::fe::Filter
A filter is any valid predicate expression.
Definition: Filter.h:56
te::se::Rule::m_filter
te::fe::Filter * m_filter
It allows the selection of features in rules to be controlled by attribute conditions....
Definition: Rule.h:164
te::se::Rule::removeLegendGraphic
void removeLegendGraphic()
te::se::Rule::setName
void setName(std::string *name)
te::se::Rule::setMaxScaleDenominator
void setMaxScaleDenominator(const double &maxScaleDenominator)
te::se::Rule::setSymbolizers
void setSymbolizers(const std::vector< Symbolizer * > &symbs)
TESEEXPORT
#define TESEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:201
te::se::Rule
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
Definition: Rule.h:77
te::se::Rule::clearSymbolizers
void clearSymbolizers()
te::se::Rule::enableElseFilter
void enableElseFilter()
te::se::Rule::m_minScaleDenominator
double m_minScaleDenominator
It defines the range of map-rendering scales for which the rule should be applied....
Definition: Rule.h:166
te::se::Rule::getFilter
const te::fe::Filter * getFilter() const
te::se::Rule::getDescription
const Description * getDescription() const
te::se::Description
A Description gives human-readable descriptive information for the object it is included within.
Definition: Description.h:57
te::se::Rule::m_description
Description * m_description
It gives the familiar short title for display lists and longer description for the rule....
Definition: Rule.h:162
te::se::Graphic
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:67
te::se::Rule::clone
Rule * clone() const
It creates a new copy of this object.
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::se::Rule::m_symbolizers
std::vector< Symbolizer * > m_symbolizers
A Symbolizer describes how a feature/coverage is to appear on a map. (Mandatory)
Definition: Rule.h:168
te::se::Rule::push_back
void push_back(Symbolizer *s)
te::se::Rule::~Rule
~Rule()
Destructor.
te::se::Symbolizer
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:81
te::se::Rule::getSymbolizers
const std::vector< Symbolizer * > & getSymbolizers() const
te::se::Rule::setLegendGraphic
void setLegendGraphic(Graphic *legendGraphic)
te::se::Rule::setSymbolizer
void setSymbolizer(std::size_t i, Symbolizer *s)
te::se::Rule::setDescription
void setDescription(Description *d)
te::se::Rule::disableElseFilter
void disableElseFilter()