27 #include "../../../common/STLUtils.h" 28 #include "../../../dataaccess/dataset/ObjectId.h" 29 #include "../../../geometry/Coord2D.h" 30 #include "../../../geometry/Geometry.h" 31 #include "../../../geometry/LineString.h" 32 #include "../../../geometry/MultiPolygon.h" 33 #include "../../../geometry/Polygon.h" 34 #include "../../../geometry/Utils.h" 35 #include "../../../qt/widgets/canvas/MapDisplay.h" 36 #include "../../../qt/widgets/Utils.h" 37 #include "../../Feature.h" 38 #include "../../RepositoryManager.h" 39 #include "../../Utils.h" 40 #include "../Renderer.h" 45 #include <QMessageBox> 46 #include <QMouseEvent> 57 m_currentStage(FEATURE_SELECTION),
59 m_fixGeometry(fixGeometry),
73 if (e->button() != Qt::LeftButton)
76 Qt::KeyboardModifiers keys = e->modifiers();
81 if(keys == Qt::NoModifier)
91 if(keys == Qt::ShiftModifier)
134 std::vector<VertexIndex> report;
151 std::unique_ptr<te::gm::Point> borderPoint;
163 draw(borderPoint.get());
191 if (e->button() != Qt::LeftButton)
301 catch(std::exception& e)
303 QMessageBox::critical(
m_display, tr(
"Error"), QString(tr(
"The geometry cannot be selected from the layer. Details:") +
" %1.").arg(e.what()));
315 draft->fill(Qt::transparent);
346 renderer.
setPointStyle(
"circle", Qt::transparent, Qt::blue, 3, 24);
347 renderer.
draw(point.get());
353 assert(virtualVertex);
355 renderer.
setPointStyle(
"circle", Qt::transparent, Qt::darkGreen, 3, 24);
356 renderer.
draw(virtualVertex);
372 QPointF pixelOffset(4.0, 4.0);
374 QRectF rect(pos - pixelOffset, pos + pixelOffset);
377 QPointF ll(rect.left(), rect.bottom());
378 QPointF ur(rect.right(), rect.top());
391 for(std::size_t i = 0; i <
m_lines.size(); ++i)
395 for(std::size_t j = 0; j < line->
getNPoints(); ++j)
456 connect(dynamic_cast<AddCommand*>(command), SIGNAL(commandFeedback()), SLOT(
onCommandFeedback()));
VertexTool(te::qt::widgets::MapDisplay *display, const te::map::AbstractLayerPtr &layer, bool fixGeometry=false, QObject *parent=0)
It constructs a vertex tool associated with the given map display.
virtual const std::string & getId() const
It returns the layer id.
Undo/Redo for add one components.
UndoStackManager & m_stack
TEEDITEXPORT void MoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index, const double &x, const double &y)
void setPointStyle(const QString &mark, const QColor &fillColor, const QColor &contourColor, const std::size_t &contourWidth, const std::size_t &size)
StageType
Defines the operation stage to this tool.
void resetVisualizationTool()
This class implements a concrete tool for vertex operations (move, add, etc.).
void setStage(StageType stage)
te::da::ObjectId * getId() const
void addWatch(Feature *feature)
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...
const std::vector< Feature * > & getAddWatches() const
te::gm::Geometry * getGeometry() const
virtual bool intersects(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if the geometry object spatially intersects rhs geometry.
bool mousePressEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse press events for th...
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
std::vector< te::gm::LineString * > m_lines
Coord2D getCenter() const
It returns the rectangle's center coordinate.
void addUndoStack(QUndoCommand *command)
Method that insert command Undo/Redo of type AddCommand in the Undo/Redo stack.
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
TEEDITEXPORT void RemoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index)
LineString is a curve with linear interpolation between points.
static T & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
virtual bool isValid() const _NOEXCEPT_OP(false)
It tells if the geometry is well formed.
An Envelope defines a 2D rectangular region.
void setIndex(const std::size_t &line, const std::size_t &pos)
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
te::gm::Envelope buildEnvelope(const QPointF &pos)
bool mouseMoveEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse move events for the...
TEEDITEXPORT Feature * PickFeature(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &env, int srid)
TEEDITQTEXPORT QPointF GetPosition(QMouseEvent *e)
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
void draw(te::gm::Geometry *geom, bool showVertexes=false)
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
virtual bool contains(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if this geometry object spatially contains rhs geometry.
VertexIndex m_currentVertexIndex
te::sam::rtree::Index< VertexIndex, 8 > m_rtree
This is a singleton for rendering geometries and features.
void draw(te::gm::Point *virtualVertex=0)
TEEDITEXPORT void AddVertex(std::vector< te::gm::LineString * > &lines, const double &x, const double &y, const te::gm::Envelope &env, int srid)
void drawVertexes(te::gm::Geometry *geom)
void begin(QPaintDevice *device, const te::gm::Envelope &e, int srid)
TEEDITEXPORT void GetLines(te::gm::Geometry *geom, std::vector< te::gm::LineString * > &lines)
bool mouseDoubleClickEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse double click events...
void drawRepository(const std::string &source, const te::gm::Envelope &e, int srid)
void setGeometry(te::gm::Geometry *geom)
virtual void transform(int srid) _NOEXCEPT_OP(false)=0
It converts the coordinate values of the geometry to the new spatial reference system.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TEGEOMEXPORT te::gm::Geometry * Validate(te::gm::Geometry *geom)
Get/create a valid version of the geometry given. If the geometry is a polygon or multi polygon...
bool isValid() const
It tells if the rectangle is valid or not.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
void pickFeature(const te::map::AbstractLayerPtr &layer, const QPointF &pos)