QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgslayoutitemmapitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemmapitem.h
3 -------------------
4 begin : October 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#ifndef QGSLAYOUTITEMMAPITEM_H
18#define QGSLAYOUTITEMMAPITEM_H
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgslayoutobject.h"
23#include "qgsmaplayerref.h"
24
26
32class CORE_EXPORT QgsLayoutItemMapItem : public QgsLayoutObject
33{
34 Q_OBJECT
35
36 public:
46
52 QgsLayoutItemMapItem( const QString &name, QgsLayoutItemMap *map );
53
57 virtual void draw( QPainter *painter ) = 0;
58
64 virtual bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
65
71 virtual bool readXml( const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context );
72
81 virtual void finalizeRestoreFromXml();
82
88
93 const QgsLayoutItemMap *map() const;
94
98 QString id() const { return mUuid; }
99
104 void setName( const QString &name );
105
110 QString name() const;
111
116 virtual void setEnabled( bool enabled );
117
122 bool enabled() const;
123
127 virtual bool usesAdvancedEffects() const;
128
139
150
163 QgsMapLayer *stackingLayer() const;
164
177 void setStackingLayer( QgsMapLayer *layer );
178
188 virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
189
195 virtual QgsMapLayer *mapLayer();
196
198
199 protected:
201 QString mName;
202
205
207 QString mUuid;
208
210 bool mEnabled = true;
211
213
215};
216
226{
227 public:
233
235
239 int size() const { return mItems.size(); }
240
246 virtual bool writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) const;
247
253 virtual bool readXml( const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context ) = 0;
254
263 virtual void finalizeRestoreFromXml();
264
272 void drawItems( QPainter *painter, bool ignoreStacking = true );
273
278 bool containsAdvancedEffects() const;
279
285 bool hasEnabledItems() const;
286
290 QgsLayoutItemMapItem *item( int index ) const;
291
292 protected:
302
309 void removeItem( const QString &itemId );
310
317 void moveItemUp( const QString &itemId );
318
325 void moveItemDown( const QString &itemId );
326
330 QgsLayoutItemMapItem *item( const QString &itemId ) const;
331
338
342 QList< QgsLayoutItemMapItem * > asList() const;
343
344 protected:
345 QList< QgsLayoutItemMapItem * > mItems;
346
348
353 void removeItems();
354};
355
356#endif //QGSLAYOUTITEMMAPITEM_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void addItem(QgsLayoutItemMapItem *item)
Adds a new map item to the stack and takes ownership of the item.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)=0
Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'Layo...
bool containsAdvancedEffects() const
Returns whether any items within the stack contain advanced effects, such as blending modes.
void removeItem(const QString &itemId)
Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapIt...
QgsLayoutItemMapItem * item(int index) const
Returns a reference to the item at the specified index within the stack.
QList< QgsLayoutItemMapItem * > asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
void drawItems(QPainter *painter, bool ignoreStacking=true)
Draws the items from the stack on a specified painter.
void moveItemUp(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items.
void removeItems()
Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.
QgsLayoutItemMapItemStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItemStack, attached to the specified map.
QList< QgsLayoutItemMapItem * > mItems
int size() const
Returns the number of items in the stack.
void moveItemDown(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items.
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
bool hasEnabledItems() const
Returns true if the stack has any currently enabled items.
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
void setMap(QgsLayoutItemMap *map)
Sets the corresponding layout map for the item.
QString id() const
Returns the unique id for the map item.
StackingPosition
Item stacking position, specifies where the in the map's stack the item should be rendered.
@ StackBelowMapLabels
Render above all map layers, but below map labels.
@ StackAboveMapLabels
Render above all map layers and labels.
@ StackBelowMapLayer
Render below a specific map layer (see stackingLayer()).
@ StackAboveMapLayer
Render above a specific map layer (see stackingLayer()).
@ StackBelowMap
Render below all map layers.
QgsLayoutItemMap * mMap
Associated map.
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)
Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'Layout...
StackingPosition mStackingPosition
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMa...
QString mName
Friendly display name.
bool mEnabled
True if item is to be displayed on map.
void setStackingPosition(StackingPosition position)
Sets the item's stacking position, which specifies where the in the map's stack the item should be re...
StackingPosition stackingPosition() const
Returns the item's stacking position, which specifies where the in the map's stack the item should be...
QgsLayoutItemMapItem(const QString &name, QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItem, attached to the specified map.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
const QgsLayoutItemMap * map() const
Returns the layout item map for the item.
virtual void draw(QPainter *painter)=0
Draws the item on to a destination painter.
Layout graphical items for displaying a map.
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the objects' current state.
QgsLayoutObject(QgsLayout *layout)
Constructor for QgsLayoutObject, with the specified parent layout.
Base class for all map layer types.
Definition qgsmaplayer.h:83
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_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
_LayerRef< QgsMapLayer > QgsMapLayerRef