QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsmaptoolidentify.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaptoolidentify.h - map tool for identifying features
3  ---------------------
4  begin : January 2006
5  copyright : (C) 2006 by Martin Dobias
6  email : wonder.sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMAPTOOLIDENTIFY_H
17 #define QGSMAPTOOLIDENTIFY_H
18 
19 
20 #include "qgsmaptool.h"
21 #include "qgspoint.h"
22 #include "qgsfeature.h"
23 #include "qgsfield.h"
24 #include "qgsdistancearea.h"
25 #include "qgsmaplayer.h"
26 
27 #include <QObject>
28 #include <QPointer>
29 
30 class QgsRasterLayer;
31 class QgsVectorLayer;
32 class QgsMapLayer;
33 class QgsMapCanvas;
34 
43 class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool
44 {
45  Q_OBJECT
46 
47  public:
48 
50  {
51  DefaultQgsSetting = -1,
54  TopDownAll
55  };
56 
57  enum LayerType
58  {
59  AllLayers = -1,
61  RasterLayer
62  };
63 
65  {
67 
68  IdentifyResult( QgsMapLayer * layer, QgsFeature feature, QMap< QString, QString > derivedAttributes ):
69  mLayer( layer ), mFeature( feature ), mDerivedAttributes( derivedAttributes ) {}
70 
71  IdentifyResult( QgsMapLayer * layer, QString label, QMap< QString, QString > attributes, QMap< QString, QString > derivedAttributes ):
72  mLayer( layer ), mLabel( label ), mAttributes( attributes ), mDerivedAttributes( derivedAttributes ) {}
73 
74  IdentifyResult( QgsMapLayer * layer, QString label, QgsFields fields, QgsFeature feature, QMap< QString, QString > derivedAttributes ):
75  mLayer( layer ), mLabel( label ), mFields( fields ), mFeature( feature ), mDerivedAttributes( derivedAttributes ) {}
76 
78  QString mLabel;
81  QMap< QString, QString > mAttributes;
82  QMap< QString, QString > mDerivedAttributes;
83  QMap< QString, QVariant > mParams;
84  };
85 
87  QgsMapToolIdentify( QgsMapCanvas * canvas );
88 
89  virtual ~QgsMapToolIdentify();
90 
92  virtual void canvasMoveEvent( QMouseEvent * e );
93 
95  virtual void canvasPressEvent( QMouseEvent * e );
96 
98  virtual void canvasReleaseEvent( QMouseEvent * e );
99 
100  virtual void activate();
101 
102  virtual void deactivate();
103 
110  QList<IdentifyResult> identify( int x, int y, QList<QgsMapLayer*> layerList = QList<QgsMapLayer*>(), IdentifyMode mode = DefaultQgsSetting );
111 
120  QList<IdentifyResult> identify( int x, int y, IdentifyMode mode, LayerType layerType = AllLayers );
121 
122  public slots:
123  void formatChanged( QgsRasterLayer *layer );
124 
125  signals:
126  void identifyProgress( int, int );
127  void identifyMessage( QString );
128  void changedRasterResults( QList<IdentifyResult>& );
129 
130  private:
140  QList<IdentifyResult> identify( int x, int y, IdentifyMode mode, QList<QgsMapLayer*> layerList, LayerType layerType = AllLayers );
141 
143  bool identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, QgsPoint point, QgsRectangle viewExtent, double mapUnitsPerPixel, LayerType layerType = AllLayers );
144 
145  bool identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, QgsPoint point, QgsRectangle viewExtent, double mapUnitsPerPixel );
146  bool identifyVectorLayer( QList<IdentifyResult> *results, QgsVectorLayer *layer, QgsPoint point );
147 
149  virtual void convertMeasurement( QgsDistanceArea &calc, double &measure, QGis::UnitType &u, bool isArea );
150 
152  virtual QGis::UnitType displayUnits();
153 
154  QMap< QString, QString > featureDerivedAttributes( QgsFeature *feature, QgsMapLayer *layer );
155 
156  // Last point in canvas CRS
158 
160 
162 };
163 
164 #endif