QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsLayoutItemMapGridStack Class Reference

A collection of grids which is drawn above the map content in a QgsLayoutItemMap. More...

#include <qgslayoutitemmapgrid.h>

Inheritance diagram for QgsLayoutItemMapGridStack:
Inheritance graph
[legend]

Public Member Functions

 QgsLayoutItemMapGridStack (QgsLayoutItemMap *map)
 Constructor for QgsLayoutItemMapGridStack, attached to the specified map.
 
void addGrid (QgsLayoutItemMapGrid *grid)
 Adds a new map grid to the stack and takes ownership of the grid.
 
QList< QgsLayoutItemMapGrid * > asList () const
 Returns a list of QgsLayoutItemMapGrids contained by the stack.
 
void calculateMaxGridExtension (double &top, double &right, double &bottom, double &left) const
 Calculates the maximum distance grids within the stack extend beyond the QgsLayoutItemMap's item rect.
 
QgsLayoutItemMapGridgrid (const QString &gridId) const
 Returns a reference to a grid with matching gridId within the stack.
 
QgsLayoutItemMapGridgrid (int index) const
 Returns a reference to a grid at the specified index within the stack.
 
double maxGridExtension () const
 Calculates the maximum distance grids within the stack extend beyond the QgsLayoutItemMap's item rect.
 
void moveGridDown (const QString &gridId)
 Moves a grid with matching gridId down the stack, causing it to be rendered below other grids.
 
void moveGridUp (const QString &gridId)
 Moves a grid with matching gridId up the stack, causing it to be rendered above other grids.
 
QgsLayoutItemMapGridoperator[] (int index)
 Returns a reference to a grid at the specified index within the stack.
 
bool readXml (const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context) override
 Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'LayoutMap' tag.
 
void removeGrid (const QString &gridId)
 Removes a grid with matching gridId from the stack and deletes the corresponding QgsLayoutItemMapGrid.
 
- Public Member Functions inherited from QgsLayoutItemMapItemStack
 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.
 
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.
 

Additional Inherited Members

- Protected Member Functions inherited from QgsLayoutItemMapItemStack
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 inherited from QgsLayoutItemMapItemStack
QList< QgsLayoutItemMapItem * > mItems
 
QgsLayoutItemMapmMap = nullptr
 

Detailed Description

A collection of grids which is drawn above the map content in a QgsLayoutItemMap.

The grid stack controls which grids are drawn and the order they are drawn in.

See also
QgsLayoutItemMapGrid

Definition at line 45 of file qgslayoutitemmapgrid.h.

Constructor & Destructor Documentation

◆ QgsLayoutItemMapGridStack()

QgsLayoutItemMapGridStack::QgsLayoutItemMapGridStack ( QgsLayoutItemMap map)

Constructor for QgsLayoutItemMapGridStack, attached to the specified map.

Definition at line 52 of file qgslayoutitemmapgrid.cpp.

Member Function Documentation

◆ addGrid()

void QgsLayoutItemMapGridStack::addGrid ( QgsLayoutItemMapGrid grid)

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

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

Note
After adding a grid to the stack, updateBoundingRect() and update() should be called for the QgsLayoutItemMap to prevent rendering artifacts.
See also
removeGrid()

Definition at line 58 of file qgslayoutitemmapgrid.cpp.

◆ asList()

QList< QgsLayoutItemMapGrid * > QgsLayoutItemMapGridStack::asList ( ) const

Returns a list of QgsLayoutItemMapGrids contained by the stack.

Definition at line 90 of file qgslayoutitemmapgrid.cpp.

◆ calculateMaxGridExtension()

void QgsLayoutItemMapGridStack::calculateMaxGridExtension ( double &  top,
double &  right,
double &  bottom,
double &  left 
) const

Calculates the maximum distance grids within the stack extend beyond the QgsLayoutItemMap's item rect.

This method calculates the distance for each side of the map item separately.

See also
maxGridExtension()

Definition at line 137 of file qgslayoutitemmapgrid.cpp.

◆ grid() [1/2]

QgsLayoutItemMapGrid * QgsLayoutItemMapGridStack::grid ( const QString &  gridId) const

Returns a reference to a grid with matching gridId within the stack.

Definition at line 78 of file qgslayoutitemmapgrid.cpp.

◆ grid() [2/2]

QgsLayoutItemMapGrid * QgsLayoutItemMapGridStack::grid ( int  index) const

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

Definition at line 84 of file qgslayoutitemmapgrid.cpp.

◆ maxGridExtension()

double QgsLayoutItemMapGridStack::maxGridExtension ( ) const

Calculates the maximum distance grids within the stack extend beyond the QgsLayoutItemMap's item rect.

See also
calculateMaxGridExtension()

Definition at line 127 of file qgslayoutitemmapgrid.cpp.

◆ moveGridDown()

void QgsLayoutItemMapGridStack::moveGridDown ( const QString &  gridId)

Moves a grid with matching gridId down the stack, causing it to be rendered below other grids.

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

Definition at line 73 of file qgslayoutitemmapgrid.cpp.

◆ moveGridUp()

void QgsLayoutItemMapGridStack::moveGridUp ( const QString &  gridId)

Moves a grid with matching gridId up the stack, causing it to be rendered above other grids.

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

Definition at line 68 of file qgslayoutitemmapgrid.cpp.

◆ operator[]()

QgsLayoutItemMapGrid & QgsLayoutItemMapGridStack::operator[] ( int  index)

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

See also
grid()

Definition at line 103 of file qgslayoutitemmapgrid.cpp.

◆ readXml()

bool QgsLayoutItemMapGridStack::readXml ( const QDomElement &  element,
const QDomDocument &  doc,
const QgsReadWriteContext context 
)
overridevirtual

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()

Implements QgsLayoutItemMapItemStack.

Definition at line 110 of file qgslayoutitemmapgrid.cpp.

◆ removeGrid()

void QgsLayoutItemMapGridStack::removeGrid ( const QString &  gridId)

Removes a grid with matching gridId from the stack and deletes the corresponding QgsLayoutItemMapGrid.

Note
After removing a grid from the stack, updateBoundingRect() and update() should be called for the QgsLayoutItemMap to prevent rendering artifacts.
See also
addGrid()

Definition at line 63 of file qgslayoutitemmapgrid.cpp.


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