Quantum GIS API Documentation  1.7.4
src/gui/qgsrubberband.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     qgsrubberband.h - Rubberband widget for drawing multilines and polygons
00003      --------------------------------------
00004     Date                 : 07-Jan-2006
00005     Copyright            : (C) 2006 by Tom Elwertowski
00006     Email                : telwertowski at users dot sourceforge dot net
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 #ifndef QGSRUBBERBAND_H
00017 #define QGSRUBBERBAND_H
00018 
00019 #include "qgsmapcanvasitem.h"
00020 #include "qgsgeometry.h"
00021 #include <QBrush>
00022 #include <QList>
00023 #include <QPen>
00024 #include <QPolygon>
00025 
00026 class QgsVectorLayer;
00027 class QPaintEvent;
00028 
00032 class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
00033 {
00034   public:
00035     QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon = false );
00036     ~QgsRubberBand();
00037 
00038     void setColor( const QColor & color );
00039     void setWidth( int width );
00040 
00041     void reset( bool isPolygon = false );
00042 
00046     void addPoint( const QgsPoint & p, bool update = true, int geometryIndex = 0 );
00047 
00049     void removeLastPoint( int geometryIndex = 0 );
00050 
00051     void movePoint( const QgsPoint & p, int geometryIndex = 0 );
00054     void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
00055 
00062     void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
00063 
00067     void setToCanvasRectangle( const QRect& rect );
00068 
00076     void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
00077 
00079     void setTranslationOffset( double dx, double dy );
00080 
00083     int size() const;
00084 
00086     int numberOfVertices() const;
00087 
00089     const QgsPoint *getPoint( int i, int j = 0 ) const;
00090 
00093     QgsGeometry* asGeometry();
00094 
00095   protected:
00096     virtual void paint( QPainter* p );
00097 
00099     void updateRect();
00100 
00101   private:
00102     QBrush mBrush;
00103     QPen mPen;
00104 
00106     QList< QList <QgsPoint> > mPoints;
00107     bool mIsPolygon;
00108     double mTranslationOffsetX;
00109     double mTranslationOffsetY;
00110 
00111     QgsRubberBand();
00112 
00113     static QgsPolyline getPolyline( const QList<QgsPoint> & points );
00114 
00115 };
00116 
00117 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines