QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 % End
26 #endif
27 
28 #include "qgsmapcanvasitem.h"
29 #include "qgis_gui.h"
30 
31 class QgsAnnotation;
32 
39 class GUI_EXPORT QgsMapCanvasAnnotationItem: public QObject, public QgsMapCanvasItem
40 {
41  Q_OBJECT
42 
43 #ifdef SIP_RUN
45  if ( dynamic_cast<QgsMapCanvasAnnotationItem *>( sipCpp ) )
46  sipType = sipType_QgsMapCanvasAnnotationItem;
47  else
48  sipType = nullptr;
49  SIP_END
50 #endif
51 
52  public:
53 
56  {
67  ResizeFrameRightDown
68  };
69 
74 
79  const QgsAnnotation *annotation() const { return mAnnotation; } SIP_SKIP
80 
84  QgsAnnotation *annotation() { return mAnnotation; }
85 
86  void updatePosition() override;
87 
88  QRectF boundingRect() const override;
89 
90  void paint( QPainter *painter ) override;
91 
95  MouseMoveAction moveActionForPosition( QPointF pos ) const;
96 
100  Qt::CursorShape cursorShapeForAction( MouseMoveAction moveAction ) const;
101 
102  private slots:
103 
104  void updateBoundingRect();
105 
106  void onCanvasLayersChanged();
107 
109  void setFeatureForMapPosition();
110 
111  void annotationDeleted();
112 
113  private:
114 
116  void drawSelectionBoxes( QPainter *p ) const;
117 
119  double scaledSymbolSize() const;
120 
121  QgsAnnotation *mAnnotation = nullptr;
122 
124  QRectF mBoundingRect;
125 
126 };
127 
128 #endif // QGSMAPCANVASANNOTATIONITEM_H
QgsMapCanvasAnnotationItem::MoveMapPosition
@ MoveMapPosition
Moving annotation map position.
Definition: qgsmapcanvasannotationitem.h:58
QgsMapCanvasAnnotationItem
An interactive map canvas item which displays a QgsAnnotation.
Definition: qgsmapcanvasannotationitem.h:40
QgsMapCanvasAnnotationItem::ResizeFrameLeft
@ ResizeFrameLeft
Resize frame left.
Definition: qgsmapcanvasannotationitem.h:62
QgsMapCanvasAnnotationItem::NoAction
@ NoAction
No action.
Definition: qgsmapcanvasannotationitem.h:57
QgsMapCanvasAnnotationItem::ResizeFrameLeftUp
@ ResizeFrameLeftUp
Resize frame left up.
Definition: qgsmapcanvasannotationitem.h:64
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
qgsmapcanvasannotationitem.h
QgsMapCanvasAnnotationItem::annotation
const QgsAnnotation * annotation() const
Returns the item's annotation.
Definition: qgsmapcanvasannotationitem.h:79
QgsMapCanvasAnnotationItem::ResizeFrameUp
@ ResizeFrameUp
Resize frame up.
Definition: qgsmapcanvasannotationitem.h:60
QgsMapCanvasAnnotationItem::MoveFramePosition
@ MoveFramePosition
Moving position of frame relative to annotation.
Definition: qgsmapcanvasannotationitem.h:59
QgsMapCanvasAnnotationItem::annotation
QgsAnnotation * annotation()
Returns the item's annotation.
Definition: qgsmapcanvasannotationitem.h:84
QgsMapCanvasItem::updatePosition
virtual void updatePosition()
called on changed extent or resize event to update position of the item
Definition: qgsmapcanvasitem.cpp:135
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
QgsMapCanvasItem::paint
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgsmapcanvasitem.h
QgsAnnotation
Abstract base class for annotation items which are drawn over a map.
Definition: qgsannotation.h:50
QgsMapCanvasItem
An abstract class for items that can be placed on the map canvas.
Definition: qgsmapcanvasitem.h:34
QgsMapCanvasAnnotationItem::MouseMoveAction
MouseMoveAction
Mouse actions for interacting with item.
Definition: qgsmapcanvasannotationitem.h:56
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsMapCanvasAnnotationItem::ResizeFrameLeftDown
@ ResizeFrameLeftDown
Resize frame left down.
Definition: qgsmapcanvasannotationitem.h:66
QgsMapCanvasAnnotationItem::ResizeFrameDown
@ ResizeFrameDown
Resize frame down.
Definition: qgsmapcanvasannotationitem.h:61
QgsMapCanvasAnnotationItem::ResizeFrameRight
@ ResizeFrameRight
Resize frame right.
Definition: qgsmapcanvasannotationitem.h:63
QgsMapCanvasItem::boundingRect
QRectF boundingRect() const override
Definition: qgsmapcanvasitem.cpp:106
SIP_END
#define SIP_END
Definition: qgis_sip.h:194
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsMapCanvasAnnotationItem::ResizeFrameRightUp
@ ResizeFrameRightUp
Resize frame right up.
Definition: qgsmapcanvasannotationitem.h:65