27 #include "../../../geometry/Envelope.h"
28 #include "../../../geometry/Geometry.h"
29 #include "../../../geometry/LinearRing.h"
30 #include "../../../geometry/LineString.h"
31 #include "../../../geometry/Point.h"
32 #include "../../../qt/widgets/canvas/MapDisplay.h"
33 #include "../../../qt/widgets/Utils.h"
34 #include "../../RepositoryManager.h"
35 #include "../../Utils.h"
36 #include "../Renderer.h"
41 #include <QMouseEvent>
50 : AbstractTool(display, parent),
52 m_continuousMode(false),
65 QPixmap* draft = m_display->getDraftPixmap();
66 draft->fill(Qt::transparent);
71 if(e->button() != Qt::LeftButton)
84 TrySnap(coord, m_display->getSRID());
86 m_coords.push_back(coord);
93 if(m_coords.size() < 1 || m_isFinished)
98 QPointF pw = m_display->transform(pos);
102 TrySnap(coord, m_display->getSRID());
104 m_coords.push_back(coord);
108 Qt::KeyboardModifiers keys = e->modifiers();
110 if(keys == Qt::NoModifier)
111 m_continuousMode =
false;
112 else if(keys == Qt::ShiftModifier)
113 m_continuousMode =
true;
127 if(e->button() != Qt::LeftButton)
144 QPixmap* draft = m_display->getDraftPixmap();
145 draft->fill(Qt::transparent);
149 renderer.
begin(draft, env, m_display->getSRID());
152 renderer.
drawRepository(m_layer->getId(), env, m_display->getSRID());
154 if(!m_coords.empty())
158 renderer.
draw(line,
true);
160 if(m_continuousMode ==
false)
166 m_display->repaint();
177 for(std::size_t i = 0; i < m_coords.size(); ++i)
178 line->
setPoint(i, m_coords[i].x, m_coords[i].y);
180 line->
setSRID(m_display->getSRID());
182 if(line->
getSRID() == m_layer->getSRID())
201 m_coords.push_back(m_lastPos);
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
void addGeometry(const std::string &source, te::gm::Geometry *geom)
An utility struct for representing 2D coordinates.
LineString is a curve with linear interpolation between points.
static Renderer & getInstance()
It returns a reference to the singleton instance.
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.
TEEDITQTEXPORT QPointF GetPosition(QMouseEvent *e)
void draw(te::gm::Geometry *geom, bool showVertexes=false)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
This is a singleton for rendering geometries and features.
TEEDITEXPORT void TrySnap(te::gm::Coord2D &coord, int srid)
void begin(QPaintDevice *device, const te::gm::Envelope &e, int srid)
void drawRepository(const std::string &source, const te::gm::Envelope &e, int srid)
void setSRID(int srid)
It sets the Spatial Reference System ID of the linestring.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
bool isValid() const
It tells if the rectangle is valid or not.
void transform(int srid)
It converts the coordinate values of the linestring to the new spatial reference system.