QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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:
43
50
51
52 int type() const override;
53 QIcon icon() const override;
54
60
66
76 void setLinkedMap( QgsLayoutItemMap *map );
77
85
92 double northArrowRotation() const { return mNorthArrowRotation; }
93
100
106 void setNorthMode( QgsLayoutNorthArrowHandler::NorthMode mode );
107
113 double northOffset() const;
114
120 void setNorthOffset( double offset );
121
122 // Depending on the symbol style, the bounding rectangle can be larger than the shape
123 QRectF boundingRect() const override;
124
125 QgsLayoutSize fixedSize() const override;
126
127 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
128
129 protected:
130 void draw( QgsLayoutItemRenderContext &context ) override;
131
132 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
133 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
134
135 void finalizeRestoreFromXml() override;
136 private slots:
137
142 void refreshSymbol();
143
145 void updateBoundingRect();
146
147 void northArrowRotationChanged( double rotation );
148
149 private:
150 std::unique_ptr< QgsMarkerSymbol > mShapeStyleSymbol;
151
152 QPointF mPoint;
153 QRectF mCurrentRectangle;
154 QgsLayoutSize mFixedSize;
155
156 QString mRotationMapUuid;
157 QgsLayoutNorthArrowHandler *mNorthArrowHandler = nullptr;
158 double mNorthArrowRotation = 0;
159
160 QgsLayoutItemMarker( const QgsLayoutItemMarker & ) = delete;
161 QgsLayoutItemMarker &operator=( const QgsLayoutItemMarker & ) = delete;
162};
163
164
165#endif //QGSLAYOUTITEMMARKER_H
A layout item for showing marker symbols.
~QgsLayoutItemMarker() override
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map object for rotation.
double northArrowRotation() const
When the marker is linked to a map in north arrow rotation mode, returns the current north arrow rota...
QgsLayoutItemMarker(QgsLayout *layout)
Constructor for QgsLayoutItemMarker, with the specified parent layout.
static QgsLayoutItemMarker * create(QgsLayout *layout)
Returns a new marker item for the specified layout.
QgsLayoutItemMap * linkedMap() const
Returns the linked rotation map, if set.
void setSymbol(QgsMarkerSymbol *symbol)
Sets the marker symbol used to draw the shape.
QgsMarkerSymbol * symbol()
Returns the marker symbol used to draw the shape.
Contains settings and helpers relating to a render of a QgsLayoutItem.
friend class QgsLayout
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
virtual QIcon icon() const
Returns the item's icon.
friend class QgsLayoutItemMap
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.
const QgsLayout * layout() const
Returns the layout the object is attached to.
Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
A marker symbol type, for rendering Point and MultiPoint geometries.
A container for the context for various read/write operations on objects.
An interface for classes which can visit style entity (e.g.
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83