Skip to content

Commit

Permalink
Move maptools from app->gui
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn authored and 3nids committed Sep 11, 2015
1 parent 26e9783 commit efcbbfd
Show file tree
Hide file tree
Showing 122 changed files with 881 additions and 832 deletions.
1 change: 1 addition & 0 deletions python/gui/gui.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
78 changes: 78 additions & 0 deletions python/gui/qgsmapmouseevent.sip
Original file line number Diff line number Diff line change
@@ -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;
};
8 changes: 4 additions & 4 deletions python/gui/qgsmaptool.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 3 additions & 3 deletions python/gui/qgsmaptoolemitpoint.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions python/gui/qgsmaptoolidentify.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmaptoolidentifyfeature.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgsmaptoolpan.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
6 changes: 3 additions & 3 deletions python/gui/qgsmaptooltouch.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
7 changes: 3 additions & 4 deletions python/gui/qgsmaptoolzoom.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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();

};

10 changes: 0 additions & 10 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ SET(QGIS_APP_SRCS
qgsattributetabledialog.cpp
qgsbookmarks.cpp
qgsbrowserdockwidget.cpp
qgsadvanceddigitizingdockwidget.cpp
qgsadvanceddigitizingcanvasitem.cpp
qgsclipboard.cpp
qgsconfigureshortcutsdialog.cpp
qgscustomization.cpp
Expand Down Expand Up @@ -47,7 +45,6 @@ SET(QGIS_APP_SRCS
qgslabelpreview.cpp
qgsloadstylefromdbdialog.cpp
qgsmaplayerstyleguiutils.cpp
qgsmapmouseevent.cpp
qgssavestyletodbdialog.cpp
qgsguivectorlayertools.cpp
qgswelcomepageitemsmodel.cpp
Expand All @@ -59,19 +56,16 @@ 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
qgsmaptoolpinlabels.cpp
qgsmaptoolshowhidelabels.cpp
qgsmaptoolidentifyaction.cpp
qgsmaptoollabel.cpp
qgsmaptooladvanceddigitizing.cpp
qgsmaptoolmeasureangle.cpp
qgsmaptoolmovefeature.cpp
qgsmaptoolmovelabel.cpp
Expand Down Expand Up @@ -181,7 +175,6 @@ SET (QGIS_APP_MOC_HDRS
qgsattributetabledialog.h
qgsbookmarks.h
qgsbrowserdockwidget.h
qgsadvanceddigitizingdockwidget.h
qgsclipboard.h
qgsconfigureshortcutsdialog.h
qgscustomization.h
Expand Down Expand Up @@ -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
Expand All @@ -233,7 +224,6 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolpinlabels.h
qgsmaptoolshowhidelabels.h
qgsmaptoolidentifyaction.h
qgsmaptooladvanceddigitizing.h
qgsmaptoolmeasureangle.h
qgsmaptoolmovefeature.h
qgsmaptoolmovelabel.h
Expand Down
8 changes: 3 additions & 5 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ QgsMapToolNodeTool::QgsMapToolNodeTool( QgsMapCanvas* canvas )
, mIsPoint( false )
{
mSnapper.setMapCanvas( canvas );
mCadAllowed = true;
mSnapOnPress = true;
}

QgsMapToolNodeTool::~QgsMapToolNodeTool()
{
cleanTool();
}

void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
void QgsMapToolNodeTool::canvasPressEvent( QgsMapMouseEvent* e )
{
removeRubberBands();
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
Expand Down Expand Up @@ -122,7 +120,7 @@ void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
}
}

void QgsMapToolNodeTool::canvasMapMoveEvent( QgsMapMouseEvent* e )
void QgsMapToolNodeTool::canvasMoveEvent( QgsMapMouseEvent* e )
{
if ( !mSelectedFeature || !mSelectedFeature->hasSelection() )
{
Expand Down Expand Up @@ -228,7 +226,7 @@ void QgsMapToolNodeTool::cleanTool( bool deleteSelectedFeature )
}
}

void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
void QgsMapToolNodeTool::canvasDoubleClickEvent( QgsMapMouseEvent* e )
{
if ( !mSelectedFeature )
return;
Expand Down
6 changes: 3 additions & 3 deletions src/app/nodetool/qgsmaptoolnodetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading

0 comments on commit efcbbfd

Please sign in to comment.