CanvasConfigurer.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/maptools/CanvasConfigurer.h
22 
23  \brief A Symbology Enconding visitor that configures a given canvas based on symbolizers elements.
24 */
25 
26 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_CANVASCONFIGURER_H
27 #define __TERRALIB_MAPTOOLS_INTERNAL_CANVASCONFIGURER_H
28 
29 // TerraLib
30 #include "../color/RGBAColor.h"
31 #include "../se/Font.h"
32 #include "../se/Visitor.h"
33 #include "Config.h"
34 #include "Enums.h"
35 
36 // STL
37 #include <map>
38 
39 // Boost
40 #include <boost/noncopyable.hpp>
41 
42 namespace te
43 {
44 // Forward declarations
45  namespace se
46  {
47  class Fill;
48  class Graphic;
49  class GraphicStroke;
50  class ParameterValue;
51  class Stroke;
52  }
53 
54  namespace map
55  {
56 // Forward declarations
57  class Canvas;
58 
59  /*!
60  \class CanvasConfigurer
61 
62  \brief A Symbology Enconding visitor that configures a given canvas based on symbolizers elements.
63  If you want to use this visitor, use a command like:
64  <code>
65  te::map::CanvasConfigurer cc(canvas);
66  cc.config(symbolizer);
67  </code>
68 
69  \ingroup map
70 
71  \sa te::se::Visitor
72  */
73  class TEMAPEXPORT CanvasConfigurer : public te::se::Visitor, public boost::noncopyable
74  {
75  public:
76 
77  /** @name Initializer Methods
78  */
79  //@{
80 
81  /*!
82  \brief Constructor.
83 
84  \param canvas A pointer to the canvas that will be configured.
85 
86  \note This class will not take the ownership of the given canvas.
87  */
89 
90  /*! \brief Destructor. */
92 
93  //@}
94 
95  /** @name Config Method
96  * Method that can be used to configure a canvas based on Symbology Enconding symbolizer elements.
97  */
98  //@{
99 
100  /*!
101  \brief It configs the canvas based on given symbolizer.
102 
103  \param symbolizer The symbolizer that will be used to config the canvas.
104  */
105  void config(const te::se::Symbolizer* symbolizer);
106 
107  //@}
108 
109  /** @name Visitor Methods
110  * All concrete visitors must implement these methods.
111  */
112  //@{
113 
114  void visit(const te::se::Style& visited);
115  void visit(const te::se::FeatureTypeStyle& visited);
116  void visit(const te::se::CoverageStyle& visited);
117  void visit(const te::se::Symbolizer& visited);
118  void visit(const te::se::PolygonSymbolizer& visited);
119  void visit(const te::se::LineSymbolizer& visited);
120  void visit(const te::se::PointSymbolizer& visited);
121  void visit(const te::se::TextSymbolizer& visited);
122  void visit(const te::se::RasterSymbolizer& visited);
123 
124  //@}
125 
126  private:
127 
128  /*!
129  \enum ConfigStyle
130 
131  \brief Internal enum that indicates which style that should be configured.
132  */
134  {
135  Point, /*!< Adjust parameters associated with point. */
136  Line, /*!< Adjust parameters associated with line. */
137  Contour, /*!< Adjust parameters associated with contour. */
138  Fill /*!< Adjust parameters associated with fill. */
139  };
140 
141  /*!
142  \brief Internal method that configs the canvas based on given Stroke element.
143 
144  \param stroke The Stroke element that will be used to config the canvas.
145  \param fromLineSymbolizer A flag that indicates if the given stroke come from LineSymbolizer element.
146  */
147  void config(const te::se::Stroke* stroke, const bool& fromLineSymbolizer = true);
148 
149  /*!
150  \brief Internal method that configs the canvas based on given Fill element.
151 
152  \param fill The Fill element that will be used to config the canvas.
153  */
154  void config(const te::se::Fill* fill);
155 
156  /*!
157  \brief Internal method that configs the canvas based on given Graphic element.
158 
159  \param graphic The Graphic element that will be used to config the canvas.
160  \param configStyle Enumerated value that indicates which style that should be configured (for Point, Line, Contour, or Fill).
161  */
162  void config(const te::se::Graphic* graphic, ConfigStyle configStyle);
163 
164  /*! \brief Configs the canvas with default values for polygon styles. */
166 
167  /*! \brief Configs the canvas with default values for line styles. */
169 
170  /*! \brief Configs the canvas with default values for point styles. */
172 
173  /*! \brief Configs the canvas with default values for text styles. */
175 
176  private:
177 
178  Canvas* m_canvas; //!< A pointer to the canvas that will be configured.
179 
180  static std::map<std::string, te::map::LineCapStyle> sm_lineCapMap; //!< A map that associates stroke-linecap value to the correct LineCapStyle.
181  static std::map<std::string, te::map::LineJoinStyle> sm_lineJoinMap; //!< A map that associates stroke-linejoin value to the correct LineJoinStyle.
182 
183  static std::map<std::string, te::se::Font::FontStyleType> sm_fontStyleMap; //!< A map that associates FontStyleType to the correct string value.
184  static std::map<std::string, te::se::Font::FontWeightType> sm_fontWeightMap; //!< A map that associates FontWeightType to the correct string value.
185  };
186 
187  } // end namespace map
188 } // end namespace te
189 
190 #endif // __TERRALIB_MAPTOOLS_INTERNAL_CANVASCONFIGURER_H
te::map::CanvasConfigurer::visit
void visit(const te::se::TextSymbolizer &visited)
te::se::Fill
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:60
te::map::CanvasConfigurer::configDefaultPolygon
void configDefaultPolygon()
Configs the canvas with default values for polygon styles.
te::map::CanvasConfigurer::sm_fontStyleMap
static std::map< std::string, te::se::Font::FontStyleType > sm_fontStyleMap
A map that associates FontStyleType to the correct string value.
Definition: CanvasConfigurer.h:183
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::map::CanvasConfigurer::configDefaultPoint
void configDefaultPoint()
Configs the canvas with default values for point styles.
te::se::Visitor
A visitor interface for the SymbologyEncoding hierarchy.
Definition: Visitor.h:42
te::map::CanvasConfigurer::visit
void visit(const te::se::FeatureTypeStyle &visited)
te::map::CanvasConfigurer::Point
@ Point
Definition: CanvasConfigurer.h:135
te::se::PointSymbolizer
A PointSymbolizer specifies the rendering of a graphic Symbolizer at a point.
Definition: PointSymbolizer.h:53
te::se::PolygonSymbolizer
A PolygonSymbolizer is used to draw a polygon (or other area-type geometries), including filling its ...
Definition: PolygonSymbolizer.h:61
te::map::CanvasConfigurer::visit
void visit(const te::se::RasterSymbolizer &visited)
te::map::CanvasConfigurer::visit
void visit(const te::se::Symbolizer &visited)
te::map::CanvasConfigurer::sm_lineCapMap
static std::map< std::string, te::map::LineCapStyle > sm_lineCapMap
A map that associates stroke-linecap value to the correct LineCapStyle.
Definition: CanvasConfigurer.h:180
te::map::CanvasConfigurer
A Symbology Enconding visitor that configures a given canvas based on symbolizers elements....
Definition: CanvasConfigurer.h:74
te::map::CanvasConfigurer::m_canvas
Canvas * m_canvas
A pointer to the canvas that will be configured.
Definition: CanvasConfigurer.h:178
te::se::FeatureTypeStyle
The FeatureTypeStyle defines the styling that is to be applied to a dataset that can be viewed as a f...
Definition: FeatureTypeStyle.h:46
te::se::LineSymbolizer
A LineSymbolizer is used to style a stroke along a linear geometry type, such as a string of line seg...
Definition: LineSymbolizer.h:52
te::se::RasterSymbolizer
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos,...
Definition: RasterSymbolizer.h:62
Enums.h
Enumerations of XML module.
te::map::CanvasConfigurer::visit
void visit(const te::se::CoverageStyle &visited)
te::map::CanvasConfigurer::visit
void visit(const te::se::LineSymbolizer &visited)
te::se::CoverageStyle
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data.
Definition: CoverageStyle.h:46
te::map::CanvasConfigurer::config
void config(const te::se::Graphic *graphic, ConfigStyle configStyle)
Internal method that configs the canvas based on given Graphic element.
te::se::TextSymbolizer
A TextSymbolizer is used to render text labels according to various graphical parameters.
Definition: TextSymbolizer.h:63
te::map::Canvas
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:93
te::map::CanvasConfigurer::visit
void visit(const te::se::PolygonSymbolizer &visited)
te::se::Stroke
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:68
te::map::CanvasConfigurer::Contour
@ Contour
Definition: CanvasConfigurer.h:137
TEMAPEXPORT
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
te::map::CanvasConfigurer::configDefaultText
void configDefaultText()
Configs the canvas with default values for text styles.
te::map::CanvasConfigurer::Line
@ Line
Definition: CanvasConfigurer.h:136
te::map::CanvasConfigurer::sm_lineJoinMap
static std::map< std::string, te::map::LineJoinStyle > sm_lineJoinMap
A map that associates stroke-linejoin value to the correct LineJoinStyle.
Definition: CanvasConfigurer.h:181
te::map::CanvasConfigurer::config
void config(const te::se::Fill *fill)
Internal method that configs the canvas based on given Fill element.
te::se::Style
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:66
te::map::CanvasConfigurer::config
void config(const te::se::Symbolizer *symbolizer)
It configs the canvas based on given symbolizer.
te::se::Graphic
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:67
te::map::CanvasConfigurer::sm_fontWeightMap
static std::map< std::string, te::se::Font::FontWeightType > sm_fontWeightMap
A map that associates FontWeightType to the correct string value.
Definition: CanvasConfigurer.h:184
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::map::CanvasConfigurer::CanvasConfigurer
CanvasConfigurer(Canvas *canvas)
Constructor.
te::map::CanvasConfigurer::configDefaultLine
void configDefaultLine()
Configs the canvas with default values for line styles.
te::map::CanvasConfigurer::ConfigStyle
ConfigStyle
Internal enum that indicates which style that should be configured.
Definition: CanvasConfigurer.h:134
te::se::Symbolizer
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:81
te::map::CanvasConfigurer::~CanvasConfigurer
~CanvasConfigurer()
Destructor.
te::map::CanvasConfigurer::config
void config(const te::se::Stroke *stroke, const bool &fromLineSymbolizer=true)
Internal method that configs the canvas based on given Stroke element.
te::map::CanvasConfigurer::visit
void visit(const te::se::Style &visited)
te::map::CanvasConfigurer::visit
void visit(const te::se::PointSymbolizer &visited)