Loading...
Searching...
No Matches
GlyphMarkRenderer.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/GlyphMarkRenderer.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_GLYPHMARKRENDERER_H
27#define __TERRALIB_QT_WIDGETS_SE_INTERNAL_GLYPHMARKRENDERER_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
39namespace te
40{
41 namespace qt
42 {
43 namespace widgets
44 {
45 /*!
46 \class GlyphMarkRenderer
47
48 \brief A concrete renderer based on Qt4 for conversion of Symbology Enconding Mark elements to an image pattern.
49 It is a extension that considers marks with well-known name in the format: "ttf://font#code".
50 Here, "font" is the name of a TrueType font and "code" is the character code.
51 The character code can be enconded in hexadecimal, octonal or decimal.
52 e.g.: "ttf://Arial#0x12", "ttf://Times#042", "ttf://Verdana#10".
53
54 \sa AbstractMarkRenderer
55 */
57 {
58 public:
59
60 /*! \brief Constructor. */
62
63 /*! \brief Destructor. */
65
66 te::color::RGBAColor** render(const te::map::MarkRendererParams& markRenderParams) override;
67
68 void getSupportedMarks(std::vector<std::string>& marks) const;
69
70 /*!
71 \brief Encodes the given parameters to a format known by this renderer.
72
73 \param font The font name. e.g. "Times".
74 \param charCoder The decimal char code.
75
76 \return A string that represents the format known by this renderer. e.g. "ttf://Times#0x12".
77
78 \note The given char code will be enconded in hexadecimal.
79 */
80 static QString encode(const QString& font, const int& charCode);
81
82 /*!
83 \brief Decodes the given name extracting the parameters known by this renderer.
84
85 \param name The name dealt by this renderer. e.g. "ttf://Times#0x12".
86 \param font The font name that will be extracted from name.
87 \param charCoder The char code that will be extracted from name.
88 */
89 static void decode(QString& name, QString& font, QChar& charCode);
90
91 protected:
92
93 /** @name Internal methods of Qt4 Mark Renderer.
94 * Methods that manipulate Qt4 concepts like QPainter, QImage, QBrush, QPen, QPainterPath, etc.
95 */
96 //@{
97
98 /*! \brief Setups the internal QPainter and associates it with the given paint device (QImage). */
99 void setup(QImage* img);
100
101 /*! \brief Finalizes the internal QPainter resources. */
102 void end();
103
104 /*!
105 \brief Draw the given path on the the given image using the internal pen and brush.
106
107 \param img The image where the path will be drawn.
108 \param path The path that will be drawn.
109 */
110 void draw(QImage* img, QPainterPath& path, const te::map::MarkRendererParams& markRenderParams);
111
112 /*!
113 \brief Converts the character code to a char.
114
115 \param charCode The character code. It can be enconded in hexadecimal, octonal or decimal.
116 \param ch The result char from character code conversion.
117
118 \return It returns true if the character code was converted. Otherwise, it returns false.
119 */
120 bool getChar(QString& charCode, QChar& ch);
121
122 //@}
123
124 private:
125
126 QPainter m_painter; //!< The painter used to draw the mark patterns.
127 QPen m_pen; //!< The pen used to draw the mark patterns.
128 QBrush m_brush; //!< The pen used to draw the mark patterns.
129
130 static std::string sm_rendererKey; //!< The renderer key.
131 };
132
133 } // end namespace widgets
134 } // end namespace qt
135} // end namespace te
136
137#endif // __TERRALIB_QT_WIDGETS_SE_INTERNAL_GLYPHMARKRENDERER_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 end()
Finalizes the internal QPainter resources.
QPen m_pen
The pen used to draw the mark patterns.
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.
bool getChar(QString &charCode, QChar &ch)
Converts the character code to a char.
te::color::RGBAColor ** render(const te::map::MarkRendererParams &markRenderParams) override
It generates the image pattern from the given Symbology Enconding Mark element.
void getSupportedMarks(std::vector< std::string > &marks) const
Method that informs the set of supported marks by a specific concrete mark renderer.
QPainter m_painter
The painter used to draw the mark patterns.
QBrush m_brush
The pen used to draw the mark patterns.
static QString encode(const QString &font, const int &charCode)
Encodes the given parameters to a format known by this renderer.
static std::string sm_rendererKey
The renderer key.
static void decode(QString &name, QString &font, QChar &charCode)
Decodes the given name extracting the parameters known by this renderer.
void setup(QImage *img)
Setups the internal QPainter and associates it with the given paint device (QImage).
TerraLib.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63