mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-18 00:04:02 -04:00
Move maptools from app->gui
This commit is contained in:
parent
26e9783023
commit
efcbbfdaeb
@ -79,6 +79,7 @@
|
||||
%Include qgsmaplayercombobox.sip
|
||||
%Include qgsmaplayermodel.sip
|
||||
%Include qgsmaplayerproxymodel.sip
|
||||
%Include qgsmapmouseevent.sip
|
||||
%Include qgsmapoverviewcanvas.sip
|
||||
%Include qgsmaptip.sip
|
||||
%Include qgsmaptool.sip
|
||||
|
78
python/gui/qgsmapmouseevent.sip
Normal file
78
python/gui/qgsmapmouseevent.sip
Normal file
@ -0,0 +1,78 @@
|
||||
/***************************************************************************
|
||||
qgsmapmouseevent.h - mouse event in map coordinates and ability to snap
|
||||
----------------------
|
||||
begin : October 2014
|
||||
copyright : (C) Denis Rouzaud
|
||||
email : denis.rouzaud@gmail.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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
|
||||
* It is sent whenever the user moves, clicks, releases or double clicks the mouse.
|
||||
* In addition to the coordiantes in pixel space it also knows the coordinates in the mapcanvas' CRS
|
||||
* as well as it knows the concept of snapping.
|
||||
*/
|
||||
class QgsMapMouseEvent : QMouseEvent
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include "qgsmapmouseevent.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
enum SnappingMode
|
||||
{
|
||||
NoSnapping,
|
||||
SnapProjectConfig, //!< snap according to the configuration set in the snapping settings
|
||||
SnapAllLayers, //!< snap to all rendered layers (tolerance and type from defaultSettings())
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new QgsMapMouseEvent. Should only be required to be called from the QgsMapCanvas.
|
||||
*
|
||||
* @param mapCanvas The map canvas on which the event occured
|
||||
* @param event The original mouse event
|
||||
*/
|
||||
QgsMapMouseEvent( QgsMapCanvas* mapCanvas, QMouseEvent* event );
|
||||
|
||||
/**
|
||||
* @brief snapPoint will snap the points using the map canvas snapping utils configuration
|
||||
* @note if snapping did not succeeded, the map point will be reset to its original position
|
||||
*/
|
||||
QgsPoint snapPoint( SnappingMode snappingMode );
|
||||
|
||||
/**
|
||||
* returns the first snapped segment. If the cached snapped match is a segment, it will simply return it.
|
||||
* Otherwise it will try to snap a segment according to the event's snapping mode. In this case the cache
|
||||
* will not be overwritten.
|
||||
* @param snapped if given, determines if a segment has been snapped
|
||||
* @param allLayers if true, override snapping mode
|
||||
*/
|
||||
QList<QgsPoint> snapSegment( SnappingMode snappingMode, bool* snapped = 0, bool allLayers = false ) const;
|
||||
|
||||
/**
|
||||
* Returns true if there is a snapped point cached.
|
||||
* Will only be useful after snapPoint has previously been called.
|
||||
*
|
||||
* @return True if there is a snapped point cached.
|
||||
*/
|
||||
bool isSnapped() const;
|
||||
|
||||
/**
|
||||
* @brief mapPoint returns the point in coordinates
|
||||
* @return the point in map coordinates, after snapping if requested in the event.
|
||||
*/
|
||||
QgsPoint mapPoint() const;
|
||||
|
||||
QgsPoint originalMapPoint() const;
|
||||
|
||||
QPoint pixelPoint() const;
|
||||
|
||||
QPoint originalPixelPoint() const;
|
||||
};
|
@ -36,16 +36,16 @@ class QgsMapTool : QObject
|
||||
virtual ~QgsMapTool();
|
||||
|
||||
//! Mouse move event for overriding. Default implementation does nothing.
|
||||
virtual void canvasMoveEvent( QMouseEvent * e );
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Mouse double click event for overriding. Default implementation does nothing.
|
||||
virtual void canvasDoubleClickEvent( QMouseEvent * e );
|
||||
virtual void canvasDoubleClickEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Mouse press event for overriding. Default implementation does nothing.
|
||||
virtual void canvasPressEvent( QMouseEvent * e );
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Mouse release event for overriding. Default implementation does nothing.
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e );
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Mouse wheel event for overriding. Default implementation does nothing.
|
||||
virtual void wheelEvent( QWheelEvent* e );
|
||||
|
@ -10,13 +10,13 @@ class QgsMapToolEmitPoint : QgsMapTool
|
||||
QgsMapToolEmitPoint( QgsMapCanvas* canvas );
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e );
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent * e );
|
||||
|
||||
//! Overridden mouse press event - emits the signal
|
||||
virtual void canvasPressEvent( QMouseEvent * e );
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent * e );
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e );
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent * e );
|
||||
|
||||
signals:
|
||||
//! signal emitted on canvas click
|
||||
|
@ -48,13 +48,13 @@ class QgsMapToolIdentify : QgsMapTool
|
||||
virtual ~QgsMapToolIdentify();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e );
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent * e );
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e );
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent * e );
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e );
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent * e );
|
||||
|
||||
virtual void activate();
|
||||
|
||||
|
@ -17,7 +17,7 @@ class QgsMapToolIdentifyFeature : QgsMapToolIdentify
|
||||
//! change the layer used by the map tool to identify
|
||||
void setLayer( QgsVectorLayer* vl );
|
||||
|
||||
void canvasReleaseEvent( QMouseEvent* e );
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e );
|
||||
|
||||
signals:
|
||||
void featureIdentified( QgsFeature );
|
||||
|
@ -10,10 +10,10 @@ class QgsMapToolPan : QgsMapTool
|
||||
QgsMapToolPan( QgsMapCanvas* canvas );
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e );
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent * e );
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e );
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent * e );
|
||||
|
||||
virtual bool isTransient();
|
||||
};
|
||||
|
@ -15,13 +15,13 @@ class QgsMapToolTouch : QgsMapTool
|
||||
void deactivate();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e );
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent * e );
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e );
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent * e );
|
||||
|
||||
//! Overridden Mouse double click event.
|
||||
virtual void canvasDoubleClickEvent( QMouseEvent * e );
|
||||
virtual void canvasDoubleClickEvent( QgsMapMouseEvent * e );
|
||||
|
||||
virtual bool isTransient();
|
||||
|
||||
|
@ -12,19 +12,18 @@ class QgsMapToolZoom : QgsMapTool
|
||||
~QgsMapToolZoom();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e );
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e );
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e );
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! indicates whether we're zooming in or out
|
||||
virtual bool isTransient();
|
||||
|
||||
//! Flag to indicate a map canvas drag operation is taking place
|
||||
virtual void deactivate();
|
||||
|
||||
};
|
||||
|
||||
|
@ -15,8 +15,6 @@ SET(QGIS_APP_SRCS
|
||||
qgsattributetabledialog.cpp
|
||||
qgsbookmarks.cpp
|
||||
qgsbrowserdockwidget.cpp
|
||||
qgsadvanceddigitizingdockwidget.cpp
|
||||
qgsadvanceddigitizingcanvasitem.cpp
|
||||
qgsclipboard.cpp
|
||||
qgsconfigureshortcutsdialog.cpp
|
||||
qgscustomization.cpp
|
||||
@ -47,7 +45,6 @@ SET(QGIS_APP_SRCS
|
||||
qgslabelpreview.cpp
|
||||
qgsloadstylefromdbdialog.cpp
|
||||
qgsmaplayerstyleguiutils.cpp
|
||||
qgsmapmouseevent.cpp
|
||||
qgssavestyletodbdialog.cpp
|
||||
qgsguivectorlayertools.cpp
|
||||
qgswelcomepageitemsmodel.cpp
|
||||
@ -59,11 +56,9 @@ SET(QGIS_APP_SRCS
|
||||
qgsmaptooladdring.cpp
|
||||
qgsmaptoolfillring.cpp
|
||||
qgsmaptoolannotation.cpp
|
||||
qgsmaptoolcapture.cpp
|
||||
qgsmaptoolchangelabelproperties.cpp
|
||||
qgsmaptooldeletering.cpp
|
||||
qgsmaptooldeletepart.cpp
|
||||
qgsmaptooledit.cpp
|
||||
qgsmaptoolfeatureaction.cpp
|
||||
qgsmaptoolformannotation.cpp
|
||||
qgsmaptoolhtmlannotation.cpp
|
||||
@ -71,7 +66,6 @@ SET(QGIS_APP_SRCS
|
||||
qgsmaptoolshowhidelabels.cpp
|
||||
qgsmaptoolidentifyaction.cpp
|
||||
qgsmaptoollabel.cpp
|
||||
qgsmaptooladvanceddigitizing.cpp
|
||||
qgsmaptoolmeasureangle.cpp
|
||||
qgsmaptoolmovefeature.cpp
|
||||
qgsmaptoolmovelabel.cpp
|
||||
@ -181,7 +175,6 @@ SET (QGIS_APP_MOC_HDRS
|
||||
qgsattributetabledialog.h
|
||||
qgsbookmarks.h
|
||||
qgsbrowserdockwidget.h
|
||||
qgsadvanceddigitizingdockwidget.h
|
||||
qgsclipboard.h
|
||||
qgsconfigureshortcutsdialog.h
|
||||
qgscustomization.h
|
||||
@ -220,11 +213,9 @@ SET (QGIS_APP_MOC_HDRS
|
||||
qgsversioninfo.h
|
||||
|
||||
qgsmaptooladdfeature.h
|
||||
qgsmaptoolcapture.h
|
||||
qgsmaptoolcircularstringradius.h
|
||||
qgsmaptooladdpart.h
|
||||
qgsmaptooladdring.h
|
||||
qgsmaptooledit.h
|
||||
qgsmaptoolfillring.h
|
||||
qgsmaptoolchangelabelproperties.h
|
||||
qgsmaptooldeletepart.h
|
||||
@ -233,7 +224,6 @@ SET (QGIS_APP_MOC_HDRS
|
||||
qgsmaptoolpinlabels.h
|
||||
qgsmaptoolshowhidelabels.h
|
||||
qgsmaptoolidentifyaction.h
|
||||
qgsmaptooladvanceddigitizing.h
|
||||
qgsmaptoolmeasureangle.h
|
||||
qgsmaptoolmovefeature.h
|
||||
qgsmaptoolmovelabel.h
|
||||
|
@ -38,8 +38,6 @@ QgsMapToolNodeTool::QgsMapToolNodeTool( QgsMapCanvas* canvas )
|
||||
, mIsPoint( false )
|
||||
{
|
||||
mSnapper.setMapCanvas( canvas );
|
||||
mCadAllowed = true;
|
||||
mSnapOnPress = true;
|
||||
}
|
||||
|
||||
QgsMapToolNodeTool::~QgsMapToolNodeTool()
|
||||
@ -47,7 +45,7 @@ QgsMapToolNodeTool::~QgsMapToolNodeTool()
|
||||
cleanTool();
|
||||
}
|
||||
|
||||
void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
|
||||
void QgsMapToolNodeTool::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
removeRubberBands();
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
@ -122,7 +120,7 @@ void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolNodeTool::canvasMapMoveEvent( QgsMapMouseEvent* e )
|
||||
void QgsMapToolNodeTool::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mSelectedFeature || !mSelectedFeature->hasSelection() )
|
||||
{
|
||||
@ -228,7 +226,7 @@ void QgsMapToolNodeTool::cleanTool( bool deleteSelectedFeature )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
|
||||
void QgsMapToolNodeTool::canvasDoubleClickEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mSelectedFeature )
|
||||
return;
|
||||
|
@ -34,13 +34,13 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
|
||||
QgsMapToolNodeTool( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolNodeTool();
|
||||
|
||||
void canvasDoubleClickEvent( QMouseEvent * e ) override;
|
||||
void canvasDoubleClickEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! mouse press event in map coordinates (eventually filtered) to be redefined in subclass
|
||||
void canvasMapPressEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! mouse move event in map coordinates (eventually filtered) to be redefined in subclass
|
||||
void canvasMapMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
void keyPressEvent( QKeyEvent* e ) override;
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsmapmouseevent.h - mouse event in map coordinates and ability to snap
|
||||
----------------------
|
||||
begin : October 2014
|
||||
copyright : (C) Denis Rouzaud
|
||||
email : denis.rouzaud@gmail.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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSMAPMOUSEEVENT_H
|
||||
#define QGSMAPMOUSEEVENT_H
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "qgspoint.h"
|
||||
#include "qgspointlocator.h"
|
||||
|
||||
class QgsMapCanvas;
|
||||
class QgsMapToolAdvancedDigitizing;
|
||||
|
||||
class APP_EXPORT QgsMapMouseEvent : public QMouseEvent
|
||||
{
|
||||
public:
|
||||
|
||||
enum SnappingMode
|
||||
{
|
||||
NoSnapping,
|
||||
SnapProjectConfig, //!< snap according to the configuration set in the snapping settings
|
||||
SnapAllLayers, //!< snap to all rendered layers (tolerance and type from defaultSettings())
|
||||
};
|
||||
|
||||
explicit QgsMapMouseEvent( QgsMapToolAdvancedDigitizing* mapTool, QMouseEvent* event, SnappingMode mode = NoSnapping );
|
||||
|
||||
explicit QgsMapMouseEvent( QgsMapToolAdvancedDigitizing* mapTool, QgsPoint point,
|
||||
Qt::MouseButton button, Qt::KeyboardModifiers modifiers,
|
||||
QEvent::Type eventType = QEvent::MouseButtonRelease, SnappingMode mode = NoSnapping );
|
||||
|
||||
//! returns the corresponding map tool
|
||||
QgsMapToolAdvancedDigitizing* mapTool() {return mMapTool;}
|
||||
|
||||
//! modify the point in map coordinates without changing values in pixel coordinates
|
||||
void setPoint( const QgsPoint& point );
|
||||
|
||||
//! returns the first snapped segment. If the snapped match is a segment, it will simply return it.
|
||||
//! Otherwise it will try to snap a segment according to the event's snapping mode
|
||||
//! @param snapped if given, determines if a segment has been snapped
|
||||
//! @param allLayers if true, override snapping mode
|
||||
QList<QgsPoint> snapSegment( bool* snapped = 0, bool allLayers = false ) const;
|
||||
|
||||
/**
|
||||
* @brief mapPoint returns the point in coordinates
|
||||
* @return the point in map coordinates, after snapping if requested in the event.
|
||||
*/
|
||||
QgsPoint mapPoint() const { return mMapPoint; }
|
||||
|
||||
//! determines if the returned mapPoint() is snapped (to a vertex or to a segment)
|
||||
bool isSnapped() const { return mSnapMatch.isValid(); }
|
||||
|
||||
//! determines if the returned mapPoint() is snapped to a vertex. If snapped to a segment (or not snapped at all), will be set to false.
|
||||
bool isSnappedToVertex() const { return mSnapMatch.hasVertex(); }
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief snapPoint will snap the points using the map canvas snapping utils configuration
|
||||
* @note if snapping did not succeeded, the map point will be reset to its original position
|
||||
*/
|
||||
void snapPoint();
|
||||
|
||||
static QPoint mapToPixelCoordinates( QgsMapCanvas* canvas, const QgsPoint& point );
|
||||
|
||||
QgsPoint mMapPoint;
|
||||
|
||||
QgsPoint mOriginalPoint;
|
||||
|
||||
QgsMapToolAdvancedDigitizing* mMapTool;
|
||||
QgsPointLocator::Match mSnapMatch;
|
||||
SnappingMode mSnappingMode;
|
||||
};
|
||||
|
||||
#endif // QGSMAPMOUSEEVENT_H
|
@ -22,10 +22,16 @@
|
||||
#include "qgslinestringv2.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgspointv2.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
QgsMapToolAddCircularString::QgsMapToolAddCircularString( QgsMapToolCapture* parentTool, QgsMapCanvas* canvas, CaptureMode mode ): QgsMapToolCapture( canvas, mode ),
|
||||
mParentTool( parentTool ), mRubberBand( 0 ), mShowCenterPointRubberBand( false ), mCenterPointRubberBand( 0 )
|
||||
QgsMapToolAddCircularString::QgsMapToolAddCircularString( QgsMapToolCapture* parentTool, QgsMapCanvas* canvas, CaptureMode mode )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), mode )
|
||||
, mParentTool( parentTool )
|
||||
, mRubberBand( 0 )
|
||||
, mShowCenterPointRubberBand( false )
|
||||
, mCenterPointRubberBand( 0 )
|
||||
{
|
||||
if ( mCanvas )
|
||||
{
|
||||
@ -33,8 +39,12 @@ QgsMapToolAddCircularString::QgsMapToolAddCircularString( QgsMapToolCapture* par
|
||||
}
|
||||
}
|
||||
|
||||
QgsMapToolAddCircularString::QgsMapToolAddCircularString( QgsMapCanvas* canvas ): QgsMapToolCapture( canvas ), mParentTool( 0 ),
|
||||
mRubberBand( 0 ), mShowCenterPointRubberBand( false ), mCenterPointRubberBand( 0 )
|
||||
QgsMapToolAddCircularString::QgsMapToolAddCircularString( QgsMapCanvas* canvas )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget() )
|
||||
, mParentTool( 0 )
|
||||
, mRubberBand( 0 )
|
||||
, mShowCenterPointRubberBand( false )
|
||||
, mCenterPointRubberBand( 0 )
|
||||
{
|
||||
if ( mCanvas )
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ class QgsMapToolAddCircularString: public QgsMapToolCapture
|
||||
void setParentTool( QgsMapTool* newTool, QgsMapTool* oldTool );
|
||||
|
||||
protected:
|
||||
QgsMapToolAddCircularString( QgsMapCanvas* canvas = 0 ); //forbidden
|
||||
QgsMapToolAddCircularString( QgsMapCanvas* canvas ); //forbidden
|
||||
|
||||
QgsMapToolCapture* mParentTool;
|
||||
/** Circular string points (in map coordinates)*/
|
||||
|
@ -30,12 +30,13 @@
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgsfeatureaction.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QSettings>
|
||||
|
||||
QgsMapToolAddFeature::QgsMapToolAddFeature( QgsMapCanvas* canvas )
|
||||
: QgsMapToolCapture( canvas )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget() )
|
||||
{
|
||||
mToolName = tr( "Add feature" );
|
||||
}
|
||||
@ -63,14 +64,12 @@ void QgsMapToolAddFeature::activate()
|
||||
return;
|
||||
}
|
||||
|
||||
QgsMapTool::activate();
|
||||
QgsMapToolCapture::activate();
|
||||
}
|
||||
|
||||
void QgsMapToolAddFeature::canvasMapReleaseEvent( QgsMapMouseEvent* e )
|
||||
void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsDebugMsg( "entered." );
|
||||
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
QgsVectorLayer* vlayer = currentVectorLayer();
|
||||
|
||||
if ( !vlayer )
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ class APP_EXPORT QgsMapToolAddFeature : public QgsMapToolCapture
|
||||
public:
|
||||
QgsMapToolAddFeature( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolAddFeature();
|
||||
void canvasMapReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
void cadCanvasReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
|
||||
bool addFeature( QgsVectorLayer *vlayer, QgsFeature *f, bool showModal = true );
|
||||
void activate() override;
|
||||
|
@ -22,11 +22,12 @@
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
QgsMapToolAddPart::QgsMapToolAddPart( QgsMapCanvas* canvas )
|
||||
: QgsMapToolCapture( canvas )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget() )
|
||||
{
|
||||
mToolName = tr( "Add part" );
|
||||
}
|
||||
@ -35,10 +36,10 @@ QgsMapToolAddPart::~QgsMapToolAddPart()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolAddPart::canvasMapReleaseEvent( QgsMapMouseEvent * e )
|
||||
void QgsMapToolAddPart::canvasReleaseEvent( QgsMapMouseEvent * e )
|
||||
{
|
||||
//check if we operate on a vector layer
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
QgsVectorLayer *vlayer = currentVectorLayer();
|
||||
if ( !vlayer )
|
||||
{
|
||||
notifyNotVectorLayer();
|
||||
|
@ -23,5 +23,5 @@ class APP_EXPORT QgsMapToolAddPart : public QgsMapToolCapture
|
||||
public:
|
||||
QgsMapToolAddPart( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolAddPart();
|
||||
void canvasMapReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
};
|
||||
|
@ -22,10 +22,11 @@
|
||||
#include "qgsproject.h"
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
|
||||
QgsMapToolAddRing::QgsMapToolAddRing( QgsMapCanvas* canvas )
|
||||
: QgsMapToolCapture( canvas, QgsMapToolCapture::CapturePolygon )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CapturePolygon )
|
||||
{
|
||||
mToolName = tr( "Add ring" );
|
||||
}
|
||||
@ -34,13 +35,13 @@ QgsMapToolAddRing::~QgsMapToolAddRing()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolAddRing::canvasMapReleaseEvent( QgsMapMouseEvent * e )
|
||||
void QgsMapToolAddRing::canvasReleaseEvent( QgsMapMouseEvent * e )
|
||||
{
|
||||
|
||||
emit messageDiscarded();
|
||||
|
||||
//check if we operate on a vector layer
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
QgsVectorLayer *vlayer = currentVectorLayer();
|
||||
|
||||
if ( !vlayer )
|
||||
{
|
||||
|
@ -23,5 +23,5 @@ class APP_EXPORT QgsMapToolAddRing: public QgsMapToolCapture
|
||||
public:
|
||||
QgsMapToolAddRing( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolAddRing();
|
||||
void canvasMapReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
};
|
||||
|
@ -1,122 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsmaptooladvanceddigitizing.cpp - map tool with event in map coordinates
|
||||
----------------------
|
||||
begin : October 2014
|
||||
copyright : (C) Denis Rouzaud
|
||||
email : denis.rouzaud@gmail.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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsmapmouseevent.h"
|
||||
#include "qgsmaptooladvanceddigitizing.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
|
||||
QgsMapToolAdvancedDigitizing::QgsMapToolAdvancedDigitizing( QgsMapCanvas* canvas )
|
||||
: QgsMapTool( canvas )
|
||||
, mCadAllowed( false )
|
||||
, mCaptureMode( CapturePoint )
|
||||
, mSnapOnPress( false )
|
||||
, mSnapOnRelease( false )
|
||||
, mSnapOnMove( false )
|
||||
, mSnapOnDoubleClick( false )
|
||||
{
|
||||
mCadDockWidget = QgisApp::instance()->cadDockWidget();
|
||||
}
|
||||
|
||||
QgsMapToolAdvancedDigitizing::~QgsMapToolAdvancedDigitizing()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasPressEvent( QMouseEvent* e )
|
||||
{
|
||||
QgsMapMouseEvent::SnappingMode mode = mSnapOnPress ? QgsMapMouseEvent::SnapProjectConfig : QgsMapMouseEvent::NoSnapping;
|
||||
QgsMapMouseEvent* event = new QgsMapMouseEvent( this, e, mode );
|
||||
if ( !mCadDockWidget->canvasPressEventFilter( event ) )
|
||||
{
|
||||
canvasMapPressEvent( event );
|
||||
}
|
||||
delete event;
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasReleaseEvent( QMouseEvent* e )
|
||||
{
|
||||
QgsMapMouseEvent::SnappingMode mode = mSnapOnRelease ? QgsMapMouseEvent::SnapProjectConfig : QgsMapMouseEvent::NoSnapping;
|
||||
if ( mCadDockWidget->cadEnabled() )
|
||||
mode = mCadDockWidget->snappingMode();
|
||||
QgsMapMouseEvent* event = new QgsMapMouseEvent( this, e, mode );
|
||||
if ( !mCadDockWidget->canvasReleaseEventFilter( event ) )
|
||||
{
|
||||
canvasMapReleaseEvent( event );
|
||||
}
|
||||
delete event;
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasMoveEvent( QMouseEvent* e )
|
||||
{
|
||||
QgsMapMouseEvent::SnappingMode mode = mSnapOnMove ? QgsMapMouseEvent::SnapProjectConfig : QgsMapMouseEvent::NoSnapping;
|
||||
if ( mCadDockWidget->cadEnabled() )
|
||||
mode = mCadDockWidget->snappingMode();
|
||||
QgsMapMouseEvent* event = new QgsMapMouseEvent( this, e, mode );
|
||||
if ( !mCadDockWidget->canvasMoveEventFilter( event ) )
|
||||
{
|
||||
canvasMapMoveEvent( event );
|
||||
}
|
||||
delete event;
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasDoubleClickEvent( QMouseEvent* e )
|
||||
{
|
||||
QgsMapMouseEvent::SnappingMode mode = mSnapOnDoubleClick ? QgsMapMouseEvent::SnapProjectConfig : QgsMapMouseEvent::NoSnapping;
|
||||
QgsMapMouseEvent* event = new QgsMapMouseEvent( this, e, mode );
|
||||
canvasMapDoubleClickEvent( event );
|
||||
delete event;
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
if ( !mCadDockWidget->canvasKeyPressEventFilter( event ) )
|
||||
canvasKeyPressEvent( event );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::keyReleaseEvent( QKeyEvent* event )
|
||||
{
|
||||
canvasKeyReleaseEvent( event );
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasMapPressEvent( QgsMapMouseEvent *e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasMapReleaseEvent( QgsMapMouseEvent *e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasMapMoveEvent( QgsMapMouseEvent *e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasMapDoubleClickEvent( QgsMapMouseEvent *e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasKeyPressEvent( QKeyEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasKeyReleaseEvent( QKeyEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
@ -81,7 +81,7 @@ QDialog* QgsMapToolAnnotation::createItemEditor( QgsAnnotationItem *item )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QgsMapToolAnnotation::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolAnnotation::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
|
||||
@ -89,7 +89,7 @@ void QgsMapToolAnnotation::canvasReleaseEvent( QMouseEvent *e )
|
||||
mCanvas->setCursor( mCursor );
|
||||
}
|
||||
|
||||
void QgsMapToolAnnotation::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mCanvas )
|
||||
{
|
||||
@ -149,7 +149,7 @@ void QgsMapToolAnnotation::keyPressEvent( QKeyEvent* e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolAnnotation::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsAnnotationItem* sItem = selectedItem();
|
||||
if ( sItem && ( e->buttons() & Qt::LeftButton ) )
|
||||
@ -233,7 +233,7 @@ void QgsMapToolAnnotation::canvasMoveEvent( QMouseEvent * e )
|
||||
mLastMousePosition = e->posF();
|
||||
}
|
||||
|
||||
void QgsMapToolAnnotation::canvasDoubleClickEvent( QMouseEvent * e )
|
||||
void QgsMapToolAnnotation::canvasDoubleClickEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsAnnotationItem* item = itemAtPos( e->posF() );
|
||||
if ( !item )
|
||||
|
@ -27,10 +27,10 @@ class APP_EXPORT QgsMapToolAnnotation: public QgsMapTool
|
||||
QgsMapToolAnnotation( QgsMapCanvas* canvas );
|
||||
~QgsMapToolAnnotation();
|
||||
|
||||
void canvasPressEvent( QMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
void canvasDoubleClickEvent( QMouseEvent * e ) override;
|
||||
void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasDoubleClickEvent( QgsMapMouseEvent* e ) override;
|
||||
void keyPressEvent( QKeyEvent* e ) override;
|
||||
|
||||
protected:
|
||||
|
@ -29,7 +29,7 @@ QgsMapToolChangeLabelProperties::~QgsMapToolChangeLabelProperties()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolChangeLabelProperties::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapToolChangeLabelProperties::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
deleteRubberBands();
|
||||
|
||||
@ -47,7 +47,7 @@ void QgsMapToolChangeLabelProperties::canvasPressEvent( QMouseEvent *e )
|
||||
createRubberBands();
|
||||
}
|
||||
|
||||
void QgsMapToolChangeLabelProperties::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolChangeLabelProperties::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
QgsVectorLayer* vlayer = currentLayer();
|
||||
|
@ -28,8 +28,8 @@ class APP_EXPORT QgsMapToolChangeLabelProperties: public QgsMapToolLabel
|
||||
QgsMapToolChangeLabelProperties( QgsMapCanvas* canvas );
|
||||
~QgsMapToolChangeLabelProperties();
|
||||
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -7,7 +7,8 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
QgsMapToolCircularStringCurvePoint::QgsMapToolCircularStringCurvePoint( QgsMapToolCapture* parentTool,
|
||||
QgsMapCanvas* canvas, CaptureMode mode ): QgsMapToolAddCircularString( parentTool, canvas, mode )
|
||||
QgsMapCanvas* canvas, CaptureMode mode )
|
||||
: QgsMapToolAddCircularString( parentTool, canvas, mode )
|
||||
{
|
||||
|
||||
}
|
||||
@ -16,7 +17,7 @@ QgsMapToolCircularStringCurvePoint::~QgsMapToolCircularStringCurvePoint()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolCircularStringCurvePoint::canvasMapReleaseEvent( QgsMapMouseEvent* e )
|
||||
void QgsMapToolCircularStringCurvePoint::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsPointV2 mapPoint( e->mapPoint().x(), e->mapPoint().y() );
|
||||
|
||||
@ -75,7 +76,7 @@ void QgsMapToolCircularStringCurvePoint::canvasMapReleaseEvent( QgsMapMouseEvent
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolCircularStringCurvePoint::canvasMapMoveEvent( QgsMapMouseEvent* e )
|
||||
void QgsMapToolCircularStringCurvePoint::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsPointV2 mapPoint( e->mapPoint().x(), e->mapPoint().y() );
|
||||
QgsVertexId idx; idx.part = 0; idx.ring = 0; idx.vertex = mPoints.size();
|
||||
|
@ -25,8 +25,8 @@ class QgsMapToolCircularStringCurvePoint: public QgsMapToolAddCircularString
|
||||
QgsMapToolCircularStringCurvePoint( QgsMapToolCapture* parentTool, QgsMapCanvas* canvas, CaptureMode mode = CaptureLine );
|
||||
~QgsMapToolCircularStringCurvePoint();
|
||||
|
||||
void canvasMapReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasMapMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
};
|
||||
|
||||
#endif // QGSMAPTOOLCIRCULARSTRINGCURVEPOINT_H
|
||||
|
@ -25,8 +25,12 @@
|
||||
#include <QMouseEvent>
|
||||
#include <cmath>
|
||||
|
||||
QgsMapToolCircularStringRadius::QgsMapToolCircularStringRadius( QgsMapToolCapture* parentTool, QgsMapCanvas* canvas, CaptureMode mode ) :
|
||||
QgsMapToolAddCircularString( parentTool, canvas, mode ), mTemporaryEndPointX( 0.0 ), mTemporaryEndPointY( 0.0 ), mRadiusMode( false ), mRadius( 0.0 ),
|
||||
QgsMapToolCircularStringRadius::QgsMapToolCircularStringRadius( QgsMapToolCapture* parentTool, QgsMapCanvas* canvas, CaptureMode mode )
|
||||
: QgsMapToolAddCircularString( parentTool, canvas, mode ),
|
||||
mTemporaryEndPointX( 0.0 ),
|
||||
mTemporaryEndPointY( 0.0 ),
|
||||
mRadiusMode( false ),
|
||||
mRadius( 0.0 ),
|
||||
mRadiusSpinBox( 0 )
|
||||
{
|
||||
|
||||
@ -37,7 +41,7 @@ QgsMapToolCircularStringRadius::~QgsMapToolCircularStringRadius()
|
||||
|
||||
}
|
||||
|
||||
void QgsMapToolCircularStringRadius::canvasMapReleaseEvent( QgsMapMouseEvent* e )
|
||||
void QgsMapToolCircularStringRadius::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsPointV2 mapPoint( e->mapPoint().x(), e->mapPoint().y() );
|
||||
|
||||
@ -111,7 +115,7 @@ void QgsMapToolCircularStringRadius::canvasMapReleaseEvent( QgsMapMouseEvent* e
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolCircularStringRadius::canvasMapMoveEvent( QgsMapMouseEvent* e )
|
||||
void QgsMapToolCircularStringRadius::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( mPoints.size() > 0 && mRadiusMode )
|
||||
{
|
||||
|
@ -29,8 +29,8 @@ class QgsMapToolCircularStringRadius: public QgsMapToolAddCircularString
|
||||
QgsMapToolCircularStringRadius( QgsMapToolCapture* parentTool, QgsMapCanvas* canvas, CaptureMode mode = CaptureLine );
|
||||
~QgsMapToolCircularStringRadius();
|
||||
|
||||
virtual void canvasMapReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
virtual void canvasMapMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
private slots:
|
||||
void updateRadiusFromSpinBox( double radius );
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgssnappingutils.h"
|
||||
#include "qgstolerance.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
@ -39,13 +40,13 @@ QgsMapToolDeletePart::~QgsMapToolDeletePart()
|
||||
delete mRubberBand;
|
||||
}
|
||||
|
||||
void QgsMapToolDeletePart::canvasMoveEvent( QMouseEvent *e )
|
||||
void QgsMapToolDeletePart::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
void QgsMapToolDeletePart::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapToolDeletePart::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
mPressedFid = -1;
|
||||
mPressedPartNum = -1;
|
||||
@ -82,7 +83,7 @@ void QgsMapToolDeletePart::canvasPressEvent( QMouseEvent *e )
|
||||
delete geomPart;
|
||||
}
|
||||
|
||||
void QgsMapToolDeletePart::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolDeletePart::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
|
||||
|
@ -30,11 +30,11 @@ class APP_EXPORT QgsMapToolDeletePart: public QgsMapToolEdit
|
||||
QgsMapToolDeletePart( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolDeletePart();
|
||||
|
||||
void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
void canvasPressEvent( QMouseEvent * e ) override;
|
||||
void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! called when map tool is being deactivated
|
||||
void deactivate() override;
|
||||
|
@ -18,13 +18,14 @@
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsvertexmarker.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <limits>
|
||||
|
||||
QgsMapToolDeleteRing::QgsMapToolDeleteRing( QgsMapCanvas* canvas )
|
||||
: QgsMapToolEdit( canvas )
|
||||
, vlayer( NULL )
|
||||
, vlayer( 0 )
|
||||
, mRubberBand( 0 )
|
||||
, mPressedFid( 0 )
|
||||
, mPressedPartNum( 0 )
|
||||
@ -38,13 +39,13 @@ QgsMapToolDeleteRing::~QgsMapToolDeleteRing()
|
||||
delete mRubberBand;
|
||||
}
|
||||
|
||||
void QgsMapToolDeleteRing::canvasMoveEvent( QMouseEvent *e )
|
||||
void QgsMapToolDeleteRing::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
void QgsMapToolDeleteRing::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapToolDeleteRing::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
delete mRubberBand;
|
||||
mRubberBand = 0;
|
||||
@ -93,7 +94,7 @@ void QgsMapToolDeleteRing::canvasPressEvent( QMouseEvent *e )
|
||||
ringGeom = 0;
|
||||
}
|
||||
|
||||
void QgsMapToolDeleteRing::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolDeleteRing::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
|
||||
|
@ -30,11 +30,11 @@ class APP_EXPORT QgsMapToolDeleteRing : public QgsMapToolEdit
|
||||
QgsMapToolDeleteRing( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolDeleteRing();
|
||||
|
||||
void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
void canvasPressEvent( QMouseEvent * e ) override;
|
||||
void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! called when map tool is being deactivated
|
||||
void deactivate() override;
|
||||
|
@ -44,17 +44,17 @@ QgsMapToolFeatureAction::~QgsMapToolFeatureAction()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolFeatureAction::canvasMoveEvent( QMouseEvent *e )
|
||||
void QgsMapToolFeatureAction::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolFeatureAction::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapToolFeatureAction::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolFeatureAction::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolFeatureAction::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsMapLayer *layer = mCanvas->currentLayer();
|
||||
|
||||
|
@ -37,13 +37,13 @@ class APP_EXPORT QgsMapToolFeatureAction : public QgsMapTool
|
||||
~QgsMapToolFeatureAction();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
virtual void activate() override;
|
||||
|
||||
|
@ -19,14 +19,14 @@
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsattributedialog.h"
|
||||
#include <qgsapplication.h>
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include <limits>
|
||||
|
||||
QgsMapToolFillRing::QgsMapToolFillRing( QgsMapCanvas* canvas )
|
||||
: QgsMapToolCapture( canvas, QgsMapToolCapture::CapturePolygon )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CapturePolygon )
|
||||
{
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ QgsMapToolFillRing::~QgsMapToolFillRing()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolFillRing::canvasMapReleaseEvent( QgsMapMouseEvent * e )
|
||||
void QgsMapToolFillRing::canvasReleaseEvent( QgsMapMouseEvent * e )
|
||||
{
|
||||
//check if we operate on a vector layer
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
@ -160,7 +160,7 @@ void QgsMapToolFillRing::canvasMapReleaseEvent( QgsMapMouseEvent * e )
|
||||
ft->setGeometry( g );
|
||||
ft->setAttributes( f.attributes() );
|
||||
|
||||
if ( QgsApplication::keyboardModifiers() == Qt::ControlModifier )
|
||||
if ( QApplication::keyboardModifiers() == Qt::ControlModifier )
|
||||
{
|
||||
res = vlayer->addFeature( *ft );
|
||||
}
|
||||
|
@ -26,5 +26,5 @@ class APP_EXPORT QgsMapToolFillRing: public QgsMapToolCapture
|
||||
public:
|
||||
QgsMapToolFillRing( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolFillRing();
|
||||
void canvasMapReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
};
|
||||
|
@ -101,17 +101,17 @@ void QgsMapToolIdentifyAction::showAttributeTable( QgsMapLayer* layer, const QLi
|
||||
tableDialog->show();
|
||||
}
|
||||
|
||||
void QgsMapToolIdentifyAction::canvasMoveEvent( QMouseEvent *e )
|
||||
void QgsMapToolIdentifyAction::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolIdentifyAction::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapToolIdentifyAction::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolIdentifyAction::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
resultsDialog()->clear();
|
||||
connect( this, SIGNAL( identifyProgress( int, int ) ), QgisApp::instance(), SLOT( showProgress( int, int ) ) );
|
||||
|
@ -50,13 +50,13 @@ class APP_EXPORT QgsMapToolIdentifyAction : public QgsMapToolIdentify
|
||||
~QgsMapToolIdentifyAction();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
virtual void activate() override;
|
||||
|
||||
|
@ -42,7 +42,7 @@ QgsMapToolMeasureAngle::~QgsMapToolMeasureAngle()
|
||||
stopMeasuring();
|
||||
}
|
||||
|
||||
void QgsMapToolMeasureAngle::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolMeasureAngle::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mRubberBand || mAnglePoints.size() < 1 || mAnglePoints.size() > 2 || !mRubberBand )
|
||||
{
|
||||
@ -81,7 +81,7 @@ void QgsMapToolMeasureAngle::canvasMoveEvent( QMouseEvent * e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolMeasureAngle::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolMeasureAngle::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
//add points until we have three
|
||||
if ( mAnglePoints.size() == 3 )
|
||||
|
@ -32,10 +32,10 @@ class APP_EXPORT QgsMapToolMeasureAngle: public QgsMapTool
|
||||
~QgsMapToolMeasureAngle();
|
||||
|
||||
//! Mouse move event for overridingqgs
|
||||
void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Mouse release event for overriding
|
||||
void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! called when set as currently active map tool
|
||||
void activate() override;
|
||||
|
@ -21,9 +21,12 @@
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgstolerance.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QSettings>
|
||||
#include <limits>
|
||||
|
||||
QgsMapToolMoveFeature::QgsMapToolMoveFeature( QgsMapCanvas* canvas )
|
||||
: QgsMapToolEdit( canvas )
|
||||
, mRubberBand( 0 )
|
||||
@ -36,7 +39,7 @@ QgsMapToolMoveFeature::~QgsMapToolMoveFeature()
|
||||
delete mRubberBand;
|
||||
}
|
||||
|
||||
void QgsMapToolMoveFeature::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolMoveFeature::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( mRubberBand )
|
||||
{
|
||||
@ -49,7 +52,7 @@ void QgsMapToolMoveFeature::canvasMoveEvent( QMouseEvent * e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolMoveFeature::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolMoveFeature::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
delete mRubberBand;
|
||||
mRubberBand = 0;
|
||||
@ -137,7 +140,7 @@ void QgsMapToolMoveFeature::canvasPressEvent( QMouseEvent * e )
|
||||
|
||||
}
|
||||
|
||||
void QgsMapToolMoveFeature::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolMoveFeature::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
//QgsDebugMsg("entering.");
|
||||
if ( !mRubberBand )
|
||||
|
@ -27,11 +27,11 @@ class APP_EXPORT QgsMapToolMoveFeature: public QgsMapToolEdit
|
||||
QgsMapToolMoveFeature( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolMoveFeature();
|
||||
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! called when map tool is being deactivated
|
||||
void deactivate() override;
|
||||
|
@ -34,7 +34,7 @@ QgsMapToolMoveLabel::~QgsMapToolMoveLabel()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolMoveLabel::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolMoveLabel::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
deleteRubberBands();
|
||||
|
||||
@ -65,7 +65,7 @@ void QgsMapToolMoveLabel::canvasPressEvent( QMouseEvent * e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolMoveLabel::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolMoveLabel::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( mLabelRubberBand )
|
||||
{
|
||||
@ -81,7 +81,7 @@ void QgsMapToolMoveLabel::canvasMoveEvent( QMouseEvent * e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolMoveLabel::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolMoveLabel::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mLabelRubberBand )
|
||||
{
|
||||
|
@ -29,11 +29,11 @@ class APP_EXPORT QgsMapToolMoveLabel: public QgsMapToolLabel
|
||||
QgsMapToolMoveLabel( QgsMapCanvas* canvas );
|
||||
~QgsMapToolMoveLabel();
|
||||
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -47,7 +47,7 @@ QgsMapToolOffsetCurve::~QgsMapToolOffsetCurve()
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolOffsetCurve::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolOffsetCurve::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mCanvas )
|
||||
{
|
||||
@ -193,7 +193,7 @@ void QgsMapToolOffsetCurve::placeOffsetCurveToValue()
|
||||
setOffsetForRubberBand( mDistanceWidget->value() );
|
||||
}
|
||||
|
||||
void QgsMapToolOffsetCurve::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolOffsetCurve::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
delete mSnapVertexMarker;
|
||||
mSnapVertexMarker = 0;
|
||||
|
@ -31,8 +31,8 @@ class APP_EXPORT QgsMapToolOffsetCurve: public QgsMapToolEdit
|
||||
QgsMapToolOffsetCurve( QgsMapCanvas* canvas );
|
||||
~QgsMapToolOffsetCurve();
|
||||
|
||||
void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
private slots:
|
||||
/** Places curve offset to value entered in the spin box*/
|
||||
|
@ -46,7 +46,7 @@ QgsMapToolPinLabels::~QgsMapToolPinLabels()
|
||||
removePinnedHighlights();
|
||||
}
|
||||
|
||||
void QgsMapToolPinLabels::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolPinLabels::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
mSelectRect.setRect( 0, 0, 0, 0 );
|
||||
@ -55,7 +55,7 @@ void QgsMapToolPinLabels::canvasPressEvent( QMouseEvent * e )
|
||||
mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
|
||||
}
|
||||
|
||||
void QgsMapToolPinLabels::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolPinLabels::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->buttons() != Qt::LeftButton )
|
||||
return;
|
||||
@ -69,7 +69,7 @@ void QgsMapToolPinLabels::canvasMoveEvent( QMouseEvent * e )
|
||||
QgsMapToolSelectUtils::setRubberBand( mCanvas, mSelectRect, mRubberBand );
|
||||
}
|
||||
|
||||
void QgsMapToolPinLabels::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolPinLabels::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
//if the user simply clicked without dragging a rect
|
||||
//we will fabricate a small 1x1 pix rect and then continue
|
||||
|
@ -35,13 +35,13 @@ class APP_EXPORT QgsMapToolPinLabels: public QgsMapToolLabel
|
||||
~QgsMapToolPinLabels();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
bool isShowingPinned() const { return mShowPinned; }
|
||||
void setShowingPinned( bool showing ) { mShowPinned = showing; }
|
||||
|
@ -17,9 +17,12 @@
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
QgsMapToolReshape::QgsMapToolReshape( QgsMapCanvas* canvas ): QgsMapToolCapture( canvas, QgsMapToolCapture::CaptureLine )
|
||||
QgsMapToolReshape::QgsMapToolReshape( QgsMapCanvas* canvas )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CaptureLine )
|
||||
{
|
||||
}
|
||||
|
||||
@ -27,7 +30,7 @@ QgsMapToolReshape::~QgsMapToolReshape()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolReshape::canvasMapReleaseEvent( QgsMapMouseEvent * e )
|
||||
void QgsMapToolReshape::canvasReleaseEvent( QgsMapMouseEvent * e )
|
||||
{
|
||||
//check if we operate on a vector layer //todo: move this to a function in parent class to avoid duplication
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
|
@ -27,7 +27,7 @@ class APP_EXPORT QgsMapToolReshape: public QgsMapToolCapture
|
||||
public:
|
||||
QgsMapToolReshape( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolReshape();
|
||||
void canvasMapReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -146,7 +146,7 @@ QgsMapToolRotateFeature::~QgsMapToolRotateFeature()
|
||||
deleteRubberband();
|
||||
}
|
||||
|
||||
void QgsMapToolRotateFeature::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolRotateFeature::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( mRotationActive )
|
||||
{
|
||||
@ -167,7 +167,7 @@ void QgsMapToolRotateFeature::canvasMoveEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolRotateFeature::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
deleteRotationWidget();
|
||||
|
||||
|
@ -71,9 +71,9 @@ class APP_EXPORT QgsMapToolRotateFeature: public QgsMapToolEdit
|
||||
QgsMapToolRotateFeature( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolRotateFeature();
|
||||
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! called when map tool is being deactivated
|
||||
void deactivate() override;
|
||||
|
@ -44,7 +44,7 @@ QgsMapToolRotateLabel::~QgsMapToolRotateLabel()
|
||||
delete mRotationPreviewBox;
|
||||
}
|
||||
|
||||
void QgsMapToolRotateLabel::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapToolRotateLabel::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
deleteRubberBands();
|
||||
|
||||
@ -102,7 +102,7 @@ void QgsMapToolRotateLabel::canvasPressEvent( QMouseEvent *e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolRotateLabel::canvasMoveEvent( QMouseEvent *e )
|
||||
void QgsMapToolRotateLabel::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( mLabelRubberBand )
|
||||
{
|
||||
@ -139,7 +139,7 @@ void QgsMapToolRotateLabel::canvasMoveEvent( QMouseEvent *e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolRotateLabel::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolRotateLabel::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
|
||||
|
@ -29,9 +29,9 @@ class APP_EXPORT QgsMapToolRotateLabel: public QgsMapToolLabel
|
||||
QgsMapToolRotateLabel( QgsMapCanvas* canvas );
|
||||
~QgsMapToolRotateLabel();
|
||||
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -22,12 +22,20 @@
|
||||
#include "qgssymbolv2.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsdatadefined.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QMouseEvent>
|
||||
|
||||
QgsMapToolRotatePointSymbols::QgsMapToolRotatePointSymbols( QgsMapCanvas* canvas ): QgsMapToolEdit( canvas ),
|
||||
mActiveLayer( 0 ), mFeatureNumber( 0 ), mCurrentMouseAzimut( 0.0 ), mCurrentRotationFeature( 0.0 ),
|
||||
mRotating( false ), mRotationItem( 0 ), mCtrlPressed( false )
|
||||
QgsMapToolRotatePointSymbols::QgsMapToolRotatePointSymbols( QgsMapCanvas* canvas )
|
||||
: QgsMapToolEdit( canvas ),
|
||||
mActiveLayer( 0 ),
|
||||
mFeatureNumber( 0 ),
|
||||
mCurrentMouseAzimut( 0.0 ),
|
||||
mCurrentRotationFeature( 0.0 ),
|
||||
mRotating( false ),
|
||||
mRotationItem( 0 ),
|
||||
mCtrlPressed( false )
|
||||
{
|
||||
|
||||
}
|
||||
@ -62,7 +70,7 @@ bool QgsMapToolRotatePointSymbols::layerIsRotatable( QgsMapLayer* ml )
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsMapToolRotatePointSymbols::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapToolRotatePointSymbols::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mCanvas )
|
||||
{
|
||||
@ -172,7 +180,7 @@ void QgsMapToolRotatePointSymbols::canvasPressEvent( QMouseEvent *e )
|
||||
mRotating = true;
|
||||
}
|
||||
|
||||
void QgsMapToolRotatePointSymbols::canvasMoveEvent( QMouseEvent *e )
|
||||
void QgsMapToolRotatePointSymbols::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mRotating )
|
||||
{
|
||||
@ -217,7 +225,7 @@ void QgsMapToolRotatePointSymbols::canvasMoveEvent( QMouseEvent *e )
|
||||
setPixmapItemRotation( displayValue );
|
||||
}
|
||||
|
||||
void QgsMapToolRotatePointSymbols::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolRotatePointSymbols::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
|
||||
|
@ -31,9 +31,9 @@ class APP_EXPORT QgsMapToolRotatePointSymbols: public QgsMapToolEdit
|
||||
QgsMapToolRotatePointSymbols( QgsMapCanvas* canvas );
|
||||
~QgsMapToolRotatePointSymbols();
|
||||
|
||||
void canvasPressEvent( QMouseEvent * e ) override;
|
||||
void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
bool isEditTool() override {return true;}
|
||||
|
||||
|
@ -37,7 +37,7 @@ QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas* canvas )
|
||||
mBorderColour = QColor( 254, 58, 29, 100 );
|
||||
}
|
||||
|
||||
void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelect::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( mCanvas );
|
||||
if ( vlayer == NULL )
|
||||
|
@ -28,7 +28,7 @@ class APP_EXPORT QgsMapToolSelect : public QgsMapTool
|
||||
QgsMapToolSelect( QgsMapCanvas* canvas );
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
private:
|
||||
QColor mFillColor;
|
||||
|
@ -38,7 +38,7 @@ QgsMapToolSelectFreehand::~QgsMapToolSelectFreehand()
|
||||
delete mRubberBand;
|
||||
}
|
||||
|
||||
void QgsMapToolSelectFreehand::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelectFreehand::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->button() != Qt::LeftButton )
|
||||
{
|
||||
@ -55,7 +55,7 @@ void QgsMapToolSelectFreehand::canvasPressEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSelectFreehand::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelectFreehand::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mDragging || mRubberBand == NULL )
|
||||
{
|
||||
@ -65,7 +65,7 @@ void QgsMapToolSelectFreehand::canvasMoveEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSelectFreehand::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelectFreehand::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( mRubberBand == NULL )
|
||||
{
|
||||
|
@ -31,13 +31,13 @@ class APP_EXPORT QgsMapToolSelectFreehand : public QgsMapTool
|
||||
virtual ~QgsMapToolSelectFreehand();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -37,7 +37,7 @@ QgsMapToolSelectPolygon::~QgsMapToolSelectPolygon()
|
||||
delete mRubberBand;
|
||||
}
|
||||
|
||||
void QgsMapToolSelectPolygon::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelectPolygon::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( mRubberBand == NULL )
|
||||
{
|
||||
@ -63,7 +63,7 @@ void QgsMapToolSelectPolygon::canvasPressEvent( QMouseEvent * e )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolSelectPolygon::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelectPolygon::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( mRubberBand == NULL )
|
||||
{
|
||||
|
@ -31,10 +31,10 @@ class APP_EXPORT QgsMapToolSelectPolygon : public QgsMapTool
|
||||
virtual ~QgsMapToolSelectPolygon();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -44,7 +44,7 @@ QgsMapToolSelectRadius::~QgsMapToolSelectRadius()
|
||||
delete mRubberBand;
|
||||
}
|
||||
|
||||
void QgsMapToolSelectRadius::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelectRadius::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->button() != Qt::LeftButton )
|
||||
{
|
||||
@ -54,7 +54,7 @@ void QgsMapToolSelectRadius::canvasPressEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSelectRadius::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelectRadius::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->buttons() != Qt::LeftButton )
|
||||
{
|
||||
@ -75,7 +75,7 @@ void QgsMapToolSelectRadius::canvasMoveEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSelectRadius::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolSelectRadius::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->button() != Qt::LeftButton )
|
||||
{
|
||||
|
@ -33,13 +33,13 @@ class APP_EXPORT QgsMapToolSelectRadius : public QgsMapTool
|
||||
virtual ~QgsMapToolSelectRadius();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -42,7 +42,7 @@ QgsMapToolSelectFeatures::QgsMapToolSelectFeatures( QgsMapCanvas* canvas )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSelectFeatures::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapToolSelectFeatures::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
mSelectRect.setRect( 0, 0, 0, 0 );
|
||||
@ -53,7 +53,7 @@ void QgsMapToolSelectFeatures::canvasPressEvent( QMouseEvent *e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSelectFeatures::canvasMoveEvent( QMouseEvent *e )
|
||||
void QgsMapToolSelectFeatures::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->buttons() != Qt::LeftButton )
|
||||
return;
|
||||
@ -68,7 +68,7 @@ void QgsMapToolSelectFeatures::canvasMoveEvent( QMouseEvent *e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSelectFeatures::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapToolSelectFeatures::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( mCanvas );
|
||||
if ( vlayer == NULL )
|
||||
|
@ -35,13 +35,13 @@ class APP_EXPORT QgsMapToolSelectFeatures : public QgsMapTool
|
||||
QgsMapToolSelectFeatures( QgsMapCanvas* canvas );
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -40,7 +40,7 @@ QgsMapToolShowHideLabels::~QgsMapToolShowHideLabels()
|
||||
delete mRubberBand;
|
||||
}
|
||||
|
||||
void QgsMapToolShowHideLabels::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolShowHideLabels::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
mSelectRect.setRect( 0, 0, 0, 0 );
|
||||
@ -49,7 +49,7 @@ void QgsMapToolShowHideLabels::canvasPressEvent( QMouseEvent * e )
|
||||
mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
|
||||
}
|
||||
|
||||
void QgsMapToolShowHideLabels::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolShowHideLabels::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->buttons() != Qt::LeftButton )
|
||||
return;
|
||||
@ -63,7 +63,7 @@ void QgsMapToolShowHideLabels::canvasMoveEvent( QMouseEvent * e )
|
||||
QgsMapToolSelectUtils::setRubberBand( mCanvas, mSelectRect, mRubberBand );
|
||||
}
|
||||
|
||||
void QgsMapToolShowHideLabels::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolShowHideLabels::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
//if the user simply clicked without dragging a rect
|
||||
//we will fabricate a small 1x1 pix rect and then continue
|
||||
|
@ -32,13 +32,13 @@ class APP_EXPORT QgsMapToolShowHideLabels : public QgsMapToolLabel
|
||||
~QgsMapToolShowHideLabels();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "qgsrubberband.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgstolerance.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
@ -186,7 +187,7 @@ void QgsMapToolSimplify::storeSimplified()
|
||||
|
||||
|
||||
|
||||
void QgsMapToolSimplify::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolSimplify::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->button() != Qt::LeftButton )
|
||||
return;
|
||||
@ -204,7 +205,7 @@ void QgsMapToolSimplify::canvasPressEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSimplify::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolSimplify::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !( e->buttons() & Qt::LeftButton ) )
|
||||
return;
|
||||
@ -228,7 +229,7 @@ void QgsMapToolSimplify::canvasMoveEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolSimplify::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolSimplify::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( e->button() != Qt::LeftButton )
|
||||
return;
|
||||
|
@ -52,9 +52,9 @@ class APP_EXPORT QgsMapToolSimplify: public QgsMapToolEdit
|
||||
QgsMapToolSimplify( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolSimplify();
|
||||
|
||||
void canvasPressEvent( QMouseEvent * e ) override;
|
||||
void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! called when map tool is being deactivated
|
||||
void deactivate() override;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
QgsMapToolSplitFeatures::QgsMapToolSplitFeatures( QgsMapCanvas* canvas )
|
||||
: QgsMapToolCapture( canvas, QgsMapToolCapture::CaptureLine )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CaptureLine )
|
||||
{
|
||||
mToolName = tr( "Split features" );
|
||||
}
|
||||
@ -34,7 +34,7 @@ QgsMapToolSplitFeatures::~QgsMapToolSplitFeatures()
|
||||
|
||||
}
|
||||
|
||||
void QgsMapToolSplitFeatures::canvasMapReleaseEvent( QgsMapMouseEvent * e )
|
||||
void QgsMapToolSplitFeatures::canvasReleaseEvent( QgsMapMouseEvent * e )
|
||||
{
|
||||
//check if we operate on a vector layer
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
|
@ -26,7 +26,7 @@ class APP_EXPORT QgsMapToolSplitFeatures: public QgsMapToolCapture
|
||||
public:
|
||||
QgsMapToolSplitFeatures( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolSplitFeatures();
|
||||
void canvasMapReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
QgsMapToolSplitParts::QgsMapToolSplitParts( QgsMapCanvas* canvas )
|
||||
: QgsMapToolCapture( canvas, QgsMapToolCapture::CaptureLine )
|
||||
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CaptureLine )
|
||||
{
|
||||
mToolName = tr( "Split parts" );
|
||||
}
|
||||
@ -34,7 +34,7 @@ QgsMapToolSplitParts::~QgsMapToolSplitParts()
|
||||
|
||||
}
|
||||
|
||||
void QgsMapToolSplitParts::canvasMapReleaseEvent( QgsMapMouseEvent * e )
|
||||
void QgsMapToolSplitParts::canvasReleaseEvent( QgsMapMouseEvent * e )
|
||||
{
|
||||
//check if we operate on a vector layer
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
|
@ -26,7 +26,7 @@ class QgsMapToolSplitParts: public QgsMapToolCapture
|
||||
public:
|
||||
QgsMapToolSplitParts( QgsMapCanvas* canvas );
|
||||
virtual ~QgsMapToolSplitParts();
|
||||
void canvasMapReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent * e ) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -133,12 +133,12 @@ void QgsMeasureTool::updateSettings()
|
||||
|
||||
//////////////////////////
|
||||
|
||||
void QgsMeasureTool::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMeasureTool::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMeasureTool::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMeasureTool::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( ! mDone )
|
||||
{
|
||||
@ -150,7 +150,7 @@ void QgsMeasureTool::canvasMoveEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
|
||||
void QgsMeasureTool::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMeasureTool::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsPoint point = snapPoint( e->pos() );
|
||||
|
||||
|
@ -54,13 +54,13 @@ class APP_EXPORT QgsMeasureTool : public QgsMapTool
|
||||
// Inherited from QgsMapTool
|
||||
|
||||
//! Mouse move event for overriding
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Mouse press event for overriding
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Mouse release event for overriding
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! called when set as currently active map tool
|
||||
virtual void activate() override;
|
||||
|
@ -125,6 +125,8 @@ SET(QGIS_GUI_SRCS
|
||||
qgisinterface.cpp
|
||||
qgsannotationitem.cpp
|
||||
qgsactionmenu.cpp
|
||||
qgsadvanceddigitizingcanvasitem.cpp
|
||||
qgsadvanceddigitizingdockwidget.cpp
|
||||
qgsattributedialog.cpp
|
||||
qgsattributeeditor.cpp
|
||||
qgsattributeform.cpp
|
||||
@ -193,9 +195,13 @@ SET(QGIS_GUI_SRCS
|
||||
qgsmaplayercombobox.cpp
|
||||
qgsmaplayermodel.cpp
|
||||
qgsmaplayerproxymodel.cpp
|
||||
qgsmapmouseevent.cpp
|
||||
qgsmapoverviewcanvas.cpp
|
||||
qgsmaptip.cpp
|
||||
qgsmaptool.cpp
|
||||
qgsmaptooladvanceddigitizing.cpp
|
||||
qgsmaptoolcapture.cpp
|
||||
qgsmaptooledit.cpp
|
||||
qgsmaptoolemitpoint.cpp
|
||||
qgsmaptoolidentify.cpp
|
||||
qgsmaptoolidentifyfeature.cpp
|
||||
@ -260,6 +266,7 @@ ENDIF (WITH_TOUCH)
|
||||
SET(QGIS_GUI_MOC_HDRS
|
||||
qgisinterface.h
|
||||
qgsactionmenu.h
|
||||
qgsadvanceddigitizingdockwidget.h
|
||||
qgsattributedialog.h
|
||||
qgsattributeeditor.h
|
||||
qgsattributeform.h
|
||||
@ -318,11 +325,16 @@ SET(QGIS_GUI_MOC_HDRS
|
||||
qgsmaplayermodel.h
|
||||
qgsmaplayerproxymodel.h
|
||||
qgsmapoverviewcanvas.h
|
||||
qgsmaptoolemitpoint.h
|
||||
qgsmaptool.h
|
||||
qgsmaptoolidentifyfeature.h
|
||||
qgsmaptooladvanceddigitizing.h
|
||||
qgsmaptoolcapture.h
|
||||
qgsmaptooledit.h
|
||||
qgsmaptoolemitpoint.h
|
||||
qgsmaptoolidentify.h
|
||||
qgsmaptoolidentifyfeature.h
|
||||
qgsmaptoolpan.h
|
||||
qgsmaptoolpan.h
|
||||
qgsmaptoolzoom.h
|
||||
qgsmaptoolzoom.h
|
||||
qgsmessagebar.h
|
||||
qgsmessagebaritem.h
|
||||
@ -500,8 +512,6 @@ SET(QGIS_GUI_HDRS
|
||||
qgsmapcanvassnapper.h
|
||||
qgsmapcanvassnappingutils.h
|
||||
qgsmaptip.h
|
||||
qgsmaptoolpan.h
|
||||
qgsmaptoolzoom.h
|
||||
qgsnumericsortlistviewitem.h
|
||||
qgsrubberband.h
|
||||
qgssvgannotationitem.h
|
||||
|
@ -14,10 +14,10 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <QSettings>
|
||||
#include <QMenu>
|
||||
|
||||
#include "math.h"
|
||||
|
||||
#include "qgisapp.h"
|
||||
#include "qgsadvanceddigitizingdockwidget.h"
|
||||
#include "qgsadvanceddigitizingcanvasitem.h"
|
||||
#include "qgsapplication.h"
|
||||
@ -28,7 +28,12 @@
|
||||
#include "qgsmaptooladvanceddigitizing.h"
|
||||
#include "qgsmessagebaritem.h"
|
||||
#include "qgspoint.h"
|
||||
#include "qgslinestringv2.h"
|
||||
|
||||
struct EdgesOnlyFilter : public QgsPointLocator::MatchFilter
|
||||
{
|
||||
bool acceptMatch( const QgsPointLocator::Match& m ) override { return m.hasEdge(); }
|
||||
};
|
||||
|
||||
bool QgsAdvancedDigitizingDockWidget::lineCircleIntersection( const QgsPoint& center, const double radius, const QList<QgsPoint>& segment, QgsPoint& intersection )
|
||||
{
|
||||
@ -80,17 +85,15 @@ bool QgsAdvancedDigitizingDockWidget::lineCircleIntersection( const QgsPoint& ce
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas* canvas, QWidget *parent )
|
||||
: QDockWidget( parent )
|
||||
, mMapCanvas( canvas )
|
||||
, mMapToolList( QList<QgsMapToolAdvancedDigitizing*>() )
|
||||
, mCurrentMapTool( 0 )
|
||||
, mCadEnabled( false )
|
||||
, mConstructionMode( false )
|
||||
, mSnappingMode(( QgsMapMouseEvent::SnappingMode ) QSettings().value( "/Cad/SnappingMode", ( int )QgsMapMouseEvent::SnapProjectConfig ).toInt() )
|
||||
, mSnappingMode(( QgsMapMouseEvent::SnappingMode ) QSettings().value( "/Cad/SnappingMode", QgsMapMouseEvent::SnapProjectConfig ).toInt() )
|
||||
, mCommonAngleConstraint( QSettings().value( "/Cad/CommonAngle", 90 ).toInt() )
|
||||
, mCadPointList( QList<QgsPoint>() )
|
||||
, mSnappedToVertex( false )
|
||||
, mSnappedSegment( QList<QgsPoint>() )
|
||||
, mErrorMessage( 0 )
|
||||
{
|
||||
@ -104,6 +107,7 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas*
|
||||
mYConstraint = new CadConstraint( mYLineEdit, mLockYButton, mRelativeYButton ) ;
|
||||
mAdditionalConstraint = NoConstraint ;
|
||||
|
||||
mMapCanvas->installEventFilter( this );
|
||||
mAngleLineEdit->installEventFilter( this );
|
||||
mDistanceLineEdit->installEventFilter( this );
|
||||
mXLineEdit->installEventFilter( this );
|
||||
@ -117,9 +121,6 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas*
|
||||
mEnabledButton->addAction( mEnableAction );
|
||||
mEnabledButton->setDefaultAction( mEnableAction );
|
||||
|
||||
// enable/disable on map tool change
|
||||
connect( canvas, SIGNAL( mapToolSet( QgsMapTool* ) ), this, SLOT( mapToolChanged( QgsMapTool* ) ) );
|
||||
|
||||
// Connect the UI to the event filter to update constraints
|
||||
connect( mEnableAction, SIGNAL( triggered( bool ) ), this, SLOT( activateCad( bool ) ) );
|
||||
connect( mConstructionModeButton, SIGNAL( clicked( bool ) ), this, SLOT( setConstructionMode( bool ) ) );
|
||||
@ -137,8 +138,6 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas*
|
||||
connect( mXLineEdit, SIGNAL( returnPressed() ), this, SLOT( lockConstraint() ) );
|
||||
connect( mYLineEdit, SIGNAL( returnPressed() ), this, SLOT( lockConstraint() ) );
|
||||
|
||||
mapToolChanged( NULL );
|
||||
|
||||
// config menu
|
||||
QMenu *menu = new QMenu( this );
|
||||
// common angles
|
||||
@ -182,16 +181,6 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas*
|
||||
updateCapacity( true );
|
||||
}
|
||||
|
||||
QgsAdvancedDigitizingDockWidget::~QgsAdvancedDigitizingDockWidget()
|
||||
{
|
||||
delete mErrorMessage;
|
||||
delete mAngleConstraint;
|
||||
delete mDistanceConstraint;
|
||||
delete mXConstraint;
|
||||
delete mYConstraint;
|
||||
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::hideEvent( QHideEvent* )
|
||||
{
|
||||
// disable CAD but do not unset map event filter
|
||||
@ -199,60 +188,6 @@ void QgsAdvancedDigitizingDockWidget::hideEvent( QHideEvent* )
|
||||
setCadEnabled( false );
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::mapToolChanged( QgsMapTool* tool )
|
||||
{
|
||||
QgsMapToolAdvancedDigitizing* toolMap = dynamic_cast<QgsMapToolAdvancedDigitizing*>( tool );
|
||||
mCurrentMapTool = 0;
|
||||
QString lblText;
|
||||
if ( !tool )
|
||||
{
|
||||
lblText = tr( "No map tool set" );
|
||||
}
|
||||
else if ( !toolMap || !toolMap->cadAllowed() )
|
||||
{
|
||||
lblText = tr( "CAD tools are not enabled for the current map tool" );
|
||||
QString toolName = tool->toolName();
|
||||
if ( !toolName.isEmpty() )
|
||||
{
|
||||
lblText.append( QString( " (%1)" ).arg( toolName ) );
|
||||
}
|
||||
}
|
||||
else if ( mMapCanvas->mapSettings().destinationCrs().geographicFlag() )
|
||||
{
|
||||
lblText = tr( "CAD tools can not be used on geographic coordinates. Change the coordinates system in the project properties." );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentMapTool = toolMap;
|
||||
}
|
||||
|
||||
if ( mCurrentMapTool )
|
||||
{
|
||||
mEnableAction->setEnabled( true );
|
||||
mErrorLabel->hide();
|
||||
mCadWidget->show();
|
||||
setMaximumSize( 5000, 220 );
|
||||
|
||||
// restore previous status
|
||||
const bool enabled = QSettings().value( "/Cad/SessionActive", false ).toBool();
|
||||
if ( enabled && !isVisible() )
|
||||
{
|
||||
show();
|
||||
}
|
||||
setCadEnabled( enabled );
|
||||
}
|
||||
else
|
||||
{
|
||||
mEnableAction->setEnabled( false );
|
||||
mErrorLabel->setText( lblText );
|
||||
mErrorLabel->show();
|
||||
mCadWidget->hide();
|
||||
setMaximumSize( 5000, 80 );
|
||||
|
||||
setCadEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled )
|
||||
{
|
||||
mCadEnabled = enabled;
|
||||
@ -267,14 +202,9 @@ void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled )
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::activateCad( bool enabled )
|
||||
{
|
||||
enabled &= mCurrentMapTool != 0;
|
||||
enabled &= mCurrentMapToolSupportsCad;
|
||||
|
||||
if ( mErrorMessage )
|
||||
{
|
||||
QgisApp::instance()->messageBar()->popWidget( mErrorMessage );
|
||||
mErrorMessage = 0;
|
||||
}
|
||||
QSettings().setValue( "/Cad/SessionActive", enabled );
|
||||
mSessionActive = enabled;
|
||||
|
||||
if ( enabled && !isVisible() )
|
||||
{
|
||||
@ -315,7 +245,6 @@ void QgsAdvancedDigitizingDockWidget::setConstraintRelative( bool activate )
|
||||
{
|
||||
mYConstraint->setRelative( activate );
|
||||
}
|
||||
triggerMouseMoveEvent();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::setConstructionMode( bool enabled )
|
||||
@ -359,7 +288,8 @@ void QgsAdvancedDigitizingDockWidget::releaseLocks()
|
||||
mYConstraint->setLockMode( CadConstraint::NoLock );
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::triggerMouseMoveEvent()
|
||||
#if 0
|
||||
void QgsAdvancedDigitizingDockWidget::emit pointChanged()
|
||||
{
|
||||
// run a fake map mouse event to update the paint item
|
||||
QPoint globalPos = mMapCanvas->cursor().pos();
|
||||
@ -367,6 +297,7 @@ void QgsAdvancedDigitizingDockWidget::triggerMouseMoveEvent()
|
||||
QMouseEvent* e = new QMouseEvent( QEvent::MouseMove, pos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier );
|
||||
mCurrentMapTool->canvasMoveEvent( e );
|
||||
}
|
||||
#endif
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default true */ )
|
||||
{
|
||||
@ -436,7 +367,7 @@ void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default t
|
||||
}
|
||||
|
||||
// run a fake map mouse event to update the paint item
|
||||
triggerMouseMoveEvent();
|
||||
emit pointChanged( mCadPointList.value( 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,8 +454,8 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent* e )
|
||||
QgsDebugMsg( QString( "Y: %1 %2 %3" ).arg( mYConstraint->isLocked() ).arg( mYConstraint->relative() ).arg( mYConstraint->value() ) );
|
||||
|
||||
QgsPoint point = e->mapPoint();
|
||||
mSnappedToVertex = e->isSnappedToVertex();
|
||||
mSnappedSegment = e->snapSegment();
|
||||
|
||||
mSnappedSegment = e->snapSegment( mSnappingMode );
|
||||
|
||||
bool previousPointExist, penulPointExist;
|
||||
QgsPoint previousPt = previousPoint( &previousPointExist );
|
||||
@ -757,8 +688,10 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent* e )
|
||||
QgsDebugMsg( QString( "penultimate point: %1 %2" ).arg( penultimatePt.x() ).arg( penultimatePt.y() ) );
|
||||
//QgsDebugMsg( QString( "dx: %1 dy: %2" ).arg( point.x() - previousPt.x() ).arg( point.y() - previousPt.y() ) );
|
||||
//QgsDebugMsg( QString( "ddx: %1 ddy: %2" ).arg( previousPt.x() - penultimatePt.x() ).arg( previousPt.y() - penultimatePt.y() ) );
|
||||
|
||||
// set the point coordinates in the map event
|
||||
e->setPoint( point );
|
||||
e->setMapPoint( point );
|
||||
|
||||
// update the point list
|
||||
updateCurrentPoint( point );
|
||||
|
||||
@ -825,7 +758,7 @@ bool QgsAdvancedDigitizingDockWidget::alignToSegment( QgsMapMouseEvent* e, CadCo
|
||||
bool previousPointExist, penulPointExist, mSnappedSegmentExist;
|
||||
QgsPoint previousPt = previousPoint( &previousPointExist );
|
||||
QgsPoint penultimatePt = penultimatePoint( &penulPointExist );
|
||||
QList<QgsPoint> mSnappedSegment = e->snapSegment( &mSnappedSegmentExist, true );
|
||||
QList<QgsPoint> mSnappedSegment = e->snapSegment( mSnappingMode, &mSnappedSegmentExist, true );
|
||||
|
||||
if ( !previousPointExist || !mSnappedSegmentExist )
|
||||
{
|
||||
@ -856,22 +789,18 @@ bool QgsAdvancedDigitizingDockWidget::alignToSegment( QgsMapMouseEvent* e, CadCo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsAdvancedDigitizingDockWidget::canvasPressEventFilter( QgsMapMouseEvent* e )
|
||||
bool QgsAdvancedDigitizingDockWidget::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
applyConstraints( e );
|
||||
return mCadEnabled && mConstructionMode;
|
||||
}
|
||||
|
||||
bool QgsAdvancedDigitizingDockWidget::canvasReleaseEventFilter( QgsMapMouseEvent* e )
|
||||
bool QgsAdvancedDigitizingDockWidget::canvasReleaseEvent( QgsMapMouseEvent* e, bool captureSegment )
|
||||
{
|
||||
if ( !mCadEnabled )
|
||||
return false;
|
||||
|
||||
if ( mErrorMessage )
|
||||
{
|
||||
QgisApp::instance()->messageBar()->popWidget( mErrorMessage );
|
||||
mErrorMessage = 0;
|
||||
}
|
||||
emit popWarning();
|
||||
|
||||
if ( e->button() == Qt::RightButton )
|
||||
{
|
||||
@ -885,7 +814,7 @@ bool QgsAdvancedDigitizingDockWidget::canvasReleaseEventFilter( QgsMapMouseEvent
|
||||
if ( alignToSegment( e ) )
|
||||
{
|
||||
// launch a fake move event so rubber bands of map tools will be adapted with new constraints
|
||||
mCurrentMapTool->canvasMoveEvent( e );
|
||||
// emit pointChanged( e );
|
||||
|
||||
// Parallel or perpendicular mode and snapped to segment
|
||||
// this has emitted the lockAngle signal
|
||||
@ -899,9 +828,7 @@ bool QgsAdvancedDigitizingDockWidget::canvasReleaseEventFilter( QgsMapMouseEvent
|
||||
if ( e->button() == Qt::LeftButton )
|
||||
{
|
||||
// stop digitizing if not intermediate point and if line or polygon
|
||||
if ( !mConstructionMode &&
|
||||
( e->mapTool()->mode() == QgsMapToolCapture::CaptureNone ||
|
||||
e->mapTool()->mode() == QgsMapToolCapture::CapturePoint ) )
|
||||
if ( !mConstructionMode && !captureSegment )
|
||||
{
|
||||
clearPoints();
|
||||
}
|
||||
@ -909,27 +836,18 @@ bool QgsAdvancedDigitizingDockWidget::canvasReleaseEventFilter( QgsMapMouseEvent
|
||||
return mConstructionMode;
|
||||
}
|
||||
|
||||
bool QgsAdvancedDigitizingDockWidget::canvasMoveEventFilter( QgsMapMouseEvent* e )
|
||||
bool QgsAdvancedDigitizingDockWidget::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mCadEnabled )
|
||||
return false;
|
||||
|
||||
if ( !applyConstraints( e ) )
|
||||
{
|
||||
if ( !mErrorMessage )
|
||||
{
|
||||
// errors messages
|
||||
mErrorMessage = new QgsMessageBarItem( tr( "CAD tools" ),
|
||||
tr( "Some constraints are incompatible. Resulting point might be incorrect." ),
|
||||
QgsMessageBar::WARNING, 0 );
|
||||
|
||||
QgisApp::instance()->messageBar()->pushItem( mErrorMessage );
|
||||
}
|
||||
emit pushWarning( tr( "Some constraints are incompatible. Resulting point might be incorrect." ) );
|
||||
}
|
||||
else if ( mErrorMessage )
|
||||
else
|
||||
{
|
||||
QgisApp::instance()->messageBar()->popWidget( mErrorMessage );
|
||||
mErrorMessage = 0;
|
||||
popWarning();
|
||||
}
|
||||
|
||||
// perpendicular/parallel constraint
|
||||
@ -971,6 +889,12 @@ bool QgsAdvancedDigitizingDockWidget::canvasKeyPressEventFilter( QKeyEvent* e )
|
||||
return false;
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::clear()
|
||||
{
|
||||
clearPoints();
|
||||
releaseLocks();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::keyPressEvent( QKeyEvent *e )
|
||||
{
|
||||
// event on dock (this)
|
||||
@ -1025,14 +949,14 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent* e )
|
||||
if ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier )
|
||||
{
|
||||
mXConstraint->toggleLocked();
|
||||
triggerMouseMoveEvent();
|
||||
emit pointChanged( mCadPointList.value( 0 ) );
|
||||
}
|
||||
else if ( e->modifiers() == Qt::ShiftModifier )
|
||||
{
|
||||
if ( mCapacities.testFlag( RelativeCoordinates ) )
|
||||
{
|
||||
mXConstraint->toggleRelative();
|
||||
triggerMouseMoveEvent();
|
||||
emit pointChanged( mCadPointList.value( 0 ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1047,14 +971,14 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent* e )
|
||||
if ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier )
|
||||
{
|
||||
mYConstraint->toggleLocked();
|
||||
triggerMouseMoveEvent();
|
||||
emit pointChanged( mCadPointList.value( 0 ) );
|
||||
}
|
||||
else if ( e->modifiers() == Qt::ShiftModifier )
|
||||
{
|
||||
if ( mCapacities.testFlag( RelativeCoordinates ) )
|
||||
{
|
||||
mYConstraint->toggleRelative();
|
||||
triggerMouseMoveEvent();
|
||||
emit pointChanged( mCadPointList.value( 0 ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1071,7 +995,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent* e )
|
||||
if ( mCapacities.testFlag( AbsoluteAngle ) )
|
||||
{
|
||||
mAngleConstraint->toggleLocked();
|
||||
triggerMouseMoveEvent();
|
||||
emit pointChanged( mCadPointList.value( 0 ) );
|
||||
}
|
||||
}
|
||||
else if ( e->modifiers() == Qt::ShiftModifier )
|
||||
@ -1079,7 +1003,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent* e )
|
||||
if ( mCapacities.testFlag( RelativeAngle ) )
|
||||
{
|
||||
mAngleConstraint->toggleRelative();
|
||||
triggerMouseMoveEvent();
|
||||
emit pointChanged( mCadPointList.value( 0 ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1096,7 +1020,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent* e )
|
||||
if ( mCapacities.testFlag( RelativeCoordinates ) )
|
||||
{
|
||||
mDistanceConstraint->toggleLocked();
|
||||
triggerMouseMoveEvent();
|
||||
emit pointChanged( mCadPointList.value( 0 ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1138,34 +1062,43 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent* e )
|
||||
return true; // stop the event
|
||||
}
|
||||
|
||||
QgsPoint QgsAdvancedDigitizingDockWidget::currentPoint( bool* exist ) const
|
||||
void QgsAdvancedDigitizingDockWidget::enable()
|
||||
{
|
||||
if ( exist )
|
||||
*exist = pointsCount() > 0;
|
||||
if ( pointsCount() > 0 )
|
||||
return mCadPointList.at( 0 );
|
||||
if ( mMapCanvas->mapSettings().destinationCrs().geographicFlag() )
|
||||
{
|
||||
mErrorLabel->setText( tr( "CAD tools can not be used on geographic coordinates. Change the coordinates system in the project properties." ) );
|
||||
mErrorLabel->show();
|
||||
mEnableAction->setEnabled( false );
|
||||
setCadEnabled( false );
|
||||
}
|
||||
else
|
||||
return QgsPoint();
|
||||
{
|
||||
mEnableAction->setEnabled( true );
|
||||
mErrorLabel->hide();
|
||||
mCadWidget->show();
|
||||
setMaximumHeight( 220 );
|
||||
|
||||
mCurrentMapToolSupportsCad = true;
|
||||
|
||||
if ( mSessionActive && !isVisible() )
|
||||
{
|
||||
show();
|
||||
}
|
||||
setCadEnabled( mSessionActive );
|
||||
}
|
||||
}
|
||||
|
||||
QgsPoint QgsAdvancedDigitizingDockWidget::previousPoint( bool* exist ) const
|
||||
void QgsAdvancedDigitizingDockWidget::disable()
|
||||
{
|
||||
if ( exist )
|
||||
*exist = pointsCount() > 1;
|
||||
if ( pointsCount() > 1 )
|
||||
return mCadPointList.at( 1 );
|
||||
else
|
||||
return QgsPoint();
|
||||
}
|
||||
mEnableAction->setEnabled( false );
|
||||
mErrorLabel->setText( tr( "CAD tools are not enabled for the current map tool" ) );
|
||||
mErrorLabel->show();
|
||||
mCadWidget->hide();
|
||||
setMaximumHeight( 80 );
|
||||
|
||||
QgsPoint QgsAdvancedDigitizingDockWidget::penultimatePoint( bool* exist ) const
|
||||
{
|
||||
if ( exist )
|
||||
*exist = pointsCount() > 2;
|
||||
if ( pointsCount() > 2 )
|
||||
return mCadPointList.at( 2 );
|
||||
else
|
||||
return QgsPoint();
|
||||
mCurrentMapToolSupportsCad = false;
|
||||
|
||||
setCadEnabled( false );
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingDockWidget::addPoint( QgsPoint point )
|
||||
@ -1250,3 +1183,33 @@ void QgsAdvancedDigitizingDockWidget::CadConstraint::toggleRelative()
|
||||
{
|
||||
setRelative( mRelative ? false : true );
|
||||
}
|
||||
|
||||
QgsPoint QgsAdvancedDigitizingDockWidget::currentPoint( bool* exist ) const
|
||||
{
|
||||
if ( exist )
|
||||
*exist = pointsCount() > 0;
|
||||
if ( pointsCount() > 0 )
|
||||
return mCadPointList.value( 0 );
|
||||
else
|
||||
return QgsPoint();
|
||||
}
|
||||
|
||||
QgsPoint QgsAdvancedDigitizingDockWidget::previousPoint( bool* exist ) const
|
||||
{
|
||||
if ( exist )
|
||||
*exist = pointsCount() > 1;
|
||||
if ( pointsCount() > 1 )
|
||||
return mCadPointList.value( 1 );
|
||||
else
|
||||
return QgsPoint();
|
||||
}
|
||||
|
||||
QgsPoint QgsAdvancedDigitizingDockWidget::penultimatePoint( bool* exist ) const
|
||||
{
|
||||
if ( exist )
|
||||
*exist = pointsCount() > 2;
|
||||
if ( pointsCount() > 2 )
|
||||
return mCadPointList.value( 2 );
|
||||
else
|
||||
return QgsPoint();
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "qgsmapmouseevent.h"
|
||||
#include "qgsmessagebaritem.h"
|
||||
|
||||
#include <ui_qgsadvanceddigitizingdockwidgetbase.h>
|
||||
|
||||
@ -27,7 +28,6 @@ class QgsAdvancedDigitizingCanvasItem;
|
||||
class QgsMapCanvas;
|
||||
class QgsMapTool;
|
||||
class QgsMapToolAdvancedDigitizing;
|
||||
class QgsMessageBarItem;
|
||||
class QgsPoint;
|
||||
|
||||
// tolerances for soft constraints (last values, and common angles)
|
||||
@ -41,12 +41,13 @@ static const double SoftConstraintToleranceDegrees = 10;
|
||||
* It handles both the UI and the constraints. Constraints are applied
|
||||
* by implemeting filters called from QgsMapToolAdvancedDigitizing.
|
||||
*/
|
||||
class APP_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private Ui::QgsAdvancedDigitizingDockWidgetBase
|
||||
class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private Ui::QgsAdvancedDigitizingDockWidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_FLAGS( CadCapacities )
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief The CadCapacity enum defines the possible constraints to be set
|
||||
* depending on the number of points in the CAD point list (the list of points
|
||||
@ -91,12 +92,12 @@ class APP_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private U
|
||||
, mValue( 0.0 )
|
||||
{}
|
||||
|
||||
LockMode lockMode() const { return mLockMode;}
|
||||
bool isLocked() const {return mLockMode != NoLock;}
|
||||
bool relative() const {return mRelative;}
|
||||
double value() const {return mValue;}
|
||||
LockMode lockMode() const { return mLockMode; }
|
||||
bool isLocked() const { return mLockMode != NoLock; }
|
||||
bool relative() const { return mRelative; }
|
||||
double value() const { return mValue; }
|
||||
|
||||
QLineEdit* lineEdit() const {return mLineEdit;}
|
||||
QLineEdit* lineEdit() const { return mLineEdit; }
|
||||
|
||||
void setLockMode( LockMode mode );
|
||||
void setRelative( bool relative );
|
||||
@ -120,16 +121,20 @@ class APP_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private U
|
||||
|
||||
explicit QgsAdvancedDigitizingDockWidget( QgsMapCanvas* canvas, QWidget *parent = 0 );
|
||||
|
||||
~QgsAdvancedDigitizingDockWidget();
|
||||
|
||||
void hideEvent( QHideEvent* ) override;
|
||||
|
||||
virtual bool canvasPressEventFilter( QgsMapMouseEvent* e );
|
||||
virtual bool canvasReleaseEventFilter( QgsMapMouseEvent* e );
|
||||
virtual bool canvasMoveEventFilter( QgsMapMouseEvent* e );
|
||||
virtual bool canvasKeyPressEventFilter( QKeyEvent *e );
|
||||
bool canvasPressEvent( QgsMapMouseEvent* e );
|
||||
bool canvasReleaseEvent( QgsMapMouseEvent* e , bool captureSegment );
|
||||
bool canvasMoveEvent( QgsMapMouseEvent* e );
|
||||
bool canvasKeyPressEventFilter( QKeyEvent *e );
|
||||
|
||||
QgsMapMouseEvent::SnappingMode snappingMode() {return mSnappingMode;}
|
||||
//! apply the CAD constraints. The will modify the position of the map event in map coordinates by applying the CAD constraints.
|
||||
//! @return false if no solution was found (invalid constraints)
|
||||
virtual bool applyConstraints( QgsMapMouseEvent* e );
|
||||
|
||||
void clear();
|
||||
|
||||
QgsMapMouseEvent::SnappingMode snappingMode() { return mSnappingMode; }
|
||||
|
||||
//! key press event on the dock
|
||||
void keyPressEvent( QKeyEvent* e ) override;
|
||||
@ -138,32 +143,39 @@ class APP_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private U
|
||||
bool cadEnabled() const { return mCadEnabled; }
|
||||
|
||||
//! construction mode is used to draw intermediate points. These points won't be given any further (i.e. to the map tools)
|
||||
bool constructionMode() const {return mConstructionMode;}
|
||||
bool constructionMode() const { return mConstructionMode; }
|
||||
|
||||
//! Additional constraints are used to place perpendicular/parallel segments to snapped segments on the canvas
|
||||
AdditionalConstraint additionalConstraint() const {return mAdditionalConstraint;}
|
||||
const CadConstraint* constraintAngle()const {return mAngleConstraint;}
|
||||
const CadConstraint* constraintDistance() const {return mDistanceConstraint;}
|
||||
const CadConstraint* constraintX() const {return mXConstraint;}
|
||||
const CadConstraint* constraintY() const {return mYConstraint;}
|
||||
bool commonAngleConstraint() const {return mCommonAngleConstraint;}
|
||||
AdditionalConstraint additionalConstraint() const { return mAdditionalConstraint; }
|
||||
const CadConstraint* constraintAngle()const { return mAngleConstraint; }
|
||||
const CadConstraint* constraintDistance() const { return mDistanceConstraint; }
|
||||
const CadConstraint* constraintX() const { return mXConstraint; }
|
||||
const CadConstraint* constraintY() const { return mYConstraint; }
|
||||
bool commonAngleConstraint() const { return mCommonAngleConstraint; }
|
||||
|
||||
/** Helpers for the CAD point list. The CAD point list is the list of points
|
||||
* currently digitized. It contains both "normal" points and intermediate points (construction mode).
|
||||
*/
|
||||
QgsPoint currentPoint( bool *exist = 0 ) const;
|
||||
QgsPoint previousPoint( bool *exist = 0 ) const;
|
||||
QgsPoint penultimatePoint( bool *exist = 0 ) const;
|
||||
int pointsCount() const {return mCadPointList.count();}
|
||||
bool snappedToVertex() const {return mSnappedToVertex;}
|
||||
const QList<QgsPoint>& snappedSegment() const {return mSnappedSegment;}
|
||||
QgsPoint currentPoint( bool* exists = 0 ) const;
|
||||
QgsPoint previousPoint( bool* exists = 0 ) const;
|
||||
QgsPoint penultimatePoint( bool* exists = 0 ) const;
|
||||
inline int pointsCount() const { return mCadPointList.count(); }
|
||||
inline bool snappedToVertex() const { return mSnappedToVertex; }
|
||||
const QList<QgsPoint>& snappedSegment() const { return mSnappedSegment; }
|
||||
|
||||
//! return the action used to enable/disable the tools
|
||||
QAction* enableAction() { return mEnableAction; }
|
||||
|
||||
public slots:
|
||||
//! whenever a map tool changes, determines if the dock shall be activated or not
|
||||
void mapToolChanged( QgsMapTool* tool );
|
||||
void enable();
|
||||
|
||||
void disable();
|
||||
|
||||
signals:
|
||||
void pushWarning( const QString& message );
|
||||
|
||||
void popWarning();
|
||||
|
||||
void pointChanged( const QgsPoint& point );
|
||||
|
||||
private slots:
|
||||
//! set the additiona constraint by clicking on the perpendicular/parallel buttons
|
||||
@ -178,7 +190,7 @@ class APP_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private U
|
||||
//! set the relative properties of constraints
|
||||
void setConstraintRelative( bool activate );
|
||||
|
||||
//! activate/deactuvate tools. It is called when tools are activated manually (from the GUI)
|
||||
//! activate/deactivate tools. It is called when tools are activated manually (from the GUI)
|
||||
//! it will call setCadEnabled to properly update the UI.
|
||||
void activateCad( bool enabled );
|
||||
|
||||
@ -201,9 +213,7 @@ class APP_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private U
|
||||
//! defines the additional constraint to be used (no/parallel/perpendicular)
|
||||
void lockAdditionalConstraint( AdditionalConstraint constraint );
|
||||
|
||||
//! apply the CAD constraints. The will modify the position of the map event in map coordinates by applying the CAD constraints.
|
||||
//! @return false if no solution was found (invalid constraints)
|
||||
virtual bool applyConstraints( QgsMapMouseEvent* e );
|
||||
QList<QgsPoint> snapSegment( const QgsPointLocator::Match& snapMatch );
|
||||
|
||||
//! align to segment for additional constraint.
|
||||
//! If additional constraints are used, this will determine the angle to be locked depending on the snapped segment.
|
||||
@ -228,14 +238,15 @@ class APP_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private U
|
||||
//! trigger fake mouse move event to update map tool rubber band and/or show new constraints
|
||||
void triggerMouseMoveEvent();
|
||||
|
||||
|
||||
|
||||
QgsMapCanvas* mMapCanvas;
|
||||
QgsAdvancedDigitizingCanvasItem* mCadPaintItem;
|
||||
|
||||
QList<QgsMapToolAdvancedDigitizing*> mMapToolList;
|
||||
QgsMapToolAdvancedDigitizing* mCurrentMapTool;
|
||||
|
||||
CadCapacities mCapacities;
|
||||
|
||||
bool mCurrentMapToolSupportsCad;
|
||||
|
||||
// CAD properties
|
||||
//! is CAD currently enabled for current map tool
|
||||
bool mCadEnabled;
|
||||
@ -252,11 +263,13 @@ class APP_EXPORT QgsAdvancedDigitizingDockWidget : public QDockWidget, private U
|
||||
|
||||
// point list and current snap point / segment
|
||||
QList<QgsPoint> mCadPointList;
|
||||
bool mSnappedToVertex;
|
||||
QList<QgsPoint> mSnappedSegment;
|
||||
bool mSnappedToVertex;
|
||||
|
||||
bool mSessionActive;
|
||||
|
||||
// error message
|
||||
QgsMessageBarItem* mErrorMessage;
|
||||
QScopedPointer<QgsMessageBarItem> mErrorMessage;
|
||||
|
||||
// UI
|
||||
QAction* mEnableAction;
|
@ -1239,17 +1239,18 @@ void QgsMapCanvas::keyReleaseEvent( QKeyEvent * e )
|
||||
} //keyReleaseEvent()
|
||||
|
||||
|
||||
void QgsMapCanvas::mouseDoubleClickEvent( QMouseEvent * e )
|
||||
void QgsMapCanvas::mouseDoubleClickEvent( QMouseEvent* e )
|
||||
{
|
||||
// call handler of current map tool
|
||||
if ( mMapTool )
|
||||
{
|
||||
mMapTool->canvasDoubleClickEvent( e );
|
||||
QScopedPointer<QgsMapMouseEvent> me( new QgsMapMouseEvent( this, e ) );
|
||||
mMapTool->canvasDoubleClickEvent( me.data() );
|
||||
}
|
||||
}// mouseDoubleClickEvent
|
||||
|
||||
|
||||
void QgsMapCanvas::mousePressEvent( QMouseEvent * e )
|
||||
void QgsMapCanvas::mousePressEvent( QMouseEvent* e )
|
||||
{
|
||||
//use middle mouse button for panning, map tools won't receive any events in that case
|
||||
if ( e->button() == Qt::MidButton )
|
||||
@ -1263,7 +1264,8 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent * e )
|
||||
// call handler of current map tool
|
||||
if ( mMapTool )
|
||||
{
|
||||
mMapTool->canvasPressEvent( e );
|
||||
QScopedPointer<QgsMapMouseEvent> me( new QgsMapMouseEvent( this, e ) );
|
||||
mMapTool->canvasPressEvent( me.data() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1278,7 +1280,7 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent * e )
|
||||
} // mousePressEvent
|
||||
|
||||
|
||||
void QgsMapCanvas::mouseReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapCanvas::mouseReleaseEvent( QMouseEvent* e )
|
||||
{
|
||||
//use middle mouse button for panning, map tools won't receive any events in that case
|
||||
if ( e->button() == Qt::MidButton )
|
||||
@ -1309,7 +1311,8 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent * e )
|
||||
}
|
||||
return;
|
||||
}
|
||||
mMapTool->canvasReleaseEvent( e );
|
||||
QScopedPointer<QgsMapMouseEvent> me( new QgsMapMouseEvent( this, e ) );
|
||||
mMapTool->canvasReleaseEvent( me.data() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1469,7 +1472,8 @@ void QgsMapCanvas::mouseMoveEvent( QMouseEvent * e )
|
||||
// call handler of current map tool
|
||||
if ( mMapTool )
|
||||
{
|
||||
mMapTool->canvasMoveEvent( e );
|
||||
QScopedPointer<QgsMapMouseEvent> me( new QgsMapMouseEvent( this, e ) );
|
||||
mMapTool->canvasMoveEvent( me.data() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,57 +15,53 @@
|
||||
|
||||
|
||||
#include "qgsmapmouseevent.h"
|
||||
#include "qgsmaptooladvanceddigitizing.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
|
||||
#include "qgisapp.h"
|
||||
#include "qgssnappingutils.h"
|
||||
|
||||
QgsMapMouseEvent::QgsMapMouseEvent( QgsMapToolAdvancedDigitizing* mapTool, QMouseEvent* event, SnappingMode mode )
|
||||
: QMouseEvent( event->type(), event->pos(), event->globalPos(), event->button(), event->buttons(), event->modifiers() )
|
||||
, mMapPoint( mapTool->canvas()->mapSettings().mapToPixel().toMapCoordinates( event->pos() ) )
|
||||
, mMapTool( mapTool )
|
||||
, mSnapMatch( QgsPointLocator::Match() )
|
||||
, mSnappingMode( mode )
|
||||
{
|
||||
mOriginalPoint = mMapPoint;
|
||||
snapPoint();
|
||||
}
|
||||
|
||||
struct EdgesOnlyFilter : public QgsPointLocator::MatchFilter
|
||||
{
|
||||
bool acceptMatch( const QgsPointLocator::Match& m ) override { return m.hasEdge(); }
|
||||
};
|
||||
|
||||
QgsMapMouseEvent::QgsMapMouseEvent( QgsMapToolAdvancedDigitizing* mapTool, QgsPoint point,
|
||||
Qt::MouseButton button, Qt::KeyboardModifiers modifiers,
|
||||
QEvent::Type eventType, SnappingMode mode )
|
||||
: QMouseEvent( eventType,
|
||||
mapToPixelCoordinates( mapTool->canvas(), point ),
|
||||
mapTool->canvas()->mapToGlobal( mapToPixelCoordinates( mapTool->canvas(), point ) ),
|
||||
button, button, modifiers )
|
||||
, mMapPoint( point )
|
||||
, mOriginalPoint( point )
|
||||
, mMapTool( mapTool )
|
||||
, mSnapMatch( QgsPointLocator::Match() )
|
||||
, mSnappingMode( mode )
|
||||
QgsMapMouseEvent::QgsMapMouseEvent( QgsMapCanvas* mapCanvas, QMouseEvent* event )
|
||||
: QMouseEvent( event->type(), event->pos(), event->button(), event->buttons(), event->modifiers() )
|
||||
, mSnappingMode( NoSnapping )
|
||||
, mOriginalMapPoint( mapCanvas ? mapCanvas->mapSettings().mapToPixel().toMapCoordinates( event->pos() ) : QgsPoint() )
|
||||
, mMapPoint( mOriginalMapPoint )
|
||||
, mPixelPoint( event->pos() )
|
||||
, mMapCanvas( mapCanvas )
|
||||
{
|
||||
snapPoint();
|
||||
}
|
||||
|
||||
void QgsMapMouseEvent::setPoint( const QgsPoint& point )
|
||||
QgsMapMouseEvent::QgsMapMouseEvent( QgsMapCanvas* mapCanvas, QEvent::Type type, const QPoint& pos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers )
|
||||
: QMouseEvent( type, pos, button, buttons, modifiers )
|
||||
, mSnappingMode( NoSnapping )
|
||||
, mOriginalMapPoint( mapCanvas ? mapCanvas->mapSettings().mapToPixel().toMapCoordinates( pos ) : QgsPoint() )
|
||||
, mMapPoint( mOriginalMapPoint )
|
||||
, mPixelPoint( pos )
|
||||
, mMapCanvas( mapCanvas )
|
||||
{
|
||||
mMapPoint.set( point.x(), point.y() );
|
||||
}
|
||||
|
||||
void QgsMapMouseEvent::snapPoint()
|
||||
QgsPoint QgsMapMouseEvent::snapPoint( SnappingMode snappingMode )
|
||||
{
|
||||
if ( mSnappingMode == NoSnapping )
|
||||
return;
|
||||
// Use cached result
|
||||
if ( mSnappingMode == snappingMode )
|
||||
return mMapPoint;
|
||||
|
||||
QgsSnappingUtils* snappingUtils = mMapTool->canvas()->snappingUtils();
|
||||
mSnappingMode = snappingMode;
|
||||
|
||||
if ( snappingMode == NoSnapping )
|
||||
{
|
||||
mMapPoint = mOriginalMapPoint;
|
||||
mPixelPoint = pos();
|
||||
return mMapPoint;
|
||||
}
|
||||
|
||||
QgsSnappingUtils* snappingUtils = mMapCanvas->snappingUtils();
|
||||
QgsSnappingUtils::SnapToMapMode canvasMode = snappingUtils->snapToMapMode();
|
||||
if ( mSnappingMode == SnapAllLayers )
|
||||
if ( snappingMode == SnapAllLayers )
|
||||
{
|
||||
int type;
|
||||
double tolerance;
|
||||
@ -81,42 +77,46 @@ void QgsMapMouseEvent::snapPoint()
|
||||
{
|
||||
mSnapMatch = snappingUtils->snapToMap( mMapPoint );
|
||||
}
|
||||
mMapPoint = mSnapMatch.isValid() ? mSnapMatch.point() : mOriginalPoint;
|
||||
|
||||
if ( mSnapMatch.isValid() )
|
||||
{
|
||||
mMapPoint = mSnapMatch.point();
|
||||
mPixelPoint = mapToPixelCoordinates( mMapPoint );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMapPoint = mOriginalMapPoint;
|
||||
mPixelPoint = pos();
|
||||
}
|
||||
|
||||
return mMapPoint;
|
||||
}
|
||||
|
||||
QPoint QgsMapMouseEvent::mapToPixelCoordinates( QgsMapCanvas* canvas, const QgsPoint& point )
|
||||
QList<QgsPoint> QgsMapMouseEvent::snapSegment( SnappingMode snappingMode, bool* snapped , bool allLayers ) const
|
||||
{
|
||||
qreal x = point.x(), y = point.y();
|
||||
|
||||
canvas->mapSettings().mapToPixel().transformInPlace( x, y );
|
||||
|
||||
return QPoint( qRound( x ), qRound( y ) );
|
||||
}
|
||||
|
||||
QList<QgsPoint> QgsMapMouseEvent::snapSegment( bool* snapped, bool allLayers ) const
|
||||
{
|
||||
QList<QgsPoint> segment = QList<QgsPoint>();
|
||||
QList<QgsPoint> segment;
|
||||
QgsPoint pt1, pt2;
|
||||
|
||||
if ( mSnapMatch.hasEdge() )
|
||||
// If there's a cached snapping result we use it
|
||||
if ( snappingMode == mSnappingMode && mSnapMatch.hasEdge() )
|
||||
{
|
||||
mSnapMatch.edgePoints( pt1, pt2 );
|
||||
segment << pt1 << pt2;
|
||||
}
|
||||
|
||||
else if ( mSnappingMode != NoSnapping )
|
||||
else if ( snappingMode != NoSnapping )
|
||||
{
|
||||
QgsPointLocator::Match match;
|
||||
if ( mSnappingMode == SnapProjectConfig && !allLayers )
|
||||
if ( snappingMode == SnapProjectConfig && !allLayers )
|
||||
{
|
||||
// run snapToMap with only segments
|
||||
EdgesOnlyFilter filter;
|
||||
match = mMapTool->canvas()->snappingUtils()->snapToMap( mOriginalPoint, &filter );
|
||||
match = mMapCanvas->snappingUtils()->snapToMap( mOriginalMapPoint, &filter );
|
||||
}
|
||||
else if ( mSnappingMode == SnapAllLayers || allLayers )
|
||||
else if ( snappingMode == SnapAllLayers || allLayers )
|
||||
{
|
||||
// run snapToMap with only edges on all layers
|
||||
QgsSnappingUtils* snappingUtils = mMapTool->canvas()->snappingUtils();
|
||||
QgsSnappingUtils* snappingUtils = mMapCanvas->snappingUtils();
|
||||
QgsSnappingUtils::SnapToMapMode canvasMode = snappingUtils->snapToMapMode();
|
||||
int type;
|
||||
double tolerance;
|
||||
@ -124,7 +124,7 @@ QList<QgsPoint> QgsMapMouseEvent::snapSegment( bool* snapped, bool allLayers ) c
|
||||
snappingUtils->defaultSettings( type, tolerance, unit );
|
||||
snappingUtils->setSnapToMapMode( QgsSnappingUtils::SnapAllLayers );
|
||||
snappingUtils->setDefaultSettings( QgsPointLocator::Edge, tolerance, unit );
|
||||
match = snappingUtils->snapToMap( mOriginalPoint );
|
||||
match = snappingUtils->snapToMap( mOriginalMapPoint );
|
||||
snappingUtils->setSnapToMapMode( canvasMode );
|
||||
snappingUtils->setDefaultSettings( type, tolerance, unit );
|
||||
}
|
||||
@ -143,4 +143,17 @@ QList<QgsPoint> QgsMapMouseEvent::snapSegment( bool* snapped, bool allLayers ) c
|
||||
return segment;
|
||||
}
|
||||
|
||||
void QgsMapMouseEvent::setMapPoint( const QgsPoint& point )
|
||||
{
|
||||
mMapPoint = point;
|
||||
mPixelPoint = mapToPixelCoordinates( point );
|
||||
}
|
||||
|
||||
QPoint QgsMapMouseEvent::mapToPixelCoordinates( const QgsPoint& point )
|
||||
{
|
||||
double x = point.x(), y = point.y();
|
||||
|
||||
mMapCanvas->mapSettings().mapToPixel().transformInPlace( x, y );
|
||||
|
||||
return QPoint( qRound( x ), qRound( y ) );
|
||||
}
|
115
src/gui/qgsmapmouseevent.h
Normal file
115
src/gui/qgsmapmouseevent.h
Normal file
@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
qgsmapmouseevent.h - mouse event in map coordinates and ability to snap
|
||||
----------------------
|
||||
begin : October 2014
|
||||
copyright : (C) Denis Rouzaud
|
||||
email : denis.rouzaud@gmail.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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSMAPMOUSEEVENT_H
|
||||
#define QGSMAPMOUSEEVENT_H
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "qgspoint.h"
|
||||
#include "qgspointlocator.h"
|
||||
#include "qgssnappingutils.h"
|
||||
|
||||
class QgsMapCanvas;
|
||||
class QgsMapToolAdvancedDigitizing;
|
||||
|
||||
/**
|
||||
* A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
|
||||
* It is sent whenever the user moves, clicks, releases or double clicks the mouse.
|
||||
* In addition to the coordiantes in pixel space it also knows the coordinates in the mapcanvas' CRS
|
||||
* as well as it knows the concept of snapping.
|
||||
*/
|
||||
class GUI_EXPORT QgsMapMouseEvent : public QMouseEvent
|
||||
{
|
||||
public:
|
||||
|
||||
enum SnappingMode
|
||||
{
|
||||
NoSnapping,
|
||||
SnapProjectConfig, //!< snap according to the configuration set in the snapping settings
|
||||
SnapAllLayers, //!< snap to all rendered layers (tolerance and type from defaultSettings())
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new QgsMapMouseEvent. Should only be required to be called from the QgsMapCanvas.
|
||||
*
|
||||
* @param mapCanvas The map canvas on which the event occured
|
||||
* @param event The original mouse event
|
||||
*/
|
||||
QgsMapMouseEvent( QgsMapCanvas* mapCanvas, QMouseEvent* event );
|
||||
|
||||
QgsMapMouseEvent( QgsMapCanvas* mapCanvas, Type type, const QPoint &pos, Qt::MouseButton button = Qt::NoButton,
|
||||
Qt::MouseButtons buttons = Qt::NoButton, Qt::KeyboardModifiers modifiers = Qt::NoModifier );
|
||||
|
||||
/**
|
||||
* @brief snapPoint will snap the points using the map canvas snapping utils configuration
|
||||
* @note if snapping did not succeeded, the map point will be reset to its original position
|
||||
*/
|
||||
QgsPoint snapPoint( SnappingMode snappingMode );
|
||||
|
||||
/**
|
||||
* returns the first snapped segment. If the cached snapped match is a segment, it will simply return it.
|
||||
* Otherwise it will try to snap a segment according to the event's snapping mode. In this case the cache
|
||||
* will not be overwritten.
|
||||
* @param snapped if given, determines if a segment has been snapped
|
||||
* @param allLayers if true, override snapping mode
|
||||
*/
|
||||
QList<QgsPoint> snapSegment( SnappingMode snappingMode, bool* snapped = 0, bool allLayers = false ) const;
|
||||
|
||||
/**
|
||||
* Returns true if there is a snapped point cached.
|
||||
* Will only be useful after snapPoint has previously been called.
|
||||
*
|
||||
* @return True if there is a snapped point cached.
|
||||
*/
|
||||
bool isSnapped() const { return mSnapMatch.isValid(); }
|
||||
|
||||
/**
|
||||
* @brief mapPoint returns the point in coordinates
|
||||
* @return the point in map coordinates, after snapping if requested in the event.
|
||||
*/
|
||||
inline QgsPoint mapPoint() const { return mMapPoint; }
|
||||
|
||||
void setMapPoint( const QgsPoint& point );
|
||||
|
||||
QgsPoint originalMapPoint() const { return mMapPoint; }
|
||||
|
||||
QPoint pixelPoint() const { return mPixelPoint; }
|
||||
|
||||
QPoint originalPixelPoint() const { return pos(); }
|
||||
|
||||
private:
|
||||
|
||||
QPoint mapToPixelCoordinates( const QgsPoint& point );
|
||||
|
||||
SnappingMode mSnappingMode;
|
||||
|
||||
//! Unsnapped point in map coordinates.
|
||||
QgsPoint mOriginalMapPoint;
|
||||
|
||||
//! Location in map coordinates. May be snapped.
|
||||
QgsPoint mMapPoint;
|
||||
|
||||
//! Location in pixel coordinates. May be snapped.
|
||||
//! Original pixel point available through the parent QMouseEvent.
|
||||
QPoint mPixelPoint;
|
||||
|
||||
//! The map canvas on which the event was triggered.
|
||||
QgsMapCanvas* mMapCanvas;
|
||||
|
||||
QgsPointLocator::Match mSnapMatch;
|
||||
};
|
||||
|
||||
#endif // QGSMAPMOUSEEVENT_H
|
@ -142,22 +142,22 @@ void QgsMapTool::setCursor( QCursor cursor )
|
||||
}
|
||||
|
||||
|
||||
void QgsMapTool::canvasMoveEvent( QMouseEvent *e )
|
||||
void QgsMapTool::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapTool::canvasDoubleClickEvent( QMouseEvent *e )
|
||||
void QgsMapTool::canvasDoubleClickEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapTool::canvasPressEvent( QMouseEvent *e )
|
||||
void QgsMapTool::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapTool::canvasReleaseEvent( QMouseEvent *e )
|
||||
void QgsMapTool::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "qgsconfig.h"
|
||||
#include "qgsmessagebar.h"
|
||||
#include "qgspointv2.h"
|
||||
#include "qgsmapmouseevent.h"
|
||||
|
||||
#include <QCursor>
|
||||
#include <QString>
|
||||
@ -57,16 +58,16 @@ class GUI_EXPORT QgsMapTool : public QObject
|
||||
virtual ~QgsMapTool();
|
||||
|
||||
//! Mouse move event for overriding. Default implementation does nothing.
|
||||
virtual void canvasMoveEvent( QMouseEvent * e );
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Mouse double click event for overriding. Default implementation does nothing.
|
||||
virtual void canvasDoubleClickEvent( QMouseEvent * e );
|
||||
virtual void canvasDoubleClickEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Mouse press event for overriding. Default implementation does nothing.
|
||||
virtual void canvasPressEvent( QMouseEvent * e );
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Mouse release event for overriding. Default implementation does nothing.
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e );
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e );
|
||||
|
||||
//! Mouse wheel event for overriding. Default implementation does nothing.
|
||||
virtual void wheelEvent( QWheelEvent* e );
|
||||
|
72
src/gui/qgsmaptooladvanceddigitizing.cpp
Normal file
72
src/gui/qgsmaptooladvanceddigitizing.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
qgsmaptooladvanceddigitizing.cpp - map tool with event in map coordinates
|
||||
----------------------
|
||||
begin : October 2014
|
||||
copyright : (C) Denis Rouzaud
|
||||
email : denis.rouzaud@gmail.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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsmapmouseevent.h"
|
||||
#include "qgsmaptooladvanceddigitizing.h"
|
||||
|
||||
|
||||
QgsMapToolAdvancedDigitizing::QgsMapToolAdvancedDigitizing( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget )
|
||||
: QgsMapToolEdit( canvas )
|
||||
, mCaptureMode( CapturePoint )
|
||||
, mSnapOnPress( false )
|
||||
, mSnapOnRelease( false )
|
||||
, mSnapOnMove( false )
|
||||
, mSnapOnDoubleClick( false )
|
||||
, mCadDockWidget( cadDockWidget )
|
||||
{
|
||||
}
|
||||
|
||||
QgsMapToolAdvancedDigitizing::~QgsMapToolAdvancedDigitizing()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mCadDockWidget->canvasPressEvent( e ) )
|
||||
cadCanvasPressEvent( e );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mCadDockWidget->canvasReleaseEvent( e, mCaptureMode == CaptureLine || mCaptureMode == CapturePolygon ) )
|
||||
cadCanvasReleaseEvent( e );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
if ( !mCadDockWidget->canvasMoveEvent( e ) )
|
||||
cadCanvasMoveEvent( e );
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::activate()
|
||||
{
|
||||
QgsMapToolEdit::activate();
|
||||
connect( mCadDockWidget, SIGNAL( pointChanged( QgsPoint ) ), this, SLOT( cadPointChanged( QgsPoint ) ) );
|
||||
mCadDockWidget->enable();
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::deactivate()
|
||||
{
|
||||
QgsMapToolEdit::deactivate();
|
||||
disconnect( mCadDockWidget, SIGNAL( pointChanged( QgsPoint ) ), this, SLOT( cadPointChanged( QgsPoint ) ) );
|
||||
mCadDockWidget->disable();
|
||||
}
|
||||
|
||||
void QgsMapToolAdvancedDigitizing::cadPointChanged( const QgsPoint& point )
|
||||
{
|
||||
QgsMapMouseEvent fakeEvent( mCanvas, QMouseEvent::Move, QPoint( 0, 0 ) );
|
||||
fakeEvent.setMapPoint( point );
|
||||
canvasMoveEvent( &fakeEvent );
|
||||
}
|
@ -17,8 +17,9 @@
|
||||
#ifndef QGSMAPTOOLADVANCEDDIGITIZE_H
|
||||
#define QGSMAPTOOLADVANCEDDIGITIZE_H
|
||||
|
||||
#include "qgsadvanceddigitizingdockwidget.h"
|
||||
#include "qgsmaptool.h"
|
||||
#include "qgsmaptooledit.h"
|
||||
#include "qgsadvanceddigitizingdockwidget.h"
|
||||
|
||||
class QgsMapMouseEvent;
|
||||
|
||||
@ -27,10 +28,10 @@ class QgsMapMouseEvent;
|
||||
* Events from QgsMapTool are caught and their QMouseEvent are transformed into QgsMapMouseEvent (with map coordinates).
|
||||
* Events are then forwarded to corresponding virtual methods which can be reimplemented in subclasses.
|
||||
* An event filter can be set on the map tool to filter and modify the events in map coordinates (@see QgsMapToolMapEventFilter).
|
||||
* @note at the momemt, the event filter is used by the CAD tools (@see QgsCadDocWidget).
|
||||
* @note at the moment, the event filter is used by the CAD tools (@see QgsCadDocWidget).
|
||||
* @note the event filter definition is not exposed in python API to avoid any unexpected behavior.
|
||||
*/
|
||||
class APP_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapTool
|
||||
class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -42,47 +43,29 @@ class APP_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapTool
|
||||
CapturePolygon
|
||||
};
|
||||
|
||||
explicit QgsMapToolAdvancedDigitizing( QgsMapCanvas* canvas );
|
||||
explicit QgsMapToolAdvancedDigitizing( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget );
|
||||
|
||||
~QgsMapToolAdvancedDigitizing();
|
||||
|
||||
//! catch the mouse press event, filters it, transforms it to map coordinates and send it to virtual method
|
||||
void canvasPressEvent( QMouseEvent* e ) override;
|
||||
void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
//! catch the mouse release event, filters it, transforms it to map coordinates and send it to virtual method
|
||||
void canvasReleaseEvent( QMouseEvent* e ) override;
|
||||
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
//! catch the mouse move event, filters it, transforms it to map coordinates and send it to virtual method
|
||||
void canvasMoveEvent( QMouseEvent* e ) override;
|
||||
//! catch the mouse double click event, filters it, transforms it to map coordinates and send it to virtual method
|
||||
void canvasDoubleClickEvent( QMouseEvent* e ) override;
|
||||
//! catch the key press event, filters it and send it to virtual method
|
||||
void keyPressEvent( QKeyEvent* event ) override;
|
||||
//! catch the key release event, filters it and send it to virtual method
|
||||
void keyReleaseEvent( QKeyEvent* event ) override;
|
||||
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! mouse press event in map coordinates (eventually filtered) to be redefined in subclass
|
||||
virtual void canvasMapPressEvent( QgsMapMouseEvent* e );
|
||||
//! mouse release event in map coordinates (eventually filtered) to be redefined in subclass
|
||||
virtual void canvasMapReleaseEvent( QgsMapMouseEvent* e );
|
||||
//! mouse move event in map coordinates (eventually filtered) to be redefined in subclass
|
||||
virtual void canvasMapMoveEvent( QgsMapMouseEvent* e );
|
||||
//! mouse double click event in map coordinates (eventually filtered) to be redefined in subclass
|
||||
virtual void canvasMapDoubleClickEvent( QgsMapMouseEvent* e );
|
||||
//! key press event (eventually filtered) to be redefined in subclass
|
||||
virtual void canvasKeyPressEvent( QKeyEvent* e );
|
||||
//! key press release (eventually filtered) to be redefined in subclass
|
||||
virtual void canvasKeyReleaseEvent( QKeyEvent* e );
|
||||
CaptureMode mode() const { return mCaptureMode; }
|
||||
|
||||
//! return if CAD is allowed in the map tool
|
||||
bool cadAllowed() { return mCadAllowed; }
|
||||
void activate();
|
||||
|
||||
//! return the capture mode of the map tool
|
||||
CaptureMode mode() { return mCaptureMode; }
|
||||
void deactivate();
|
||||
|
||||
QgsAdvancedDigitizingDockWidget* cadDockWidget() const { return mCadDockWidget; }
|
||||
|
||||
protected:
|
||||
|
||||
QgsAdvancedDigitizingDockWidget* mCadDockWidget;
|
||||
|
||||
bool mCadAllowed;
|
||||
virtual void cadCanvasPressEvent( QgsMapMouseEvent* e ) { Q_UNUSED( e ) }
|
||||
virtual void cadCanvasReleaseEvent( QgsMapMouseEvent* e ) { Q_UNUSED( e ) }
|
||||
virtual void cadCanvasMoveEvent( QgsMapMouseEvent* e ) { Q_UNUSED( e ) }
|
||||
|
||||
CaptureMode mCaptureMode;
|
||||
|
||||
@ -90,6 +73,12 @@ class APP_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapTool
|
||||
bool mSnapOnRelease;
|
||||
bool mSnapOnMove;
|
||||
bool mSnapOnDoubleClick;
|
||||
|
||||
private slots:
|
||||
void cadPointChanged( const QgsPoint& point );
|
||||
|
||||
private:
|
||||
QgsAdvancedDigitizingDockWidget* mCadDockWidget;
|
||||
};
|
||||
|
||||
#endif // QGSMAPTOOLADVANCEDDIGITIZE_H
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include "qgsmaptoolcapture.h"
|
||||
|
||||
#include "qgisapp.h"
|
||||
#include "qgscursors.h"
|
||||
#include "qgsgeometryvalidator.h"
|
||||
#include "qgslayertreeview.h"
|
||||
@ -35,15 +34,14 @@
|
||||
#include <QStatusBar>
|
||||
|
||||
|
||||
QgsMapToolCapture::QgsMapToolCapture( QgsMapCanvas* canvas, enum CaptureMode tool )
|
||||
: QgsMapToolEdit( canvas )
|
||||
QgsMapToolCapture::QgsMapToolCapture( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget, CaptureMode mode )
|
||||
: QgsMapToolAdvancedDigitizing( canvas, cadDockWidget )
|
||||
, mRubberBand( 0 )
|
||||
, mTempRubberBand( 0 )
|
||||
, mValidator( 0 )
|
||||
, mSnappingMarker( 0 )
|
||||
{
|
||||
mCaptureMode = tool;
|
||||
mCadAllowed = true;
|
||||
mCaptureMode = mode;
|
||||
|
||||
// enable the snapping on mouse move / release
|
||||
mSnapOnMove = true;
|
||||
@ -51,13 +49,13 @@ QgsMapToolCapture::QgsMapToolCapture( QgsMapCanvas* canvas, enum CaptureMode too
|
||||
mSnapOnDoubleClick = false;
|
||||
mSnapOnPress = false;
|
||||
|
||||
mCaptureModeFromLayer = tool == CaptureNone;
|
||||
mCaptureModeFromLayer = mode == CaptureNone;
|
||||
mCapturing = false;
|
||||
|
||||
QPixmap mySelectQPixmap = QPixmap(( const char ** ) capture_point_cursor );
|
||||
mCursor = QCursor( mySelectQPixmap, 8, 8 );
|
||||
setCursor( QCursor( mySelectQPixmap, 8, 8 ) );
|
||||
|
||||
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer * ) ),
|
||||
connect( canvas, SIGNAL( currentLayerChanged( QgsMapLayer * ) ),
|
||||
this, SLOT( currentLayerChanged( QgsMapLayer * ) ) );
|
||||
}
|
||||
|
||||
@ -82,6 +80,16 @@ void QgsMapToolCapture::deactivate()
|
||||
QgsMapToolEdit::deactivate();
|
||||
}
|
||||
|
||||
void QgsMapToolCapture::validationFinished()
|
||||
{
|
||||
emit messageDiscarded();
|
||||
QString msgFinished = tr( "Validation finished" );
|
||||
if ( mValidationWarnings.count() )
|
||||
emit messageEmitted( mValidationWarnings.join( "\n" ).append( "\n" ).append( msgFinished ), QgsMessageBar::WARNING );
|
||||
else
|
||||
emit messageEmitted( msgFinished );
|
||||
}
|
||||
|
||||
void QgsMapToolCapture::currentLayerChanged( QgsMapLayer *layer )
|
||||
{
|
||||
if ( !mCaptureModeFromLayer )
|
||||
@ -112,8 +120,9 @@ void QgsMapToolCapture::currentLayerChanged( QgsMapLayer *layer )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolCapture::canvasMapMoveEvent( QgsMapMouseEvent * e )
|
||||
void QgsMapToolCapture::cadCanvasMoveEvent( QgsMapMouseEvent * e )
|
||||
{
|
||||
QgsMapToolAdvancedDigitizing::cadCanvasMoveEvent( e );
|
||||
bool snapped = e->isSnapped();
|
||||
QgsPoint point = e->mapPoint();
|
||||
|
||||
@ -148,13 +157,6 @@ void QgsMapToolCapture::canvasMapMoveEvent( QgsMapMouseEvent * e )
|
||||
}
|
||||
} // mouseMoveEvent
|
||||
|
||||
|
||||
void QgsMapToolCapture::canvasMapPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
// nothing to be done
|
||||
}
|
||||
|
||||
int QgsMapToolCapture::nextPoint( const QgsPoint& mapPoint, QgsPoint& layerPoint )
|
||||
{
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
@ -314,7 +316,7 @@ void QgsMapToolCapture::undo()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolCapture::canvasKeyPressEvent( QKeyEvent* e )
|
||||
void QgsMapToolCapture::keyPressEvent( QKeyEvent* e )
|
||||
{
|
||||
if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete )
|
||||
{
|
||||
@ -399,14 +401,14 @@ void QgsMapToolCapture::validateGeometry()
|
||||
mValidator = 0;
|
||||
}
|
||||
|
||||
mTip = "";
|
||||
mValidationWarnings.clear();
|
||||
mGeomErrors.clear();
|
||||
while ( !mGeomErrorMarkers.isEmpty() )
|
||||
{
|
||||
delete mGeomErrorMarkers.takeFirst();
|
||||
}
|
||||
|
||||
QgsGeometry *g = 0;
|
||||
QScopedPointer<QgsGeometry> g;
|
||||
|
||||
switch ( mCaptureMode )
|
||||
{
|
||||
@ -416,7 +418,7 @@ void QgsMapToolCapture::validateGeometry()
|
||||
case CaptureLine:
|
||||
if ( size() < 2 )
|
||||
return;
|
||||
g = new QgsGeometry( mCaptureCurve.curveToLine() );
|
||||
g.reset( new QgsGeometry( mCaptureCurve.curveToLine() ) );
|
||||
break;
|
||||
case CapturePolygon:
|
||||
if ( size() < 3 )
|
||||
@ -425,21 +427,18 @@ void QgsMapToolCapture::validateGeometry()
|
||||
exteriorRing->close();
|
||||
QgsPolygonV2* polygon = new QgsPolygonV2();
|
||||
polygon->setExteriorRing( exteriorRing );
|
||||
g = new QgsGeometry( polygon );
|
||||
g.reset( new QgsGeometry( polygon ) );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !g )
|
||||
if ( !g.data() )
|
||||
return;
|
||||
|
||||
mValidator = new QgsGeometryValidator( g );
|
||||
mValidator = new QgsGeometryValidator( g.data() );
|
||||
connect( mValidator, SIGNAL( errorFound( QgsGeometry::Error ) ), this, SLOT( addError( QgsGeometry::Error ) ) );
|
||||
connect( mValidator, SIGNAL( finished() ), this, SLOT( validationFinished() ) );
|
||||
mValidator->start();
|
||||
|
||||
QStatusBar *sb = QgisApp::instance()->statusBar();
|
||||
sb->showMessage( tr( "Validation started." ) );
|
||||
delete g;
|
||||
messageEmitted( tr( "Validation started" ) );
|
||||
}
|
||||
|
||||
void QgsMapToolCapture::addError( QgsGeometry::Error e )
|
||||
@ -449,10 +448,7 @@ void QgsMapToolCapture::addError( QgsGeometry::Error e )
|
||||
if ( !vlayer )
|
||||
return;
|
||||
|
||||
if ( !mTip.isEmpty() )
|
||||
mTip += "\n";
|
||||
|
||||
mTip += e.what();
|
||||
mValidationWarnings << e.what();
|
||||
|
||||
if ( e.hasWhere() )
|
||||
{
|
||||
@ -466,16 +462,8 @@ void QgsMapToolCapture::addError( QgsGeometry::Error e )
|
||||
mGeomErrorMarkers << vm;
|
||||
}
|
||||
|
||||
QStatusBar *sb = QgisApp::instance()->statusBar();
|
||||
sb->showMessage( e.what() );
|
||||
if ( !mTip.isEmpty() )
|
||||
sb->setToolTip( mTip );
|
||||
}
|
||||
|
||||
void QgsMapToolCapture::validationFinished()
|
||||
{
|
||||
QStatusBar *sb = QgisApp::instance()->statusBar();
|
||||
sb->showMessage( tr( "Validation finished." ) );
|
||||
emit messageDiscarded();
|
||||
emit messageEmitted( mValidationWarnings.join( "\n" ), QgsMessageBar::WARNING );
|
||||
}
|
||||
|
||||
int QgsMapToolCapture::size()
|
@ -17,10 +17,11 @@
|
||||
#define QGSMAPTOOLCAPTURE_H
|
||||
|
||||
|
||||
#include "qgsmaptooledit.h"
|
||||
#include "qgsmaptooladvanceddigitizing.h"
|
||||
#include "qgscompoundcurvev2.h"
|
||||
#include "qgspoint.h"
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgslayertreeview.h"
|
||||
|
||||
#include <QPoint>
|
||||
#include <QList>
|
||||
@ -30,26 +31,17 @@ class QgsVertexMarker;
|
||||
class QgsMapLayer;
|
||||
class QgsGeometryValidator;
|
||||
|
||||
class APP_EXPORT QgsMapToolCapture : public QgsMapToolEdit
|
||||
class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! constructor
|
||||
QgsMapToolCapture( QgsMapCanvas* canvas, CaptureMode mode = CaptureNone );
|
||||
QgsMapToolCapture( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget, CaptureMode mode = CaptureNone );
|
||||
|
||||
//! destructor
|
||||
virtual ~QgsMapToolCapture();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMapMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasMapPressEvent( QgsMapMouseEvent * e ) override;
|
||||
|
||||
//! Overridden key press event
|
||||
virtual void canvasKeyPressEvent( QKeyEvent* e ) override;
|
||||
|
||||
//! deactive the tool
|
||||
virtual void deactivate() override;
|
||||
|
||||
@ -59,11 +51,15 @@ class APP_EXPORT QgsMapToolCapture : public QgsMapToolEdit
|
||||
const QgsCompoundCurveV2* captureCurve() const { return &mCaptureCurve; }
|
||||
|
||||
void deleteTempRubberBand();
|
||||
void cadCanvasMoveEvent( QgsMapMouseEvent * e );
|
||||
void keyPressEvent( QKeyEvent* e );
|
||||
|
||||
private slots:
|
||||
void validationFinished();
|
||||
|
||||
public slots:
|
||||
void currentLayerChanged( QgsMapLayer *layer );
|
||||
void addError( QgsGeometry::Error );
|
||||
void validationFinished();
|
||||
|
||||
|
||||
protected:
|
||||
int nextPoint( const QgsPoint& mapPoint, QgsPoint& layerPoint );
|
||||
@ -99,7 +95,7 @@ class APP_EXPORT QgsMapToolCapture : public QgsMapToolEdit
|
||||
QgsCompoundCurveV2 mCaptureCurve;
|
||||
|
||||
void validateGeometry();
|
||||
QString mTip;
|
||||
QStringList mValidationWarnings;
|
||||
QgsGeometryValidator *mValidator;
|
||||
QList< QgsGeometry::Error > mGeomErrors;
|
||||
QList< QgsVertexMarker * > mGeomErrorMarkers;
|
@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
QgsMapToolEdit::QgsMapToolEdit( QgsMapCanvas* canvas )
|
||||
: QgsMapToolAdvancedDigitizing( canvas )
|
||||
: QgsMapTool( canvas )
|
||||
{
|
||||
}
|
||||
|
||||
@ -60,18 +60,7 @@ QgsRubberBand* QgsMapToolEdit::createRubberBand( QGis::GeometryType geometryType
|
||||
|
||||
QgsVectorLayer* QgsMapToolEdit::currentVectorLayer()
|
||||
{
|
||||
QgsMapLayer* currentLayer = mCanvas->currentLayer();
|
||||
if ( !currentLayer )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( currentLayer );
|
||||
if ( !vlayer )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return vlayer;
|
||||
return qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
#define QGSMAPTOOLEDIT_H
|
||||
|
||||
#include "qgis.h"
|
||||
#include "qgsmaptooladvanceddigitizing.h"
|
||||
#include "qgsmaptool.h"
|
||||
|
||||
class QgsRubberBand;
|
||||
class QgsGeometryRubberBand;
|
||||
@ -25,7 +25,7 @@ class QgsVectorLayer;
|
||||
class QKeyEvent;
|
||||
|
||||
/** Base class for map tools that edit vector geometry*/
|
||||
class APP_EXPORT QgsMapToolEdit: public QgsMapToolAdvancedDigitizing
|
||||
class GUI_EXPORT QgsMapToolEdit: public QgsMapTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -24,18 +24,18 @@ QgsMapToolEmitPoint::QgsMapToolEmitPoint( QgsMapCanvas* canvas )
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolEmitPoint::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolEmitPoint::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolEmitPoint::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolEmitPoint::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsPoint pnt = toMapCoordinates( e->pos() );
|
||||
emit canvasClicked( pnt, e->button() );
|
||||
}
|
||||
|
||||
void QgsMapToolEmitPoint::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolEmitPoint::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ class GUI_EXPORT QgsMapToolEmitPoint : public QgsMapTool
|
||||
QgsMapToolEmitPoint( QgsMapCanvas* canvas );
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event - emits the signal
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
signals:
|
||||
//! signal emitted on canvas click
|
||||
|
@ -59,17 +59,17 @@ QgsMapToolIdentify::~QgsMapToolIdentify()
|
||||
delete mIdentifyMenu;
|
||||
}
|
||||
|
||||
void QgsMapToolIdentify::canvasMoveEvent( QMouseEvent * e )
|
||||
void QgsMapToolIdentify::canvasMoveEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolIdentify::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolIdentify::canvasPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
||||
void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
|
||||
void QgsMapToolIdentify::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
}
|
||||
|
@ -93,13 +93,13 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool
|
||||
virtual ~QgsMapToolIdentify();
|
||||
|
||||
//! Overridden mouse move event
|
||||
virtual void canvasMoveEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse press event
|
||||
virtual void canvasPressEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
//! Overridden mouse release event
|
||||
virtual void canvasReleaseEvent( QMouseEvent * e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
virtual void activate() override;
|
||||
|
||||
|
@ -35,7 +35,7 @@ QgsMapToolIdentifyFeature::~QgsMapToolIdentifyFeature()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapToolIdentifyFeature::canvasReleaseEvent( QMouseEvent* e )
|
||||
void QgsMapToolIdentifyFeature::canvasReleaseEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
|
||||
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() );
|
||||
|
@ -40,7 +40,7 @@ class GUI_EXPORT QgsMapToolIdentifyFeature : public QgsMapToolIdentify
|
||||
//! change the layer used by the map tool to identify
|
||||
void setLayer( QgsVectorLayer* vl ) { mLayer = vl; }
|
||||
|
||||
virtual void canvasReleaseEvent( QMouseEvent* e ) override;
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
signals:
|
||||
void featureIdentified( const QgsFeature& );
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user