00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00071 void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
00072
00074 void setTranslationOffset( double dx, double dy );
00075
00078 int size() const;
00079
00081 int numberOfVertices() const;
00082
00084 const QgsPoint *getPoint( int i, int j = 0 ) const;
00085
00088 QgsGeometry* asGeometry();
00089
00090 protected:
00091 virtual void paint( QPainter* p );
00092
00094 void updateRect();
00095
00096 private:
00097 QBrush mBrush;
00098 QPen mPen;
00099
00101 QList< QList <QgsPoint> > mPoints;
00102 bool mIsPolygon;
00103 double mTranslationOffsetX;
00104 double mTranslationOffsetY;
00105
00106 QgsRubberBand();
00107
00108 static QgsPolyline getPolyline( const QList<QgsPoint> & points );
00109
00110 };
00111
00112 #endif