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