~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/gui/qgsrubberband.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 *   (at your option) any later version.                                   *
13
13
 *                                                                         *
14
14
 ***************************************************************************/
15
 
/* $Id: qgsrubberband.h 5878 2006-09-27 14:19:44Z wonder $ */
 
15
/* $Id$ */
16
16
#ifndef QGSRUBBERBAND_H
17
17
#define QGSRUBBERBAND_H
18
18
 
19
19
#include "qgsmapcanvasitem.h"
20
 
#include <deque>
21
20
#include <QBrush>
 
21
#include <QList>
22
22
#include <QPen>
23
23
#include <QPolygon>
 
24
 
 
25
class QgsGeometry;
 
26
class QgsVectorLayer;
24
27
class QPaintEvent;
25
28
 
26
 
class QgsRubberBand: public QgsMapCanvasItem
 
29
/** \ingroup gui
 
30
 * A class for drawing transient features (e.g. digitising lines) on the map.
 
31
 */
 
32
class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
27
33
{
28
34
  public:
29
 
    QgsRubberBand(QgsMapCanvas* mapCanvas, bool isPolygon = false);
 
35
    QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon = false );
30
36
    ~QgsRubberBand();
31
37
 
32
 
    void setColor(const QColor & color);
33
 
    void setWidth(int width);
 
38
    void setColor( const QColor & color );
 
39
    void setWidth( int width );
34
40
 
35
 
    void reset(bool isPolygon = false);
 
41
    void reset( bool isPolygon = false );
36
42
 
37
43
    //! Add point to rubberband and update canvas
38
44
    //! If adding more points consider using update=false for better performance
39
 
    void addPoint(const QgsPoint & p, bool update = true);
40
 
 
41
 
    void movePoint(const QgsPoint & p);
42
 
    void movePoint(int index, const QgsPoint& p);
 
45
    //! geometryIndex is the index of the feature part (in case of multipart geometries)
 
46
    void addPoint( const QgsPoint & p, bool update = true, int geometryIndex = 0 );
 
47
 
 
48
    //!Removes the last point. Most useful in connection with undo operations
 
49
    void removeLastPoint( int geometryIndex = 0 );
 
50
 
 
51
    void movePoint( const QgsPoint & p, int geometryIndex = 0 );
 
52
    /**Moves the rubber band point specified by index. Note that if the rubber band is
 
53
     not used to track the last mouse position, the first point of the rubber band has two vertices*/
 
54
    void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
 
55
 
 
56
    /**Sets this rubber band to the geometry of an existing feature.
 
57
     This is useful for feature highlighting.
 
58
    @param geom the geometry object
 
59
    @param layer the layer containing the feature, used for coord transformation to map
 
60
    crs. In case of 0 pointer, the coordinates are not going to be transformed.
 
61
    @param render the maprender object (used for coord transformation)*/
 
62
    void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
 
63
 
 
64
    /**Adds translation to original coordinates (all in map coordinates)*/
 
65
    void setTranslationOffset( double dx, double dy );
 
66
 
 
67
    /**Returns count of vertices in all lists of mPoint*/
 
68
    int numberOfVertices() const;
 
69
 
 
70
    /**Return vertex*/
 
71
    const QgsPoint *getPoint( int i, int j = 0 ) const;
43
72
 
44
73
  protected:
45
 
    virtual void drawShape(QPainter & p);
46
 
    
 
74
    virtual void paint( QPainter* p );
 
75
 
47
76
    //! recalculates needed rectangle
48
77
    void updateRect();
49
78
 
50
79
  private:
51
80
    QBrush mBrush;
52
81
    QPen mPen;
53
 
    std::deque<QgsPoint> mPoints;
 
82
 
 
83
    /**Nested lists used for multitypes*/
 
84
    QList< QList <QgsPoint> > mPoints;
54
85
    bool mIsPolygon;
 
86
    double mTranslationOffsetX;
 
87
    double mTranslationOffsetY;
 
88
 
 
89
    QgsRubberBand();
55
90
};
56
91
 
57
92
#endif