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 
39 namespace 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 
103  const te::gm::Envelope& getWindow() const;
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 
140  void draw(const te::gm::MultiSurface* g);
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 
210  void setTextColor(const te::color::RGBAColor& color);
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 
236  void setTextContourEnabled(bool b);
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 
258  void setLineColor(const te::color::RGBAColor& color);
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 
312  void setEraseMode();
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  */
484  void drawContour(const te::gm::LineString* line);
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 
te::qt::widgets::Canvas::m_txtContourPen
QPen m_txtContourPen
The pen used to draw the text contour.
Definition: Canvas.h:528
te::qt::widgets::Canvas::draw
void draw(const te::gm::LineString *line)
It draws the LineString on canvas.
te::qt::widgets::Canvas::drawPixel
void drawPixel(int x, int y, const te::color::RGBAColor &color)
It sets a pixel to a particular color.
te::qt::widgets::Canvas::drawImage
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).
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
te::qt::widgets::Canvas::m_erase
bool m_erase
used for erase operation.
Definition: Canvas.h:502
te::gm::MultiPoint
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:54
te::qt::widgets::Canvas::drawImage
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,...
te::qt::widgets::Canvas::m_ptColor
QColor m_ptColor
The color used to draw point (pixel) or marker.
Definition: Canvas.h:506
te::qt::widgets::Canvas::setLineDashStyle
void setLineDashStyle(te::map::LineDashStyle style)
It sets the line dash style.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::qt::widgets::Canvas::draw
void draw(const te::gm::GeometryCollection *g)
It draws the GeometryCollection on canvas.
te::qt::widgets::Canvas::setPolygonContourDashStyle
void setPolygonContourDashStyle(te::map::LineDashStyle style)
It sets the polygon contour dash style.
te::qt::widgets::Canvas::updateAlpha
void updateAlpha(QImage &img, const int &opacity)
It updates the alpha channel of the given image using the given opacity value.
te::qt::widgets::Canvas::drawImage
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...
te::qt::widgets::Canvas::drawText
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.
te::qt::widgets::Canvas::Canvas
Canvas(const Canvas &rhs)
Copy constructor not allowed.
te::qt::widgets::Canvas::setTextDecorationColor
void setTextDecorationColor(const te::color::RGBAColor &color)
It sets the text color for drawing text decoration.
te::qt::widgets::Canvas::setLinePattern
void setLinePattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the line pattern.
te::map::LineJoinStyle
LineJoinStyle
This enum encodes enumerated values telling how line strings should be joined (between line segments)...
Definition: Enums.h:85
te::qt::widgets::Canvas::setPolygonContourColor
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
te::qt::widgets::Canvas::getTextBoundary
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).
te::qt::widgets::Canvas::drawImage
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,...
te::qt::widgets::Canvas::setDevice
void setDevice(QPaintDevice *device, bool takeOwnerShip)
It sets new device as QPrinter.
te::qt::widgets::Canvas::calcAspectRatio
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...
te::qt::widgets::Canvas::setPolygonFillPattern
void setPolygonFillPattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the polygon fill pattern.
te::qt::widgets::Canvas::setPolygonFillColor
void setPolygonFillColor(const QBrush &color)
te::qt::widgets::Canvas::Canvas
Canvas(QPaintDevice *device)
It initializes a new Canvas associated with the given paint device.
te::qt::widgets::Canvas::setTextContourOpacity
void setTextContourOpacity(int opacity)
It sets the text contour opacity.
te::qt::widgets::Canvas::getResolution
int getResolution()
It returns the device resolution.
te::qt::widgets::Canvas::setPolygonPatternWidth
void setPolygonPatternWidth(int w)
It sets the polygon pattern width.
te::qt::widgets::Canvas
A canvas built on top of Qt.
Definition: Canvas.h:55
te::qt::widgets::Canvas::draw
void draw(const te::gm::Geometry *geom)
It draws the geometry on canvas.
te::qt::widgets::Canvas::drawText
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.
te::map::AlignType
AlignType
This enum contains values to control the alignment of components (like Canvas and MapDisplay).
Definition: Enums.h:126
te::qt::widgets::Canvas::drawImage
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.
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::qt::widgets::Canvas::drawImage
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).
te::qt::widgets::Canvas::m_matrix
QMatrix m_matrix
Matrix that transforms the world coordinate to device coordinate.
Definition: Canvas.h:491
te::qt::widgets::Canvas::getDevice
QPaintDevice * getDevice() const
It returns the internal device used to draw geographical objects.
te::qt::widgets::Canvas::m_ptSelectionPatternImg
QImage * m_ptSelectionPatternImg
The marker or pattern used to show selection status. The color is mixed with point pattern.
Definition: Canvas.h:510
te::qt::widgets::Canvas::m_polyImage
QImage * m_polyImage
The pattern image used to fill polygon.
Definition: Canvas.h:525
te::qt::widgets::Canvas::clear
void clear()
It clears the canvas content and fills with the background color.
te::qt::widgets::Canvas::~Canvas
~Canvas()
Destructor.
te::qt::widgets::Canvas::drawText
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.
te::se::Font::FontStyleType
FontStyleType
It defines the style to use for a font.
Definition: Font.h:73
te::qt::widgets::Canvas::m_envelope
te::gm::Envelope * m_envelope
Stores the current world (or window) coordinates area.
Definition: Canvas.h:492
te::qt::widgets::Canvas::getImage
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.
te::qt::widgets::Canvas::m_polyDefaultBrush
QBrush m_polyDefaultBrush
The brush used to fill polygon.
Definition: Canvas.h:524
te::qt::widgets::Canvas::setEraseMode
void setEraseMode()
It sets the painter to erase mode.
te::qt::widgets::Canvas::createPointPatterns
void createPointPatterns()
It creates two patterns. A pattern used to draw selected objects and the other used to erase this pat...
te::qt::widgets::Canvas::m_isDeviceOwner
bool m_isDeviceOwner
Tells if canvas is the owner of the paint device.
Definition: Canvas.h:498
te::qt::widgets::Canvas::setWindow
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).
te::qt::widgets::Canvas::setPolygonContourPatternRotation
void setPolygonContourPatternRotation(const double &angle)
It sets the polygon contour pattern rotation.
te::qt::widgets::Canvas::setPolygonFillColor
void setPolygonFillColor(const te::color::RGBAColor &color)
It sets the color used to fill the draw of polygon geometries.
te::qt::widgets::Canvas::getWindow
const te::gm::Envelope & getWindow() const
It gets the world (or window) coordinates area (supposing a cartesian reference system).
te::qt::widgets::Canvas::draw
void draw(const te::gm::Polygon *poly)
It draws the polygon on canvas.
te::qt::widgets::Canvas::draw
void draw(const te::gm::MultiPoint *mpoint)
It draws the MultiPoint on canvas.
TEQTWIDGETSEXPORT
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
te::qt::widgets::Canvas::m_txtLineSpacing
int m_txtLineSpacing
Text multi line spacing.
Definition: Canvas.h:535
te::qt::widgets::Canvas::m_txtLetterSpacing
int m_txtLetterSpacing
Text letter spacing.
Definition: Canvas.h:532
te::gm::GeometryCollection
It is a collection of other geometric objects.
Definition: GeometryCollection.h:58
te::qt::widgets::Canvas::m_pt
QPointF m_pt
Point buffer to avoid creating another point instance.
Definition: Canvas.h:504
te::qt::widgets::Canvas::m_bgColor
QColor m_bgColor
Canvas background color. Defaults: white fully transparent.
Definition: Canvas.h:500
te::qt::widgets::Canvas::draw
void draw(const te::gm::Point *point)
It draws the point on canvas.
te::qt::widgets::Canvas::m_lnColor
QColor m_lnColor
The color used to draw lines.
Definition: Canvas.h:516
te::qt::widgets::Canvas::setNormalMode
void setNormalMode()
It sets the painter to normal copy source to destination mode.
te::qt::widgets::Canvas::calcAspectRatio
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...
te::qt::widgets::Canvas::m_ptClearPatternImg
QImage * m_ptClearPatternImg
The marker or pattern used to clear (erase point).
Definition: Canvas.h:511
te::qt::widgets::Canvas::m_polyColor
QColor m_polyColor
The color used to fill polygon (solid, marker or pattern).
Definition: Canvas.h:522
te::gm::Polygon
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
te::qt::widgets::Canvas::setTextOpacity
void setTextOpacity(int opacity)
It sets the text opacity.
te::qt::widgets::Canvas::setPointPatternRotation
void setPointPatternRotation(const double &angle)
It sets the point pattern rotation. Rotation is made ​​from the center of the pattern.
te::qt::widgets::Canvas::setFontFamily
void setFontFamily(const std::string &family)
It sets the text font family.
te::qt::widgets::Canvas::m_ptRotation
double m_ptRotation
The point pattern rotation.
Definition: Canvas.h:512
te::qt::widgets::Canvas::setPointWidth
void setPointWidth(int w)
It sets the point width. If point has a patterns, this pattern is scaled to width.
te::qt::widgets::Canvas::getPixmap
QPixmap * getPixmap() const
It returns the internal pixmap used to draw geographical objects.
te::qt::widgets::Canvas::operator=
Canvas & operator=(const Canvas &rhs)
Assignment operator not allowed.
te::qt::widgets::Canvas::drawImage
void drawImage(te::color::RGBAColor **src, int w, int h)
It draws the src image over the canvas.
te::qt::widgets::Canvas::setTextContourWidth
void setTextContourWidth(int width)
It sets the text contour width.
te::map::LineCapStyle
LineCapStyle
This enum encodes enumerated values telling how line strings should be capped (at the two ends of the...
Definition: Enums.h:73
te::qt::widgets::Canvas::setTextStretch
void setTextStretch(std::size_t stretch)
It sets the text stretch.
te::qt::widgets::Canvas::getImage
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, ...).
te::qt::widgets::Canvas::setTextWeight
void setTextWeight(te::se::Font::FontWeightType weight)
It sets the text weight.
te::qt::widgets::Canvas::m_patterns
std::map< std::string, QPixmap * > m_patterns
The pixmap styles used to draw patterns.
Definition: Canvas.h:537
te::qt::widgets::Canvas::setRenderHint
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.
TE_OPAQUE
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
Definition: Config.h:36
te::qt::widgets::Canvas::getPainter
QPainter * getPainter()
te::qt::widgets::Canvas::freeImage
void freeImage(char *img) const
This is the method that you should use to release an image generated by the canvas.
te::qt::widgets::Canvas::Canvas
Canvas(QPainter *painter)
It initializes a new Canvas associated with the given painter.
te::qt::widgets::Canvas::m_ptVOffset
int m_ptVOffset
Vertical offset in pixels (in device coordinate) applied to point pattern or marker.
Definition: Canvas.h:513
te::map::LineDashStyle
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
te::qt::widgets::Canvas::m_txtContourEnabled
bool m_txtContourEnabled
The flag indicates whether the outline of the text should be drawn.
Definition: Canvas.h:529
te::se::Font::FontWeightType
FontWeightType
It gives the amount of weight or boldness to use for a font.
Definition: Font.h:85
te::qt::widgets::Canvas::setLineWidth
void setLineWidth(int w)
It sets the line width.
te::qt::widgets::Canvas::setPointColor
void setPointColor(const te::color::RGBAColor &color)
It sets the point drawing color.
te::qt::widgets::Canvas::m_polyContourPen
QPen m_polyContourPen
The pen used to draw contour polygon.
Definition: Canvas.h:520
te::qt::widgets::Canvas::getMatrix
QMatrix getMatrix()
It returns the matrix.
te::qt::widgets::Canvas::setPolygonContourPattern
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.
te::qt::widgets::Canvas::setMatrix
void setMatrix(const QMatrix &matrix)
te::qt::widgets::Canvas::setLineColor
void setLineColor(const te::color::RGBAColor &color)
It sets the pen color used to draw line geometries.
te::gm::MultiPolygon
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:51
te::qt::widgets::Canvas::setLineDashStyle
void setLineDashStyle(QPen &pen, const std::vector< double > &style)
It adjusts the given pen to use the given pattern.
te::qt::widgets::Canvas::Canvas
Canvas(int w, int h, int devType=QInternal::Pixmap)
It initializes a new Canvas and associates a pixmap as the default device.
te::qt::widgets::Canvas::m_polyContourColor
QColor m_polyContourColor
The color used to draw polygon contour.
Definition: Canvas.h:519
te::qt::widgets::Canvas::drawText
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.
te::qt::widgets::Canvas::m_isPainterOwner
bool m_isPainterOwner
Tells if canvas is the owner of the painter.
Definition: Canvas.h:496
te::qt::widgets::Canvas::setPolygonContourDashStyle
void setPolygonContourDashStyle(const std::vector< double > &style)
It sets the polygon contour dash style to the given pattern.
te::map::Canvas
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:93
te::qt::widgets::Canvas::setPolygonContourCapStyle
void setPolygonContourCapStyle(te::map::LineCapStyle style)
It sets the polygon contour cap style.
te::qt::widgets::Canvas::setTextMultiLineSpacing
void setTextMultiLineSpacing(int spacing)
It sets the multi line text spacing.
te::qt::widgets::Canvas::setTextContourColor
void setTextContourColor(const te::color::RGBAColor &color)
It sets the text contour (outline) drawing color.
te::qt::widgets::Canvas::getBackgroundColor
te::color::RGBAColor getBackgroundColor() const
It returns the canvas background color.
te::qt::widgets::Canvas::m_polyPatternWidth
int m_polyPatternWidth
The width used to draw marker or pattern.
Definition: Canvas.h:526
te::qt::widgets::Canvas::m_txtBrush
QBrush m_txtBrush
The brush used to draw texts.
Definition: Canvas.h:530
te::gm::LineString
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
te::qt::widgets::Canvas::getWidth
int getWidth() const
It returns the canvas width.
te::qt::widgets::Canvas::setLineCapStyle
void setLineCapStyle(te::map::LineCapStyle style)
It sets the line cap style.
te::qt::widgets::Canvas::m_lnPen
QPen m_lnPen
The pen used to draw lines.
Definition: Canvas.h:517
te::qt::widgets::Canvas::m_polyBrush
QBrush m_polyBrush
The brush used to fill polygon.
Definition: Canvas.h:523
te::qt::widgets::Canvas::getTextBoundary
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).
te::qt::widgets::Canvas::save
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::qt::widgets::Canvas::resize
void resize(int w, int h)
It adjusts the canvas size (width and height).
te::qt::widgets::Canvas::setTextStyle
void setTextStyle(te::se::Font::FontStyleType style)
It sets the text style.
te::qt::widgets::Canvas::setPolygonPatternRotation
void setPolygonPatternRotation(const double &angle)
It sets the polygon pattern rotation.
te::qt::widgets::Canvas::setLinePattern
void setLinePattern(char *pattern, std::size_t size, te::map::ImageType t)
It sets the line pattern using a buffered image.
te::qt::widgets::Canvas::setPolygonContourWidth
void setPolygonContourWidth(int w)
It sets the polygon contour width.
te::qt::widgets::Canvas::m_ptHOffset
int m_ptHOffset
Horizontal offset in pixels (in device coordinate) applied to point pattern or marker.
Definition: Canvas.h:514
te::color::RGBAColor
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:58
te::qt::widgets::Canvas::draw
void draw(const te::gm::MultiLineString *mline)
It draws the MultiLineString on canvas.
te::qt::widgets::Canvas::setTextDecorationWidth
void setTextDecorationWidth(int width)
It sets the width for drawing text decoration.
te::qt::widgets::Canvas::m_ptColorFrom
QColor m_ptColorFrom
Indicates the color that originated the pattern that shows the status of selection....
Definition: Canvas.h:507
te::qt::widgets::Canvas::m_painterTransform
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
te::qt::widgets::Canvas::setPointPattern
void setPointPattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the point pattern.
te::qt::widgets::Canvas::setTextUnderline
void setTextUnderline(bool b)
It sets the text underline flag.
te::qt::widgets::Canvas::setPolygonFillPattern
void setPolygonFillPattern(char *pattern, std::size_t size, te::map::ImageType t)
It sets the polygon fill pattern using a buffered image.
te::map::Center
@ Center
Definition: Enums.h:128
te::qt::widgets::Canvas::setTextColor
void setTextColor(const te::color::RGBAColor &color)
It sets the text drawing color.
te::qt::widgets::Canvas::m_ptWidth
int m_ptWidth
The width for point markers and point pattern.
Definition: Canvas.h:505
te::qt::widgets::Canvas::setPointPattern
void setPointPattern(char *pattern, std::size_t size, te::map::ImageType t)
It sets the point pattern using a buffered image.
te::qt::widgets::Canvas::m_ptImgRotated
QImage * m_ptImgRotated
The marker or pattern already with rotation used to draw points.
Definition: Canvas.h:509
te::qt::widgets::Canvas::setTextJustification
void setTextJustification(int justType)
It sets the text justification for multi line text.
te::qt::widgets::Canvas::setTextPointSize
void setTextPointSize(double psize)
It sets the text point Size.
te::qt::widgets::Canvas::setLinePatternRotation
void setLinePatternRotation(const double &angle)
It sets the line pattern rotation. Rotation is made ​​from the center of the pattern.
te::qt::widgets::Canvas::setPolygonPatternOpacity
void setPolygonPatternOpacity(int opacity)
It sets the polygon pattern opacity.
te::map::ImageType
ImageType
This enum specifies the possible input and output image formats supported by the canvas API.
Definition: Enums.h:39
te::qt::widgets::Canvas::draw
void draw(const te::gm::MultiSurface *g)
It draws the MultiSurface on canvas.
te::qt::widgets::Canvas::m_txtWordSpacing
int m_txtWordSpacing
Text word spacing.
Definition: Canvas.h:533
te::qt::widgets::Canvas::m_painter
QPainter * m_painter
The painter used to draw geometric objects.
Definition: Canvas.h:494
te::qt::widgets::Canvas::getHeight
int getHeight() const
It returns the canvas height.
te::qt::widgets::Canvas::setPolygonContourPatternOpacity
void setPolygonContourPatternOpacity(int opacity)
It sets the polygon contour pattern opacity.
te::qt::widgets::Canvas::m_font
QFont m_font
The text font.
Definition: Canvas.h:531
te::gm::MultiLineString
MultiLineString is a MultiCurve whose elements are LineStrings.
Definition: MultiLineString.h:55
te::qt::widgets::Canvas::drawContour
void drawContour(const te::gm::LineString *line)
It draw the polygon contour.
te::qt::widgets::Canvas::setTextOverline
void setTextOverline(bool b)
It sets the text overline flag.
te::qt::widgets::Canvas::setTextContourEnabled
void setTextContourEnabled(bool b)
It controls the display of the text outline.
te::qt::widgets::Canvas::getTextBoundary
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.
te::qt::widgets::Canvas::setLineDashStyle
void setLineDashStyle(const std::vector< double > &style)
It sets the line dash style to the given pattern.
te::qt::widgets::Canvas::m_ptPen
QPen m_ptPen
The pen used to draw points.
Definition: Canvas.h:503
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
te::qt::widgets::Canvas::setBackgroundColor
void setBackgroundColor(const te::color::RGBAColor &color)
It sets the canvas background color.
te::qt::widgets::Canvas::setPointPatternOpacity
void setPointPatternOpacity(int opacity)
It sets the point pattern opacity.
te::qt::widgets::Canvas::getTextBoundary
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).
te::qt::widgets::Canvas::setLinePatternOpacity
void setLinePatternOpacity(int opacity)
It sets the line pattern opacity.
te::qt::widgets::Canvas::draw
void draw(const te::gm::MultiPolygon *mpoly)
It draws the MultiPolygon on canvas.
te::qt::widgets::Canvas::drawImage
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,...
te::gm::Point
A point with x and y coordinate values.
Definition: Point.h:51
te::qt::widgets::Canvas::setLineJoinStyle
void setLineJoinStyle(te::map::LineJoinStyle style)
It sets the line join style.
te::qt::widgets::Canvas::setPolygonContourPattern
void setPolygonContourPattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the pen pattern used to draw the boundary of polygon geometries.
te::qt::widgets::Canvas::m_ptImg
QImage * m_ptImg
The marker or pattern used to point.
Definition: Canvas.h:508
te::qt::widgets::Canvas::drawImage
void drawImage(char *src, std::size_t size, te::map::ImageType t)
It draws the src image over the canvas.
te::qt::widgets::Canvas::drawPixel
void drawPixel(int x, int y)
It sets a pixel using the point pen.
te::qt::widgets::Canvas::setTextStrikeOut
void setTextStrikeOut(bool b)
It sets the text strike out flag.
te::qt::widgets::Canvas::getImage
QImage * getImage() const
It returns the internal image used to draw geographical objects.
te::gm::MultiSurface
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:55
te::qt::widgets::Canvas::setPolygonContourJoinStyle
void setPolygonContourJoinStyle(te::map::LineJoinStyle style)
It sets the polygon contour join style.
te::qt::widgets::Canvas::drawImage
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.