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 "../annotationtext/Enums.h"
31 #include "../color/RGBAColor.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 gm
42  {
43  class Envelope;
44  class Geometry;
45  class GeometryCollection;
46  class LineString;
47  class MultiLineString;
48  class MultiPoint;
49  class MultiPolygon;
50  class Point;
51  class PointM;
52  class PointZ;
53  class PointZM;
54  class Polygon;
55  class MultiSurface;
56  }
57 
58  namespace at
59  {
60  class Text;
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 hAlign The horizontal text alignment.
490  \param vAlign The vertical text alignment.
491  */
492  virtual void drawText(int x, int y,
493  const std::string& txt,
494  float angle = 0.0,
497 
498  /*!
499  \brief It draws a text.
500 
501  Color and font family should be defined in advance.
502 
503  \param p The text entry point in world coordinate.
504  \param txt The text to be drawn.
505  \param angle The text rotation.
506  \param hAlign The horizontal text alignment.
507  \param vAlign The vertical text alignment.
508  */
509  virtual void drawText(const te::gm::Point* p,
510  const std::string& txt,
511  float angle = 0.0,
514 
515  /*!
516  \brief It draws a text.
517 
518  Color and font family should be defined in advance.
519 
520  \param x The text entry point x in world coordinate.
521  \param y The text entry point y in world coordinate.
522  \param txt The text to be drawn.
523  \param angle The text rotation.
524  \param hAlign The horizontal text alignment.
525  \param vAlign The vertical text alignment.
526  */
527  virtual void drawText(const double& x, const double& y,
528  const std::string& txt,
529  float angle = 0.0,
532 
533  /*!
534  \brief It draws an annotaion text.
535 
536  \param txt The annotation text to be drawn.
537  */
538  virtual void draw(const te::at::Text* txt) = 0;
539 
540 
541  /*!
542  \brief It returns the text boundary (its enclose rectangle).
543 
544  Color and font family should be defined in advance.
545 
546  \param x The text entry point x in device coordinate.
547  \param y The text entry point y in device coordinate.
548  \param txt The text to be drawn.
549  \param angle The text rotation.
550  \param hAlign The horizontal text alignment.
551  \param vAlign The vertical text alignment.
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,
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 hAlign The horizontal text alignment.
572  \param vAlign The vertical text alignment.
573 
574  \return The text boundary in world coordinate.
575 
576  \note The caller of this method will take the ownership of the returned Polygon.
577  */
579  const std::string& txt,
580  float angle = 0.0,
583 
584  /*!
585  \brief It returns the text boundary (its enclose rectangle).
586 
587  Color and font family should be defined in advance.
588 
589  \param x The text entry point x in world coordinate.
590  \param y The text entry point y in world coordinate.
591  \param txt The text to be drawn.
592  \param angle The text rotation.
593  \param hAlign The horizontal text alignment.
594  \param vAlign The vertical text alignment.
595 
596  \return The text boundary in world coordinates.
597 
598  \note The caller of this method will take the ownership of the returned Polygon.
599  */
600  virtual te::gm::Polygon* getTextBoundary(const double& x, const double& y,
601  const std::string& txt,
602  float angle = 0.0,
605 
606  //@}
607 
608  /** @name Visual and Style Configuration
609  * Note that the visual (style and symbol) used to draw geometries is affected by the visual methods.
610  */
611  //@{
612 
613  /*!
614  \brief It sets the text drawing color.
615 
616  \param color The new color for drawing a text.
617  */
618  virtual void setTextColor(const te::color::RGBAColor& color) = 0;
619 
620  /*!
621  \brief It sets the text opacity.
622 
623  \param opacity The new opacity for drawing a text.
624  */
625  virtual void setTextOpacity(int opacity) = 0;
626 
627  /*!
628  \brief It sets the text font family.
629 
630  \param family The new font family for drawing a text.
631  */
632  virtual void setFontFamily(const std::string& family) = 0;
633 
634  /*!
635  \brief It sets the text point Size.
636 
637  \param size The new point size for drawing a text.
638  */
639  virtual void setTextPointSize(double size) = 0;
640 
641  /*!
642  \brief It sets the text style.
643 
644  \param style The new style for drawing a text.
645  */
646  virtual void setTextStyle(te::at::FontStyle style) = 0;
647 
648  /*!
649  \brief It sets the text weight.
650 
651  \param weight The new weight for drawing a text.
652  */
653  virtual void setTextWeight(te::at::FontWeight weight) = 0;
654 
655  /*!
656  \brief It sets the text stretch.
657 
658  \param stretch The new stretch for drawing a text.
659  */
660  virtual void setTextStretch(std::size_t stretch) = 0;
661 
662  /*!
663  \brief It sets the text underline flag.
664 
665  \param b True: for underline. False otherwise.
666  */
667  virtual void setTextUnderline(bool b) = 0;
668 
669  /*!
670  \brief It sets the text overline flag.
671 
672  \param b True: for overline. False otherwise.
673  */
674  virtual void setTextOverline(bool b) = 0;
675 
676  /*!
677  \brief It sets the text strike out flag.
678 
679  \param b True: for strike out. False otherwise.
680  */
681  virtual void setTextStrikeOut(bool b) = 0;
682 
683  /*!
684  \brief It sets the text color for drawing text decoration.
685 
686  \param color The new color for drawing text decoration.
687  */
688  virtual void setTextDecorationColor(const te::color::RGBAColor& color) = 0;
689 
690  /*!
691  \brief It sets the width for drawing text decoration.
692 
693  \param width The new width for drawing text decoration.
694  */
695  virtual void setTextDecorationWidth(int width) = 0;
696 
697  /*!
698  \brief It sets the text contour (outline) drawing color.
699 
700  \param color The new color for drawing the contour of texts.
701  */
702  virtual void setTextContourColor(const te::color::RGBAColor& color) = 0;
703 
704  /*!
705  \brief It controls the display of the text outline.
706 
707  \param b True to display and false to not display.
708  */
709  virtual void setTextContourEnabled(bool b) = 0;
710 
711  /*!
712  \brief It sets the text contour opacity.
713 
714  \param opacity The new opacity for drawing the text contour.
715  */
716  virtual void setTextContourOpacity(int opacity) = 0;
717 
718  /*!
719  \brief It sets the text contour width.
720 
721  \param width The new width for drawing the text contour.
722  */
723  virtual void setTextContourWidth(int width) = 0;
724 
725  /*!
726  \brief It sets the text justification for multi line text.
727 
728  \param just The new justification for drawing a multi line text.
729  */
730  virtual void setTextJustification(te::at::LineJustification just) = 0;
731 
732  /*!
733  \brief It sets the multi line text spacing.
734 
735  \param spacing The new spacing for drawing a multi line text.
736  */
737  virtual void setTextMultiLineSpacing(int spacing) = 0;
738 
739  /*!
740  \brief It sets the point drawing color.
741 
742  This method will instruct the canvas to draw points like pixels.
743  Any pattern previously set will be released.
744 
745  \param color The new color for drawing a point.
746  */
747  virtual void setPointColor(const te::color::RGBAColor& color) = 0;
748 
749  /*!
750  \brief It sets the point width. If point has a patterns, this pattern is scaled to width.
751 
752  \param w The width used to draw point.
753  */
754  virtual void setPointWidth(int w) = 0;
755 
756  /*!
757  \brief It sets the point pattern.
758 
759  The pattern is a matrix of int's, and each position corresponds to a RGBA color.
760 
761  \param pattern The pattern matrix: a square matrix of int's where each position corresponds to a RGBA color.
762  \param ncols Number of columns in the matrix.
763  \param nrows Number of rows in the matrix.
764  */
765  virtual void setPointPattern(te::color::RGBAColor** pattern, int ncols, int nrows) = 0;
766 
767  /*!
768  \brief It sets the point pattern using a buffered image.
769 
770  \param pattern The buffered image.
771  \param size The buffer image size.
772  \param t The image type used by the style.
773  */
774  virtual void setPointPattern(char* pattern, std::size_t size, ImageType t) = 0;
775 
776  /*!
777  \brief It sets the point pattern rotation. Rotation is made ​​from the center of the pattern.
778 
779  \param angle The rotation angle in degress.
780  */
781  virtual void setPointPatternRotation(const double& angle) = 0;
782 
783  /*!
784  \brief It sets the point pattern opacity.
785 
786  \param opacity The pattern opacity.
787  */
788  virtual void setPointPatternOpacity(int opacity) = 0;
789 
790  /*!
791  \brief It sets the pen color used to draw line geometries.
792 
793  This method will drop any pattern or line style previously set.
794 
795  \param color The color to be used by the pen.
796  */
797  virtual void setLineColor(const te::color::RGBAColor& color) = 0;
798 
799  /*!
800  \brief It sets the line pattern.
801 
802  The pattern is a matrix of int's, and each position corresponds to a RGBA color.
803 
804  \param pattern The pattern matrix: a square matrix of int's where each position corresponds to a RGBA color.
805  \param ncols Number of columns in the matrix.
806  \param nrows Number of rows in the matrix.
807  */
808  virtual void setLinePattern(te::color::RGBAColor** pattern, int ncols, int nrows) = 0;
809 
810  /*!
811  \brief It sets the line pattern using a buffered image.
812 
813  \param pattern The buffered image.
814  \param size The buffer image size.
815  \param t The image type used by the style.
816  */
817  virtual void setLinePattern(char* pattern, std::size_t size, ImageType t) = 0;
818 
819  /*!
820  \brief It sets the line pattern rotation. Rotation is made ​​from the center of the pattern.
821 
822  \param angle The rotation angle in degress.
823  */
824  virtual void setLinePatternRotation(const double& angle) = 0;
825 
826  /*!
827  \brief It sets the line pattern opacity.
828 
829  \param opacity The pattern opacity.
830  */
831  virtual void setLinePatternOpacity(int opacity) = 0;
832 
833  /*!
834  \brief It sets the line width.
835 
836  \param w The line width.
837  */
838  virtual void setLineWidth(int w) = 0;
839 
840  /*!
841  \brief It sets the line dash style.
842 
843  \param style The line dash style.
844  */
845  virtual void setLineDashStyle(LineDashStyle style) = 0;
846 
847  /*!
848  \brief It sets the line dash style to the given pattern.
849 
850  \param style The line custom dash style.
851 
852  \note The style should be specified as an even number of positive double where
853  the entries 0, 2, 4, ... are dashes and 1, 3, 5, ... are spaces.
854  */
855  virtual void setLineDashStyle(const std::vector<double>& style) = 0;
856 
857  /*!
858  \brief It sets the line cap style.
859 
860  \param style The line cap style.
861  */
862  virtual void setLineCapStyle(LineCapStyle style) = 0;
863 
864  /*!
865  \brief It sets the line join style.
866 
867  \param style The line join style.
868  */
869  virtual void setLineJoinStyle(LineJoinStyle style) = 0;
870 
871  /*!
872  \brief It sets the color used to fill the draw of polygon geometries.
873 
874  \param color The color to be used when filling a polygon.
875  */
876  virtual void setPolygonFillColor(const te::color::RGBAColor& color) = 0;
877 
878  /*!
879  \brief It sets the pen color used to draw the boundary of polygon geometries.
880 
881  \param color The color to be used to outline a polygon.
882  */
883  virtual void setPolygonContourColor(const te::color::RGBAColor& color) = 0;
884 
885  /*!
886  \brief It sets the polygon fill pattern.
887 
888  The pattern is a matrix of int's, and each position corresponds to a RGBA color.
889 
890  \param pattern The style matrix: a square matrix of int's where each position corresponds to a RGBA color.
891  \param ncols Number of columns in the matrix.
892  \param nrows Number of rows in the matrix.
893  */
894  virtual void setPolygonFillPattern(te::color::RGBAColor** pattern, int ncols, int nrows) = 0;
895 
896  /*!
897  \brief It sets the polygon fill pattern using a buffered image.
898 
899  \param pattern The buffered image.
900  \param size The buffer image size.
901  \param t The image type used by the style.
902  */
903  virtual void setPolygonFillPattern(char* pattern, std::size_t size, ImageType t) = 0;
904 
905  /*!
906  \brief It sets the polygon pattern width.
907 
908  \param w The pattern width.
909  */
910  virtual void setPolygonPatternWidth(int w) = 0;
911 
912  /*!
913  \brief It sets the polygon pattern rotation.
914 
915  \param angle The rotation angle in degress.
916  */
917  virtual void setPolygonPatternRotation(const double& angle) = 0;
918 
919  /*!
920  \brief It sets the polygon pattern opacity.
921 
922  \param opacity The pattern opacity.
923  */
924  virtual void setPolygonPatternOpacity(int opacity) = 0;
925 
926  /*!
927  \brief It sets the pen pattern used to draw the boundary of polygon geometries.
928 
929  The pattern is a matrix of int's, and each position corresponds to a RGBA color.
930 
931  \param pattern The pattern matrix: a square matrix of int's where each position corresponds to a RGBA color.
932  \param ncols Number of columns in the matrix.
933  \param nrows Number of rows in the matrix.
934  */
935  virtual void setPolygonContourPattern(te::color::RGBAColor** pattern, int ncols, int nrows) = 0;
936 
937  /*!
938  \brief It sets the pen pattern used to draw the boundary of polygon geometries using a buffered image.
939 
940  \param pattern The buffered image.
941  \param size The buffer image size.
942  \param t The image type used by the style.
943  */
944  virtual void setPolygonContourPattern(char* pattern, std::size_t size, ImageType t) = 0;
945 
946  /*!
947  \brief It sets the polygon contour width.
948 
949  \param w The contour width.
950  */
951  virtual void setPolygonContourWidth(int w) = 0;
952 
953  /*!
954  \brief It sets the polygon contour pattern rotation.
955 
956  \param angle The rotation angle in degress.
957  */
958  virtual void setPolygonContourPatternRotation(const double& angle) = 0;
959 
960  /*!
961  \brief It sets the polygon contour pattern opacity.
962 
963  \param opacity The pattern opacity.
964  */
965  virtual void setPolygonContourPatternOpacity(int opacity) = 0;
966 
967  /*!
968  \brief It sets the polygon contour dash style.
969 
970  \param style The polygon contour dash style.
971  */
972  virtual void setPolygonContourDashStyle(LineDashStyle style) = 0;
973 
974  /*!
975  \brief It sets the polygon contour dash style to the given pattern.
976 
977  \param style The polygon contour custom dash style.
978 
979  \note The style should be specified as an even number of positive double where
980  the entries 0, 2, 4, ... are dashes and 1, 3, 5, ... are spaces.
981  */
982  virtual void setPolygonContourDashStyle(const std::vector<double>& style) = 0;
983 
984  /*!
985  \brief It sets the polygon contour cap style.
986 
987  \param style The polygon contour cap style.
988  */
989  virtual void setPolygonContourCapStyle(LineCapStyle style) = 0;
990 
991  /*!
992  \brief It sets the polygon contour join style.
993 
994  \param style The polygon contour join style.
995  */
996  virtual void setPolygonContourJoinStyle(LineJoinStyle style) = 0;
997 
998  /*!
999  \brief It sets the painter to erase mode.
1000  */
1001  virtual void setEraseMode() = 0;
1002 
1003  /*!
1004  \brief It sets the painter to normal copy source to destination mode.
1005  */
1006  virtual void setNormalMode() = 0;
1007 
1008  //@}
1009  };
1010 
1011  } // end namespace map
1012 } // end namespace te
1013 
1014 #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.
FontWeight
Font weight for drawing text.
Definition: Enums.h:50
virtual void setFontFamily(const std::string &family)=0
It sets the text font family.
virtual void setTextMultiLineSpacing(int spacing)=0
It sets the multi line text spacing.
LineJustification
Line justification for drawing multi line text.
Definition: Enums.h:106
FontStyle
Font style for drawing text.
Definition: Enums.h:38
virtual te::gm::Polygon * getTextBoundary(int x, int y, const std::string &txt, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)=0
It returns the text boundary (its enclose rectangle).
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 int getHeight() const =0
It returns the canvas height.
virtual void setPointPattern(te::color::RGBAColor **pattern, int ncols, int nrows)=0
It sets the point pattern.
virtual void drawText(int x, int y, const std::string &txt, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)=0
It draws a text.
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 void clear()=0
It clears the canvas content and fills with the background color.
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.
A Text may contain 1 or more Text Elements.
Definition: Text.h:51
virtual int getWidth() const =0
It returns the canvas width.
Several enumerations related to Annotation Text.
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:124
LineCapStyle
This enum encodes enumerated values telling how line strings should be capped (at the two ends of the...
Definition: Enums.h:71
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
HorizontalAlignment
Horizontal alignment for drawing text.
Definition: Enums.h:81
virtual void setTextJustification(te::at::LineJustification just)=0
It sets the text justification for multi line text.
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 void drawPixel(int x, int y)=0
It sets a pixel using the point pen.
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 setPolygonContourPatternOpacity(int opacity)=0
It sets the polygon contour pattern opacity.
virtual void setTextStyle(te::at::FontStyle style)=0
It sets the text style.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
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.
virtual te::color::RGBAColor getBackgroundColor() const =0
It returns the canvas background color.
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:55
LineJoinStyle
This enum encodes enumerated values telling how line strings should be joined (between line segments)...
Definition: Enums.h:83
virtual void setTextContourEnabled(bool b)=0
It controls the display of the text outline.
VerticalAlignment
Vertical alignment for drawing text.
Definition: Enums.h:93
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:54
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 setPolygonContourJoinStyle(LineJoinStyle style)=0
It sets the polygon contour join style.
virtual void freeImage(char *img) const =0
This is the method that you should use to release an image generated by the canvas.
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.
virtual void setPolygonContourDashStyle(LineDashStyle style)=0
It sets the polygon contour dash style.
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, ...).
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 void setTextWeight(te::at::FontWeight weight)=0
It sets the text weight.
virtual ~Canvas()
Virtual destructor.
Definition: Canvas.h:105
virtual void setTextOverline(bool b)=0
It sets the text overline flag.
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.