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();
|
|
|
|
|
2015-10-07 11:55:34 +11:00
|
|
|
IdentifyResult( QgsMapLayer * layer, const QgsFeature& feature, const QMap< QString, QString >& derivedAttributes );
|
2013-02-07 10:12:10 +01:00
|
|
|
|
2015-10-07 11:55:34 +11:00
|
|
|
IdentifyResult( QgsMapLayer * layer, const QString& label, const QMap< QString, QString >& attributes, const QMap< QString, QString >& derivedAttributes );
|
2013-02-07 10:12:10 +01:00
|
|
|
|
2015-10-07 11:55:34 +11:00
|
|
|
IdentifyResult( QgsMapLayer * layer, const QString& label, const QgsFields& fields, const QgsFeature& feature, const QMap< QString, QString >& derivedAttributes );
|
2013-02-07 10:12:10 +01:00
|
|
|
|
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
|
2015-08-16 16:26:01 +02:00
|
|
|
virtual void canvasMoveEvent( QgsMapMouseEvent * e );
|
2013-01-25 08:06:30 +01:00
|
|
|
|
|
|
|
//! Overridden mouse press event
|
2015-08-16 16:26:01 +02:00
|
|
|
virtual void canvasPressEvent( QgsMapMouseEvent * e );
|
2013-01-25 08:06:30 +01:00
|
|
|
|
|
|
|
//! Overridden mouse release event
|
2015-08-16 16:26:01 +02:00
|
|
|
virtual void canvasReleaseEvent( QgsMapMouseEvent * e );
|
2013-01-25 08:06:30 +01:00
|
|
|
|
|
|
|
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*/
|
2015-10-07 11:55:34 +11:00
|
|
|
QList<QgsMapToolIdentify::IdentifyResult> identify( int x, int y, const 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*/
|
2015-10-07 11:55:34 +11:00
|
|
|
QList<QgsMapToolIdentify::IdentifyResult> identify( int x, int y, IdentifyMode mode, const LayerType& layerType = AllLayers );
|
2013-01-25 08:06:30 +01:00
|
|
|
|
2015-02-03 02:21:52 +01:00
|
|
|
//! return a pointer to the identify menu which will be used in layer selection mode
|
|
|
|
//! this menu can also be customized
|
|
|
|
QgsIdentifyMenu* identifyMenu();
|
|
|
|
|
2013-06-23 16:00:16 +02:00
|
|
|
public slots:
|
|
|
|
void formatChanged( QgsRasterLayer *layer );
|
|
|
|
|
2013-01-25 08:06:30 +01:00
|
|
|
signals:
|
|
|
|
void identifyProgress( int, int );
|
2015-10-26 22:46:25 +11:00
|
|
|
void identifyMessage( const QString& );
|
2013-06-23 16:00:16 +02:00
|
|
|
void changedRasterResults( QList<QgsMapToolIdentify::IdentifyResult>& );
|
2014-05-22 16:39:18 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/** 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).
|
2015-02-03 02:21:52 +01:00
|
|
|
@return a list of IdentifyResult*/
|
2015-10-07 11:55:34 +11:00
|
|
|
QList<QgsMapToolIdentify::IdentifyResult> identify( int x, int y, IdentifyMode mode, const QList<QgsMapLayer*>& layerList, const LayerType& layerType = AllLayers );
|
2014-05-22 16:39:18 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Call the right method depending on layer type */
|
2015-10-07 11:55:34 +11:00
|
|
|
bool identifyLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsMapLayer *layer, const QgsPoint& point, const QgsRectangle& viewExtent, double mapUnitsPerPixel, const LayerType& layerType = AllLayers );
|
2014-05-22 16:39:18 +02:00
|
|
|
|
2015-10-07 11:55:34 +11:00
|
|
|
bool identifyRasterLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsRasterLayer *layer, QgsPoint point, const QgsRectangle& viewExtent, double mapUnitsPerPixel );
|
|
|
|
bool identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsPoint& point );
|
2016-02-14 21:04:41 +11:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
//! Private helper
|
Fix project unit confusion (pt 3): add area unit settings with a
ton of available area units (eg m2, km2, mi2, ft2, yd2, ha, ac,
etc)
Adds a new option in both the QGIS setting and project properties to
set the units used for area measurements. Just like the distance
setting, this defaults to the units set in QGIS options, but can
then be overridden for specific projects.
The setting is respected for area calculations in:
- Attribute table field update bar
- Field calculator calculations
- Identify tool derived length and perimeter values
Also adds unit tests to ensure that area calculated by attribute table
update bar, field calculator and identify tool are consistent wrt
ellipsoidal calculations and area units.
TODO: make measure tool respect area setting
(refs #13209, #4252 and fixes #12939, #2402, #4857)
2016-02-15 07:25:32 +11:00
|
|
|
//! @deprecated use displayDistanceUnits() and displayAreaUnits() instead
|
|
|
|
virtual void convertMeasurement( QgsDistanceArea &calc, double &measure, QGis::UnitType &u, bool isArea ) /Deprecated/;
|
2016-02-14 21:04:41 +11:00
|
|
|
|
Fix project unit confusion (pt 3): add area unit settings with a
ton of available area units (eg m2, km2, mi2, ft2, yd2, ha, ac,
etc)
Adds a new option in both the QGIS setting and project properties to
set the units used for area measurements. Just like the distance
setting, this defaults to the units set in QGIS options, but can
then be overridden for specific projects.
The setting is respected for area calculations in:
- Attribute table field update bar
- Field calculator calculations
- Identify tool derived length and perimeter values
Also adds unit tests to ensure that area calculated by attribute table
update bar, field calculator and identify tool are consistent wrt
ellipsoidal calculations and area units.
TODO: make measure tool respect area setting
(refs #13209, #4252 and fixes #12939, #2402, #4857)
2016-02-15 07:25:32 +11:00
|
|
|
/** Transforms the measurements of derived attributes in the desired units
|
|
|
|
* @deprecated use displayDistanceUnits() and displayAreaUnits() instead
|
|
|
|
*/
|
|
|
|
virtual QGis::UnitType displayUnits() /Deprecated/;
|
2016-02-14 21:04:41 +11:00
|
|
|
|
|
|
|
/** Desired units for distance display.
|
|
|
|
* @note added in QGIS 2.14
|
Fix project unit confusion (pt 3): add area unit settings with a
ton of available area units (eg m2, km2, mi2, ft2, yd2, ha, ac,
etc)
Adds a new option in both the QGIS setting and project properties to
set the units used for area measurements. Just like the distance
setting, this defaults to the units set in QGIS options, but can
then be overridden for specific projects.
The setting is respected for area calculations in:
- Attribute table field update bar
- Field calculator calculations
- Identify tool derived length and perimeter values
Also adds unit tests to ensure that area calculated by attribute table
update bar, field calculator and identify tool are consistent wrt
ellipsoidal calculations and area units.
TODO: make measure tool respect area setting
(refs #13209, #4252 and fixes #12939, #2402, #4857)
2016-02-15 07:25:32 +11:00
|
|
|
* @see displayAreaUnits()
|
2016-02-14 21:04:41 +11:00
|
|
|
*/
|
Fix project unit confusion (pt 3): add area unit settings with a
ton of available area units (eg m2, km2, mi2, ft2, yd2, ha, ac,
etc)
Adds a new option in both the QGIS setting and project properties to
set the units used for area measurements. Just like the distance
setting, this defaults to the units set in QGIS options, but can
then be overridden for specific projects.
The setting is respected for area calculations in:
- Attribute table field update bar
- Field calculator calculations
- Identify tool derived length and perimeter values
Also adds unit tests to ensure that area calculated by attribute table
update bar, field calculator and identify tool are consistent wrt
ellipsoidal calculations and area units.
TODO: make measure tool respect area setting
(refs #13209, #4252 and fixes #12939, #2402, #4857)
2016-02-15 07:25:32 +11:00
|
|
|
virtual QGis::UnitType displayDistanceUnits() const;
|
|
|
|
|
|
|
|
/** Desired units for area display.
|
|
|
|
* @note added in QGIS 2.14
|
|
|
|
* @see displayDistanceUnits()
|
|
|
|
*/
|
|
|
|
virtual QgsUnitTypes::AreaUnit displayAreaUnits() const;
|
2013-01-25 08:06:30 +01:00
|
|
|
};
|