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

« back to all changes in this revision

Viewing changes to src/gui/qgsmapcanvasitem.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:
17
17
#ifndef QGSMAPCANVASITEM_H
18
18
#define QGSMAPCANVASITEM_H
19
19
 
20
 
#include <Q3CanvasItem>
21
 
#include "qgsrect.h"
 
20
#include <QGraphicsItem>
 
21
#include "qgsrectangle.h"
22
22
 
23
23
class QgsMapCanvas;
24
24
class QPainter;
25
25
 
26
 
class QgsMapCanvasItem : public QObject, public Q3CanvasRectangle
 
26
/** \ingroup gui
 
27
 * An abstract class for items that can be placed on the
 
28
 * map canvas.
 
29
 */
 
30
class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem
27
31
{
28
 
  Q_OBJECT;
29
 
  
30
32
  protected:
31
 
    
 
33
 
32
34
    //! protected constructor: cannot be constructed directly
33
 
    QgsMapCanvasItem(QgsMapCanvas* mapCanvas);
34
 
    
 
35
    QgsMapCanvasItem( QgsMapCanvas* mapCanvas );
 
36
 
35
37
    virtual ~QgsMapCanvasItem();
36
 
    
 
38
 
37
39
    //! function to be implemented by derived classes
38
 
    virtual void drawShape(QPainter & p)=0;
39
 
    
 
40
    virtual void paint( QPainter * painter ) = 0;
 
41
 
 
42
    //! paint function called by map canvas
 
43
    virtual void paint( QPainter * painter,
 
44
                        const QStyleOptionGraphicsItem * option,
 
45
                        QWidget * widget = 0 );
 
46
 
40
47
    //! schedules map canvas for repaint
41
48
    void updateCanvas();
42
 
    
43
 
  
 
49
 
 
50
 
44
51
  public:
45
 
    
 
52
 
 
53
    //! called on changed extent or resize event to update position of the item
 
54
    virtual void updatePosition();
 
55
 
 
56
    //! default implementation for canvas items
 
57
    virtual QRectF boundingRect() const;
 
58
 
46
59
    //! sets current offset, to be called from QgsMapCanvas
47
 
    void setPanningOffset(const QPoint& point);
48
 
    
 
60
    void setPanningOffset( const QPoint& point );
 
61
 
49
62
    //! returns canvas item rectangle
50
 
    QgsRect rect();
51
 
    
 
63
    QgsRectangle rect() const;
 
64
 
52
65
    //! sets canvas item rectangle
53
 
    void setRect(const QgsRect& r);
54
 
    
 
66
    void setRect( const QgsRectangle& r );
 
67
 
55
68
    //! transformation from screen coordinates to map coordinates
56
 
    QgsPoint toMapCoords(const QPoint& point);
57
 
    
 
69
    QgsPoint toMapCoordinates( const QPoint& point );
 
70
 
58
71
    //! transformation from map coordinates to screen coordinates
59
 
    QPoint toCanvasCoords(const QgsPoint& point);
60
 
 
61
 
    /** called on changed extents or changed item rectangle
62
 
     * Override this in your subclass if you wish to have custom
63
 
     * behaviour for when the canvas area of interest is changed */
64
 
    virtual void updatePosition();
 
72
    QPointF toCanvasCoordinates( const QgsPoint& point );
65
73
 
66
74
  protected:
67
 
    
 
75
 
68
76
    //! pointer to map canvas
69
77
    QgsMapCanvas* mMapCanvas;
70
 
    
 
78
 
71
79
    //! canvas item rectangle (in map coordinates)
72
 
    QgsRect mRect;
 
80
    QgsRectangle mRect;
73
81
 
74
82
    //! offset from normal position due current panning operation,
75
83
    //! used when converting map coordinates to move map canvas items
76
84
    QPoint mPanningOffset;
 
85
 
 
86
    //! cached size of the item (to return in boundingRect())
 
87
    QSizeF mItemSize;
77
88
};
78
89
 
79
90