2013-01-25 08:06:30 +01:00
class QgsMapToolIdentify : QgsMapTool
{
%TypeHeaderCode
#include <qgsmaptoolidentify.h>
%End
public:
2013-06-23 16:00:16 +02:00
2013-01-25 08:06:30 +01:00
enum IdentifyMode
{
2014-06-02 21:00:51 +02:00
DefaultQgsSetting,
2013-06-23 16:00:16 +02:00
ActiveLayer,
TopDownStopAtFirst,
2013-10-28 08:29:49 +01:00
TopDownAll,
LayerSelection
2013-01-25 08:06:30 +01:00
};
2014-08-14 08:25:09 +02:00
enum Type
2013-01-25 08:06:30 +01:00
{
2013-06-23 16:00:16 +02:00
VectorLayer,
2014-08-14 08:25:09 +02:00
RasterLayer,
AllLayers
2013-01-25 08:06:30 +01:00
};
2014-08-14 08:25:09 +02:00
typedef QFlags<QgsMapToolIdentify::Type> LayerType;
2013-02-07 10:12:10 +01:00
struct IdentifyResult
2013-01-25 08:06:30 +01:00
{
2013-02-07 10:12:10 +01:00
IdentifyResult();
IdentifyResult( QgsMapLayer * layer, QgsFeature feature, QMap< QString, QString > derivedAttributes );
IdentifyResult( QgsMapLayer * layer, QString label, QMap< QString, QString > attributes, QMap< QString, QString > derivedAttributes );
IdentifyResult( QgsMapLayer * layer, QString label, QgsFields fields, QgsFeature feature, QMap< QString, QString > derivedAttributes );
2013-06-23 16:00:16 +02:00
QgsMapLayer* mLayer;
2013-02-06 15:14:16 +01:00
QString mLabel;
QgsFields mFields;
QgsFeature mFeature;
QMap< QString, QString > mAttributes;
QMap< QString, QString > mDerivedAttributes;
2013-06-23 16:00:16 +02:00
QMap< QString, QVariant > mParams;
2013-01-25 08:06:30 +01:00
};
2013-06-23 16:00:16 +02:00
//! constructor
QgsMapToolIdentify( QgsMapCanvas * canvas );
virtual ~QgsMapToolIdentify();
2013-01-25 08:06:30 +01:00
//! 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();
/** 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.
2013-02-07 10:12:10 +01:00
@return a list of IdentifyResult*/
2014-01-26 18:35:21 +01:00
QList<QgsMapToolIdentify::IdentifyResult> identify( int x, int y, QList<QgsMapLayer*> layerList = QList<QgsMapLayer*>(), IdentifyMode mode = DefaultQgsSetting );
2013-01-25 08:06:30 +01:00
/** 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.
2013-02-07 10:12:10 +01:00
@return a list of IdentifyResult*/
2014-01-26 18:35:21 +01:00
QList<QgsMapToolIdentify::IdentifyResult> identify( int x, int y, IdentifyMode mode, LayerType layerType = AllLayers );
2013-01-25 08:06:30 +01:00
2014-05-27 23:22:50 +02:00
protected:
//! rubber bands for layer select mode
void deleteRubberBands();
2013-06-23 16:00:16 +02:00
public slots:
void formatChanged( QgsRasterLayer *layer );
2014-05-27 23:22:50 +02:00
void layerDestroyed();
2013-06-23 16:00:16 +02:00
2013-01-25 08:06:30 +01:00
signals:
void identifyProgress( int, int );
void identifyMessage( QString );
2013-06-23 16:00:16 +02:00
void changedRasterResults( QList<QgsMapToolIdentify::IdentifyResult>& );
2013-01-25 08:06:30 +01:00
};