Class: QgsLayoutItemMapGridStack¶
- class qgis.core.QgsLayoutItemMapGridStack¶
Bases:
QgsLayoutItemMapItemStack
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
QgsLayoutItemMapGridStack(map:
QgsLayoutItemMap
) Constructor forQgsLayoutItemMapGridStack
, attached to the specifiedmap
.QgsLayoutItemMapGridStack(
QgsLayoutItemMapGridStack
)Methods
Adds a new map
grid
to the stack and takes ownership of the grid.Adds a new map item to the stack and takes ownership of the item.
Returns a list of
QgsLayoutItemMapGrids
contained by the stack.Calculates the maximum distance grids within the stack extend beyond the
QgsLayoutItemMap
's item rect.Returns a reference to a grid with matching
gridId
within the stack.Returns a reference to the item at the specified
index
within the stack.Calculates the maximum distance grids within the stack extend beyond the
QgsLayoutItemMap
's item rect.Moves a grid with matching
gridId
down the stack, causing it to be rendered below other grids.Moves a grid with matching
gridId
up the stack, causing it to be rendered above other grids.Moves an item which matching
itemId
up the stack, causing it to be rendered above other items.Moves an item which matching
itemId
up the stack, causing it to be rendered above other items.- param elem:
Removes a grid with matching
gridId
from the stack and deletes the correspondingQgsLayoutItemMapGrid
.Removes an item which matching
itemId
from the stack and deletes the correspondingQgsLayoutItemMapItem
Clears the item stack and deletes all
QgsLayoutItemMapItems
contained by the stack- addGrid(self, grid: QgsLayoutItemMapGrid)¶
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()
andupdate()
should be called for theQgsLayoutItemMap
to prevent rendering artifacts.See also
- Parameters:
grid (QgsLayoutItemMapGrid) –
- addItem(self, item: QgsLayoutItemMapItem)¶
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 theQgsLayoutItemMap
to prevent rendering artifacts.See also
- asList(self) List[QgsLayoutItemMapGrid] ¶
Returns a list of
QgsLayoutItemMapGrids
contained by the stack.- Return type:
List[QgsLayoutItemMapGrid]
- calculateMaxGridExtension(self) Tuple[float, float, float, float] ¶
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
- Return type:
Tuple[float, float, float, float]
- grid(self, gridId: str) QgsLayoutItemMapGrid ¶
Returns a reference to a grid with matching
gridId
within the stack.grid(self, index: int) -> QgsLayoutItemMapGrid Returns a reference to a grid at the specified
index
within the stack.- Parameters:
gridId (str) –
- Return type:
- item(self, index: int) QgsLayoutItemMapItem ¶
Returns a reference to the item at the specified
index
within the stack.item(self, itemId: str) -> QgsLayoutItemMapItem Returns a reference to an item which matching
itemId
within the stack.
- maxGridExtension(self) float ¶
Calculates the maximum distance grids within the stack extend beyond the
QgsLayoutItemMap
’s item rect.See also
- Return type:
float
- moveGridDown(self, gridId: str)¶
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 theQgsLayoutItemMap
to redraw the map with the new grid stack order.See also
- Parameters:
gridId (str) –
- moveGridUp(self, gridId: str)¶
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 theQgsLayoutItemMap
to redraw the map with the new grid stack order.See also
- Parameters:
gridId (str) –
- moveItemDown(self, itemId: str)¶
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 theQgsLayoutItemMap
to redraw the map with the new item stack order.See also
- moveItemUp(self, itemId: str)¶
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 theQgsLayoutItemMap
to redraw the map with the new item stack order.See also
- readXml(self, elem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) bool ¶
- Parameters:
elem (QDomElement) –
doc (QDomDocument) –
context (QgsReadWriteContext) –
- Return type:
bool
- removeGrid(self, gridId: str)¶
Removes a grid with matching
gridId
from the stack and deletes the correspondingQgsLayoutItemMapGrid
.Note
After removing a grid from the stack,
updateBoundingRect()
andupdate()
should be called for theQgsLayoutItemMap
to prevent rendering artifacts.See also
- Parameters:
gridId (str) –
- removeItem(self, itemId: str)¶
Removes an item which matching
itemId
from the stack and deletes the correspondingQgsLayoutItemMapItem
Note
After removing an item from the stack,
update()
should be called for theQgsLayoutItemMap
to prevent rendering artifacts.See also
- removeItems(self)¶
Clears the item stack and deletes all
QgsLayoutItemMapItems
contained by the stack