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