QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsmapcanvasitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmapcanvasitem.h - base class for map canvas items
3  ----------------------
4  begin : February 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 QGSMAPCANVASITEM_H
17 #define QGSMAPCANVASITEM_H
18 
19 #include <QGraphicsItem>
20 #include "qgsrectangle.h"
21 
22 class QgsMapCanvas;
23 class QgsRenderContext;
24 class QPainter;
25 
30 class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem
31 {
32  protected:
33 
35  QgsMapCanvasItem( QgsMapCanvas* mapCanvas );
36 
37  virtual ~QgsMapCanvasItem();
38 
40  virtual void paint( QPainter * painter ) = 0;
41 
43  virtual void paint( QPainter * painter,
44  const QStyleOptionGraphicsItem * option,
45  QWidget * widget = 0 );
46 
48  void updateCanvas();
49 
55  bool setRenderContextVariables( QPainter* p, QgsRenderContext& context ) const;
56 
57  public:
58 
60  virtual void updatePosition();
61 
63  virtual QRectF boundingRect() const;
64 
66  void setPanningOffset( const QPoint& point );
67 
69  QgsRectangle rect() const;
70 
72  void setRect( const QgsRectangle& r );
73 
75  QgsPoint toMapCoordinates( const QPoint& point );
76 
78  QPointF toCanvasCoordinates( const QgsPoint& point );
79 
80  protected:
81 
84 
87 
91 
93  QSizeF mItemSize;
94 };
95 
96 
97 #endif