Quantum GIS API Documentation
1.8
|
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 00016 #ifndef QGSMAPCANVASITEM_H 00017 #define QGSMAPCANVASITEM_H 00018 00019 #include <QGraphicsItem> 00020 #include "qgsrectangle.h" 00021 00022 class QgsMapCanvas; 00023 class QgsRenderContext; 00024 class QPainter; 00025 00030 class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem 00031 { 00032 protected: 00033 00035 QgsMapCanvasItem( QgsMapCanvas* mapCanvas ); 00036 00037 virtual ~QgsMapCanvasItem(); 00038 00040 virtual void paint( QPainter * painter ) = 0; 00041 00043 virtual void paint( QPainter * painter, 00044 const QStyleOptionGraphicsItem * option, 00045 QWidget * widget = 0 ); 00046 00048 void updateCanvas(); 00049 00055 bool setRenderContextVariables( QPainter* p, QgsRenderContext& context ) const; 00056 00057 00058 public: 00059 00061 virtual void updatePosition(); 00062 00064 virtual QRectF boundingRect() const; 00065 00067 void setPanningOffset( const QPoint& point ); 00068 00070 QgsRectangle rect() const; 00071 00073 void setRect( const QgsRectangle& r ); 00074 00076 QgsPoint toMapCoordinates( const QPoint& point ); 00077 00079 QPointF toCanvasCoordinates( const QgsPoint& point ); 00080 00081 protected: 00082 00084 QgsMapCanvas* mMapCanvas; 00085 00087 QgsRectangle mRect; 00088 00091 QPoint mPanningOffset; 00092 00094 QSizeF mItemSize; 00095 }; 00096 00097 00098 #endif