DrawingGeometricObjects.cpp
Go to the documentation of this file.
1 #include "CanvasExamples.h"
2 
3 // TerraLib
4 #include <terralib/color.h>
5 #include <terralib/geometry.h>
7 
8 // Qt
9 #include <QApplication>
10 
12 {
13 // If you want to use any Qt resource you must initialize a QApplication in some place!!!
14  int argc = 0;
15  QApplication app(argc, 0);
16 
17 // create the canvas and adjust the world-device transformation parameters
18  te::qt::widgets::Canvas canvas(800, 600);
19 
20  canvas.setWindow(-180.0, -90.0, +180.0, +90.0);
21 
22 // adjust line pen
23  canvas.setLineColor(te::color::RGBAColor(255, 0, 0, 255));
24 
25 // draw a line
27  l.setPoint(0, -90.0, -45.0);
28  l.setPoint(1, +90.0, +45.0);
29 
30  canvas.draw(&l);
31 
32 // draw a polygon
34  shell->setPoint(0, -90.0, -45.0);
35  shell->setPoint(1, +90.0, -45.0);
36  shell->setPoint(2, 0.0, +45.0);
37  shell->setPoint(3, -90.0, -45.0);
38 
40  hole1->setPoint(0, -50.0, -30.0);
41  hole1->setPoint(1, -40.0, -30.0);
42  hole1->setPoint(2, -45.0, -10.0);
43  hole1->setPoint(3, -50.0, -30.0);
44 
46  hole2->setPoint(0, -30.0, -30.0);
47  hole2->setPoint(1, -20.0, -30.0);
48  hole2->setPoint(2, -25.0, -10.0);
49  hole2->setPoint(3, -30.0, -30.0);
50 
52  p.setRingN(0, shell);
53  p.setRingN(1, hole1);
54  p.setRingN(2, hole2);
55 
56  canvas.setPolygonContourColor(te::color::RGBAColor(0, 0, 255, 255));
57  canvas.setPolygonFillColor(te::color::RGBAColor(0, 255, 0, 100));
58 
59  canvas.draw(&p);
60 
61 
62 // save a PNG to disk
63  canvas.save("canvas.png", te::map::PNG);
64 }
65 
A canvas built on top of Qt.
void setPolygonFillColor(const te::color::RGBAColor &color)
It sets the color used to fill the draw of polygon geometries.
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
void draw(const te::gm::Geometry *geom)
It draws the geometry on canvas.
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
Several examples declarations.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
void setLineColor(const te::color::RGBAColor &color)
It sets the pen color used to draw line geometries.
te::gm::Polygon * p
This file contains include headers for the Color Model of TerraLib.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
This file contains include headers for the Vector Geometry model of TerraLib.
void save(const char *fileName, te::map::ImageType t, int quality=75, int fg=0) const
It saves the canvas content to a file image in the specified format type.
void DrawingGeometricObjects()
It retrieves data from a Shape-file and prints it to a png graphics file.
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.