Loading...
Searching...
No Matches
Canvas.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/canvas/Canvas.h
22
23 \brief A canvas built on top of Qt.
24 */
25
26#ifndef __TERRALIB_QT_WIDGETS_INTERNAL_CANVAS_H
27#define __TERRALIB_QT_WIDGETS_INTERNAL_CANVAS_H
28
29// TerraLib
30#include "../../../maptools/Canvas.h"
31#include "../Config.h"
32
33// Qt
34#include <QColor>
35#include <QPainter>
36#include <QPolygonF>
37#include <QWidget>
38
39namespace te
40{
41 namespace qt
42 {
43 namespace widgets
44 {
45 /*!
46 \class Canvas
47
48 \brief A canvas built on top of Qt.
49
50 \ingroup widgets
51
52 \sa te::map::Canvas
53 */
55 {
56 public:
57
58 /** @name Initializer Methods
59 * Methods related to instantiation and destruction.
60 */
61 //@{
62
63 /*!
64 \brief It initializes a new Canvas and associates a pixmap as the default device.
65
66 \param w The internal pixmap width in pixels.
67 \param h The internal pixmap height in pixels.
68 \param devType The internal device. It can be Pixmap or Image.
69 */
70 Canvas(int w, int h, int devType = QInternal::Pixmap);
71
72 /*!
73 \brief It initializes a new Canvas associated with the given paint device.
74
75 \param device The paint device that will be associated to this canvas.
76
77 \note The canvas will NOT take the ownership of the given device.
78 */
79 Canvas(QPaintDevice* device);
80
81 /*!
82 \brief It initializes a new Canvas associated with the given painter.
83
84 \param device The painter that will be associated to this canvas.
85
86 \note The canvas will NOT take the ownership of the given painter.
87 */
88 Canvas(QPainter* painter);
89
90 /*! \brief Destructor. */
92
93 //@}
94
95 /** @name Methods Inherited From Abstract Canvas
96 * These methods are re-implementations from abstract canvas.
97 */
98 //@{
99
100 void setWindow(const double& llx, const double& lly,
101 const double& urx, const double& ury);
102
104
105 void calcAspectRatio(double& llx, double& lly, double& urx, double& ury,
107
109 const te::map::AlignType hAlign = te::map::Center,
110 const te::map::AlignType vAlign = te::map::Center);
111
113
115
116 void clear();
117
118 void resize(int w, int h);
119
120 int getWidth() const;
121
122 int getHeight() const;
123
124 void draw(const te::gm::Geometry* geom);
125
126 void draw(const te::gm::Point* point);
127
128 void draw(const te::gm::MultiPoint* mpoint);
129
130 void draw(const te::gm::LineString* line);
131
132 void draw(const te::gm::MultiLineString* mline);
133
134 void draw(const te::gm::Polygon* poly);
135
136 void draw(const te::gm::MultiPolygon* mpoly);
137
139
141
142 void save(const char* fileName, te::map::ImageType t, int quality = 75, int fg = 0) const;
143
144 char* getImage(te::map::ImageType t, std::size_t& size, int quality = 75, int fg = 0) const;
145
146 te::color::RGBAColor** getImage(const int x = 0, const int y = 0, const int w = 0, const int h = 0) const;
147
148 void freeImage(char* img) const;
149
150 void drawImage(char* src, std::size_t size, te::map::ImageType t);
151
152 void drawImage(te::color::RGBAColor** src, int w, int h);
153
154 void drawImage(int x, int y, char* src, std::size_t size, te::map::ImageType t);
155
156 void drawImage(int x, int y, te::color::RGBAColor** src, int w, int h);
157
158 void drawImage(int x, int y, int w, int h, char* src, std::size_t size, te::map::ImageType t);
159
160 void drawImage(int x, int y, int w, int h, te::color::RGBAColor** src, int srcw, int srch);
161
162 void drawImage(int x, int y, int w, int h, char* src, std::size_t size, te::map::ImageType t, int sx, int sy, int sw, int sh);
163
164 void drawImage(int x, int y, int w, int h, te::color::RGBAColor** src, int sx, int sy, int sw, int sh);
165
166 void drawImage(int x, int y, te::rst::Raster* src, int opacity = TE_OPAQUE);
167
168 void drawImage(int x, int y, int w, int h, te::rst::Raster* src, int sx, int sy, int sw, int sh, int opacity = TE_OPAQUE);
169
170 void drawPixel(int x, int y);
171
172 void drawPixel(int x, int y, const te::color::RGBAColor& color);
173
174 void drawText(int x, int y,
175 const std::string& txt,
176 float angle = 0.0,
177 double anchorX = 0.5, double anchorY = 0.5,
178 int displacementX = 0, int displacementY = 0);
179
180 void drawText(const te::gm::Point* p,
181 const std::string& txt,
182 float angle = 0.0,
183 double anchorX = 0.5, double anchorY = 0.5,
184 int displacementX = 0, int displacementY = 0);
185
186 void drawText(const double& x, const double& y,
187 const std::string& txt,
188 float angle = 0.0,
189 double anchorX = 0.5, double anchorY = 0.5,
190 int displacementX = 0, int displacementY = 0);
191
193 const std::string& txt,
194 float angle = 0.0,
195 double anchorX = 0.5, double anchorY = 0.5,
196 int displacementX = 0, int displacementY = 0);
197
199 const std::string& txt,
200 float angle = 0.0,
201 double anchorX = 0.5, double anchorY = 0.5,
202 int displacementX = 0, int displacementY = 0);
203
204 te::gm::Polygon* getTextBoundary(const double& x, const double& y,
205 const std::string& txt,
206 float angle = 0.0,
207 double anchorX = 0.5, double anchorY = 0.5,
208 int displacementX = 0, int displacementY = 0);
209
211
212 void setTextOpacity(int opacity);
213
214 void setFontFamily(const std::string& family);
215
216 void setTextPointSize(double psize);
217
219
221
222 void setTextStretch(std::size_t stretch);
223
224 void setTextUnderline(bool b);
225
226 void setTextOverline(bool b);
227
228 void setTextStrikeOut(bool b);
229
231
232 void setTextDecorationWidth(int width);
233
235
237
238 void setTextContourOpacity(int opacity);
239
240 void setTextContourWidth(int width);
241
242 void setTextJustification(int justType);
243
244 void setTextMultiLineSpacing(int spacing);
245
247
248 void setPointWidth(int w);
249
250 void setPointPattern(te::color::RGBAColor** pattern, int ncols, int nrows);
251
252 void setPointPattern(char* pattern, std::size_t size, te::map::ImageType t);
253
254 void setPointPatternRotation(const double& angle);
255
256 void setPointPatternOpacity(int opacity);
257
259
260 void setLinePattern(te::color::RGBAColor** pattern, int ncols, int nrows);
261
262 void setLinePattern(char* pattern, std::size_t size, te::map::ImageType t);
263
264 void setLinePatternRotation(const double& angle);
265
266 void setLinePatternOpacity(int opacity);
267
269
270 void setLineDashStyle(const std::vector<double>& style);
271
273
275
276 void setLineWidth(int w);
277
279
280 void setPolygonFillColor(const QBrush& color);
281
283
284 void setPolygonFillPattern(te::color::RGBAColor** pattern, int ncols, int nrows);
285
286 void setPolygonFillPattern(char* pattern, std::size_t size, te::map::ImageType t);
287
289
290 void setPolygonPatternRotation(const double& angle);
291
292 void setPolygonPatternOpacity(int opacity);
293
294 void setPolygonContourPattern(te::color::RGBAColor** pattern, int ncols, int nrows);
295
296 void setPolygonContourPattern(char* pattern, std::size_t size, te::map::ImageType t);
297
299
300 void setPolygonContourPatternRotation(const double& angle);
301
303
305
306 void setPolygonContourDashStyle(const std::vector<double>& style);
307
309
311
313
315
316 //@}
317
318 /** @name Qt Canvas Specific Methos
319 * Methods that belongs only to Qt Canvas.
320 */
321 //@{
322
323 /*!
324 \brief It draws a text.
325
326 Color and font family should be defined in advance.
327
328 \param p The text entry point i device coordinate.
329 \param txt The text to be drawed.
330 \param angle The text rotation.
331 \param anchorX The horizontal text anchor.
332 \param anchorY The vertical text anchor.
333 \param displacementX The horizontal text displacement.
334 \param displacementY The vertical text displacement.
335
336 \note Qt Canvas extended method.
337 */
338 void drawText(const QPoint& p,
339 const std::string& txt,
340 float angle = 0.0,
341 double anchorX = 0.5, double anchorY = 0.5,
342 int displacementX = 0, int displacementY = 0);
343
344 /*!
345 \brief It returns text boundary. Color and font family should be defined in advance.
346
347 \param p The text entry point in device coordinate.
348 \param tx The text to be drawed.
349 \param angle The text rotation.
350 \param anchorX The horizontal text anchor.
351 \param anchorY The vertical text anchor.
352 \param displacementX The horizontal text displacement.
353 \param displacementY The vertical text displacement.
354
355 \return The text boundary in world coordinate.
356
357 \note The caller of this method will take the ownership of the returned Polygon.
358
359 \warning Qt Canvas extended method.
360 */
361 te::gm::Polygon* getTextBoundary(const QPoint& p, const std::string& txt, float angle = 0.0,
362 double anchorX = 0.5, double anchorY = 0.5,
363 int displacementX = 0, int displacementY = 0);
364
365 /*!
366 \brief It returns the internal pixmap used to draw geographical objects.
367
368 \return The internal pixmap used to draw geographical objects. Don't delete it! Null is returned if device is not a pixmap.
369
370 \warning Qt Canvas extended method.
371
372 \note You can not delete this pointer.
373 */
374 QPixmap* getPixmap() const;
375
376 /*!
377 \brief It returns the internal image used to draw geographical objects.
378
379 \return The internal image used to draw geographical objects. Don't delete it! Null is returned if device is not a image.
380
381 \warning Qt Canvas extended method.
382
383 \note You can not delete this pointer.
384 */
385 QImage* getImage() const;
386
387 /*!
388 \brief It returns the internal device used to draw geographical objects.
389
390 \return The internal device used to draw geographical objects. Don't delete it!
391
392 \warning Qt Canvas extended method.
393
394 \note You can not delete this pointer.
395 */
396 QPaintDevice* getDevice() const;
397
398 /*!
399 \brief It sets new device as QPrinter.
400
401 \param device The new paint device.
402 \param takeOwnerShip If true the canvas will take the ownership of the given device otherwise it is the caller responsability to release the device.
403 */
404 void setDevice(QPaintDevice* device, bool takeOwnerShip);
405
406 /*!
407 \brief It returns the device resolution.
408
409 \return The device resolution.
410 */
412
413 /*!
414 \brief It returns the matrix.
415
416 \return The marix.
417 */
418 QMatrix getMatrix();
419
420 void setMatrix(const QMatrix& matrix);
421
422 /*! \brief Sets the given render hint on the canvas painter if on is true; otherwise clears the render hint. */
423 void setRenderHint(QPainter::RenderHint hint, bool on = true);
424
425 //@}
426
427 QPainter* getPainter();
428
429 private:
430
431 /** @name Copy Constructor and Assignment Operator
432 * Copy constructor and assignment operator not allowed.
433 */
434 //@{
435
436 /*!
437 \brief Copy constructor not allowed.
438
439 \param rhs The right-hand-side copy that would be used to copy from.
440 */
441 Canvas(const Canvas& rhs);
442
443 /*!
444 \brief Assignment operator not allowed.
445
446 \param rhs The right-hand-side copy that would be used to copy from.
447
448 \return A reference to this object.
449 */
450 Canvas& operator=(const Canvas& rhs);
451
452 //@}
453
454 /** @name Auxiliary Methods
455 * Auxiliary methods.
456 */
457 //@{
458
459 /*!
460 \brief It adjusts the given pen to use the given pattern.
461
462 \param pen The pen that will be adjusted.
463 \param style The line custom dash style.
464 */
465 void setLineDashStyle(QPen& pen, const std::vector<double>& style);
466
467 /*!
468 \brief It updates the alpha channel of the given image using the given opacity value.
469
470 \param img The image that will be updated.
471 \param opacity The opacity value that will be used.
472 */
473 void updateAlpha(QImage& img, const int& opacity);
474
475 /*!
476 \brief It creates two patterns. A pattern used to draw selected objects and
477 the other used to erase this pattern.
478 */
480
481 /*!
482 \brief It draw the polygon contour.
483 */
485
486
487 //@}
488
489 private:
490
491 QMatrix m_matrix; //!< Matrix that transforms the world coordinate to device coordinate.
492 te::gm::Envelope* m_envelope; //!< Stores the current world (or window) coordinates area
493
494 QPainter* m_painter; //!< The painter used to draw geometric objects.
495 QTransform m_painterTransform; //!< This transform holds the original transform of the painter. It is stored to be combined to the canvas matrix every time setWindow is called
496 bool m_isPainterOwner; //!< Tells if canvas is the owner of the painter.
497
498 bool m_isDeviceOwner; //!< Tells if canvas is the owner of the paint device.
499
500 QColor m_bgColor; //!< Canvas background color. Defaults: white fully transparent.
501
502 bool m_erase; //!< used for erase operation.
503 QPen m_ptPen; //!< The pen used to draw points.
504 QPointF m_pt; //!< Point buffer to avoid creating another point instance.
505 int m_ptWidth; //!< The width for point markers and point pattern.
506 QColor m_ptColor; //!< The color used to draw point (pixel) or marker.
507 QColor m_ptColorFrom; //!< Indicates the color that originated the pattern that shows the status of selection. Used for optmization
508 QImage* m_ptImg; //!< The marker or pattern used to point.
509 QImage* m_ptImgRotated; //!< The marker or pattern already with rotation used to draw points.
510 QImage* m_ptSelectionPatternImg; //!< The marker or pattern used to show selection status. The color is mixed with point pattern.
511 QImage* m_ptClearPatternImg; //!< The marker or pattern used to clear (erase point).
512 double m_ptRotation; //!< The point pattern rotation.
513 int m_ptVOffset; //!< Vertical offset in pixels (in device coordinate) applied to point pattern or marker.
514 int m_ptHOffset; //!< Horizontal offset in pixels (in device coordinate) applied to point pattern or marker.
515
516 QColor m_lnColor; //!< The color used to draw lines.
517 QPen m_lnPen; //!< The pen used to draw lines.
518
519 QColor m_polyContourColor; //!< The color used to draw polygon contour.
520 QPen m_polyContourPen; //!< The pen used to draw contour polygon.
521
522 QColor m_polyColor; //!< The color used to fill polygon (solid, marker or pattern).
523 QBrush m_polyBrush; //!< The brush used to fill polygon.
524 QBrush m_polyDefaultBrush; //!< The brush used to fill polygon.
525 QImage* m_polyImage; //!< The pattern image used to fill polygon.
526 int m_polyPatternWidth; //!< The width used to draw marker or pattern.
527
528 QPen m_txtContourPen; //!< The pen used to draw the text contour.
529 bool m_txtContourEnabled; //!< The flag indicates whether the outline of the text should be drawn.
530 QBrush m_txtBrush; //!< The brush used to draw texts.
531 QFont m_font; //!< The text font.
532 int m_txtLetterSpacing; //!< Text letter spacing.
533 int m_txtWordSpacing; //!< Text word spacing.
534 //int m_txtLineJustification; //!< Text multi line justification.
535 int m_txtLineSpacing; //!< Text multi line spacing.
536
537 std::map<std::string, QPixmap*> m_patterns; //!< The pixmap styles used to draw patterns.
538 };
539 } // end namespace widgets
540 } // end namespace qt
541} // end namespace te
542
543#endif // __TERRALIB_QT_WIDGETS_INTERNAL_CANVAS_H
544
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:58
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
It is a collection of other geometric objects.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
MultiLineString is a MultiCurve whose elements are LineStrings.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:54
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:51
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:55
A point with x and y coordinate values.
Definition: Point.h:51
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:93
A canvas built on top of Qt.
Definition: Canvas.h:55
Canvas(const Canvas &rhs)
Copy constructor not allowed.
void drawImage(int x, int y, int w, int h, te::color::RGBAColor **src, int sx, int sy, int sw, int sh)
It draws the rectangular portion with the origin (sx, sy), width sw and height sh,...
bool m_isDeviceOwner
Tells if canvas is the owner of the paint device.
Definition: Canvas.h:498
QPainter * m_painter
The painter used to draw geometric objects.
Definition: Canvas.h:494
QPointF m_pt
Point buffer to avoid creating another point instance.
Definition: Canvas.h:504
void setPolygonFillColor(const QBrush &color)
void drawText(const te::gm::Point *p, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)
It draws a text.
void setPointPattern(char *pattern, std::size_t size, te::map::ImageType t)
It sets the point pattern using a buffered image.
void setPolygonFillColor(const te::color::RGBAColor &color)
It sets the color used to fill the draw of polygon geometries.
void setPointWidth(int w)
It sets the point width. If point has a patterns, this pattern is scaled to width.
double m_ptRotation
The point pattern rotation.
Definition: Canvas.h:512
QMatrix getMatrix()
It returns the matrix.
te::gm::Polygon * getTextBoundary(const QPoint &p, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)
It returns text boundary. Color and font family should be defined in advance.
void setLinePatternOpacity(int opacity)
It sets the line pattern opacity.
QBrush m_polyBrush
The brush used to fill polygon.
Definition: Canvas.h:523
bool m_erase
used for erase operation.
Definition: Canvas.h:502
void setTextColor(const te::color::RGBAColor &color)
It sets the text drawing color.
int m_ptWidth
The width for point markers and point pattern.
Definition: Canvas.h:505
void setPointPattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the point pattern.
void setPolygonContourWidth(int w)
It sets the polygon contour width.
std::map< std::string, QPixmap * > m_patterns
The pixmap styles used to draw patterns.
Definition: Canvas.h:537
void draw(const te::gm::Polygon *poly)
It draws the polygon on canvas.
void updateAlpha(QImage &img, const int &opacity)
It updates the alpha channel of the given image using the given opacity value.
void drawImage(int x, int y, te::color::RGBAColor **src, int w, int h)
It draws the src image over the canvas at the specified position (x, y).
QPen m_lnPen
The pen used to draw lines.
Definition: Canvas.h:517
QBrush m_polyDefaultBrush
The brush used to fill polygon.
Definition: Canvas.h:524
QMatrix m_matrix
Matrix that transforms the world coordinate to device coordinate.
Definition: Canvas.h:491
QColor m_ptColorFrom
Indicates the color that originated the pattern that shows the status of selection....
Definition: Canvas.h:507
QImage * m_polyImage
The pattern image used to fill polygon.
Definition: Canvas.h:525
int m_txtWordSpacing
Text word spacing.
Definition: Canvas.h:533
int m_ptHOffset
Horizontal offset in pixels (in device coordinate) applied to point pattern or marker.
Definition: Canvas.h:514
void setTextContourOpacity(int opacity)
It sets the text contour opacity.
int getResolution()
It returns the device resolution.
void setPolygonContourPatternRotation(const double &angle)
It sets the polygon contour pattern rotation.
void setPointPatternOpacity(int opacity)
It sets the point pattern opacity.
void setTextStyle(te::se::Font::FontStyleType style)
It sets the text style.
void setLinePattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the line pattern.
void freeImage(char *img) const
This is the method that you should use to release an image generated by the canvas.
QImage * getImage() const
It returns the internal image used to draw geographical objects.
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
void drawImage(int x, int y, int w, int h, char *src, std::size_t size, te::map::ImageType t, int sx, int sy, int sw, int sh)
It draws the rectangular portion with the origin (sx, sy), width sw and height sh,...
void setPolygonContourCapStyle(te::map::LineCapStyle style)
It sets the polygon contour cap style.
char * getImage(te::map::ImageType t, std::size_t &size, int quality=75, int fg=0) const
It returns the internal content as an image in a specific format (PNG, JPEG, ...).
QColor m_polyColor
The color used to fill polygon (solid, marker or pattern).
Definition: Canvas.h:522
void drawImage(char *src, std::size_t size, te::map::ImageType t)
It draws the src image over the canvas.
void setTextWeight(te::se::Font::FontWeightType weight)
It sets the text weight.
void setFontFamily(const std::string &family)
It sets the text font family.
void setLineWidth(int w)
It sets the line width.
void setPolygonContourPattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the pen pattern used to draw the boundary of polygon geometries.
void drawContour(const te::gm::LineString *line)
It draw the polygon contour.
void drawText(const QPoint &p, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)
It draws a text.
QPen m_ptPen
The pen used to draw points.
Definition: Canvas.h:503
void resize(int w, int h)
It adjusts the canvas size (width and height).
void setPolygonPatternOpacity(int opacity)
It sets the polygon pattern opacity.
void setMatrix(const QMatrix &matrix)
void save(const char *fileName, te::map::ImageType t, int quality=75, int fg=0) const
It saves the canvas content to a file image in the specified format type.
te::color::RGBAColor getBackgroundColor() const
It returns the canvas background color.
QPen m_polyContourPen
The pen used to draw contour polygon.
Definition: Canvas.h:520
void drawText(const double &x, const double &y, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)
It draws a text.
void setLineJoinStyle(te::map::LineJoinStyle style)
It sets the line join style.
void setPointPatternRotation(const double &angle)
It sets the point pattern rotation. Rotation is made ​​from the center of the pattern.
bool m_txtContourEnabled
The flag indicates whether the outline of the text should be drawn.
Definition: Canvas.h:529
QPen m_txtContourPen
The pen used to draw the text contour.
Definition: Canvas.h:528
void setPolygonFillPattern(char *pattern, std::size_t size, te::map::ImageType t)
It sets the polygon fill pattern using a buffered image.
void setPointColor(const te::color::RGBAColor &color)
It sets the point drawing color.
void setEraseMode()
It sets the painter to erase mode.
void drawImage(int x, int y, char *src, std::size_t size, te::map::ImageType t)
It draws the src image over the canvas at the specified position (x, y).
bool m_isPainterOwner
Tells if canvas is the owner of the painter.
Definition: Canvas.h:496
void setTextContourColor(const te::color::RGBAColor &color)
It sets the text contour (outline) drawing color.
void draw(const te::gm::GeometryCollection *g)
It draws the GeometryCollection on canvas.
void draw(const te::gm::MultiPolygon *mpoly)
It draws the MultiPolygon on canvas.
void setRenderHint(QPainter::RenderHint hint, bool on=true)
Sets the given render hint on the canvas painter if on is true; otherwise clears the render hint.
void draw(const te::gm::MultiLineString *mline)
It draws the MultiLineString on canvas.
QColor m_bgColor
Canvas background color. Defaults: white fully transparent.
Definition: Canvas.h:500
int m_txtLetterSpacing
Text letter spacing.
Definition: Canvas.h:532
te::gm::Polygon * getTextBoundary(const double &x, const double &y, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)
It returns the text boundary (its enclose rectangle).
Canvas(int w, int h, int devType=QInternal::Pixmap)
It initializes a new Canvas and associates a pixmap as the default device.
void setBackgroundColor(const te::color::RGBAColor &color)
It sets the canvas background color.
void setPolygonPatternRotation(const double &angle)
It sets the polygon pattern rotation.
void setTextJustification(int justType)
It sets the text justification for multi line text.
QImage * m_ptSelectionPatternImg
The marker or pattern used to show selection status. The color is mixed with point pattern.
Definition: Canvas.h:510
void setTextContourWidth(int width)
It sets the text contour width.
void setTextPointSize(double psize)
It sets the text point Size.
void setTextOpacity(int opacity)
It sets the text opacity.
void setPolygonContourDashStyle(const std::vector< double > &style)
It sets the polygon contour dash style to the given pattern.
QBrush m_txtBrush
The brush used to draw texts.
Definition: Canvas.h:530
int getHeight() const
It returns the canvas height.
const te::gm::Envelope & getWindow() const
It gets the world (or window) coordinates area (supposing a cartesian reference system).
Canvas & operator=(const Canvas &rhs)
Assignment operator not allowed.
void setTextStrikeOut(bool b)
It sets the text strike out flag.
int m_ptVOffset
Vertical offset in pixels (in device coordinate) applied to point pattern or marker.
Definition: Canvas.h:513
void draw(const te::gm::MultiPoint *mpoint)
It draws the MultiPoint on canvas.
void setTextDecorationColor(const te::color::RGBAColor &color)
It sets the text color for drawing text decoration.
QTransform m_painterTransform
This transform holds the original transform of the painter. It is stored to be combined to the canvas...
Definition: Canvas.h:495
void draw(const te::gm::LineString *line)
It draws the LineString on canvas.
te::gm::Polygon * getTextBoundary(const te::gm::Point *p, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)
It returns the text boundary (its enclose rectangle).
void setLinePattern(char *pattern, std::size_t size, te::map::ImageType t)
It sets the line pattern using a buffered image.
void drawImage(int x, int y, int w, int h, te::rst::Raster *src, int sx, int sy, int sw, int sh, int opacity=TE_OPAQUE)
It draws the rectangular portion with the origin (sx, sy), width sw and height sh,...
QPaintDevice * getDevice() const
It returns the internal device used to draw geographical objects.
void setDevice(QPaintDevice *device, bool takeOwnerShip)
It sets new device as QPrinter.
void setLinePatternRotation(const double &angle)
It sets the line pattern rotation. Rotation is made ​​from the center of the pattern.
int getWidth() const
It returns the canvas width.
te::gm::Envelope * m_envelope
Stores the current world (or window) coordinates area.
Definition: Canvas.h:492
void drawImage(int x, int y, int w, int h, te::color::RGBAColor **src, int srcw, int srch)
It draws the source image into the rectangle at position (x, y) with the given width and height.
void setTextDecorationWidth(int width)
It sets the width for drawing text decoration.
void setLineColor(const te::color::RGBAColor &color)
It sets the pen color used to draw line geometries.
void draw(const te::gm::Point *point)
It draws the point on canvas.
te::color::RGBAColor ** getImage(const int x=0, const int y=0, const int w=0, const int h=0) const
It gets a RGBA color array from internal canvas buffer.
void drawImage(int x, int y, int w, int h, char *src, std::size_t size, te::map::ImageType t)
It draws the source image into the rectangle at position (x, y) with the given width and height.
QImage * m_ptImgRotated
The marker or pattern already with rotation used to draw points.
Definition: Canvas.h:509
QColor m_ptColor
The color used to draw point (pixel) or marker.
Definition: Canvas.h:506
QImage * m_ptImg
The marker or pattern used to point.
Definition: Canvas.h:508
QImage * m_ptClearPatternImg
The marker or pattern used to clear (erase point).
Definition: Canvas.h:511
void setLineDashStyle(te::map::LineDashStyle style)
It sets the line dash style.
void calcAspectRatio(te::gm::Envelope *envelope, const te::map::AlignType hAlign=te::map::Center, const te::map::AlignType vAlign=te::map::Center)
It calculates the best aspect ratio for world (or window) coordinates area (supposing a cartesian ref...
void setPolygonContourJoinStyle(te::map::LineJoinStyle style)
It sets the polygon contour join style.
void setLineDashStyle(const std::vector< double > &style)
It sets the line dash style to the given pattern.
void setPolygonContourDashStyle(te::map::LineDashStyle style)
It sets the polygon contour dash style.
void setTextContourEnabled(bool b)
It controls the display of the text outline.
void setTextStretch(std::size_t stretch)
It sets the text stretch.
void drawPixel(int x, int y, const te::color::RGBAColor &color)
It sets a pixel to a particular color.
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
void drawImage(int x, int y, te::rst::Raster *src, int opacity=TE_OPAQUE)
It draws a raster over the canvas at the specified position (x, y). The raster must be with three 8-b...
void setTextUnderline(bool b)
It sets the text underline flag.
void drawImage(te::color::RGBAColor **src, int w, int h)
It draws the src image over the canvas.
void setLineCapStyle(te::map::LineCapStyle style)
It sets the line cap style.
void setPolygonContourPatternOpacity(int opacity)
It sets the polygon contour pattern opacity.
void setTextMultiLineSpacing(int spacing)
It sets the multi line text spacing.
void calcAspectRatio(double &llx, double &lly, double &urx, double &ury, const te::map::AlignType hAlign=te::map::Center, const te::map::AlignType vAlign=te::map::Center)
It calculates the best aspect ratio for world (or window) coordinates area (supposing a cartesian ref...
void setNormalMode()
It sets the painter to normal copy source to destination mode.
void clear()
It clears the canvas content and fills with the background color.
QColor m_lnColor
The color used to draw lines.
Definition: Canvas.h:516
void setPolygonPatternWidth(int w)
It sets the polygon pattern width.
QPixmap * getPixmap() const
It returns the internal pixmap used to draw geographical objects.
void draw(const te::gm::Geometry *geom)
It draws the geometry on canvas.
void drawText(int x, int y, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)
It draws a text.
Canvas(QPaintDevice *device)
It initializes a new Canvas associated with the given paint device.
void setTextOverline(bool b)
It sets the text overline flag.
QColor m_polyContourColor
The color used to draw polygon contour.
Definition: Canvas.h:519
int m_txtLineSpacing
Text multi line spacing.
Definition: Canvas.h:535
void createPointPatterns()
It creates two patterns. A pattern used to draw selected objects and the other used to erase this pat...
void setPolygonFillPattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the polygon fill pattern.
void setLineDashStyle(QPen &pen, const std::vector< double > &style)
It adjusts the given pen to use the given pattern.
int m_polyPatternWidth
The width used to draw marker or pattern.
Definition: Canvas.h:526
te::gm::Polygon * getTextBoundary(int x, int y, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)
It returns the text boundary (its enclose rectangle).
Canvas(QPainter *painter)
It initializes a new Canvas associated with the given painter.
void drawPixel(int x, int y)
It sets a pixel using the point pen.
void setPolygonContourPattern(char *pattern, std::size_t size, te::map::ImageType t)
It sets the pen pattern used to draw the boundary of polygon geometries using a buffered image.
void draw(const te::gm::MultiSurface *g)
It draws the MultiSurface on canvas.
QFont m_font
The text font.
Definition: Canvas.h:531
An abstract class for raster data strucutures.
Definition: Raster.h:72
FontStyleType
It defines the style to use for a font.
Definition: Font.h:73
FontWeightType
It gives the amount of weight or boldness to use for a font.
Definition: Font.h:85
LineJoinStyle
This enum encodes enumerated values telling how line strings should be joined (between line segments)...
Definition: Enums.h:85
LineDashStyle
This enum encodes enumerated values telling how lines should be drawn. e.g. as a plain line or dash l...
Definition: Enums.h:57
ImageType
This enum specifies the possible input and output image formats supported by the canvas API.
Definition: Enums.h:39
LineCapStyle
This enum encodes enumerated values telling how line strings should be capped (at the two ends of the...
Definition: Enums.h:73
AlignType
This enum contains values to control the alignment of components (like Canvas and MapDisplay).
Definition: Enums.h:126
@ Center
Definition: Enums.h:128
TerraLib.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
Definition: Config.h:36
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63