QGIS API Documentation  master-59fd5e0
src/gui/qgsmapcanvasitem.h
Go to the documentation of this file.
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   public:
00058 
00060     virtual void updatePosition();
00061 
00063     virtual QRectF boundingRect() const;
00064 
00066     void setPanningOffset( const QPoint& point );
00067 
00069     QgsRectangle rect() const;
00070 
00072     void setRect( const QgsRectangle& r );
00073 
00075     QgsPoint toMapCoordinates( const QPoint& point );
00076 
00078     QPointF toCanvasCoordinates( const QgsPoint& point );
00079 
00080   protected:
00081 
00083     QgsMapCanvas* mMapCanvas;
00084 
00086     QgsRectangle mRect;
00087 
00090     QPoint mPanningOffset;
00091 
00093     QSizeF mItemSize;
00094 };
00095 
00096 
00097 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines