class QgsMapToolIdentify : QgsMapTool { %TypeHeaderCode #include %End public: enum IdentifyMode { DefaultQgsSetting, ActiveLayer, TopDownStopAtFirst, TopDownAll, LayerSelection }; enum Type { VectorLayer, RasterLayer, AllLayers }; typedef QFlags LayerType; struct IdentifyResult { IdentifyResult(); IdentifyResult( QgsMapLayer *layer, const QgsFeature &feature, const QMap< QString, QString > &derivedAttributes ); IdentifyResult( QgsMapLayer *layer, const QString &label, const QMap< QString, QString > &attributes, const QMap< QString, QString > &derivedAttributes ); IdentifyResult( QgsMapLayer *layer, const QString &label, const QgsFields &fields, const QgsFeature &feature, const QMap< QString, QString > &derivedAttributes ); QgsMapLayer *mLayer; QString mLabel; QgsFields mFields; QgsFeature mFeature; QMap< QString, QString > mAttributes; QMap< QString, QString > mDerivedAttributes; QMap< QString, QVariant > mParams; }; //! constructor QgsMapToolIdentify( QgsMapCanvas *canvas ); virtual ~QgsMapToolIdentify(); virtual Flags flags() const; //! Overridden mouse move event virtual void canvasMoveEvent( QgsMapMouseEvent *e ); //! Overridden mouse press event virtual void canvasPressEvent( QgsMapMouseEvent *e ); //! Overridden mouse release event virtual void canvasReleaseEvent( QgsMapMouseEvent *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. @return a list of IdentifyResult*/ QList identify( int x, int y, const QList &layerList = QList(), IdentifyMode mode = DefaultQgsSetting ); /** Performs the identification. To avoid being 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 a list of IdentifyResult*/ QList identify( int x, int y, IdentifyMode mode, LayerType layerType = AllLayers ); //! return a pointer to the identify menu which will be used in layer selection mode //! this menu can also be customized QgsIdentifyMenu *identifyMenu(); public slots: void formatChanged( QgsRasterLayer *layer ); signals: void identifyProgress( int, int ); void identifyMessage( const QString& ); void changedRasterResults( QList& ); protected: /** Performs the identification. To avoid being 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 a list of IdentifyResult*/ QList identify( int x, int y, IdentifyMode mode, const QList &layerList, LayerType layerType = AllLayers ); /** Call the right method depending on layer type */ bool identifyLayer( QList *results, QgsMapLayer *layer, const QgsPoint &point, const QgsRectangle &viewExtent, double mapUnitsPerPixel, LayerType layerType = AllLayers ); bool identifyRasterLayer( QList *results, QgsRasterLayer *layer, QgsPoint point, const QgsRectangle &viewExtent, double mapUnitsPerPixel ); bool identifyVectorLayer( QList *results, QgsVectorLayer *layer, const QgsPoint &point ); private: /** Desired units for distance display. * @note added in QGIS 2.14 * @see displayAreaUnits() */ virtual QgsUnitTypes::DistanceUnit displayDistanceUnits() const; /** Desired units for area display. * @note added in QGIS 2.14 * @see displayDistanceUnits() */ virtual QgsUnitTypes::AreaUnit displayAreaUnits() const; };