33 #include <QMouseEvent>
40 , mTempRubberBand( 0 )
42 , mSnappingMarker( 0 )
44 , mSkipNextContextMenuEvent( 0 )
62 this, SLOT( currentLayerChanged(
QgsMapLayer * ) ) );
67 delete mSnappingMarker;
80 delete mSnappingMarker;
86 void QgsMapToolCapture::validationFinished()
89 QString msgFinished =
tr(
"Validation finished" );
90 if ( mValidationWarnings.
count() )
96 void QgsMapToolCapture::currentLayerChanged(
QgsMapLayer *layer )
98 if ( !mCaptureModeFromLayer )
134 delete mSnappingMarker;
139 if ( !mSnappingMarker )
143 mSnappingMarker->
setColor( Qt::magenta );
149 if ( !mTempRubberBand && mCaptureCurve.
numPoints() > 0 )
178 QgsDebugMsg(
"transformation to layer coordinate failed" );
189 return nextPoint( mapPoint, layerPoint );
215 if ( !mTempRubberBand )
230 mTempRubberBand->
addPoint( *firstPoint );
254 lineString->
points( linePoints );
257 for ( ; ptIt != linePoints.
constEnd(); ++ptIt )
262 if ( !mTempRubberBand )
268 mTempRubberBand->
reset();
292 int captureListSize =
size();
294 if ( rubberBandSize < 1 || captureListSize < 1 )
301 if ( rubberBandSize > 1 )
303 if ( tempRubberBandSize > 1 )
306 mTempRubberBand->
movePoint( tempRubberBandSize - 2, *point );
324 if ( e->
key() == Qt::Key_Backspace || e->
key() == Qt::Key_Delete )
331 else if ( e->
key() == Qt::Key_Escape )
358 if ( mTempRubberBand )
360 delete mTempRubberBand;
364 while ( !mGeomErrorMarkers.
isEmpty() )
372 Q_FOREACH (
QWidget *w, qApp->topLevelWidgets() )
376 if ( mSkipNextContextMenuEvent++ == 0 )
384 mCaptureCurve.
clear();
391 if ( mTempRubberBand )
393 delete mTempRubberBand;
400 mCaptureCurve.
close();
403 void QgsMapToolCapture::validateGeometry()
406 if ( settings.
value(
"/qgis/digitizing/validate_geometries", 1 ).
toInt() == 0 )
415 mValidationWarnings.
clear();
417 while ( !mGeomErrorMarkers.
isEmpty() )
438 exteriorRing->
close();
450 connect( mValidator, SIGNAL( finished() ),
this, SLOT( validationFinished() ) );
462 mValidationWarnings << e.what();
473 mGeomErrorMarkers << vm;
489 mCaptureCurve.
points( pts );
502 mCaptureCurve.
clear();
509 if ( event->
type() != QEvent::ContextMenu )
512 if ( --mSkipNextContextMenuEvent == 0 )
515 return mSkipNextContextMenuEvent >= 0;
void close()
Appends first point if not already closed.
Base class for all map layer types.
QgsPoint layerToMapCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from layer's CRS to output CRS
QString & append(QChar ch)
virtual QgsLineStringV2 * curveToLine() const override
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
QgsPoint mapPoint() const
mapPoint returns the point in coordinates
void close()
Appends first point if not already closed.
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
void points(QList< QgsPointV2 > &pt) const override
Returns a list of points within the curve.
virtual QgsPointV2 endPoint() const override
Returns the end point of the curve.
virtual bool deleteVertex(const QgsVertexId &position) override
Deletes a vertex within the geometry.
void movePoint(const QgsPoint &p, int geometryIndex=0)
Moves the rubber band point specified by index.
const QgsPoint * getPoint(int i, int j=0) const
Return vertex.
void setPenWidth(int width)
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
A geometry is the spatial representation of a feature.
int numberOfVertices() const
Returns count of vertices in all lists of mPoint.
QString join(const QString &separator) const
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
double x() const
Get the x value of the point.
void start(Priority priority)
int count(const T &value) const
void installEventFilter(QObject *filterObj)
int toInt(bool *ok) const
Utility class for identifying a unique vertex within a geometry.
Line string geometry type.
void addVertex(const QgsPointV2 &pt)
Adds a vertex to the end of the geometry.
static void convertPointList(const QList< QgsPoint > &input, QList< QgsPointV2 > &output)
Upgrades a point list from QgsPoint to QgsPointV2.
void removePoint(int index=0, bool doUpdate=true, int geometryIndex=0)
Remove a vertex from the rubberband and (optionally) update canvas.
void setCenter(const QgsPoint &point)
void triggerRepaint()
Will advice the map canvas (and any other interested party) that this layer requires to be repainted...
void addPoint(const QgsPoint &p, bool doUpdate=true, int geometryIndex=0)
Add a vertex to the rubberband and update canvas.
void reset(QGis::GeometryType geometryType=QGis::Line)
Clears all the geometries in this rubberband.
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform)=0
Transforms the geometry using a coordinate transform.
A class for marking vertices of features using e.g.
virtual bool eventFilter(QObject *watched, QEvent *event)
QGis::GeometryType geometryType() const
Returns point, line or polygon.
A class to represent a point.
QgsMapLayer * currentLayer()
returns current layer (set by legend widget)
const char * capture_point_cursor[]
void addCurve(QgsCurveV2 *c)
Adds a curve to the geometr (takes ownership)
QVariant value(const QString &key, const QVariant &defaultValue) const
virtual QgsLineStringV2 * curveToLine() const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
virtual QgsPointV2 endPoint() const =0
Returns the end point of the curve.
void setPoints(const QList< QgsPointV2 > &points)
void setExteriorRing(QgsCurveV2 *ring)
Sets exterior ring (takes ownership)
bool isSnapped() const
Returns true if there is a snapped point cached.
virtual void points(QList< QgsPointV2 > &pts) const override
Returns a list of points within the curve.
double y() const
Get the y value of the point.
Custom exception class for Coordinate Reference System related exceptions.
const_iterator constEnd() const
const_iterator constBegin() const
Abstract base class for curved geometry type.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setColor(const QColor &color)
Represents a vector layer which manages a vector based data sets.
virtual int numPoints() const override
Returns the number of points in the curve.
void setIconType(int iconType)
void removeEventFilter(QObject *obj)
virtual void clear() override
Clears the geometry, ie reset it to a null geometry.