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();
74 draft->fill(Qt::transparent);
79 if(e->button() != Qt::LeftButton)
103 #if QT_VERSION >= 0x050000 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);
130 if(e->button() != Qt::LeftButton)
143 if (e->key() == Qt::Key_Escape)
160 draft->fill(Qt::transparent);
166 canvas.setRenderHint(QPainter::Antialiasing,
true);
190 for(std::size_t i = 0; i <
m_coords.size(); ++i)
203 std::unique_ptr<te::gm::Point> endPoint = line->
getEndPoint();
210 std::unique_ptr<te::gm::Point> point1 = line->
getPointN(1);
211 drawText(canvas, (tr(
"Angle: ") + QString::number(
calculateAngle(line)) +
" deg").toUtf8().data(), point1.get());
225 for(std::size_t i = 0; i <
m_coords.size(); ++i)
238 canvas.
draw(polygon);
243 drawText(canvas, (tr(
"Area: ") + QString::number(polygon->
getArea()) + (
m_unit.empty() ?
"" : (
" " +
m_unit +
"^2").c_str())).toUtf8().data(), &
p);
266 draft->fill(Qt::transparent);
275 for (std::size_t i = 0; i < n - 1; ++i)
277 std::unique_ptr<te::gm::Point> pA = line->
getPointN(i);
278 std::unique_ptr<te::gm::Point> pB = line->
getPointN(i + 1);
279 length += pA->distance(pB.get());
287 std::unique_ptr<te::gm::Point> p1 = line->
getPointN(0);
288 std::unique_ptr<te::gm::Point> p2 = line->
getPointN(1);
289 std::unique_ptr<te::gm::Point> p3 = line->
getPointN(2);
291 QLineF line1(p2->getX(), p2->getY(), p1->getX(), p1->getY());
292 QLineF line2(p2->getX(), p2->getY(), p3->getX(), p3->getY());
294 return line1.angle(line2);
303 m_unit = unit->getSymbol();
std::unique_ptr< Point > getEndPoint() const
It returns the curve end point.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
double m_urx
Upper right corner x-coordinate.
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
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.
static SpatialReferenceSystemManager & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
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.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
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.
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.