27 #include "../../../common/STLUtils.h"
28 #include "../../../geometry/Envelope.h"
29 #include "../../../geometry/Geometry.h"
30 #include "../../../geometry/LinearRing.h"
31 #include "../../../geometry/Polygon.h"
32 #include "../canvas/Canvas.h"
33 #include "../canvas/MapDisplay.h"
37 #include <QtGui/QMouseEvent>
38 #include <QtGui/QPainter>
39 #include <QtGui/QPixmap>
49 m_pen.setColor(QColor(0, 0, 0));
51 m_brush = QColor(233, 88, 63, 80);
59 QPixmap* draft = m_display->getDraftPixmap();
60 draft->fill(Qt::transparent);
65 if(e->button() != Qt::LeftButton)
74 QPointF pw = m_display->transform(e->pos());
82 if(m_coords.size() < 1 || m_isFinished)
85 QPointF pw = m_display->transform(e->posF());
88 QPointF pos = e->posF() + QPointF(0.0001, 0.0001);
89 pw = m_display->transform(pos);
104 if(e->button() != Qt::LeftButton)
107 if(m_coords.size() < 3)
114 for(std::size_t i = 0; i < m_coords.size(); ++i)
115 ring->
setPoint(i, m_coords[i].x, m_coords[i].y);
116 ring->
setPoint(m_coords.size(), m_coords[0].x, m_coords[0].y);
121 emit polygonAquired(polygon);
133 QPixmap* draft = m_display->getDraftPixmap();
134 draft->fill(Qt::transparent);
137 Canvas canvas(m_display->width(), m_display->height());
140 canvas.setRenderHint(QPainter::Antialiasing,
true);
147 m_display->repaint();
154 for(std::size_t i = 0; i < m_coords.size(); ++i)
155 line->
setPoint(i, m_coords[i].x, m_coords[i].y);
169 if(m_coords.size() < 3)
170 return drawLine(canvas);
174 for(std::size_t i = 0; i < m_coords.size(); ++i)
175 ring->
setPoint(i, m_coords[i].x, m_coords[i].y);
176 ring->
setPoint(m_coords.size(), m_coords[0].x, m_coords[0].y);
187 canvas.
draw(polygon);
196 QPixmap* draft = m_display->getDraftPixmap();
197 draft->fill(Qt::transparent);
199 m_display->repaint();
207 m_coords.push_back(m_lastPos);
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
bool isValid() const
It tells if the rectangle is valid or not.
void setLineColor(const te::color::RGBAColor &color)
It sets the pen color used to draw line geometries.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
A LinearRing is a LineString that is both closed and simple.
void setLineWidth(int w)
It sets the line width.
PolygonAcquire(MapDisplay *display, QObject *parent=0)
It constructs a PolygonAcquire tool associated with the given map display.
bool mouseMoveEvent(QMouseEvent *e)
This class implements a concrete tool to acquire a polygon geometry.
This class defines an interface for objects that can receive application events and respond to them...
void setDevice(QPaintDevice *device, bool takeOwnerShip)
It sets new device as QPrinter.
void setPolygonFillColor(const te::color::RGBAColor &color)
It sets the color used to fill the draw of polygon geometries.
An utility struct for representing 2D coordinates.
LineString is a curve with linear interpolation between points.
void drawLine(Canvas &canvas)
bool mouseReleaseEvent(QMouseEvent *e)
void draw(const te::gm::Geometry *geom)
It draws the geometry on canvas.
QPen m_pen
The pen used to draw the path.
double m_lly
Lower left corner y-coordinate.
double m_ury
Upper right corner y-coordinate.
QBrush m_brush
The brush used to draw the path.
MapDisplay * m_display
The map display associated with the tool.
A canvas built on top of Qt.
double m_urx
Upper right corner x-coordinate.
A widget to control the display of a set of layers.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
void setPolygonContourWidth(int w)
It sets the polygon contour width.
bool mousePressEvent(QMouseEvent *e)
double m_llx
Lower left corner x-coordinate.
void drawPolygon(Canvas &canvas)
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.
An Envelope defines a 2D rectangular region.
~PolygonAcquire()
Destructor.
bool mouseDoubleClickEvent(QMouseEvent *e)