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  };
77 
78  /*! \brief Constructor. */
80 
81  /*! \brief Destructor. */
83 
84  te::color::RGBAColor** render(const te::se::Mark* mark, std::size_t size);
85 
86  void getSupportedMarks(std::vector<std::string>& marks) const;
87 
88  protected:
89 
90  /** @name Internal methods of Qt4 Mark Renderer.
91  * Methods that manipulate Qt4 concepts like QPainter, QImage, QBrush, QPen, QPainterPath, etc.
92  */
93  //@{
94 
95  /*! \brief Builds the internal auxiliary maps to map Symbology Enconding concepts to Qt. */
96  void buildMaps();
97 
98  /*! \brief Builds the pre-defined marks paths. */
99  void buildPaths();
100 
101  /*! \brief Setups the internal QPainter and associates it with the given paint device (QImage). */
102  void setup(QImage* img);
103 
104  /*! \brief Finalizes the internal QPainter resources. */
105  void end();
106 
107  /*!
108  \brief Draw the given path on the the given image using the internal pen and brush.
109 
110  \param img The image where the path will be drawn.
111  \param path The path that will be drawn.
112  */
113  void draw(QImage* img, QPainterPath& path);
114 
115  //@}
116 
117  private:
118 
119  static std::map<std::string, MarkType> sm_markMap; //!< A map that associates a well-known mark name to the correct mark type.
120 
121  QPainter m_painter; //!< The painter used to draw the mark patterns.
122  QPen m_pen; //!< The pen used to draw the mark patterns.
123  QBrush m_brush; //!< The pen used to draw the mark patterns.
124 
125  QPainterPath m_squarePath; //!< Pre-defined path to square mark.
126  QPainterPath m_circlePath; //!< Pre-defined path to circle mark.
127  QPainterPath m_trianglePath; //!< Pre-defined path to triangle mark.
128  QPainterPath m_starPath; //!< Pre-defined path to star mark.
129  QPainterPath m_crossPath; //!< Pre-defined path to cross mark.
130  QPainterPath m_xPath; //!< Pre-defined path to x mark.
131  QPainterPath m_diamondPath; //!< Pre-defined path to diamond mark.
132  QPainterPath m_ellipsePath; //!< Pre-defined path to ellipse mark.
133  QPainterPath m_semiCirclePath; //!< Pre-defined path to semicircle mark.
134  QPainterPath m_pentagonPath; //!< Pre-defined path to pentagon mark.
135  QPainterPath m_hexagonPath; //!< Pre-defined path to hexagon mark.
136  QPainterPath m_octagonPath; //!< Pre-defined path to octagon mark.
137  };
138 
139  } // end namespace widgets
140  } // end namespace qt
141 } // end namespace te
142 
143 #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.
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:84
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.
URI C++ Library.
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.