QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsmapcanvasannotationitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmapcanvasannotationitem.h
3 ----------------------------
4 begin : January 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
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 QGSMAPCANVASANNOTATIONITEM_H
19#define QGSMAPCANVASANNOTATIONITEM_H
20
21#ifdef SIP_RUN
22//%ModuleHeaderCode
23// For ConvertToSubClassCode.
25
26//%End
27#endif
28
29#include "qgsmapcanvasitem.h"
30#include "qgis_gui.h"
31
32class QgsAnnotation;
33
39class GUI_EXPORT QgsMapCanvasAnnotationItem : public QObject, public QgsMapCanvasItem
40{
41 Q_OBJECT
42
43#ifdef SIP_RUN
45 if ( dynamic_cast<QgsMapCanvasAnnotationItem *>( sipCpp ) )
46 {
47 sipType = sipType_QgsMapCanvasAnnotationItem;
48 *sipCppRet = dynamic_cast<QgsMapCanvasAnnotationItem *>( sipCpp );
49 }
50 else
51 sipType = nullptr;
53#endif
54
55 public:
71
76
82 {
83 return mAnnotation;
84 }
85
89 QgsAnnotation *annotation() { return mAnnotation; }
90
91 void updatePosition() override;
92
93 QRectF boundingRect() const override;
94
95 void paint( QPainter *painter ) override;
96
100 MouseMoveAction moveActionForPosition( QPointF pos ) const;
101
105 Qt::CursorShape cursorShapeForAction( MouseMoveAction moveAction ) const;
106
107 private slots:
108
109 void updateBoundingRect();
110
111 void onCanvasLayersChanged();
112
114 void setFeatureForMapPosition();
115
116 void annotationDeleted();
117
118 private:
120 void drawSelectionBoxes( QPainter *p ) const;
121
123 double scaledSymbolSize() const;
124
125 QgsAnnotation *mAnnotation = nullptr;
126
128 QRectF mBoundingRect;
129};
130
131#endif // QGSMAPCANVASANNOTATIONITEM_H
Abstract base class for annotation items which are drawn over a map.
An interactive map canvas item which displays a QgsAnnotation.
const QgsAnnotation * annotation() const
Returns the item's annotation.
QgsMapCanvasAnnotationItem(QgsAnnotation *annotation, QgsMapCanvas *mapCanvas)
Constructor for QgsMapCanvasAnnotationItem.
QgsAnnotation * annotation()
Returns the item's annotation.
MouseMoveAction
Mouse actions for interacting with item.
@ ResizeFrameRightUp
Resize frame right up.
@ MoveFramePosition
Moving position of frame relative to annotation.
@ ResizeFrameRightDown
Resize frame right down.
@ MoveMapPosition
Moving annotation map position.
@ ResizeFrameLeftUp
Resize frame left up.
@ ResizeFrameLeftDown
Resize frame left down.
QRectF boundingRect() const override
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
QgsMapCanvasItem(QgsMapCanvas *mapCanvas)
protected constructor: cannot be constructed directly
virtual void updatePosition()
called on changed extent or resize event to update position of the item
Map canvas is a class for displaying all GIS data types on a canvas.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_END
Definition qgis_sip.h:216