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