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