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