Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 /* $Id$ */
16 
17 #ifndef QGSMAPCANVASITEM_H
18 #define QGSMAPCANVASITEM_H
19 
20 #include <QGraphicsItem>
21 #include "qgsrectangle.h"
22 
23 class QgsMapCanvas;
24 class QgsRenderContext;
25 class QPainter;
26 
31 class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem
32 {
33  protected:
34 
36  QgsMapCanvasItem( QgsMapCanvas* mapCanvas );
37 
38  virtual ~QgsMapCanvasItem();
39 
41  virtual void paint( QPainter * painter ) = 0;
42 
44  virtual void paint( QPainter * painter,
45  const QStyleOptionGraphicsItem * option,
46  QWidget * widget = 0 );
47 
49  void updateCanvas();
50 
56  bool setRenderContextVariables( QPainter* p, QgsRenderContext& context ) const;
57 
58 
59  public:
60 
62  virtual void updatePosition();
63 
65  virtual QRectF boundingRect() const;
66 
68  void setPanningOffset( const QPoint& point );
69 
71  QgsRectangle rect() const;
72 
74  void setRect( const QgsRectangle& r );
75 
77  QgsPoint toMapCoordinates( const QPoint& point );
78 
80  QPointF toCanvasCoordinates( const QgsPoint& point );
81 
82  protected:
83 
86 
89 
93 
95  QSizeF mItemSize;
96 };
97 
98 
99 #endif