2015-09-11 09:10:35 +02:00
|
|
|
/***************************************************************************
|
|
|
|
qgsmaptoolcapture.h - map tool for capturing points, lines, polygons
|
|
|
|
---------------------
|
|
|
|
begin : January 2006
|
|
|
|
copyright : (C) 2006 by Martin Dobias
|
|
|
|
email : wonder.sk at gmail dot com
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
class QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsmaptoolcapture.h"
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
//! constructor
|
|
|
|
QgsMapToolCapture( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget, CaptureMode mode = CaptureNone );
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~QgsMapToolCapture();
|
|
|
|
|
2015-12-16 20:01:19 +01:00
|
|
|
//! active the tool
|
|
|
|
virtual void activate();
|
|
|
|
|
2015-09-11 09:10:35 +02:00
|
|
|
//! deactive the tool
|
|
|
|
virtual void deactivate();
|
|
|
|
|
|
|
|
/** Adds a whole curve (e.g. circularstring) to the captured geometry. Curve must be in map CRS*/
|
|
|
|
int addCurve( QgsCurveV2* c );
|
|
|
|
|
2015-10-20 20:41:47 +02:00
|
|
|
/**
|
|
|
|
* Get the capture curve
|
|
|
|
*
|
|
|
|
* @return Capture curve
|
|
|
|
*/
|
2015-09-11 09:10:35 +02:00
|
|
|
const QgsCompoundCurveV2* captureCurve() const;
|
|
|
|
|
2015-10-20 20:41:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the rubberband according to mouse position
|
|
|
|
*
|
|
|
|
* @param e The mouse event
|
|
|
|
*/
|
|
|
|
virtual void cadCanvasMoveEvent( QgsMapMouseEvent * e );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Intercept key events like Esc or Del to delete the last point
|
|
|
|
* @param e key event
|
|
|
|
*/
|
|
|
|
virtual void keyPressEvent( QKeyEvent* e );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clean a temporary rubberband
|
|
|
|
*/
|
2015-09-11 09:10:35 +02:00
|
|
|
void deleteTempRubberBand();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void validationFinished();
|
|
|
|
|
|
|
|
void currentLayerChanged( QgsMapLayer *layer );
|
|
|
|
void addError( QgsGeometry::Error );
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
2016-01-20 18:25:58 +01:00
|
|
|
/** Converts a map point to layer coordinates
|
|
|
|
@param mapPoint the point in map coordinates
|
|
|
|
@param[inout] layerPoint the point in layer coordinates
|
|
|
|
@return
|
|
|
|
0 in case of success
|
|
|
|
1 if the current layer is null or not a vector layer
|
|
|
|
2 if the transformation failed
|
|
|
|
@deprecated use nextPoint(const QgsPointV2&, QgsPointV2&)
|
|
|
|
*/
|
|
|
|
int nextPoint( const QgsPoint& mapPoint, QgsPoint& layerPoint ) /Deprecated/;
|
|
|
|
|
|
|
|
/** Converts a map point to layer coordinates
|
|
|
|
@param mapPoint the point in map coordinates
|
|
|
|
@param[inout] layerPoint the point in layer coordinates
|
|
|
|
@return
|
|
|
|
0 in case of success
|
|
|
|
1 if the current layer is null or not a vector layer
|
|
|
|
2 if the transformation failed
|
|
|
|
*/
|
|
|
|
int nextPoint( const QgsPointV2& mapPoint, QgsPointV2& layerPoint );
|
|
|
|
|
|
|
|
/** Converts a point to map coordinates and layer coordinates
|
|
|
|
@param p the input point
|
|
|
|
@param[inout] layerPoint the point in layer coordinates
|
|
|
|
@param[inout] mapPoint the point in map coordinates
|
|
|
|
@return
|
|
|
|
0 in case of success
|
|
|
|
1 if the current layer is null or not a vector layer
|
|
|
|
2 if the transformation failed
|
|
|
|
@deprecated use nextPoint( const QPoint&, QgsPointV2&, QgsPointV2& )
|
|
|
|
*/
|
|
|
|
int nextPoint( QPoint p, QgsPoint &layerPoint, QgsPoint &mapPoint ) /Deprecated/;
|
|
|
|
|
|
|
|
/** Converts a point to map coordinates and layer coordinates
|
|
|
|
@param p the input point
|
|
|
|
@param[inout] layerPoint the point in layer coordinates
|
|
|
|
@param[inout] mapPoint the point in map coordinates
|
|
|
|
@return
|
|
|
|
0 in case of success
|
|
|
|
1 if the current layer is null or not a vector layer
|
|
|
|
2 if the transformation failed
|
|
|
|
*/
|
|
|
|
int nextPoint( QPoint p, QgsPointV2 &layerPoint, QgsPointV2 &mapPoint );
|
2015-09-11 09:10:35 +02:00
|
|
|
|
|
|
|
/** Adds a point to the rubber band (in map coordinates) and to the capture list (in layer coordinates)
|
|
|
|
@return 0 in case of success, 1 if current layer is not a vector layer, 2 if coordinate transformation failed*/
|
|
|
|
int addVertex( const QgsPoint& point );
|
|
|
|
|
|
|
|
/** Removes the last vertex from mRubberBand and mCaptureList*/
|
|
|
|
void undo();
|
|
|
|
|
|
|
|
void startCapturing();
|
|
|
|
bool isCapturing() const;
|
|
|
|
void stopCapturing();
|
|
|
|
|
|
|
|
int size();
|
|
|
|
QList<QgsPoint> points();
|
|
|
|
void setPoints( const QList<QgsPoint>& pointList );
|
|
|
|
void closePolygon();
|
|
|
|
};
|