QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsannotationitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationitem.h
3  ------------------------
4  begin : February 9, 2010
5  copyright : (C) 2010 by Marco Hugentobler
6  email : marco dot hugentobler at hugis dot net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSANNOTATIONITEM_H
19 #define QGSANNOTATIONITEM_H
20 
21 #include "qgsmapcanvasitem.h"
22 
23 class QDomDocument;
24 class QDomElement;
25 class QDialog;
26 class QgsVectorLayer;
27 class QgsMarkerSymbolV2;
28 
31 class GUI_EXPORT QgsAnnotationItem: public QgsMapCanvasItem
32 {
33  public:
35  {
46  ResizeFrameRightDown
47  };
48 
49  QgsAnnotationItem( QgsMapCanvas* mapCanvas );
50  virtual ~QgsAnnotationItem();
51 
52  void updatePosition();
53 
54  QRectF boundingRect() const;
55 
56  virtual QSizeF minimumFrameSize() const;
57 
60  QgsAnnotationItem::MouseMoveAction moveActionForPosition( const QPointF& pos ) const;
62  Qt::CursorShape cursorShapeForAction( MouseMoveAction moveAction ) const;
63 
64  //setters and getters
65  void setMapPositionFixed( bool fixed );
66  bool mapPositionFixed() const { return mMapPositionFixed; }
67 
68  virtual void setMapPosition( const QgsPoint& pos );
69  QgsPoint mapPosition() const { return mMapPosition; }
70 
71  void setFrameSize( const QSizeF& size );
72  QSizeF frameSize() const { return mFrameSize; }
73 
74  void setOffsetFromReferencePoint( const QPointF& offset );
75  QPointF offsetFromReferencePoint() const { return mOffsetFromReferencePoint; }
76 
78  void setMarkerSymbol( QgsMarkerSymbolV2* symbol );
79  const QgsMarkerSymbolV2* markerSymbol() const {return mMarkerSymbol;}
80 
81  void setFrameBorderWidth( double w ) { mFrameBorderWidth = w; }
82  double frameBorderWidth() const { return mFrameBorderWidth; }
83 
84  void setFrameColor( const QColor& c ) { mFrameColor = c; }
85  QColor frameColor() const { return mFrameColor; }
86 
87  void setFrameBackgroundColor( const QColor& c ) { mFrameBackgroundColor = c; }
88  QColor frameBackgroundColor() const { return mFrameBackgroundColor; }
89 
90  virtual void writeXML( QDomDocument& doc ) const = 0;
91  virtual void readXML( const QDomDocument& doc, const QDomElement& itemElem ) = 0;
92 
93  void _writeXML( QDomDocument& doc, QDomElement& itemElem ) const;
94  void _readXML( const QDomDocument& doc, const QDomElement& annotationElem );
95 
96  protected:
103 
105  QSizeF mFrameSize;
108 
114  QColor mFrameColor;
116 
123 
124  void updateBoundingRect();
126  void updateBalloon();
127 
128  void drawFrame( QPainter* p );
129  void drawMarkerSymbol( QPainter* p );
130  void drawSelectionBoxes( QPainter* p );
132  //double scaledFrameWidth( QPainter* p) const;
134  QLineF segment( int index );
136  QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;
138  double scaledSymbolSize() const;
139 };
140 
141 #endif // QGSANNOTATIONITEM_H
static unsigned index
Definition: mersenne-twister.cpp:36
QgsPoint mapPosition() const
Definition: qgsannotationitem.h:69
Definition: qgsannotationitem.h:40
QgsMarkerSymbolV2 * mMarkerSymbol
Point symbol that is to be drawn at the map reference location.
Definition: qgsannotationitem.h:110
virtual QRectF boundingRect() const
default implementation for canvas items
Definition: qgsmapcanvasitem.cpp:96
double mFrameBorderWidth
Width of the frame.
Definition: qgsannotationitem.h:112
QPointF mOffsetFromReferencePoint
Describes the shift of the item content box to the reference point.
Definition: qgsannotationitem.h:102
Definition: qgsannotationitem.h:39
An abstract class for items that can be placed on the map canvas.
Definition: qgsmapcanvasitem.h:30
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:104
void setFrameColor(const QColor &c)
Definition: qgsannotationitem.h:84
QRectF mBoundingRect
Bounding rect (including item frame and balloon)
Definition: qgsannotationitem.h:107
QPointF mBalloonSegmentPoint1
First segment point for drawing the connection (ccw direction)
Definition: qgsannotationitem.h:120
QColor frameColor() const
Definition: qgsannotationitem.h:85
void setFrameBorderWidth(double w)
Definition: qgsannotationitem.h:81
const QgsMarkerSymbolV2 * markerSymbol() const
Definition: qgsannotationitem.h:79
Definition: qgsannotationitem.h:43
MouseMoveAction
Definition: qgsannotationitem.h:34
Definition: qgsannotationitem.h:44
Definition: qgsannotationitem.h:45
int mBalloonSegment
Segment number where the connection to the map point is attached.
Definition: qgsannotationitem.h:118
A class to represent a point geometry.
Definition: qgspoint.h:63
Definition: qgsannotationitem.h:42
Definition: qgsannotationitem.h:36
double frameBorderWidth() const
Definition: qgsannotationitem.h:82
An annotation item can be either placed either on screen corrdinates or on map coordinates.
Definition: qgsannotationitem.h:31
Definition: qgssymbolv2.h:229
bool mMapPositionFixed
True: the item stays at the same map position, False: the item stays on same screen position...
Definition: qgsannotationitem.h:98
QColor mFrameColor
Frame / balloon color.
Definition: qgsannotationitem.h:114
Definition: qgsannotationitem.h:41
QSizeF frameSize() const
Definition: qgsannotationitem.h:72
Definition: qgsannotationitem.h:37
QPointF offsetFromReferencePoint() const
Definition: qgsannotationitem.h:75
QColor mFrameBackgroundColor
Definition: qgsannotationitem.h:115
QPointF mBalloonSegmentPoint2
Second segment point for drawing the balloon connection (ccw direction)
Definition: qgsannotationitem.h:122
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:470
double size
Definition: qgssvgcache.cpp:77
QgsPoint mMapPosition
Map position (in case mMapPositionFixed is true)
Definition: qgsannotationitem.h:100
virtual void updatePosition()
called on changed extent or resize event to update position of the item
Definition: qgsmapcanvasitem.cpp:126
QSizeF mFrameSize
Size of the frame (without balloon)
Definition: qgsannotationitem.h:105
bool mapPositionFixed() const
Definition: qgsannotationitem.h:66
QColor frameBackgroundColor() const
Definition: qgsannotationitem.h:88
void setFrameBackgroundColor(const QColor &c)
Definition: qgsannotationitem.h:87
Definition: qgsannotationitem.h:38