QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsLayoutItemMapItemStack Class Referenceabstract

A collection of map items which are drawn above the map content in a QgsLayoutItemMap. More...

#include <qgslayoutitemmapitem.h>

Inheritance diagram for QgsLayoutItemMapItemStack:
Inheritance graph
[legend]

Public Member Functions

 QgsLayoutItemMapItemStack (QgsLayoutItemMap *map)
 Constructor for QgsLayoutItemMapItemStack, attached to the specified map.
 
virtual ~QgsLayoutItemMapItemStack ()
 
bool containsAdvancedEffects () const
 Returns whether any items within the stack contain advanced effects, such as blending modes.
 
void drawItems (QPainter *painter, bool ignoreStacking=true)
 Draws the items from the stack on a specified painter.
 
virtual void finalizeRestoreFromXml ()
 Called after all pending items have been restored from XML.
 
bool hasEnabledItems () const
 Returns true if the stack has any currently enabled items.
 
QgsLayoutItemMapItemitem (int index) const
 Returns a reference to the item at the specified index within the stack.
 
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 'LayoutMap' tag.
 
int size () const
 Returns the number of items in the stack.
 
virtual bool writeXml (QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) const
 Stores the state of the item stack in a DOM node, where element is the DOM element corresponding to a 'LayoutMap' tag.
 

Protected Member Functions

void addItem (QgsLayoutItemMapItem *item)
 Adds a new map item to the stack and takes ownership of the item.
 
QList< QgsLayoutItemMapItem * > asList () const
 Returns a list of QgsLayoutItemMapItems contained by the stack.
 
QgsLayoutItemMapItemitem (const QString &itemId) const
 Returns a reference to an item which matching itemId within the stack.
 
void moveItemDown (const QString &itemId)
 Moves an item which matching itemId up the stack, causing it to be rendered above other items.
 
void moveItemUp (const QString &itemId)
 Moves an item which matching itemId up the stack, causing it to be rendered above other items.
 
QgsLayoutItemMapItemoperator[] (int index)
 Returns a reference to an item at the specified index within the stack.
 
void removeItem (const QString &itemId)
 Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapItem.
 
void removeItems ()
 Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.
 

Protected Attributes

QList< QgsLayoutItemMapItem * > mItems
 
QgsLayoutItemMapmMap = nullptr
 

Detailed Description

A collection of map items which are drawn above the map content in a QgsLayoutItemMap.

The item stack controls which items are drawn and the order they are drawn in.

See also
QgsLayoutItemMapItem

Definition at line 228 of file qgslayoutitemmapitem.h.

Constructor & Destructor Documentation

◆ QgsLayoutItemMapItemStack()

QgsLayoutItemMapItemStack::QgsLayoutItemMapItemStack ( QgsLayoutItemMap map)

Constructor for QgsLayoutItemMapItemStack, attached to the specified map.

Definition at line 147 of file qgslayoutitemmapitem.cpp.

◆ ~QgsLayoutItemMapItemStack()

QgsLayoutItemMapItemStack::~QgsLayoutItemMapItemStack ( )
virtual

Definition at line 153 of file qgslayoutitemmapitem.cpp.

Member Function Documentation

◆ addItem()

void QgsLayoutItemMapItemStack::addItem ( QgsLayoutItemMapItem item)
protected

Adds a new map item to the stack and takes ownership of the item.

The item will be added to the end of the stack, and rendered above any existing map items already present in the stack.

Note
After adding an item to the stack update() should be called for the QgsLayoutItemMap to prevent rendering artifacts.
See also
removeItem()

Definition at line 158 of file qgslayoutitemmapitem.cpp.

◆ asList()

QList< QgsLayoutItemMapItem * > QgsLayoutItemMapItemStack::asList ( ) const
protected

Returns a list of QgsLayoutItemMapItems contained by the stack.

Definition at line 235 of file qgslayoutitemmapitem.cpp.

◆ containsAdvancedEffects()

bool QgsLayoutItemMapItemStack::containsAdvancedEffects ( ) const

Returns whether any items within the stack contain advanced effects, such as blending modes.

Definition at line 292 of file qgslayoutitemmapitem.cpp.

◆ drawItems()

void QgsLayoutItemMapItemStack::drawItems ( QPainter *  painter,
bool  ignoreStacking = true 
)

Draws the items from the stack on a specified painter.

If ignoreStacking is true, then all items will be drawn, regardless of their actual stacking position settings. If it is false, only items which are set to stack above the map item will be drawn.

Definition at line 265 of file qgslayoutitemmapitem.cpp.

◆ finalizeRestoreFromXml()

void QgsLayoutItemMapItemStack::finalizeRestoreFromXml ( )
virtual

Called after all pending items have been restored from XML.

Map item stacks can use this method to run steps which must take place after all items have been restored to the layout, such as connecting to signals emitted by other items, which may not have existed in the layout at the time readXml() was called. E.g. an overview can use this to connect to its linked map item after restoration from XML.

See also
readXml()

Definition at line 257 of file qgslayoutitemmapitem.cpp.

◆ hasEnabledItems()

bool QgsLayoutItemMapItemStack::hasEnabledItems ( ) const

Returns true if the stack has any currently enabled items.

Since
QGIS 3.10

Definition at line 304 of file qgslayoutitemmapitem.cpp.

◆ item() [1/2]

QgsLayoutItemMapItem * QgsLayoutItemMapItemStack::item ( const QString &  itemId) const
protected

Returns a reference to an item which matching itemId within the stack.

Definition at line 207 of file qgslayoutitemmapitem.cpp.

◆ item() [2/2]

QgsLayoutItemMapItem * QgsLayoutItemMapItemStack::item ( int  index) const

Returns a reference to the item at the specified index within the stack.

Definition at line 220 of file qgslayoutitemmapitem.cpp.

◆ moveItemDown()

void QgsLayoutItemMapItemStack::moveItemDown ( const QString &  itemId)
protected

Moves an item which matching itemId up the stack, causing it to be rendered above other items.

Note
After moving an item within the stack, update() should be called for the QgsLayoutItemMap to redraw the map with the new item stack order.
See also
moveItemUp()

Definition at line 191 of file qgslayoutitemmapitem.cpp.

◆ moveItemUp()

void QgsLayoutItemMapItemStack::moveItemUp ( const QString &  itemId)
protected

Moves an item which matching itemId up the stack, causing it to be rendered above other items.

Note
After moving an item within the stack, update() should be called for the QgsLayoutItemMap to redraw the map with the new item stack order.
See also
moveItemDown()

Definition at line 175 of file qgslayoutitemmapitem.cpp.

◆ operator[]()

QgsLayoutItemMapItem & QgsLayoutItemMapItemStack::operator[] ( int  index)
protected

Returns a reference to an item at the specified index within the stack.

See also
item()
Note
not available in Python bindings

Definition at line 230 of file qgslayoutitemmapitem.cpp.

◆ readXml()

virtual bool QgsLayoutItemMapItemStack::readXml ( const QDomElement &  element,
const QDomDocument &  doc,
const QgsReadWriteContext context 
)
pure virtual

Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'LayoutMap' tag.

Returns true if read was successful.

See also
writeXml()

Implemented in QgsLayoutItemMapGridStack, and QgsLayoutItemMapOverviewStack.

◆ removeItem()

void QgsLayoutItemMapItemStack::removeItem ( const QString &  itemId)
protected

Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapItem.

Note
After removing an item from the stack, update() should be called for the QgsLayoutItemMap to prevent rendering artifacts.
See also
addItem()

Definition at line 163 of file qgslayoutitemmapitem.cpp.

◆ removeItems()

void QgsLayoutItemMapItemStack::removeItems ( )
protected

Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.

Definition at line 316 of file qgslayoutitemmapitem.cpp.

◆ size()

int QgsLayoutItemMapItemStack::size ( ) const
inline

Returns the number of items in the stack.

Definition at line 243 of file qgslayoutitemmapitem.h.

◆ writeXml()

bool QgsLayoutItemMapItemStack::writeXml ( QDomElement &  element,
QDomDocument &  doc,
const QgsReadWriteContext context 
) const
virtual

Stores the state of the item stack in a DOM node, where element is the DOM element corresponding to a 'LayoutMap' tag.

Returns true if write was successful.

See also
readXml()

Definition at line 246 of file qgslayoutitemmapitem.cpp.

Member Data Documentation

◆ mItems

QList< QgsLayoutItemMapItem * > QgsLayoutItemMapItemStack::mItems
protected

Definition at line 351 of file qgslayoutitemmapitem.h.

◆ mMap

QgsLayoutItemMap* QgsLayoutItemMapItemStack::mMap = nullptr
protected

Definition at line 353 of file qgslayoutitemmapitem.h.


The documentation for this class was generated from the following files: