QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 #include "qgsmapcanvasitem.h"
22 #include "qgis_gui.h"
23 
24 class QgsAnnotation;
25 
32 class GUI_EXPORT QgsMapCanvasAnnotationItem: public QObject, public QgsMapCanvasItem
33 {
34  Q_OBJECT
35 
36  public:
37 
40  {
51  ResizeFrameRightDown
52  };
53 
58 
63  const QgsAnnotation *annotation() const { return mAnnotation; } SIP_SKIP
64 
68  QgsAnnotation *annotation() { return mAnnotation; }
69 
70  void updatePosition() override;
71 
72  QRectF boundingRect() const override;
73 
74  void paint( QPainter *painter ) override;
75 
79  MouseMoveAction moveActionForPosition( QPointF pos ) const;
80 
84  Qt::CursorShape cursorShapeForAction( MouseMoveAction moveAction ) const;
85 
86  private slots:
87 
88  void updateBoundingRect();
89 
90  void onCanvasLayersChanged();
91 
93  void setFeatureForMapPosition();
94 
95  private:
96 
98  void drawSelectionBoxes( QPainter *p ) const;
99 
101  double scaledSymbolSize() const;
102 
103  QgsAnnotation *mAnnotation = nullptr;
104 
106  QRectF mBoundingRect;
107 
108 };
109 
110 #endif // QGSMAPCANVASANNOTATIONITEM_H
const QgsAnnotation * annotation() const
Returns the item's annotation.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
An abstract class for items that can be placed on the map canvas.
Moving position of frame relative to annotation.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
Abstract base class for annotation items which are drawn over a map.
Definition: qgsannotation.h:49
QRectF boundingRect() const override
#define SIP_SKIP
Definition: qgis_sip.h:119
#define SIP_TRANSFER
Definition: qgis_sip.h:36
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
MouseMoveAction
Mouse actions for interacting with item.
QgsAnnotation * annotation()
Returns the item's annotation.
virtual void updatePosition()
called on changed extent or resize event to update position of the item
An interactive map canvas item which displays a QgsAnnotation.