Quantum GIS API Documentation
1.7.4
|
00001 /*************************************************************************** 00002 qgsmapcanvasitem.h - base class for map canvas items 00003 ---------------------- 00004 begin : February 2006 00005 copyright : (C) 2006 by Martin Dobias 00006 email : wonder.sk at gmail dot com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 /* $Id$ */ 00016 00017 #ifndef QGSMAPCANVASITEM_H 00018 #define QGSMAPCANVASITEM_H 00019 00020 #include <QGraphicsItem> 00021 #include "qgsrectangle.h" 00022 00023 class QgsMapCanvas; 00024 class QgsRenderContext; 00025 class QPainter; 00026 00031 class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem 00032 { 00033 protected: 00034 00036 QgsMapCanvasItem( QgsMapCanvas* mapCanvas ); 00037 00038 virtual ~QgsMapCanvasItem(); 00039 00041 virtual void paint( QPainter * painter ) = 0; 00042 00044 virtual void paint( QPainter * painter, 00045 const QStyleOptionGraphicsItem * option, 00046 QWidget * widget = 0 ); 00047 00049 void updateCanvas(); 00050 00056 bool setRenderContextVariables( QPainter* p, QgsRenderContext& context ) const; 00057 00058 00059 public: 00060 00062 virtual void updatePosition(); 00063 00065 virtual QRectF boundingRect() const; 00066 00068 void setPanningOffset( const QPoint& point ); 00069 00071 QgsRectangle rect() const; 00072 00074 void setRect( const QgsRectangle& r ); 00075 00077 QgsPoint toMapCoordinates( const QPoint& point ); 00078 00080 QPointF toCanvasCoordinates( const QgsPoint& point ); 00081 00082 protected: 00083 00085 QgsMapCanvas* mMapCanvas; 00086 00088 QgsRectangle mRect; 00089 00092 QPoint mPanningOffset; 00093 00095 QSizeF mItemSize; 00096 }; 00097 00098 00099 #endif