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