27 #include "../../../common/STLUtils.h"
28 #include "../../../common/UnitOfMeasure.h"
29 #include "../../../common/UnitsOfMeasureManager.h"
30 #include "../../../geometry/Envelope.h"
31 #include "../../../geometry/Geometry.h"
32 #include "../../../geometry/LinearRing.h"
33 #include "../../../geometry/LineString.h"
34 #include "../../../geometry/Point.h"
35 #include "../../../geometry/Polygon.h"
36 #include "../canvas/Canvas.h"
37 #include "../canvas/MapDisplay.h"
41 #include <QMouseEvent>
50 m_measureType(measureType),
57 m_pen.setColor(QColor(100, 177, 216));
59 m_brush = QColor(100, 177, 216, 80);
65 m_unit = unit->getSymbol();
73 QPixmap* draft = m_display->getDraftPixmap();
74 draft->fill(Qt::transparent);
79 if(e->button() != Qt::LeftButton)
89 if(m_coords.size() == 2 && m_measureType ==
Angle)
92 QPointF pw = m_display->transform(e->pos());
100 if(m_coords.size() < 1 || m_isFinished)
103 #if QT_VERSION >= 0x050000
104 QPointF pw = m_display->transform(e->localPos());
106 QPointF pw = m_display->transform(e->posF());
110 #if QT_VERSION >= 0x050000
111 QPointF pos = e->localPos() + QPointF(0.0001, 0.0001);
113 QPointF pos = e->posF() + QPointF(0.0001, 0.0001);
115 pw = m_display->transform(pos);
130 if(e->button() != Qt::LeftButton)
133 if(m_measureType ==
Area && m_coords.size() < 3)
148 QPixmap* draft = m_display->getDraftPixmap();
149 draft->fill(Qt::transparent);
152 Canvas canvas(m_display->width(), m_display->height());
155 canvas.setRenderHint(QPainter::Antialiasing,
true);
158 switch(m_measureType)
172 m_display->repaint();
179 for(std::size_t i = 0; i < m_coords.size(); ++i)
180 line->
setPoint(i, m_coords[i].x, m_coords[i].y);
190 if(m_measureType == Distance)
192 drawText(canvas, (tr(
"Distance: ") + QString::number(calculateLength(line)) +
" " + m_unit.c_str()).toStdString(), line->
getEndPoint());
194 else if(m_measureType ==
Angle)
197 drawText(canvas, (tr(
"Angle: ") + QString::number(calculateAngle(line)) +
" deg").toStdString(), line->
getPointN(1));
205 if(m_coords.size() < 3)
206 return drawLine(canvas);
210 for(std::size_t i = 0; i < m_coords.size(); ++i)
211 ring->
setPoint(i, m_coords[i].x, m_coords[i].y);
212 ring->
setPoint(m_coords.size(), m_coords[0].x, m_coords[0].y);
223 canvas.
draw(polygon);
228 drawText(canvas, (tr(
"Area: ") + QString::number(polygon->
getArea()) + (m_unit.empty() ?
"" : (
" " + m_unit +
"^2").c_str())).toStdString(), &p);
250 QPixmap* draft = m_display->getDraftPixmap();
251 draft->fill(Qt::transparent);
253 m_display->repaint();
260 for(std::size_t i = 0; i < n - 1; ++i)
278 return line1.angle(line2);
287 m_unit = unit->getSymbol();
297 m_coords.push_back(m_lastPos);
Point * getEndPoint() const
It returns the curve end point.
Point * getPointN(std::size_t i) const
It returns the specified point in this LineString.
double m_urx
Upper right corner x-coordinate.
An utility struct for representing 2D coordinates.
This class implements a concrete tool to measure operation (distance, area, and angle).
Coord2D getCenter() const
It returns the rectangle's center coordinate.
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.
const double & getY() const
It returns the Point y-coordinate value.
static SpatialReferenceSystemManager & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
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.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
double m_lly
Lower left corner y-coordinate.
double getArea() const
It returns the area of this surface, as measured in the spatial reference system of this surface...
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
double m_ury
Upper right corner y-coordinate.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
virtual double distance(const Geometry *const rhs) const
It returns the shortest distance between any two points in the two geometry objects.
const double & getX() const
It returns the Point x-coordinate value.
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.