27 #include "../../../common/StringUtils.h"
28 #include "../../../maptools/Utils.h"
29 #include "../../../se/Mark.h"
41 : te::map::AbstractMarkRenderer()
43 m_brush.setStyle(Qt::SolidPattern);
61 font.setFamily(fontName);
62 font.setPixelSize(size);
65 QPainterPath charPath;
66 charPath.addText(0.0, 0.0, font, ch);
68 QRectF bounds = charPath.boundingRect();
69 double invMax = 1 / std::max(bounds.width(), bounds.height());
71 t.scale(invMax, invMax);
72 t.translate(-bounds.center().x(), -bounds.center().y());
73 charPath = t.map(charPath);
76 QImage* img =
new QImage(size, size, QImage::Format_ARGB32_Premultiplied);
77 img->fill(Qt::transparent);
100 QString result = QString::fromStdString(sm_rendererKey);
101 result +=
"://" + font +
"#0x" + QString::number(charCode, 16);
108 QString pattern(name);
109 pattern.remove(0, sm_rendererKey.size() + 3);
110 if(!pattern.contains(
"#"))
114 QStringList myParams = pattern.split(
"#", QString::SkipEmptyParts);
115 if(myParams.size() < 2)
119 bool wasConverted =
false;
121 charCode = myParams[1].toInt(&wasConverted, 0);
131 m_painter.begin(img);
132 m_painter.setRenderHints(QPainter::Antialiasing);
133 m_painter.setPen(m_pen);
134 m_painter.setBrush(m_brush);
149 double s = img->width() - m_pen.width() - 1;
150 double t = img->width() * 0.5;
152 QTransform transform;
153 QPainterPath transformedPath = transform.translate(t, t).scale(s, s).map(path);
155 m_painter.drawPath(transformedPath);
164 ch = charCode.toInt(&isOk, 0);
void Config(QPen &pen, const te::se::Stroke *stroke)
It configs the given pen based on Symbology Enconding Stroke element.
A concrete renderer based on Qt4 for conversion of Symbology Enconding Mark elements to an image patt...
Utility functions for MapTools module.
const Fill * getFill() const
const std::string * getWellKnownName() const
bool getChar(QString &charCode, QChar &ch)
Converts the character code to a char.
te::color::RGBAColor ** render(const te::se::Mark *mark, std::size_t size)
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.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
static QString encode(const QString &font, const int &charCode)
Encodes the given parameters to a format known by this renderer.
#define TE_SE_DEFAULT_STROKE_BASIC_COLOR
It specifies the default color used by stroke basic (solid colors).
#define TE_SE_DEFAULT_FILL_BASIC_COLOR
It specifies the default color used by basic fill (solid colors).
const Stroke * getStroke() const
QBrush m_brush
The pen used to draw the mark patterns.
GlyphMarkRenderer()
Constructor.
void setup(QImage *img)
Setups the internal QPainter and associates it with the given paint device (QImage).
void end()
Finalizes the internal QPainter resources.
void draw(QImage *img, QPainterPath &path)
Draw the given path on the the given image using the internal pen and brush.
static std::string sm_rendererKey
The renderer key.
~GlyphMarkRenderer()
Destructor.
static void decode(QString &name, QString &font, QChar &charCode)
Decodes the given name extracting the parameters known by this renderer.
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
A Mark specifies a geometric shape and applies coloring to it.