diff --git a/python/gui/gui_auto.sip b/python/gui/gui_auto.sip index a71fedaa8497..543824b7580e 100644 --- a/python/gui/gui_auto.sip +++ b/python/gui/gui_auto.sip @@ -144,7 +144,6 @@ %Include qgsmaptoolidentify.sip %Include qgsmaptoolidentifyfeature.sip %Include qgsmaptoolpan.sip -%Include qgsmaptoolselectionhandler.sip %Include qgsmaptoolzoom.sip %Include qgsmaplayerconfigwidget.sip %Include qgsmenuheader.sip diff --git a/python/gui/qgsmaptoolselectionhandler.sip.in b/python/gui/qgsmaptoolselectionhandler.sip.in deleted file mode 100644 index be5c38b707e6..000000000000 --- a/python/gui/qgsmaptoolselectionhandler.sip.in +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************ - * This file has been generated automatically from * - * * - * src/gui/qgsmaptoolselectionhandler.h * - * * - * Do not edit manually ! Edit header and run scripts/sipify.pl again * - ************************************************************************/ - - - - - - - - -class QgsMapToolSelectionHandler : QObject -{ -%Docstring - Utility class for handling various methods to create geometry for selection in layers. - -.. versionadded:: 3.2 -%End - -%TypeHeaderCode -#include "qgsmaptoolselectionhandler.h" -%End - public: - - enum SelectionMode - { - //! SelectSimple - SelectSimple, - //! SelectPolygon - SelectPolygon, - //! SelectFreehand - SelectFreehand, - //! SelectRadius - SelectRadius - }; - - QgsMapToolSelectionHandler( QgsMapCanvas *canvas, - QgsMapToolSelectionHandler::SelectionMode selectionMode = QgsMapToolSelectionHandler::SelectionMode::SelectSimple ); -%Docstring -constructor -%End - - ~QgsMapToolSelectionHandler(); - - void setInterface( QgisInterface *iface ); -%Docstring -Configures QGIS interface - used to register selection radius widget -%End - - QgsGeometry selectedGeometry(); -%Docstring -Returns most recently selected geometry (may be a point or a polygon) -%End - - SelectionMode selectionMode(); -%Docstring -Sets the current selection mode -%End - void setSelectionMode( SelectionMode mode ); -%Docstring -Returns the current selection mode -%End - - void deactivate(); -%Docstring -Deactivates handler (when map tool gets deactivated) -%End - - void canvasMoveEvent( QgsMapMouseEvent *e ); -%Docstring -Handles mouse move event from map tool -%End - void canvasPressEvent( QgsMapMouseEvent *e ); -%Docstring -Handles mouse press event from map tool -%End - void canvasReleaseEvent( QgsMapMouseEvent *e ); -%Docstring -Handles mouse releasae event from map tool -%End - bool keyReleaseEvent( QKeyEvent *e ); -%Docstring -Handles escape press event - returns true if the even has been processed -%End - - signals: - void geometryChanged( Qt::KeyboardModifiers modifiers = Qt::NoModifier ); -%Docstring -emitted when a new geometry has been picked (selectedGeometry()) -%End - -}; - -/************************************************************************ - * This file has been generated automatically from * - * * - * src/gui/qgsmaptoolselectionhandler.h * - * * - * Do not edit manually ! Edit header and run scripts/sipify.pl again * - ************************************************************************/ diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 660a46b2a6c6..28ad0db6ea40 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -97,6 +97,7 @@ SET(QGIS_APP_SRCS qgsmaptoolrotatelabel.cpp qgsmaptoolrotatepointsymbols.cpp qgsmaptoolselect.cpp + qgsmaptoolselectionhandler.cpp qgsmaptoolselectutils.cpp qgsmaptoolsimplify.cpp qgsmaptoolsplitfeatures.cpp @@ -307,6 +308,7 @@ SET (QGIS_APP_MOC_HDRS qgsmaptoolrotatelabel.h qgsmaptoolrotatepointsymbols.h qgsmaptoolselect.h + qgsmaptoolselectionhandler.h qgsmaptoolsimplify.h qgsmaptoolsplitfeatures.h qgsmaptoolsplitparts.h diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index be1612c18602..c9b66cec5afd 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1311,13 +1311,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh // should come after fileNewBlank to ensure project is properly set up to receive any data source files QgsApplication::setFileOpenEventReceiver( this ); - // finish initialization of map tools that need access to QGIS interface - mMapTools.mSelectFeatures->setInterface( mQgisInterface ); - mMapTools.mSelectPolygon->setInterface( mQgisInterface ); - mMapTools.mSelectFreehand->setInterface( mQgisInterface ); - mMapTools.mSelectRadius->setInterface( mQgisInterface ); - mMapTools.mIdentify->setInterface( mQgisInterface ); - #ifdef ANDROID toggleFullScreen(); #endif diff --git a/src/app/qgsmaptoolidentifyaction.cpp b/src/app/qgsmaptoolidentifyaction.cpp index 424496b655ba..8366a2a63241 100644 --- a/src/app/qgsmaptoolidentifyaction.cpp +++ b/src/app/qgsmaptoolidentifyaction.cpp @@ -204,11 +204,6 @@ void QgsMapToolIdentifyAction::deactivate() QgsMapToolIdentify::deactivate(); } -void QgsMapToolIdentifyAction::setInterface( QgisInterface *iface ) -{ - mSelectionHandler->setInterface( iface ); -} - QgsUnitTypes::DistanceUnit QgsMapToolIdentifyAction::displayDistanceUnits() const { return QgsProject::instance()->distanceUnits(); diff --git a/src/app/qgsmaptoolidentifyaction.h b/src/app/qgsmaptoolidentifyaction.h index ff96d874f1a7..4d1abff8f284 100644 --- a/src/app/qgsmaptoolidentifyaction.h +++ b/src/app/qgsmaptoolidentifyaction.h @@ -61,8 +61,6 @@ class APP_EXPORT QgsMapToolIdentifyAction : public QgsMapToolIdentify void deactivate() override; - void setInterface( QgisInterface *iface ); - public slots: void handleCopyToClipboard( QgsFeatureStore & ); void handleChangedRasterResults( QList &results ); diff --git a/src/app/qgsmaptoolselect.cpp b/src/app/qgsmaptoolselect.cpp index 92145de8fa5c..0babb130c896 100644 --- a/src/app/qgsmaptoolselect.cpp +++ b/src/app/qgsmaptoolselect.cpp @@ -38,11 +38,6 @@ QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas *canvas ) setSelectionMode( QgsMapToolSelectionHandler::SelectSimple ); } -void QgsMapToolSelect::setInterface( QgisInterface *iface ) -{ - mSelectionHandler->setInterface( iface ); -} - void QgsMapToolSelect::setSelectionMode( QgsMapToolSelectionHandler::SelectionMode selectionMode ) { mSelectionHandler->setSelectionMode( selectionMode ); diff --git a/src/app/qgsmaptoolselect.h b/src/app/qgsmaptoolselect.h index d2f5efb24e6a..d82fbf872b4e 100644 --- a/src/app/qgsmaptoolselect.h +++ b/src/app/qgsmaptoolselect.h @@ -31,8 +31,6 @@ class APP_EXPORT QgsMapToolSelect : public QgsMapTool void setSelectionMode( QgsMapToolSelectionHandler::SelectionMode selectionMode ); - void setInterface( QgisInterface *iface ); - void canvasPressEvent( QgsMapMouseEvent *e ) override; void canvasMoveEvent( QgsMapMouseEvent *e ) override; void canvasReleaseEvent( QgsMapMouseEvent *e ) override; diff --git a/src/gui/qgsmaptoolselectionhandler.cpp b/src/app/qgsmaptoolselectionhandler.cpp similarity index 96% rename from src/gui/qgsmaptoolselectionhandler.cpp rename to src/app/qgsmaptoolselectionhandler.cpp index 0a14be4b40f4..bf171031f1a0 100644 --- a/src/gui/qgsmaptoolselectionhandler.cpp +++ b/src/app/qgsmaptoolselectionhandler.cpp @@ -19,7 +19,7 @@ #include #include -#include "qgisinterface.h" +#include "qgisapp.h" #include "qgsdoublespinbox.h" #include "qgsmapcanvas.h" #include "qgsmapmouseevent.h" @@ -102,8 +102,6 @@ QgsMapToolSelectionHandler::QgsMapToolSelectionHandler( QgsMapCanvas *canvas, Qg , mCanvas( canvas ) , mSelectionMode( selectionMode ) , mSnapIndicator( qgis::make_unique< QgsSnapIndicator >( canvas ) ) - , mFillColor( QColor( 254, 178, 76, 63 ) ) - , mStrokeColor( QColor( 254, 58, 29, 100 ) ) { } @@ -112,11 +110,6 @@ QgsMapToolSelectionHandler::~QgsMapToolSelectionHandler() cancel(); } -void QgsMapToolSelectionHandler::setInterface( QgisInterface *iface ) -{ - mQgisInterface = iface; -} - void QgsMapToolSelectionHandler::canvasReleaseEvent( QgsMapMouseEvent *e ) { switch ( mSelectionMode ) @@ -362,7 +355,7 @@ void QgsMapToolSelectionHandler::initRubberBand() void QgsMapToolSelectionHandler::createDistanceWidget() { - if ( !mCanvas || !mQgisInterface ) + if ( !mCanvas ) { return; } @@ -370,7 +363,7 @@ void QgsMapToolSelectionHandler::createDistanceWidget() deleteDistanceWidget(); mDistanceWidget = new QgsDistanceWidget( tr( "Selection radius:" ) ); - mQgisInterface->addUserInputWidget( mDistanceWidget ); + QgisApp::instance()->addUserInputWidget( mDistanceWidget ); mDistanceWidget->setFocus( Qt::TabFocusReason ); connect( mDistanceWidget, &QgsDistanceWidget::distanceChanged, this, &QgsMapToolSelectionHandler::updateRadiusRubberband ); @@ -438,7 +431,7 @@ void QgsMapToolSelectionHandler::updateRadiusFromEdge( QgsPointXY &radiusEdge ) } } -QgsGeometry QgsMapToolSelectionHandler::selectedGeometry() +QgsGeometry QgsMapToolSelectionHandler::selectedGeometry() const { return mSelectionGeometry; } @@ -454,7 +447,7 @@ void QgsMapToolSelectionHandler::setSelectionMode( SelectionMode mode ) mSelectionMode = mode; } -QgsMapToolSelectionHandler::SelectionMode QgsMapToolSelectionHandler::selectionMode() +QgsMapToolSelectionHandler::SelectionMode QgsMapToolSelectionHandler::selectionMode() const { return mSelectionMode; } diff --git a/src/gui/qgsmaptoolselectionhandler.h b/src/app/qgsmaptoolselectionhandler.h similarity index 92% rename from src/gui/qgsmaptoolselectionhandler.h rename to src/app/qgsmaptoolselectionhandler.h index f5030f6e2ed2..4c662691cb87 100644 --- a/src/gui/qgsmaptoolselectionhandler.h +++ b/src/app/qgsmaptoolselectionhandler.h @@ -19,21 +19,17 @@ #include #include -#include "qgis_gui.h" #include "qgsgeometry.h" class QHBoxLayout; class QKeyEvent; -class QgisInterface; class QgsDoubleSpinBox; class QgsMapCanvas; class QgsMapMouseEvent; class QgsRubberBand; class QgsSnapIndicator; -#ifndef SIP_RUN - /// @cond private /** @@ -75,15 +71,13 @@ class QgsDistanceWidget : public QWidget /// @endcond -#endif - /** * \ingroup gui * \brief Utility class for handling various methods to create geometry for selection in layers. * \since QGIS 3.2 */ -class GUI_EXPORT QgsMapToolSelectionHandler : public QObject +class QgsMapToolSelectionHandler : public QObject { Q_OBJECT @@ -110,14 +104,11 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject //! destructor ~QgsMapToolSelectionHandler() override; - //! Configures QGIS interface - used to register selection radius widget - void setInterface( QgisInterface *iface ); - //! Returns most recently selected geometry (may be a point or a polygon) - QgsGeometry selectedGeometry(); + QgsGeometry selectedGeometry() const; //! Sets the current selection mode - SelectionMode selectionMode(); + SelectionMode selectionMode() const; //! Returns the current selection mode void setSelectionMode( SelectionMode mode ); @@ -180,9 +171,6 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject QgsMapCanvas *mCanvas = nullptr; - //! QGIS interface - used to register selection radius widget - QgisInterface *mQgisInterface = nullptr; - //! the rubberband for selection visualization std::unique_ptr mSelectionRubberBand; @@ -206,8 +194,8 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject //! Shows current angle value and allows numerical editing QgsDistanceWidget *mDistanceWidget = nullptr; - QColor mFillColor; - QColor mStrokeColor; + QColor mFillColor = QColor( 254, 178, 76, 63 ); + QColor mStrokeColor = QColor( 254, 58, 29, 100 ); }; #endif diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 43bae0de66a1..e96f8c82b82d 100755 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -302,7 +302,6 @@ SET(QGIS_GUI_SRCS qgsmaptoolidentify.cpp qgsmaptoolidentifyfeature.cpp qgsmaptoolpan.cpp - qgsmaptoolselectionhandler.cpp qgsmaptoolzoom.cpp qgsmaplayerconfigwidget.cpp qgsmenuheader.cpp @@ -471,7 +470,6 @@ SET(QGIS_GUI_MOC_HDRS qgsmaptoolidentify.h qgsmaptoolidentifyfeature.h qgsmaptoolpan.h - qgsmaptoolselectionhandler.h qgsmaptoolzoom.h qgsmaplayerconfigwidget.h qgsmenuheader.h