1 /*************************************************************************** 2 qgsannotationmarkeritem.h 3 ---------------- 4 begin : July 2020 5 copyright : (C) 2020 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 QGSANNOTATIONMARKERITEM_H 19 #define QGSANNOTATIONMARKERITEM_H 20 21 #include "qgis_core.h" 22 #include "qgis_sip.h" 23 #include "qgsannotationitem.h" 24 #include "qgspoint.h" 25 26 /** 27 * \ingroup core 28 * \brief An annotation item which renders a marker symbol at a point location. 29 * 30 * \since QGIS 3.16 31 */ 32 class CORE_EXPORT QgsAnnotationMarkerItem : public QgsAnnotationItem 33 { 34 public: 35 36 /** 37 * Constructor for QgsAnnotationMarkerItem, at the specified \a point. 38 */ 39 QgsAnnotationMarkerItem( const QgsPoint &point ); 40 ~QgsAnnotationMarkerItem() override; 41 42 QString type() const override; 43 void render( QgsRenderContext &context, QgsFeedback *feedback ) override; 44 bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override; 45 Qgis::AnnotationItemFlags flags() const override; 46 QList< QgsAnnotationItemNode > nodes() const override; 47 Qgis::AnnotationItemEditOperationResult applyEdit( QgsAbstractAnnotationItemEditOperation *operation ) override; 48 QgsAnnotationItemEditOperationTransientResults *transientEditResults( QgsAbstractAnnotationItemEditOperation *operation ) override SIP_FACTORY; 49 50 /** 51 * Creates a new marker annotation item. 52 */ 53 static QgsAnnotationMarkerItem *create() SIP_FACTORY; 54 55 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override; 56 QgsAnnotationMarkerItem *clone() override SIP_FACTORY; 57 QgsRectangle boundingBox() const override; 58 QgsRectangle boundingBox( QgsRenderContext &context ) const override; 59 60 /** 61 * Returns the point geometry of the marker. 62 * 63 * The coordinate reference system for the point will be the parent layer's QgsAnnotationLayer::crs(). 64 * 65 * \see setGeometry() 66 */ geometry()67 QgsPointXY geometry() const { return mPoint; } 68 69 /** 70 * Sets the point \a geometry location of the marker. 71 * 72 * The coordinate reference system for the point will be the parent layer's QgsAnnotationLayer::crs(). 73 * 74 * \see geometry() 75 */ setGeometry(const QgsPoint & geometry)76 void setGeometry( const QgsPoint &geometry ) { mPoint = geometry; } 77 78 /** 79 * Returns the symbol used to render the marker item. 80 * 81 * \see setSymbol() 82 */ 83 const QgsMarkerSymbol *symbol() const; 84 85 /** 86 * Sets the \a symbol used to render the marker item. 87 * 88 * The item takes ownership of the symbol. 89 * 90 * \see symbol() 91 */ 92 void setSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER ); 93 94 private: 95 96 QgsPoint mPoint; 97 std::unique_ptr< QgsMarkerSymbol > mSymbol; 98 99 #ifdef SIP_RUN 100 QgsAnnotationMarkerItem( const QgsAnnotationMarkerItem &other ); 101 #endif 102 103 }; 104 105 #endif // QGSANNOTATIONMARKERITEM_H 106