QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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