QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgslayoutitemmarker.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemmarker.h
3 ---------------------
4 begin : April 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSLAYOUTITEMMARKER_H
18#define QGSLAYOUTITEMMARKER_H
19
20#include "qgis_core.h"
21#include "qgslayoutitem.h"
24
25class QgsMarkerSymbol;
26
33class CORE_EXPORT QgsLayoutItemMarker : public QgsLayoutItem
34{
35 Q_OBJECT
36
37 public:
38
42 explicit QgsLayoutItemMarker( QgsLayout *layout );
44
50 static QgsLayoutItemMarker *create( QgsLayout *layout ) SIP_FACTORY;
51
52
53 int type() const override;
54 QIcon icon() const override;
55
60 void setSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
61
66 QgsMarkerSymbol *symbol();
67
77 void setLinkedMap( QgsLayoutItemMap *map );
78
85 QgsLayoutItemMap *linkedMap() const;
86
93 double northArrowRotation() const { return mNorthArrowRotation; }
94
101
107 void setNorthMode( QgsLayoutNorthArrowHandler::NorthMode mode );
108
114 double northOffset() const;
115
121 void setNorthOffset( double offset );
122
123 // Depending on the symbol style, the bounding rectangle can be larger than the shape
124 QRectF boundingRect() const override;
125
126 QgsLayoutSize fixedSize() const override;
127
128 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
129
130 protected:
131
132 void draw( QgsLayoutItemRenderContext &context ) override;
133
134 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
135 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
136
137 void finalizeRestoreFromXml() override;
138 private slots:
139
144 void refreshSymbol();
145
147 void updateBoundingRect();
148
149 void northArrowRotationChanged( double rotation );
150
151 private:
152
153 std::unique_ptr< QgsMarkerSymbol > mShapeStyleSymbol;
154
155 QPointF mPoint;
156 QRectF mCurrentRectangle;
157 QgsLayoutSize mFixedSize;
158
159 QString mRotationMapUuid;
160 QgsLayoutNorthArrowHandler *mNorthArrowHandler = nullptr;
161 double mNorthArrowRotation = 0;
162
163 QgsLayoutItemMarker( const QgsLayoutItemMarker & ) = delete;
164 QgsLayoutItemMarker &operator=( const QgsLayoutItemMarker & ) = delete;
165};
166
167
168#endif //QGSLAYOUTITEMMARKER_H
Layout graphical items for displaying a map.
A layout item for showing marker symbols.
~QgsLayoutItemMarker() override
double northArrowRotation() const
When the marker is linked to a map in north arrow rotation mode, returns the current north arrow rota...
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:44
Base class for graphical items within a QgsLayout.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
virtual QIcon icon() const
Returns the item's icon.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
int type() const override
Returns a unique graphics item type identifier.
virtual QgsLayoutSize fixedSize() const
Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
An object which handles north-arrow type behavior for layout items.
NorthMode
Method for syncing rotation to a map's North direction.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Definition: qgslayoutsize.h:41
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
A marker symbol type, for rendering Point and MultiPoint geometries.
The class is used as a container of context for various read/write operations on other objects.
An interface for classes which can visit style entity (e.g.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76