Quantum GIS API Documentation  1.8
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 #ifndef QGSRUBBERBAND_H
00016 #define QGSRUBBERBAND_H
00017 
00018 #include "qgsmapcanvasitem.h"
00019 #include "qgsgeometry.h"
00020 #include <QBrush>
00021 #include <QList>
00022 #include <QPen>
00023 #include <QPolygon>
00024 
00025 class QgsVectorLayer;
00026 class QPaintEvent;
00027 
00031 class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
00032 {
00033   public:
00034     QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon = false );
00035     ~QgsRubberBand();
00036 
00037     void setColor( const QColor & color );
00038     void setWidth( int width );
00039 
00040     void reset( bool isPolygon = false );
00041 
00045     void addPoint( const QgsPoint & p, bool update = true, int geometryIndex = 0 );
00046 
00048     void removeLastPoint( int geometryIndex = 0 );
00049 
00050     void movePoint( const QgsPoint & p, int geometryIndex = 0 );
00053     void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
00054 
00061     void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
00062 
00066     void setToCanvasRectangle( const QRect& rect );
00067 
00075     void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
00076 
00078     void setTranslationOffset( double dx, double dy );
00079 
00082     int size() const;
00083 
00085     int numberOfVertices() const;
00086 
00088     const QgsPoint *getPoint( int i, int j = 0 ) const;
00089 
00092     QgsGeometry* asGeometry();
00093 
00094   protected:
00095     virtual void paint( QPainter* p );
00096 
00098     void updateRect();
00099 
00100   private:
00101     QBrush mBrush;
00102     QPen mPen;
00103 
00105     QList< QList <QgsPoint> > mPoints;
00106     bool mIsPolygon;
00107     double mTranslationOffsetX;
00108     double mTranslationOffsetY;
00109 
00110     QgsRubberBand();
00111 
00112     static QgsPolyline getPolyline( const QList<QgsPoint> & points );
00113 
00114 };
00115 
00116 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines