WellKnownMarkRenderer.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/qt/widgets/se/WellKnownMarkRenderer.h
22 
23  \brief A concrete renderer based on Qt4 for conversion of Symbology Enconding Mark elements to an image pattern.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_SE_INTERNAL_WELLKNOWNMARKRENDERER_H
27 #define __TERRALIB_QT_WIDGETS_SE_INTERNAL_WELLKNOWNMARKRENDERER_H
28 
29 // TerraLib
30 #include "../../../maptools/AbstractMarkRenderer.h"
31 #include "../Config.h"
32 
33 // Qt
34 #include <QPainter>
35 #include <QPainterPath>
36 
37 // STL
38 #include <map>
39 
40 namespace te
41 {
42  namespace qt
43  {
44  namespace widgets
45  {
46  /*!
47  \class WellKnownMarkRenderer
48 
49  \brief A concrete renderer based on Qt4 for conversion of Symbology Enconding Mark elements to an image pattern.
50  It considers basic marks defined on Symbology Enconding Specification: "square", "circle", "triangle", "star", "cross", and "x".
51 
52  \sa AbstractMarkRenderer
53  */
55  {
56  public:
57 
58  /*!
59  \enum MarkType
60 
61  \brief This enum specifies mark types handle by this renderer.
62  */
63  enum MarkType
64  {
65  Square, /*!< A square mark. */
66  Circle, /*!< A circle mark. */
67  Triangle, /*!< A triangle mark. */
68  Star, /*!< A start mark. */
69  Cross, /*!< A cross mark. */
70  X, /*!< A x mark. */
71  Diamond, /*!< A diamond mark. */
72  Ellipse, /*!< A ellipse mark. */
73  Semicircle, /*!< A semicircle mark. */
74  Pentagon, /*!< A pentagon mark. */
75  Hexagon, /*!< A hegaxon mark. */
76  Octagon, /*!< A octagon mark. */
77  Horizontalline /*!< A horizontal line mark. */
78  };
79 
80  /*! \brief Constructor. */
82 
83  /*! \brief Destructor. */
85 
86  te::color::RGBAColor** render(const te::map::MarkRendererParams& markRenderParams) override;
87 
88  void getSupportedMarks(std::vector<std::string>& marks) const;
89 
90  protected:
91 
92  /** @name Internal methods of Qt4 Mark Renderer.
93  * Methods that manipulate Qt4 concepts like QPainter, QImage, QBrush, QPen, QPainterPath, etc.
94  */
95  //@{
96 
97  /*! \brief Builds the internal auxiliary maps to map Symbology Enconding concepts to Qt. */
98  void buildMaps();
99 
100  /*! \brief Builds the pre-defined marks paths. */
101  void buildPaths();
102 
103  /*! \brief Setups the internal QPainter and associates it with the given paint device (QImage). */
104  void setup(QImage* img);
105 
106  /*! \brief Finalizes the internal QPainter resources. */
107  void end();
108 
109  /*!
110  \brief Draw the given path on the the given image using the internal pen and brush.
111 
112  \param img The image where the path will be drawn.
113  \param path The path that will be drawn.
114  */
115  void draw(QImage* img, QPainterPath& path, const te::map::MarkRendererParams& markRenderParams);
116 
117  /*!
118  \brief Draw the given path with continuity on the the given image using the internal pen and brush.
119 
120  \param img The image where the path will be drawn.
121  \param path The path that will be drawn.
122  */
123  void drawContinuosLine(QImage* img, QPainterPath& path, const te::map::MarkRendererParams& markRenderParams);
124 
125  //@}
126 
127  private:
128 
129  static std::map<std::string, MarkType> sm_markMap; //!< A map that associates a well-known mark name to the correct mark type.
130 
131  QPainter m_painter; //!< The painter used to draw the mark patterns.
132  QPen m_pen; //!< The pen used to draw the mark patterns.
133  QBrush m_brush; //!< The pen used to draw the mark patterns.
134 
135  QPainterPath m_squarePath; //!< Pre-defined path to square mark.
136  QPainterPath m_circlePath; //!< Pre-defined path to circle mark.
137  QPainterPath m_trianglePath; //!< Pre-defined path to triangle mark.
138  QPainterPath m_starPath; //!< Pre-defined path to star mark.
139  QPainterPath m_crossPath; //!< Pre-defined path to cross mark.
140  QPainterPath m_xPath; //!< Pre-defined path to x mark.
141  QPainterPath m_diamondPath; //!< Pre-defined path to diamond mark.
142  QPainterPath m_ellipsePath; //!< Pre-defined path to ellipse mark.
143  QPainterPath m_semiCirclePath; //!< Pre-defined path to semicircle mark.
144  QPainterPath m_pentagonPath; //!< Pre-defined path to pentagon mark.
145  QPainterPath m_hexagonPath; //!< Pre-defined path to hexagon mark.
146  QPainterPath m_octagonPath; //!< Pre-defined path to octagon mark.
147  QPainterPath m_horizontalLinePath; //!< Pre-defined path to horizontal line mark.
148  };
149 
150  } // end namespace widgets
151  } // end namespace qt
152 } // end namespace te
153 
154 #endif // __TERRALIB_QT_WIDGETS_SE_INTERNAL_WELLKNOWNMARKRENDERER_H
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:58
An abstract class for conversion of Symbology Enconding Mark elements to an image pattern.
A concrete renderer based on Qt4 for conversion of Symbology Enconding Mark elements to an image patt...
void getSupportedMarks(std::vector< std::string > &marks) const
Method that informs the set of supported marks by a specific concrete mark renderer.
QPainterPath m_xPath
Pre-defined path to x mark.
QPainterPath m_starPath
Pre-defined path to star mark.
MarkType
This enum specifies mark types handle by this renderer.
QPainterPath m_diamondPath
Pre-defined path to diamond mark.
void setup(QImage *img)
Setups the internal QPainter and associates it with the given paint device (QImage).
void buildMaps()
Builds the internal auxiliary maps to map Symbology Enconding concepts to Qt.
te::color::RGBAColor ** render(const te::map::MarkRendererParams &markRenderParams) override
It generates the image pattern from the given Symbology Enconding Mark element.
QPainterPath m_pentagonPath
Pre-defined path to pentagon mark.
QPainterPath m_circlePath
Pre-defined path to circle mark.
QPainterPath m_crossPath
Pre-defined path to cross mark.
QPainterPath m_squarePath
Pre-defined path to square mark.
void end()
Finalizes the internal QPainter resources.
QPainter m_painter
The painter used to draw the mark patterns.
QBrush m_brush
The pen used to draw the mark patterns.
QPainterPath m_horizontalLinePath
Pre-defined path to horizontal line mark.
QPainterPath m_ellipsePath
Pre-defined path to ellipse mark.
void draw(QImage *img, QPainterPath &path, const te::map::MarkRendererParams &markRenderParams)
Draw the given path on the the given image using the internal pen and brush.
static std::map< std::string, MarkType > sm_markMap
A map that associates a well-known mark name to the correct mark type.
QPainterPath m_semiCirclePath
Pre-defined path to semicircle mark.
QPainterPath m_octagonPath
Pre-defined path to octagon mark.
void buildPaths()
Builds the pre-defined marks paths.
QPainterPath m_trianglePath
Pre-defined path to triangle mark.
QPen m_pen
The pen used to draw the mark patterns.
void drawContinuosLine(QImage *img, QPainterPath &path, const te::map::MarkRendererParams &markRenderParams)
Draw the given path with continuity on the the given image using the internal pen and brush.
QPainterPath m_hexagonPath
Pre-defined path to hexagon mark.
TerraLib.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63