Skip to content

Commit

Permalink
Moved selection handler from gui lib to app
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 23, 2018
1 parent 4adb762 commit 8c7b632
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 157 deletions.
1 change: 0 additions & 1 deletion python/gui/gui_auto.sip
Expand Up @@ -144,7 +144,6 @@
%Include qgsmaptoolidentify.sip %Include qgsmaptoolidentify.sip
%Include qgsmaptoolidentifyfeature.sip %Include qgsmaptoolidentifyfeature.sip
%Include qgsmaptoolpan.sip %Include qgsmaptoolpan.sip
%Include qgsmaptoolselectionhandler.sip
%Include qgsmaptoolzoom.sip %Include qgsmaptoolzoom.sip
%Include qgsmaplayerconfigwidget.sip %Include qgsmaplayerconfigwidget.sip
%Include qgsmenuheader.sip %Include qgsmenuheader.sip
Expand Down
104 changes: 0 additions & 104 deletions python/gui/qgsmaptoolselectionhandler.sip.in

This file was deleted.

2 changes: 2 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -97,6 +97,7 @@ SET(QGIS_APP_SRCS
qgsmaptoolrotatelabel.cpp qgsmaptoolrotatelabel.cpp
qgsmaptoolrotatepointsymbols.cpp qgsmaptoolrotatepointsymbols.cpp
qgsmaptoolselect.cpp qgsmaptoolselect.cpp
qgsmaptoolselectionhandler.cpp
qgsmaptoolselectutils.cpp qgsmaptoolselectutils.cpp
qgsmaptoolsimplify.cpp qgsmaptoolsimplify.cpp
qgsmaptoolsplitfeatures.cpp qgsmaptoolsplitfeatures.cpp
Expand Down Expand Up @@ -307,6 +308,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolrotatelabel.h qgsmaptoolrotatelabel.h
qgsmaptoolrotatepointsymbols.h qgsmaptoolrotatepointsymbols.h
qgsmaptoolselect.h qgsmaptoolselect.h
qgsmaptoolselectionhandler.h
qgsmaptoolsimplify.h qgsmaptoolsimplify.h
qgsmaptoolsplitfeatures.h qgsmaptoolsplitfeatures.h
qgsmaptoolsplitparts.h qgsmaptoolsplitparts.h
Expand Down
7 changes: 0 additions & 7 deletions src/app/qgisapp.cpp
Expand Up @@ -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 // should come after fileNewBlank to ensure project is properly set up to receive any data source files
QgsApplication::setFileOpenEventReceiver( this ); 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 #ifdef ANDROID
toggleFullScreen(); toggleFullScreen();
#endif #endif
Expand Down
5 changes: 0 additions & 5 deletions src/app/qgsmaptoolidentifyaction.cpp
Expand Up @@ -204,11 +204,6 @@ void QgsMapToolIdentifyAction::deactivate()
QgsMapToolIdentify::deactivate(); QgsMapToolIdentify::deactivate();
} }


void QgsMapToolIdentifyAction::setInterface( QgisInterface *iface )
{
mSelectionHandler->setInterface( iface );
}

QgsUnitTypes::DistanceUnit QgsMapToolIdentifyAction::displayDistanceUnits() const QgsUnitTypes::DistanceUnit QgsMapToolIdentifyAction::displayDistanceUnits() const
{ {
return QgsProject::instance()->distanceUnits(); return QgsProject::instance()->distanceUnits();
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsmaptoolidentifyaction.h
Expand Up @@ -61,8 +61,6 @@ class APP_EXPORT QgsMapToolIdentifyAction : public QgsMapToolIdentify


void deactivate() override; void deactivate() override;


void setInterface( QgisInterface *iface );

public slots: public slots:
void handleCopyToClipboard( QgsFeatureStore & ); void handleCopyToClipboard( QgsFeatureStore & );
void handleChangedRasterResults( QList<QgsMapToolIdentify::IdentifyResult> &results ); void handleChangedRasterResults( QList<QgsMapToolIdentify::IdentifyResult> &results );
Expand Down
5 changes: 0 additions & 5 deletions src/app/qgsmaptoolselect.cpp
Expand Up @@ -38,11 +38,6 @@ QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas *canvas )
setSelectionMode( QgsMapToolSelectionHandler::SelectSimple ); setSelectionMode( QgsMapToolSelectionHandler::SelectSimple );
} }


void QgsMapToolSelect::setInterface( QgisInterface *iface )
{
mSelectionHandler->setInterface( iface );
}

void QgsMapToolSelect::setSelectionMode( QgsMapToolSelectionHandler::SelectionMode selectionMode ) void QgsMapToolSelect::setSelectionMode( QgsMapToolSelectionHandler::SelectionMode selectionMode )
{ {
mSelectionHandler->setSelectionMode( selectionMode ); mSelectionHandler->setSelectionMode( selectionMode );
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsmaptoolselect.h
Expand Up @@ -31,8 +31,6 @@ class APP_EXPORT QgsMapToolSelect : public QgsMapTool


void setSelectionMode( QgsMapToolSelectionHandler::SelectionMode selectionMode ); void setSelectionMode( QgsMapToolSelectionHandler::SelectionMode selectionMode );


void setInterface( QgisInterface *iface );

void canvasPressEvent( QgsMapMouseEvent *e ) override; void canvasPressEvent( QgsMapMouseEvent *e ) override;
void canvasMoveEvent( QgsMapMouseEvent *e ) override; void canvasMoveEvent( QgsMapMouseEvent *e ) override;
void canvasReleaseEvent( QgsMapMouseEvent *e ) override; void canvasReleaseEvent( QgsMapMouseEvent *e ) override;
Expand Down
Expand Up @@ -19,7 +19,7 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QLabel> #include <QLabel>


#include "qgisinterface.h" #include "qgisapp.h"
#include "qgsdoublespinbox.h" #include "qgsdoublespinbox.h"
#include "qgsmapcanvas.h" #include "qgsmapcanvas.h"
#include "qgsmapmouseevent.h" #include "qgsmapmouseevent.h"
Expand Down Expand Up @@ -102,8 +102,6 @@ QgsMapToolSelectionHandler::QgsMapToolSelectionHandler( QgsMapCanvas *canvas, Qg
, mCanvas( canvas ) , mCanvas( canvas )
, mSelectionMode( selectionMode ) , mSelectionMode( selectionMode )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator >( canvas ) ) , mSnapIndicator( qgis::make_unique< QgsSnapIndicator >( canvas ) )
, mFillColor( QColor( 254, 178, 76, 63 ) )
, mStrokeColor( QColor( 254, 58, 29, 100 ) )
{ {
} }


Expand All @@ -112,11 +110,6 @@ QgsMapToolSelectionHandler::~QgsMapToolSelectionHandler()
cancel(); cancel();
} }


void QgsMapToolSelectionHandler::setInterface( QgisInterface *iface )
{
mQgisInterface = iface;
}

void QgsMapToolSelectionHandler::canvasReleaseEvent( QgsMapMouseEvent *e ) void QgsMapToolSelectionHandler::canvasReleaseEvent( QgsMapMouseEvent *e )
{ {
switch ( mSelectionMode ) switch ( mSelectionMode )
Expand Down Expand Up @@ -362,15 +355,15 @@ void QgsMapToolSelectionHandler::initRubberBand()


void QgsMapToolSelectionHandler::createDistanceWidget() void QgsMapToolSelectionHandler::createDistanceWidget()
{ {
if ( !mCanvas || !mQgisInterface ) if ( !mCanvas )
{ {
return; return;
} }


deleteDistanceWidget(); deleteDistanceWidget();


mDistanceWidget = new QgsDistanceWidget( tr( "Selection radius:" ) ); mDistanceWidget = new QgsDistanceWidget( tr( "Selection radius:" ) );
mQgisInterface->addUserInputWidget( mDistanceWidget ); QgisApp::instance()->addUserInputWidget( mDistanceWidget );
mDistanceWidget->setFocus( Qt::TabFocusReason ); mDistanceWidget->setFocus( Qt::TabFocusReason );


connect( mDistanceWidget, &QgsDistanceWidget::distanceChanged, this, &QgsMapToolSelectionHandler::updateRadiusRubberband ); connect( mDistanceWidget, &QgsDistanceWidget::distanceChanged, this, &QgsMapToolSelectionHandler::updateRadiusRubberband );
Expand Down Expand Up @@ -438,7 +431,7 @@ void QgsMapToolSelectionHandler::updateRadiusFromEdge( QgsPointXY &radiusEdge )
} }
} }


QgsGeometry QgsMapToolSelectionHandler::selectedGeometry() QgsGeometry QgsMapToolSelectionHandler::selectedGeometry() const
{ {
return mSelectionGeometry; return mSelectionGeometry;
} }
Expand All @@ -454,7 +447,7 @@ void QgsMapToolSelectionHandler::setSelectionMode( SelectionMode mode )
mSelectionMode = mode; mSelectionMode = mode;
} }


QgsMapToolSelectionHandler::SelectionMode QgsMapToolSelectionHandler::selectionMode() QgsMapToolSelectionHandler::SelectionMode QgsMapToolSelectionHandler::selectionMode() const
{ {
return mSelectionMode; return mSelectionMode;
} }
Expand Up @@ -19,21 +19,17 @@
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>


#include "qgis_gui.h"
#include "qgsgeometry.h" #include "qgsgeometry.h"


class QHBoxLayout; class QHBoxLayout;
class QKeyEvent; class QKeyEvent;


class QgisInterface;
class QgsDoubleSpinBox; class QgsDoubleSpinBox;
class QgsMapCanvas; class QgsMapCanvas;
class QgsMapMouseEvent; class QgsMapMouseEvent;
class QgsRubberBand; class QgsRubberBand;
class QgsSnapIndicator; class QgsSnapIndicator;


#ifndef SIP_RUN

/// @cond private /// @cond private


/** /**
Expand Down Expand Up @@ -75,15 +71,13 @@ class QgsDistanceWidget : public QWidget


/// @endcond /// @endcond


#endif



/** /**
* \ingroup gui * \ingroup gui
* \brief Utility class for handling various methods to create geometry for selection in layers. * \brief Utility class for handling various methods to create geometry for selection in layers.
* \since QGIS 3.2 * \since QGIS 3.2
*/ */
class GUI_EXPORT QgsMapToolSelectionHandler : public QObject class QgsMapToolSelectionHandler : public QObject
{ {
Q_OBJECT Q_OBJECT


Expand All @@ -110,14 +104,11 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject
//! destructor //! destructor
~QgsMapToolSelectionHandler() override; ~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) //! Returns most recently selected geometry (may be a point or a polygon)
QgsGeometry selectedGeometry(); QgsGeometry selectedGeometry() const;


//! Sets the current selection mode //! Sets the current selection mode
SelectionMode selectionMode(); SelectionMode selectionMode() const;
//! Returns the current selection mode //! Returns the current selection mode
void setSelectionMode( SelectionMode mode ); void setSelectionMode( SelectionMode mode );


Expand Down Expand Up @@ -180,9 +171,6 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject


QgsMapCanvas *mCanvas = nullptr; QgsMapCanvas *mCanvas = nullptr;


//! QGIS interface - used to register selection radius widget
QgisInterface *mQgisInterface = nullptr;

//! the rubberband for selection visualization //! the rubberband for selection visualization
std::unique_ptr<QgsRubberBand> mSelectionRubberBand; std::unique_ptr<QgsRubberBand> mSelectionRubberBand;


Expand All @@ -206,8 +194,8 @@ class GUI_EXPORT QgsMapToolSelectionHandler : public QObject
//! Shows current angle value and allows numerical editing //! Shows current angle value and allows numerical editing
QgsDistanceWidget *mDistanceWidget = nullptr; QgsDistanceWidget *mDistanceWidget = nullptr;


QColor mFillColor; QColor mFillColor = QColor( 254, 178, 76, 63 );
QColor mStrokeColor; QColor mStrokeColor = QColor( 254, 58, 29, 100 );
}; };


#endif #endif
2 changes: 0 additions & 2 deletions src/gui/CMakeLists.txt
Expand Up @@ -302,7 +302,6 @@ SET(QGIS_GUI_SRCS
qgsmaptoolidentify.cpp qgsmaptoolidentify.cpp
qgsmaptoolidentifyfeature.cpp qgsmaptoolidentifyfeature.cpp
qgsmaptoolpan.cpp qgsmaptoolpan.cpp
qgsmaptoolselectionhandler.cpp
qgsmaptoolzoom.cpp qgsmaptoolzoom.cpp
qgsmaplayerconfigwidget.cpp qgsmaplayerconfigwidget.cpp
qgsmenuheader.cpp qgsmenuheader.cpp
Expand Down Expand Up @@ -471,7 +470,6 @@ SET(QGIS_GUI_MOC_HDRS
qgsmaptoolidentify.h qgsmaptoolidentify.h
qgsmaptoolidentifyfeature.h qgsmaptoolidentifyfeature.h
qgsmaptoolpan.h qgsmaptoolpan.h
qgsmaptoolselectionhandler.h
qgsmaptoolzoom.h qgsmaptoolzoom.h
qgsmaplayerconfigwidget.h qgsmaplayerconfigwidget.h
qgsmenuheader.h qgsmenuheader.h
Expand Down

0 comments on commit 8c7b632

Please sign in to comment.