Skip to content
Permalink
Browse files
MapToolIdentify moved to gui to make it accessible in python
put back convertMeasurement in gui as it is not app specific

use display settings for specific app units
  • Loading branch information
3nids authored and NathanW2 committed Feb 5, 2013
1 parent 0ebc058 commit 682524ff54d8fff5f8fabb72a4862cd485eee4ff
@@ -39,6 +39,7 @@
%Include qgsmaptip.sip
%Include qgsmaptool.sip
%Include qgsmaptoolemitpoint.sip
%Include qgsmaptoolidentify.sip
%Include qgsmaptoolpan.sip
%Include qgsmaptooltouch.sip
%Include qgsmaptoolzoom.sip
@@ -6,6 +6,7 @@
#include <qgsmaptoolzoom.h>
#include <qgsmaptoolpan.h>
#include <qgsmaptoolemitpoint.h>
#include <qgsmaptoolidentify.h>
%End

%Feature HAVE_TOUCH
@@ -23,6 +24,8 @@ class QgsMapTool : QObject
sipClass = sipClass_QgsMapToolPan;
else if (dynamic_cast<QgsMapToolEmitPoint*>(sipCpp) != NULL)
sipClass = sipClass_QgsMapToolEmitPoint;
else if (dynamic_cast<QgsMapToolIdentify*>(sipCpp) != NULL)
sipClass = sipClass_QgsMapToolIdentify;
else
sipClass = NULL;
%End
@@ -0,0 +1,115 @@

class QgsMapToolIdentify : QgsMapTool
{
%TypeHeaderCode
#include <qgsmaptoolidentify.h>
%End

public:
enum IdentifyMode
{
DefaultQgsSetting=-1,
ActiveLayer,
TopDownStopAtFirst,
TopDownAll,
};

enum LayerType
{
AllLayers=-1,
VectorLayer,
RasterLayer,
};

struct VectorResult
{
VectorResult();
VectorResult(QgsVectorLayer* layer, QgsFeature feature, QMap< QString, QString > derivedAttributes);
QgsVectorLayer* mLayer;
QgsFeature mFeature;
QMap< QString, QString > mDerivedAttributes;
};

struct RasterResult
{
RasterResult();
RasterResult( QgsRasterLayer* layer, QString label, QMap< QString, QString > attributes, QMap< QString, QString > derivedAttributes);
QgsRasterLayer* mLayer;
QString mLabel;
QMap< QString, QString > mAttributes;
QMap< QString, QString > mDerivedAttributes;
};

struct IdentifyResults
{
IdentifyResults();
IdentifyResults ( QList<QgsMapToolIdentify::VectorResult> vectorResults , QList<QgsMapToolIdentify::RasterResult> rasterResults);
QList<QgsMapToolIdentify::VectorResult> mVectorResults;
QList<QgsMapToolIdentify::RasterResult> mRasterResults;
};

//! constructor
QgsMapToolIdentify( QgsMapCanvas* canvas );

//! Overridden mouse move event
virtual void canvasMoveEvent( QMouseEvent * e );

//! Overridden mouse press event
virtual void canvasPressEvent( QMouseEvent * e );

//! Overridden mouse release event
virtual void canvasReleaseEvent( QMouseEvent * e );

virtual void activate();

virtual void deactivate();

//QgsMapLayer::LayerType LayerType;

/** Performs the identification.
@param x x coordinates of mouseEvent
@param y y coordinates of mouseEvent
@param layerList Performs the identification within the given list of layers. Default value is an empty list, i.e. uses all the layers.
@param mode Identification mode. Can use Qgis default settings or a defined mode. Default mode is DefaultQgsSetting.
@return true if identification succeeded and a feature has been found, false otherwise.*/
bool identify(int x, int y, QList<QgsMapLayer*> layerList = QList<QgsMapLayer*>(), IdentifyMode mode = DefaultQgsSetting);

/** Performs the identification.
To avoid beeing forced to specify IdentifyMode with a list of layers
this has been made private and two publics methods are offered
@param x x coordinates of mouseEvent
@param y y coordinates of mouseEvent
@param mode Identification mode. Can use Qgis default settings or a defined mode.
@param layerType Only performs identification in a certain type of layers (raster, vector). Default value is AllLayers.
@return true if identification succeeded and a feature has been found, false otherwise.*/
bool identify(int x, int y, IdentifyMode mode, LayerType layerType = AllLayers);

/** Access to results */
IdentifyResults &results();

signals:
void identifyProgress( int, int );
void identifyMessage( QString );

private:
/** Performs the identification.
To avoid beeing forced to specify IdentifyMode with a list of layers
this has been made private and two publics methods are offered
@param x x coordinates of mouseEvent
@param y y coordinates of mouseEvent
@param mode Identification mode. Can use Qgis default settings or a defined mode.
@param layerList Performs the identification within the given list of layers.
@param layerType Only performs identification in a certain type of layers (raster, vector).
@return true if identification succeeded and a feature has been found, false otherwise.*/
bool identify(int x, int y, IdentifyMode mode, QList<QgsMapLayer*> layerList, LayerType layerType = AllLayers);

bool identifyLayer( QgsMapLayer *layer, int x, int y, LayerType layerType = AllLayers );
bool identifyRasterLayer( QgsRasterLayer *layer, int x, int y );
bool identifyVectorLayer( QgsVectorLayer *layer, int x, int y );

//! Private helper
virtual void convertMeasurement( QgsDistanceArea &calc, double &measure, QGis::UnitType &u, bool isArea );

/** Transforms the measurements of derived attributes in the desired units*/
virtual QGis::UnitType displayUnits();
};
@@ -38,7 +38,7 @@ SET(QGIS_APP_SRCS
qgsfieldcalculator.cpp
qgsfieldsproperties.cpp
qgsgraduatedsymboldialog.cpp
qgsidentifyresults.cpp
qgsidentifyresultsdialog.cpp
qgsfeatureaction.cpp
qgslabeldialog.cpp
qgslabelpropertydialog.cpp
@@ -62,7 +62,7 @@ SET(QGIS_APP_SRCS
qgsmaptoolhtmlannotation.cpp
qgsmaptoolpinlabels.cpp
qgsmaptoolshowhidelabels.cpp
qgsmaptoolidentify.cpp
qgsmaptoolidentifyaction.cpp
qgsmaptoollabel.cpp
qgsmaptoolmeasureangle.cpp
qgsmaptoolmovefeature.cpp
@@ -203,7 +203,7 @@ SET (QGIS_APP_MOC_HDRS
qgsformannotationdialog.h
qgshtmlannotationdialog.h
qgsgraduatedsymboldialog.h
qgsidentifyresults.h
qgsidentifyresultsdialog.h
qgslabeldialog.h
qgslabelengineconfigdialog.h
qgslabelinggui.h
@@ -222,7 +222,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolfeatureaction.h
qgsmaptoolpinlabels.h
qgsmaptoolshowhidelabels.h
qgsmaptoolidentify.h
qgsmaptoolidentifyaction.h
qgsmaptoolmeasureangle.h
qgsmaptoolmovefeature.h
qgsmaptoolmovelabel.h
@@ -224,7 +224,7 @@
#include "qgsmaptoolfeatureaction.h"
#include "qgsmaptoolformannotation.h"
#include "qgsmaptoolhtmlannotation.h"
#include "qgsmaptoolidentify.h"
#include "qgsmaptoolidentifyaction.h"
#include "qgsmaptoolmeasureangle.h"
#include "qgsmaptoolmovefeature.h"
#include "qgsmaptoolrotatefeature.h"
@@ -1861,7 +1861,7 @@ void QgisApp::createCanvasTools()
mMapTools.mTouch = new QgsMapToolTouch( mMapCanvas );
mMapTools.mTouch->setAction( mActionTouch );
#endif
mMapTools.mIdentify = new QgsMapToolIdentify( mMapCanvas );
mMapTools.mIdentify = new QgsMapToolIdentifyAction( mMapCanvas );
mMapTools.mIdentify->setAction( mActionIdentify );
mMapTools.mFeatureAction = new QgsMapToolFeatureAction( mMapCanvas );
mMapTools.mFeatureAction->setAction( mActionFeatureAction );
@@ -18,7 +18,7 @@
#include "qgsfeatureaction.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsidentifyresults.h"
#include "qgsidentifyresultsdialog.h"
#include "qgsattributedialog.h"
#include "qgslogger.h"

Loading

0 comments on commit 682524f

Please sign in to comment.