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 <QMouseEvent>
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 #if QT_VERSION >= 0x050000
86 QPointF pw = m_display->transform(e->localPos());
88 QPointF pw = m_display->transform(e->posF());
92 #if QT_VERSION >= 0x050000
93 QPointF pos = e->localPos() + QPointF(0.0001, 0.0001);
95 QPointF pos = e->posF() + QPointF(0.0001, 0.0001);
98 pw = m_display->transform(pos);
113 if(e->button() != Qt::LeftButton)
116 if(m_coords.size() < 3)
123 for(std::size_t i = 0; i < m_coords.size(); ++i)
124 ring->
setPoint(i, m_coords[i].x, m_coords[i].y);
125 ring->
setPoint(m_coords.size(), m_coords[0].x, m_coords[0].y);
129 polygon->
setSRID(m_display->getSRID());
131 emit polygonAquired(polygon);
143 QPixmap* draft = m_display->getDraftPixmap();
144 draft->fill(Qt::transparent);
147 Canvas canvas(m_display->width(), m_display->height());
150 canvas.setRenderHint(QPainter::Antialiasing,
true);
157 m_display->repaint();
164 for(std::size_t i = 0; i < m_coords.size(); ++i)
165 line->
setPoint(i, m_coords[i].x, m_coords[i].y);
179 if(m_coords.size() < 3)
180 return drawLine(canvas);
184 for(std::size_t i = 0; i < m_coords.size(); ++i)
185 ring->
setPoint(i, m_coords[i].x, m_coords[i].y);
186 ring->
setPoint(m_coords.size(), m_coords[0].x, m_coords[0].y);
197 canvas.
draw(polygon);
206 QPixmap* draft = m_display->getDraftPixmap();
207 draft->fill(Qt::transparent);
209 m_display->repaint();
217 m_coords.push_back(m_lastPos);
void setSRID(int srid)
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
double m_urx
Upper right corner x-coordinate.
An utility struct for representing 2D coordinates.
A LinearRing is a LineString that is both closed and simple.
double m_llx
Lower left corner x-coordinate.
LineString is a curve with linear interpolation between points.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
An Envelope defines a 2D rectangular region.
This class implements a concrete tool to acquire a polygon geometry.
double m_lly
Lower left corner y-coordinate.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
double m_ury
Upper right corner y-coordinate.
bool isValid() const
It tells if the rectangle is valid or not.
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.