QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgshighlight.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgshighlight.h - widget to highlight geometries
3  --------------------------------------
4  Date : 02-Mar-2011
5  Copyright : (C) 2011 by Juergen E. Fischer, norBIT GmbH
6  Email : jef at norbit dot de
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 #ifndef QGSHIGHLIGHT_H
16 #define QGSHIGHLIGHT_H
17 
18 #include "qgsmapcanvasitem.h"
19 #include "qgsfeaturestore.h"
20 #include "qgsgeometry.h"
21 #include "qgsrendererv2.h"
22 #include <QBrush>
23 #include <QColor>
24 #include <QList>
25 #include <QPen>
26 #include <QPainter>
27 #include <QPainterPath>
28 
29 class QgsMapLayer;
30 class QgsVectorLayer;
31 class QgsSymbolV2;
32 
35 class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
36 {
37  public:
38  QgsHighlight( QgsMapCanvas *mapCanvas, QgsGeometry *geom, QgsMapLayer *layer );
39  QgsHighlight( QgsMapCanvas *mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer );
46  QgsHighlight( QgsMapCanvas *mapCanvas, const QgsFeature& feature, QgsVectorLayer *layer );
47  ~QgsHighlight();
48 
49  void setColor( const QColor & color );
50 
52  void setWidth( int width );
53 
54  protected:
55  virtual void paint( QPainter* p );
56 
58  void updateRect();
59 
60  private:
61  void init();
62  void setSymbolColor( QgsSymbolV2* symbol, const QColor & color );
63  void paintPoint( QPainter *p, QgsPoint point );
64  void paintLine( QPainter *p, QgsPolyline line );
65  void paintPolygon( QPainter *p, QgsPolygon polygon );
66 
67  QgsVectorLayer *vectorLayer();
68 
69  QgsHighlight();
70 
71  QBrush mBrush;
72  QPen mPen;
78 };
79 
80 #endif
Base class for all map layer types.
Definition: qgsmaplayer.h:45
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
Definition: qgsgeometry.h:38
An abstract class for items that can be placed on the map canvas.
QgsMapLayer * mLayer
Definition: qgshighlight.h:74
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:114
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:99
QgsFeature mFeature
Definition: qgshighlight.h:75
QgsGeometry * mGeometry
Definition: qgshighlight.h:73
A class for highlight features on the map.
Definition: qgshighlight.h:35
QgsFeatureRendererV2 * mRenderer
Definition: qgshighlight.h:76
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
Definition: qgsgeometry.h:44
A class to represent a point geometry.
Definition: qgspoint.h:63
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
QColor mTemporaryFillColor
Definition: qgshighlight.h:77
QBrush mBrush
Definition: qgshighlight.h:71
Represents a vector layer which manages a vector based data sets.