QGIS API Documentation  3.2.0-Bonn (bc43194)
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. More...
 
void addGrid (QgsLayoutItemMapGrid *grid)
 Adds a new map grid to the stack and takes ownership of the grid. More...
 
QList< QgsLayoutItemMapGrid *> asList () const
 Returns a list of QgsLayoutItemMapGrids contained by the stack. More...
 
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. More...
 
QgsLayoutItemMapGridgrid (const QString &gridId) const
 Returns a reference to a grid with matching gridId within the stack. More...
 
QgsLayoutItemMapGridgrid (int index) const
 Returns a reference to a grid at the specified index within the stack. More...
 
double maxGridExtension () const
 Calculates the maximum distance grids within the stack extend beyond the QgsLayoutItemMap's item rect. More...
 
void moveGridDown (const QString &gridId)
 Moves a grid with matching gridId down the stack, causing it to be rendered below other grids. More...
 
void moveGridUp (const QString &gridId)
 Moves a grid with matching gridId up the stack, causing it to be rendered above other grids. More...
 
QgsLayoutItemMapGridoperator[] (int index)
 Returns a reference to a grid at the specified index within the stack. More...
 
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. More...
 
void removeGrid (const QString &gridId)
 Removes a grid with matching gridId from the stack and deletes the corresponding QgsLayoutItemMapGrid. More...
 
- Public Member Functions inherited from QgsLayoutItemMapItemStack
 QgsLayoutItemMapItemStack (QgsLayoutItemMap *map)
 Constructor for QgsLayoutItemMapItemStack, attached to the specified map. More...
 
virtual ~QgsLayoutItemMapItemStack ()
 
bool containsAdvancedEffects () const
 Returns whether any items within the stack contain advanced effects, such as blending modes. More...
 
void drawItems (QPainter *painter)
 Draws the items from the stack on a specified painter. More...
 
virtual void finalizeRestoreFromXml ()
 Called after all pending items have been restored from XML. More...
 
int size () const
 Returns the number of items in the stack. More...
 
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. More...
 

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. More...
 
QList< QgsLayoutItemMapItem *> asList () const
 Returns a list of QgsLayoutItemMapItems contained by the stack. More...
 
QgsLayoutItemMapItemitem (const QString &itemId) const
 Returns a reference to an item which matching itemId within the stack. More...
 
QgsLayoutItemMapItemitem (int index) const
 Returns a reference to the item at the specified index within the stack. More...
 
void moveItemDown (const QString &itemId)
 Moves an item which matching itemId up the stack, causing it to be rendered above other items. More...
 
void moveItemUp (const QString &itemId)
 Moves an item which matching itemId up the stack, causing it to be rendered above other items. More...
 
QgsLayoutItemMapItemoperator[] (int index)
 Returns a reference to an item at the specified index within the stack. More...
 
void removeItem (const QString &itemId)
 Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapItem. More...
 
void removeItems ()
 Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack. More...
 
- 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
Since
QGIS 3.0

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 43 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 49 of file qgslayoutitemmapgrid.cpp.

◆ asList()

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

Returns a list of QgsLayoutItemMapGrids contained by the stack.

Definition at line 81 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 128 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 69 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 75 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 118 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 64 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 59 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 94 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 101 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 54 of file qgslayoutitemmapgrid.cpp.


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