QGIS API Documentation  2.3.0-Master
 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
static unsigned index
QgsPoint mapPosition() const
QgsMarkerSymbolV2 * mMarkerSymbol
Point symbol that is to be drawn at the map reference location.
virtual QRectF boundingRect() const
default implementation for canvas items
double mFrameBorderWidth
Width of the frame.
QPointF mOffsetFromReferencePoint
Describes the shift of the item content box to the reference point.
An abstract class for items that can be placed on the map canvas.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
void setFrameColor(const QColor &c)
QRectF mBoundingRect
Bounding rect (including item frame and balloon)
QPointF mBalloonSegmentPoint1
First segment point for drawing the connection (ccw direction)
QColor frameColor() const
void setFrameBorderWidth(double w)
const QgsMarkerSymbolV2 * markerSymbol() const
int mBalloonSegment
Segment number where the connection to the map point is attached.
A class to represent a point geometry.
Definition: qgspoint.h:63
double frameBorderWidth() const
An annotation item can be either placed either on screen corrdinates or on map coordinates.
bool mMapPositionFixed
True: the item stays at the same map position, False: the item stays on same screen position...
QColor mFrameColor
Frame / balloon color.
QSizeF frameSize() const
QPointF offsetFromReferencePoint() const
QPointF mBalloonSegmentPoint2
Second segment point for drawing the balloon connection (ccw direction)
Represents a vector layer which manages a vector based data sets.
double size
Definition: qgssvgcache.cpp:77
QgsPoint mMapPosition
Map position (in case mMapPositionFixed is true)
virtual void updatePosition()
called on changed extent or resize event to update position of the item
QSizeF mFrameSize
Size of the frame (without balloon)
bool mapPositionFixed() const
QColor frameBackgroundColor() const
void setFrameBackgroundColor(const QColor &c)