QGIS API Documentation  2.14.0-Essen
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"
23 
24 class QDomDocument;
25 class QDomElement;
26 class QDialog;
27 class QgsVectorLayer;
28 class QgsMarkerSymbolV2;
29 
32 class GUI_EXPORT QgsAnnotationItem: public QgsMapCanvasItem
33 {
34  public:
36  {
47  ResizeFrameRightDown
48  };
49 
50  QgsAnnotationItem( QgsMapCanvas* mapCanvas );
51  virtual ~QgsAnnotationItem();
52 
53  void updatePosition() override;
54 
55  QRectF boundingRect() const override;
56 
57  virtual QSizeF minimumFrameSize() const;
58 
61  QgsAnnotationItem::MouseMoveAction moveActionForPosition( QPointF pos ) const;
63  Qt::CursorShape cursorShapeForAction( MouseMoveAction moveAction ) const;
64 
65  //setters and getters
66  void setMapPositionFixed( bool fixed );
67  bool mapPositionFixed() const { return mMapPositionFixed; }
68 
69  virtual void setMapPosition( const QgsPoint& pos );
70  QgsPoint mapPosition() const { return mMapPosition; }
71 
74  virtual void setMapPositionCrs( const QgsCoordinateReferenceSystem& crs );
76  QgsCoordinateReferenceSystem mapPositionCrs() const { return mMapPositionCrs; }
77 
78  void setFrameSize( QSizeF size );
79  QSizeF frameSize() const { return mFrameSize; }
80 
81  void setOffsetFromReferencePoint( QPointF offset );
82  QPointF offsetFromReferencePoint() const { return mOffsetFromReferencePoint; }
83 
85  void setMarkerSymbol( QgsMarkerSymbolV2* symbol );
86  const QgsMarkerSymbolV2* markerSymbol() const {return mMarkerSymbol;}
87 
88  void setFrameBorderWidth( double w ) { mFrameBorderWidth = w; }
89  double frameBorderWidth() const { return mFrameBorderWidth; }
90 
91  void setFrameColor( const QColor& c ) { mFrameColor = c; }
92  QColor frameColor() const { return mFrameColor; }
93 
94  void setFrameBackgroundColor( const QColor& c ) { mFrameBackgroundColor = c; }
95  QColor frameBackgroundColor() const { return mFrameBackgroundColor; }
96 
97  virtual void writeXML( QDomDocument& doc ) const = 0;
98  virtual void readXML( const QDomDocument& doc, const QDomElement& itemElem ) = 0;
99 
100  void _writeXML( QDomDocument& doc, QDomElement& itemElem ) const;
101  void _readXML( const QDomDocument& doc, const QDomElement& annotationElem );
102 
103  protected:
110 
113 
118 
126 
133 
134  void updateBoundingRect();
136  void updateBalloon();
137 
138  void drawFrame( QPainter* p );
139  void drawMarkerSymbol( QPainter* p );
140  void drawSelectionBoxes( QPainter* p );
142  //double scaledFrameWidth( QPainter* p) const;
144  QLineF segment( int index );
146  QPointF pointOnLineWithDistance( QPointF startPoint, QPointF directionPoint, double distance ) const;
148  double scaledSymbolSize() const;
149 };
150 
151 #endif // QGSANNOTATIONITEM_H
static unsigned index
QgsPoint mapPosition() const
QgsMarkerSymbolV2 * mMarkerSymbol
Point symbol that is to be drawn at the map reference location.
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.
QgsCoordinateReferenceSystem mapPositionCrs() const
Returns the CRS of the map position.
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)
virtual QRectF boundingRect() const override
default implementation for canvas items
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.
Definition: qgspoint.h:65
QgsCoordinateReferenceSystem mMapPositionCrs
CRS of the map position.
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.
Class for storing a coordinate reference system (CRS)
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.
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)