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 Canvas.h
22 
23  \brief A canvas is an abstraction of a drawing area.
24 */
25 
26 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_CANVAS_H
27 #define __TERRALIB_MAPTOOLS_INTERNAL_CANVAS_H
28 
29 // TerraLib
30 #include "../color/RGBAColor.h"
31 #include "../se/Font.h"
32 #include "Config.h"
33 #include "Enums.h"
34 
35 // Boost
36 #include <boost/noncopyable.hpp>
37 
38 namespace te
39 {
40 // Forward declarations
41  namespace at
42  {
43  class Text;
44  }
45 
46  namespace gm
47  {
48  class Envelope;
49  class Geometry;
50  class GeometryCollection;
51  class LineString;
52  class MultiLineString;
53  class MultiPoint;
54  class MultiPolygon;
55  class Point;
56  class PointM;
57  class PointZ;
58  class PointZM;
59  class Polygon;
60  class MultiSurface;
61  }
62 
63  namespace rst
64  {
65  class Raster;
66  }
67 
68  namespace map
69  {
70  /*!
71  \class Canvas
72 
73  \brief A canvas is an abstraction of a drawing area.
74 
75  What is a Canvas?
76 
77  It is an abstraction of a drawing area. You can use it to:
78  <ul>
79  <li>draw geographical objects from a layer, with a given visual (or style);</li>
80  <li>draw texts;</li>
81  <li>draw the map legend;</li>
82  <li>create a chart.</li>
83  </ul>
84 
85  The Canvas can be viewed as one of the rendering surface
86  used by an application to show a map.
87 
88  \ingroup map
89 
90  \sa te::qt::widgets::Canvas, te::agg::Canvas, te::gd::Canvas
91  */
92  class Canvas : public boost::noncopyable
93  {
94  public:
95 
96  /** @name Initializer Methods
97  * Methods related to instantiation and destruction.
98  */
99  //@{
100 
101  /*! \brief Constructor. */
102  Canvas() {}
103 
104  /*! \brief Virtual destructor. */
105  virtual ~Canvas() {}
106 
107  //@}
108 
109  /** @name Accessor Methods
110  * Methods used to access internal attributes.
111  */
112  //@{
113 
114  /*!
115  \brief It sets the world (or window) coordinates area (supposing a cartesian reference system).
116 
117  \param llx Lower left x-coordinate of the World.
118  \param lly Lower left y-coordinate of the World.
119  \param urx Upper right x-coordinate of the World.
120  \param ury Upper right y-coordinate of the World.
121 
122  \note The coordinates must be in the Spatial Reference System of the features to be drawn in canvas.
123  */
124  virtual void setWindow(const double& llx, const double& lly,
125  const double& urx, const double& ury) = 0;
126 
127  /*!
128  \brief It calculates the best aspect ratio for world (or window) coordinates area (supposing a cartesian reference system).
129 
130  \param llx Lower left x-coordinate of the World.
131  \param lly Lower left y-coordinate of the World.
132  \param urx Upper right x-coordinate of the World.
133  \param ury Upper right y-coordinate of the World.
134  \param hAlign Horizontal Alignment. It can be left, center or right.
135  \param vAlign Vertical Alignment. It can be top, center or bottom.
136 
137  \note The input coordinates will be adjusted according to the alignment parameters provided.
138  */
139  virtual void calcAspectRatio(double& llx, double& lly, double& urx, double& ury,
140  const AlignType hAlign = Center,
141  const AlignType vAlign = Center) = 0;
142 
143  /*!
144  \brief It calculates the best aspect ratio for world (or window) coordinates area (supposing a cartesian reference system).
145 
146  \param envelope A rectangle with world coordinates that will be adjusted.
147  \param hAlign Horizontal Alignment. It can be left, center or right.
148  \param vAlign Vertical Alignment. It can be top, center or bottom.
149 
150  \note The input coordinates will be adjusted according to the alignment parameters provided.
151  */
152  virtual void calcAspectRatio(te::gm::Envelope* envelope,
153  const AlignType hAlign = Center,
154  const AlignType vAlign = Center) = 0;
155 
156  /*!
157  \brief It sets the canvas background color.
158 
159  The default is totally transparent (255, 255, 255, 0).
160 
161  \param color The background color.
162 
163  \note When this method is called, all the canvas content is dropped out.
164  */
165  virtual void setBackgroundColor(const te::color::RGBAColor& color) = 0;
166 
167  /*!
168  \brief It returns the canvas background color.
169 
170  \return The canvas background color.
171  */
172  virtual te::color::RGBAColor getBackgroundColor() const = 0;
173 
174  /*! \brief It clears the canvas content and fills with the background color. */
175  virtual void clear() = 0;
176 
177  /*!
178  \brief It adjusts the canvas size (width and height).
179 
180  \param w The new canvas width.
181  \param h The new canvas height.
182  */
183  virtual void resize(int w, int h) = 0;
184 
185  /*!
186  \brief It returns the canvas width.
187 
188  \return The canvas width.
189  */
190  virtual int getWidth() const = 0;
191 
192  /*!
193  \brief It returns the canvas height.
194 
195  \return The canvas height.
196  */
197  virtual int getHeight() const = 0;
198 
199  //@}
200 
201  /** @name Geographical Objects Drawing Methods (TerraLib Geometry)
202  * Methods used to draw geographical objects encoded as a TerraLib Geometry.
203  * Note that the visual (style and symbol) used to draw geometries is affected by the visual methods.
204  */
205  //@{
206 
207  /*!
208  \brief It draws the geometry on canvas.
209 
210  \param geom Any geometry (point, line, polygon, ...).
211  */
212  virtual void draw(const te::gm::Geometry* geom) = 0;
213 
214  /*!
215  \brief It draws the point on canvas.
216 
217  \param point The point.
218  */
219  virtual void draw(const te::gm::Point* point) = 0;
220 
221  /*!
222  \brief It draws the MultiPoint on canvas.
223 
224  \param mpoint The MultiPoint.
225  */
226  virtual void draw(const te::gm::MultiPoint* mpoint) = 0;
227 
228  /*!
229  \brief It draws the LineString on canvas.
230 
231  \param line The LineString.
232  */
233  virtual void draw(const te::gm::LineString* line) = 0;
234 
235  /*!
236  \brief It draws the MultiLineString on canvas.
237 
238  \param mline The MultiLineString.
239  */
240  virtual void draw(const te::gm::MultiLineString* mline) = 0;
241 
242  /*!
243  \brief It draws the polygon on canvas.
244 
245  \param poly The polygon.
246  */
247  virtual void draw(const te::gm::Polygon* poly) = 0;
248 
249  /*!
250  \brief It draws the MultiPolygon on canvas.
251 
252  \param mpoly The MultiPolygon.
253  */
254  virtual void draw(const te::gm::MultiPolygon* mpoly) = 0;
255 
256  /*!
257  \brief It draws the GeometryCollection on canvas.
258 
259  \param g The GeometryCollection.
260  */
261  virtual void draw(const te::gm::GeometryCollection* g) = 0;
262 
263  /*!
264  \brief It draws the MultiSurface on canvas.
265 
266  \param g The MultiSurface.
267  */
268  virtual void draw(const te::gm::MultiSurface* g) = 0;
269  //@}
270 
271  /** @name Image Handling
272  * Methods used to draw an image on Canvas.
273  */
274  //@{
275 
276  /*!
277  \brief It saves the canvas content to a file image in the specified format type.
278 
279  \param fileName The file name and path where the image will be saved.
280  \param t The image format type (see ImageType enum).
281  \param quality JPEG quality, generally a value between 0 and 95.
282  \param fg Foreground color for WBMP images.
283  */
284  virtual void save(const char* fileName, ImageType t, int quality = 75, int fg = 0) const = 0;
285 
286  /*!
287  \brief It returns the internal content as an image in a specific format (PNG, JPEG, ...).
288 
289  \param t The image format type (see ImageType enum).
290  \param size The image size in bytes.
291  \param quality JPEG quality, generally a value between 0 and 95.
292  \param fg Foreground color for WBMP images.
293 
294  \return The internal content as an image. The caller will take the ownership of the returned pointer.
295 
296  \note Use canvas freeImage in order to release the returned image resources.
297  */
298  virtual char* getImage(ImageType t, std::size_t& size, int quality = 75, int fg = 0) const = 0;
299 
300  /*!
301  \brief It gets a RGBA color array from internal canvas buffer.
302 
303  \return The Pointer RGBA colors.
304 
305  \note The caller of this method will take the ownership of the returned array.
306  */
307  virtual te::color::RGBAColor** getImage(const int x = 0, const int y = 0, const int w = 0, const int h = 0) const = 0;
308 
309  /*!
310  \brief This is the method that you should use to release an image generated by the canvas.
311 
312  \param img A pointer to an image previously created by the canvas.
313  */
314  virtual void freeImage(char* img) const = 0;
315 
316  /*!
317  \brief It draws the src image over the canvas.
318 
319  \param src A source image of any type (PNG, JPEG, GIF, ...).
320  \param size The image size in bytes.
321  \param t The image format type (see ImageType enum).
322  */
323  virtual void drawImage(char* src, std::size_t size, ImageType t) = 0;
324 
325  /*!
326  \brief It draws the src image over the canvas.
327 
328  \param src The source image.
329  \param w The image width (number of columns).
330  \param h The image height (number of rows).
331  */
332  virtual void drawImage(te::color::RGBAColor** src, int w, int h) = 0;
333 
334  /*!
335  \brief It draws the src image over the canvas at the specified position (x, y).
336 
337  \param x The canvas start position where the src image will be drawn.
338  \param y The canvas start position where the src image will be drawn.
339  \param src A source image of any type (PNG, JPEG, GIF, ...).
340  \param size The image size in bytes.
341  \param t The image format type (see ImageType enum).
342  */
343  virtual void drawImage(int x, int y, char* src, std::size_t size, ImageType t) = 0;
344 
345  /*!
346  \brief It draws the src image over the canvas at the specified position (x, y).
347 
348  \param x The canvas start position where the src image will be drawn.
349  \param y The canvas start position where the src image will be drawn.
350  \param src The source image.
351  \param w The image width (number of columns).
352  \param h The image height (number of rows).
353  */
354  virtual void drawImage(int x, int y, te::color::RGBAColor** src, int w, int h) = 0;
355 
356  /*!
357  \brief It draws the source image into the rectangle at position (x, y) with the given width and height.
358 
359  \param x The canvas start position where the src image will be drawn.
360  \param y The canvas start position where the src image will be drawn.
361  \param w The rectangle width.
362  \param h The rectangle height.
363  \param src A source image of any type (PNG, JPEG, GIF, ...).
364  \param size The image size in bytes.
365  \param t The image format type (see ImageType enum).
366  */
367  virtual void drawImage(int x, int y, int w, int h, char* src, std::size_t size, ImageType t) = 0;
368 
369  /*!
370  \brief It draws the source image into the rectangle at position (x, y) with the given width and height.
371 
372  \param x The canvas start position where the src image will be drawn.
373  \param y The canvas start position where the src image will be drawn.
374  \param w The rectangle width.
375  \param h The rectangle height.
376  \param src The source image.
377  \param srcw The source image width (number of columns).
378  \param srch The source image height (number of rows).
379  */
380  virtual void drawImage(int x, int y, int w, int h, te::color::RGBAColor** src, int srcw, int srch) = 0;
381 
382  /*!
383  \brief It draws the rectangular portion with the origin (sx, sy), width sw and height sh, of the source image, at the point (x, y), with a width of w and a height of h. If sw or sh are equal to zero the width/height of the pixmap is used and adjusted by the offset sx/sy.
384 
385  \param x The canvas start position where the src image will be drawn.
386  \param y The canvas start position where the src image will be drawn.
387  \param w The rectangle width.
388  \param h The rectangle height.
389  \param src A source image of any type (PNG, JPEG, GIF, ...).
390  \param size The image size in bytes.
391  \param t The image format type (see ImageType enum).
392  \param sx The source image position.
393  \param sy The source image position.
394  \param sw The source image rectangle width.
395  \param sh The source image rectangle height.
396  */
397  virtual void drawImage(int x, int y, int w, int h, char* src, std::size_t size, ImageType t, int sx, int sy, int sw, int sh) = 0;
398 
399  /*!
400  \brief It draws the rectangular portion with the origin (sx, sy), width sw and height sh, of the source image, at the point (x, y), with a width of w and a height of h. If sw or sh are equal to zero the width/height of the pixmap is used and adjusted by the offset sx/sy.
401 
402  \param x The canvas start position where the src image will be drawn.
403  \param y The canvas start position where the src image will be drawn.
404  \param w The rectangle width.
405  \param h The rectangle height.
406  \param src The source image.
407  \param sx The source image start position.
408  \param sy The source image start position.
409  \param sw The source image rectangle width.
410  \param sh The source image rectangle height.
411  */
412  virtual void drawImage(int x, int y, int w, int h, te::color::RGBAColor** src, int sx, int sy, int sw, int sh) = 0;
413 
414  /*!
415  \brief It draws a raster over the canvas at the specified position (x, y). The raster must be with three 8-bit bands (1R, 2G, 3B),
416 
417  \param x The canvas start position in x where the raster image will be drawn.
418  \param y The canvas start position in y where the raster image will be drawn.
419  \param src The source raster.
420  \param opacity The opacity value used to draw the image
421  */
422  virtual void drawImage(int x, int y, te::rst::Raster* src, int opacity = TE_OPAQUE) = 0;
423 
424  /*!
425  \brief It draws the rectangular portion with the origin (sx, sy), width sw and height sh, of the source raster,
426  starting at the point (x, y), with a width of w and a height of h. If sw or sh are equal to zero the width/height
427  of the pixmap is used and adjusted by the offset sx/sy.
428 
429  \param x The canvas start position where the src image will be drawn.
430  \param y The canvas start position where the src image will be drawn.
431  \param w The rectangle width.
432  \param h The rectangle height.
433  \param src The source raster.
434  \param sx The source image start position.
435  \param sy The source image start position.
436  \param sw The source image rectangle width.
437  \param sh The source image rectangle height.
438  \param opacity The opacity value used to draw the image
439  */
440  virtual 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) = 0;
441 
442  //@}
443 
444  /** @name Pixel Handling
445  * Methods used to draw a pixel on Canvas.
446  */
447  //@{
448 
449  /*!
450  \brief It sets a pixel using the point pen.
451 
452  \param x Column.
453  \param y Row.
454  */
455  virtual void drawPixel(int x, int y) = 0;
456 
457  /*!
458  \brief It sets a pixel to a particular color.
459 
460  The color must be an RGBA value. With the following range:
461  <ul>
462  <li>R: 0-255;</li>
463  <li>G: 0-255;</li>
464  <li>B: 0-255;</li>
465  <li>A: 0-255.</li>
466 
467  \param x Column.
468  \param y Row.
469  \param color Pixel color.
470  */
471  virtual void drawPixel(int x, int y, const te::color::RGBAColor& color) = 0;
472 
473  //@}
474 
475  /** @name Text Handling
476  * Methods used to draw a text on Canvas.
477  */
478  //@{
479 
480  /*!
481  \brief It draws a text.
482 
483  Color and font family should be defined in advance.
484 
485  \param x The text entry point x in device coordinate.
486  \param y The text entry point y in device coordinate.
487  \param txt The text to be drawn.
488  \param angle The text rotation.
489  \param anchorX The horizontal text anchor.
490  \param anchorY The vertical text anchor.
491  \param displacementX The horizontal text displacement.
492  \param displacementY The vertical text displacement.
493  */
494  virtual void drawText(int x, int y,
495  const std::string& txt,
496  float angle = 0.0,
497  double anchorX = 0.5, double anchorY = 0.5,
498  int displacementX = 0, int displacementY = 0) = 0;
499 
500  /*!
501  \brief It draws a text.
502 
503  Color and font family should be defined in advance.
504 
505  \param p The text entry point in world coordinate.
506  \param txt The text to be drawn.
507  \param angle The text rotation.
508  \param anchorX The horizontal text anchor.
509  \param anchorY The vertical text anchor.
510  \param displacementX The horizontal text displacement.
511  \param displacementY The vertical text displacement.
512  */
513  virtual void drawText(const te::gm::Point* p,
514  const std::string& txt,
515  float angle = 0.0,
516  double anchorX = 0.5, double anchorY = 0.5,
517  int displacementX = 0, int displacementY = 0) = 0;
518 
519  /*!
520  \brief It draws a text.
521 
522  Color and font family should be defined in advance.
523 
524  \param x The text entry point x in world coordinate.
525  \param y The text entry point y in world coordinate.
526  \param txt The text to be drawn.
527  \param angle The text rotation.
528  \param anchorX The horizontal text anchor.
529  \param anchorY The vertical text anchor.
530  \param displacementX The horizontal text displacement.
531  \param displacementY The vertical text displacement.
532  */
533  virtual void drawText(const double& x, const double& y,
534  const std::string& txt,
535  float angle = 0.0,
536  double anchorX = 0.5, double anchorY = 0.5,
537  int displacementX = 0, int displacementY = 0) = 0;
538 
539  /*!
540  \brief It returns the text boundary (its enclose rectangle).
541 
542  Color and font family should be defined in advance.
543 
544  \param x The text entry point x in device coordinate.
545  \param y The text entry point y in device coordinate.
546  \param txt The text to be drawn.
547  \param angle The text rotation.
548  \param anchorX The horizontal text anchor.
549  \param anchorY The vertical text anchor.
550  \param displacementX The horizontal text displacement.
551  \param displacementY The vertical text displacement.
552 
553  \return The text boundary in world coordinate.
554 
555  \note The caller of this method will take the ownership of the returned Polygon.
556  */
557  virtual te::gm::Polygon* getTextBoundary(int x, int y,
558  const std::string& txt,
559  float angle = 0.0,
560  double anchorX = 0.5, double anchorY = 0.5,
561  int displacementX = 0, int displacementY = 0) = 0;
562 
563  /*!
564  \brief It returns the text boundary (its enclose rectangle).
565 
566  Color and font family should be defined in advance.
567 
568  \param p The text entry point in world coordinate.
569  \param txt The text to be drawn.
570  \param angle The text rotation.
571  \param anchorX The horizontal text anchor.
572  \param anchorY The vertical text anchor.
573  \param displacementX The horizontal text displacement.
574  \param displacementY The vertical text displacement.
575 
576  \return The text boundary in world coordinate.
577 
578  \note The caller of this method will take the ownership of the returned Polygon.
579  */
581  const std::string& txt,
582  float angle = 0.0,
583  double anchorX = 0.5, double anchorY = 0.5,
584  int displacementX = 0, int displacementY = 0) = 0;
585 
586  /*!
587  \brief It returns the text boundary (its enclose rectangle).
588 
589  Color and font family should be defined in advance.
590 
591  \param x The text entry point x in world coordinate.
592  \param y The text entry point y in world coordinate.
593  \param txt The text to be drawn.
594  \param angle The text rotation.
595  \param anchorX The horizontal text anchor.
596  \param anchorY The vertical text anchor.
597  \param displacementX The horizontal text displacement.
598  \param displacementY The vertical text displacement.
599 
600  \return The text boundary in world coordinates.
601 
602  \note The caller of this method will take the ownership of the returned Polygon.
603  */
604  virtual te::gm::Polygon* getTextBoundary(const double& x, const double& y,
605  const std::string& txt,
606  float angle = 0.0,
607  double anchorX = 0.5, double anchorY = 0.5,
608  int displacementX = 0, int displacementY = 0) = 0;
609 
610  //@}
611 
612  /** @name Visual and Style Configuration
613  * Note that the visual (style and symbol) used to draw geometries is affected by the visual methods.
614  */
615  //@{
616 
617  /*!
618  \brief It sets the text drawing color.
619 
620  \param color The new color for drawing a text.
621  */
622  virtual void setTextColor(const te::color::RGBAColor& color) = 0;
623 
624  /*!
625  \brief It sets the text opacity.
626 
627  \param opacity The new opacity for drawing a text.
628  */
629  virtual void setTextOpacity(int opacity) = 0;
630 
631  /*!
632  \brief It sets the text font family.
633 
634  \param family The new font family for drawing a text.
635  */
636  virtual void setFontFamily(const std::string& family) = 0;
637 
638  /*!
639  \brief It sets the text point Size.
640 
641  \param size The new point size for drawing a text.
642  */
643  virtual void setTextPointSize(double size) = 0;
644 
645  /*!
646  \brief It sets the text style.
647 
648  \param style The new style for drawing a text.
649  */
650  virtual void setTextStyle(te::se::Font::FontStyleType style) = 0;
651 
652  /*!
653  \brief It sets the text weight.
654 
655  \param weight The new weight for drawing a text.
656  */
657  virtual void setTextWeight(te::se::Font::FontWeightType weight) = 0;
658 
659  /*!
660  \brief It sets the text stretch.
661 
662  \param stretch The new stretch for drawing a text.
663  */
664  virtual void setTextStretch(std::size_t stretch) = 0;
665 
666  /*!
667  \brief It sets the text underline flag.
668 
669  \param b True: for underline. False otherwise.
670  */
671  virtual void setTextUnderline(bool b) = 0;
672 
673  /*!
674  \brief It sets the text overline flag.
675 
676  \param b True: for overline. False otherwise.
677  */
678  virtual void setTextOverline(bool b) = 0;
679 
680  /*!
681  \brief It sets the text strike out flag.
682 
683  \param b True: for strike out. False otherwise.
684  */
685  virtual void setTextStrikeOut(bool b) = 0;
686 
687  /*!
688  \brief It sets the text color for drawing text decoration.
689 
690  \param color The new color for drawing text decoration.
691  */
692  virtual void setTextDecorationColor(const te::color::RGBAColor& color) = 0;
693 
694  /*!
695  \brief It sets the width for drawing text decoration.
696 
697  \param width The new width for drawing text decoration.
698  */
699  virtual void setTextDecorationWidth(int width) = 0;
700 
701  /*!
702  \brief It sets the text contour (outline) drawing color.
703 
704  \param color The new color for drawing the contour of texts.
705  */
706  virtual void setTextContourColor(const te::color::RGBAColor& color) = 0;
707 
708  /*!
709  \brief It controls the display of the text outline.
710 
711  \param b True to display and false to not display.
712  */
713  virtual void setTextContourEnabled(bool b) = 0;
714 
715  /*!
716  \brief It sets the text contour opacity.
717 
718  \param opacity The new opacity for drawing the text contour.
719  */
720  virtual void setTextContourOpacity(int opacity) = 0;
721 
722  /*!
723  \brief It sets the text contour width.
724 
725  \param width The new width for drawing the text contour.
726  */
727  virtual void setTextContourWidth(int width) = 0;
728 
729  /*!
730  \brief It sets the text justification for multi line text.
731 
732  \param just The new justification for drawing a multi line text.
733  */
734  virtual void setTextJustification(int justType) = 0;
735 
736  /*!
737  \brief It sets the multi line text spacing.
738 
739  \param spacing The new spacing for drawing a multi line text.
740  */
741  virtual void setTextMultiLineSpacing(int spacing) = 0;
742 
743  /*!
744  \brief It sets the point drawing color.
745 
746  This method will instruct the canvas to draw points like pixels.
747  Any pattern previously set will be released.
748 
749  \param color The new color for drawing a point.
750  */
751  virtual void setPointColor(const te::color::RGBAColor& color) = 0;
752 
753  /*!
754  \brief It sets the point width. If point has a patterns, this pattern is scaled to width.
755 
756  \param w The width used to draw point.
757  */
758  virtual void setPointWidth(int w) = 0;
759 
760  /*!
761  \brief It sets the point pattern.
762 
763  The pattern is a matrix of int's, and each position corresponds to a RGBA color.
764 
765  \param pattern The pattern matrix: a square matrix of int's where each position corresponds to a RGBA color.
766  \param ncols Number of columns in the matrix.
767  \param nrows Number of rows in the matrix.
768  */
769  virtual void setPointPattern(te::color::RGBAColor** pattern, int ncols, int nrows) = 0;
770 
771  /*!
772  \brief It sets the point pattern using a buffered image.
773 
774  \param pattern The buffered image.
775  \param size The buffer image size.
776  \param t The image type used by the style.
777  */
778  virtual void setPointPattern(char* pattern, std::size_t size, ImageType t) = 0;
779 
780  /*!
781  \brief It sets the point pattern rotation. Rotation is made ​​from the center of the pattern.
782 
783  \param angle The rotation angle in degress.
784  */
785  virtual void setPointPatternRotation(const double& angle) = 0;
786 
787  /*!
788  \brief It sets the point pattern opacity.
789 
790  \param opacity The pattern opacity.
791  */
792  virtual void setPointPatternOpacity(int opacity) = 0;
793 
794  /*!
795  \brief It sets the pen color used to draw line geometries.
796 
797  This method will drop any pattern or line style previously set.
798 
799  \param color The color to be used by the pen.
800  */
801  virtual void setLineColor(const te::color::RGBAColor& color) = 0;
802 
803  /*!
804  \brief It sets the line pattern.
805 
806  The pattern is a matrix of int's, and each position corresponds to a RGBA color.
807 
808  \param pattern The pattern matrix: a square matrix of int's where each position corresponds to a RGBA color.
809  \param ncols Number of columns in the matrix.
810  \param nrows Number of rows in the matrix.
811  */
812  virtual void setLinePattern(te::color::RGBAColor** pattern, int ncols, int nrows) = 0;
813 
814  /*!
815  \brief It sets the line pattern using a buffered image.
816 
817  \param pattern The buffered image.
818  \param size The buffer image size.
819  \param t The image type used by the style.
820  */
821  virtual void setLinePattern(char* pattern, std::size_t size, ImageType t) = 0;
822 
823  /*!
824  \brief It sets the line pattern rotation. Rotation is made ​​from the center of the pattern.
825 
826  \param angle The rotation angle in degress.
827  */
828  virtual void setLinePatternRotation(const double& angle) = 0;
829 
830  /*!
831  \brief It sets the line pattern opacity.
832 
833  \param opacity The pattern opacity.
834  */
835  virtual void setLinePatternOpacity(int opacity) = 0;
836 
837  /*!
838  \brief It sets the line width.
839 
840  \param w The line width.
841  */
842  virtual void setLineWidth(int w) = 0;
843 
844  /*!
845  \brief It sets the line dash style.
846 
847  \param style The line dash style.
848  */
849  virtual void setLineDashStyle(LineDashStyle style) = 0;
850 
851  /*!
852  \brief It sets the line dash style to the given pattern.
853 
854  \param style The line custom dash style.
855 
856  \note The style should be specified as an even number of positive double where
857  the entries 0, 2, 4, ... are dashes and 1, 3, 5, ... are spaces.
858  */
859  virtual void setLineDashStyle(const std::vector<double>& style) = 0;
860 
861  /*!
862  \brief It sets the line cap style.
863 
864  \param style The line cap style.
865  */
866  virtual void setLineCapStyle(LineCapStyle style) = 0;
867 
868  /*!
869  \brief It sets the line join style.
870 
871  \param style The line join style.
872  */
873  virtual void setLineJoinStyle(LineJoinStyle style) = 0;
874 
875  /*!
876  \brief It sets the color used to fill the draw of polygon geometries.
877 
878  \param color The color to be used when filling a polygon.
879  */
880  virtual void setPolygonFillColor(const te::color::RGBAColor& color) = 0;
881 
882  /*!
883  \brief It sets the pen color used to draw the boundary of polygon geometries.
884 
885  \param color The color to be used to outline a polygon.
886  */
887  virtual void setPolygonContourColor(const te::color::RGBAColor& color) = 0;
888 
889  /*!
890  \brief It sets the polygon fill pattern.
891 
892  The pattern is a matrix of int's, and each position corresponds to a RGBA color.
893 
894  \param pattern The style matrix: a square matrix of int's where each position corresponds to a RGBA color.
895  \param ncols Number of columns in the matrix.
896  \param nrows Number of rows in the matrix.
897  */
898  virtual void setPolygonFillPattern(te::color::RGBAColor** pattern, int ncols, int nrows) = 0;
899 
900  /*!
901  \brief It sets the polygon fill pattern using a buffered image.
902 
903  \param pattern The buffered image.
904  \param size The buffer image size.
905  \param t The image type used by the style.
906  */
907  virtual void setPolygonFillPattern(char* pattern, std::size_t size, ImageType t) = 0;
908 
909  /*!
910  \brief It sets the polygon pattern width.
911 
912  \param w The pattern width.
913  */
914  virtual void setPolygonPatternWidth(int w) = 0;
915 
916  /*!
917  \brief It sets the polygon pattern rotation.
918 
919  \param angle The rotation angle in degress.
920  */
921  virtual void setPolygonPatternRotation(const double& angle) = 0;
922 
923  /*!
924  \brief It sets the polygon pattern opacity.
925 
926  \param opacity The pattern opacity.
927  */
928  virtual void setPolygonPatternOpacity(int opacity) = 0;
929 
930  /*!
931  \brief It sets the pen pattern used to draw the boundary of polygon geometries.
932 
933  The pattern is a matrix of int's, and each position corresponds to a RGBA color.
934 
935  \param pattern The pattern matrix: a square matrix of int's where each position corresponds to a RGBA color.
936  \param ncols Number of columns in the matrix.
937  \param nrows Number of rows in the matrix.
938  */
939  virtual void setPolygonContourPattern(te::color::RGBAColor** pattern, int ncols, int nrows) = 0;
940 
941  /*!
942  \brief It sets the pen pattern used to draw the boundary of polygon geometries using a buffered image.
943 
944  \param pattern The buffered image.
945  \param size The buffer image size.
946  \param t The image type used by the style.
947  */
948  virtual void setPolygonContourPattern(char* pattern, std::size_t size, ImageType t) = 0;
949 
950  /*!
951  \brief It sets the polygon contour width.
952 
953  \param w The contour width.
954  */
955  virtual void setPolygonContourWidth(int w) = 0;
956 
957  /*!
958  \brief It sets the polygon contour pattern rotation.
959 
960  \param angle The rotation angle in degress.
961  */
962  virtual void setPolygonContourPatternRotation(const double& angle) = 0;
963 
964  /*!
965  \brief It sets the polygon contour pattern opacity.
966 
967  \param opacity The pattern opacity.
968  */
969  virtual void setPolygonContourPatternOpacity(int opacity) = 0;
970 
971  /*!
972  \brief It sets the polygon contour dash style.
973 
974  \param style The polygon contour dash style.
975  */
976  virtual void setPolygonContourDashStyle(LineDashStyle style) = 0;
977 
978  /*!
979  \brief It sets the polygon contour dash style to the given pattern.
980 
981  \param style The polygon contour custom dash style.
982 
983  \note The style should be specified as an even number of positive double where
984  the entries 0, 2, 4, ... are dashes and 1, 3, 5, ... are spaces.
985  */
986  virtual void setPolygonContourDashStyle(const std::vector<double>& style) = 0;
987 
988  /*!
989  \brief It sets the polygon contour cap style.
990 
991  \param style The polygon contour cap style.
992  */
993  virtual void setPolygonContourCapStyle(LineCapStyle style) = 0;
994 
995  /*!
996  \brief It sets the polygon contour join style.
997 
998  \param style The polygon contour join style.
999  */
1000  virtual void setPolygonContourJoinStyle(LineJoinStyle style) = 0;
1001 
1002  /*!
1003  \brief It sets the painter to erase mode.
1004  */
1005  virtual void setEraseMode() = 0;
1006 
1007  /*!
1008  \brief It sets the painter to normal copy source to destination mode.
1009  */
1010  virtual void setNormalMode() = 0;
1011 
1012  //@}
1013  };
1014 
1015  } // end namespace map
1016 } // end namespace te
1017 
1018 #endif // __TERRALIB_MAPTOOLS_INTERNAL_CANVAS_H
virtual void setLineCapStyle(LineCapStyle style)=0
It sets the line cap style.
ImageType
This enum specifies the possible input and output image formats supported by the canvas API...
Definition: Enums.h:38
virtual void resize(int w, int h)=0
It adjusts the canvas size (width and height).
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
Canvas()
Constructor.
Definition: Canvas.h:102
virtual void setPointWidth(int w)=0
It sets the point width. If point has a patterns, this pattern is scaled to width.
virtual void setTextDecorationColor(const te::color::RGBAColor &color)=0
It sets the text color for drawing text decoration.
virtual void setFontFamily(const std::string &family)=0
It sets the text font family.
virtual 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)=0
It draws a text.
virtual void setTextMultiLineSpacing(int spacing)=0
It sets the multi line text spacing.
virtual void setTextOpacity(int opacity)=0
It sets the text opacity.
virtual void setPolygonFillColor(const te::color::RGBAColor &color)=0
It sets the color used to fill the draw of polygon geometries.
virtual void setPointPattern(te::color::RGBAColor **pattern, int ncols, int nrows)=0
It sets the point pattern.
virtual void setLineWidth(int w)=0
It sets the line width.
virtual void setPointPatternRotation(const double &angle)=0
It sets the point pattern rotation. Rotation is made ​​from the center of the pattern.
virtual 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)=0
It returns the text boundary (its enclose rectangle).
virtual void clear()=0
It clears the canvas content and fills with the background color.
virtual void setBackgroundColor(const te::color::RGBAColor &color)=0
It sets the canvas background color.
virtual void setPolygonContourPatternRotation(const double &angle)=0
It sets the polygon contour pattern rotation.
virtual void setPolygonPatternRotation(const double &angle)=0
It sets the polygon pattern rotation.
virtual void setLineJoinStyle(LineJoinStyle style)=0
It sets the line join style.
AlignType
This enum contains values to control the alignment of components (like Canvas and MapDisplay)...
Definition: Enums.h:125
LineCapStyle
This enum encodes enumerated values telling how line strings should be capped (at the two ends of the...
Definition: Enums.h:72
virtual void setLinePattern(te::color::RGBAColor **pattern, int ncols, int nrows)=0
It sets the line pattern.
virtual void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)=0
It sets the world (or window) coordinates area (supposing a cartesian reference system).
virtual void setTextUnderline(bool b)=0
It sets the text underline flag.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
virtual void setPolygonContourPattern(te::color::RGBAColor **pattern, int ncols, int nrows)=0
It sets the pen pattern used to draw the boundary of polygon geometries.
virtual void setPolygonFillPattern(te::color::RGBAColor **pattern, int ncols, int nrows)=0
It sets the polygon fill pattern.
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
virtual char * getImage(ImageType t, std::size_t &size, int quality=75, int fg=0) const =0
It returns the internal content as an image in a specific format (PNG, JPEG, ...).
virtual void setPolygonPatternOpacity(int opacity)=0
It sets the polygon pattern opacity.
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
An abstract class for raster data strucutures.
Definition: Raster.h:71
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
Definition: Config.h:36
URI C++ Library.
virtual void setLineDashStyle(LineDashStyle style)=0
It sets the line dash style.
virtual void setTextColor(const te::color::RGBAColor &color)=0
It sets the text drawing color.
virtual int getHeight() const =0
It returns the canvas height.
virtual void drawPixel(int x, int y)=0
It sets a pixel using the point pen.
virtual void setTextWeight(te::se::Font::FontWeightType weight)=0
It sets the text weight.
virtual void setLinePatternOpacity(int opacity)=0
It sets the line pattern opacity.
virtual void setTextContourOpacity(int opacity)=0
It sets the text contour opacity.
virtual void setTextContourWidth(int width)=0
It sets the text contour width.
virtual void drawImage(char *src, std::size_t size, ImageType t)=0
It draws the src image over the canvas.
virtual void setTextDecorationWidth(int width)=0
It sets the width for drawing text decoration.
virtual void setLinePatternRotation(const double &angle)=0
It sets the line pattern rotation. Rotation is made ​​from the center of the pattern.
virtual void freeImage(char *img) const =0
This is the method that you should use to release an image generated by the canvas.
FontStyleType
It defines the style to use for a font.
Definition: Font.h:72
virtual void setPolygonContourPatternOpacity(int opacity)=0
It sets the polygon contour pattern opacity.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:74
virtual void setPolygonContourWidth(int w)=0
It sets the polygon contour width.
virtual void setTextContourColor(const te::color::RGBAColor &color)=0
It sets the text contour (outline) drawing color.
virtual void setEraseMode()=0
It sets the painter to erase mode.
MultiLineString is a MultiCurve whose elements are LineStrings.
virtual void setTextStrikeOut(bool b)=0
It sets the text strike out flag.
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:92
virtual void setPointColor(const te::color::RGBAColor &color)=0
It sets the point drawing color.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
LineDashStyle
This enum encodes enumerated values telling how lines should be drawn. e.g. as a plain line or dash l...
Definition: Enums.h:56
LineJoinStyle
This enum encodes enumerated values telling how line strings should be joined (between line segments)...
Definition: Enums.h:84
virtual void setTextContourEnabled(bool b)=0
It controls the display of the text outline.
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:54
virtual te::color::RGBAColor getBackgroundColor() const =0
It returns the canvas background color.
virtual void setPolygonContourColor(const te::color::RGBAColor &color)=0
It sets the pen color used to draw the boundary of polygon geometries.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
virtual void setTextStyle(te::se::Font::FontStyleType style)=0
It sets the text style.
virtual void setPolygonContourJoinStyle(LineJoinStyle style)=0
It sets the polygon contour join style.
virtual void setLineColor(const te::color::RGBAColor &color)=0
It sets the pen color used to draw line geometries.
virtual void setPointPatternOpacity(int opacity)=0
It sets the point pattern opacity.
virtual void setPolygonPatternWidth(int w)=0
It sets the polygon pattern width.
FontWeightType
It gives the amount of weight or boldness to use for a font.
Definition: Font.h:84
virtual void setPolygonContourDashStyle(LineDashStyle style)=0
It sets the polygon contour dash style.
It is a collection of other geometric objects.
virtual void calcAspectRatio(double &llx, double &lly, double &urx, double &ury, const AlignType hAlign=Center, const AlignType vAlign=Center)=0
It calculates the best aspect ratio for world (or window) coordinates area (supposing a cartesian ref...
virtual void draw(const te::gm::Geometry *geom)=0
It draws the geometry on canvas.
virtual ~Canvas()
Virtual destructor.
Definition: Canvas.h:105
virtual void setTextOverline(bool b)=0
It sets the text overline flag.
virtual void setTextJustification(int justType)=0
It sets the text justification for multi line text.
virtual void save(const char *fileName, ImageType t, int quality=75, int fg=0) const =0
It saves the canvas content to a file image in the specified format type.
virtual int getWidth() const =0
It returns the canvas width.
virtual void setNormalMode()=0
It sets the painter to normal copy source to destination mode.
virtual void setTextPointSize(double size)=0
It sets the text point Size.
virtual void setTextStretch(std::size_t stretch)=0
It sets the text stretch.
virtual void setPolygonContourCapStyle(LineCapStyle style)=0
It sets the polygon contour cap style.