QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsComposerMapItemStack Class Referenceabstract

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

#include <qgscomposermapitem.h>

Inheritance diagram for QgsComposerMapItemStack:
Inheritance graph
[legend]

Public Member Functions

 QgsComposerMapItemStack (QgsComposerMap *map)
 Constructor for QgsComposerMapItemStack. More...
 
virtual ~QgsComposerMapItemStack ()
 
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 bool readXML (const QDomElement &elem, const QDomDocument &doc)=0
 Sets the item stack's state from a DOM document. More...
 
int size () const
 Returns the number of items in the stack. More...
 
virtual bool writeXML (QDomElement &elem, QDomDocument &doc) const
 Stores the state of the item stack in a DOM node. More...
 

Protected Member Functions

void addItem (QgsComposerMapItem *item)
 Adds a new map item to the stack and takes ownership of the item. More...
 
QList< QgsComposerMapItem *> asList () const
 Returns a list of QgsComposerMapItems contained by the stack. More...
 
const QgsComposerMapItemconstItem (const QString &itemId) const
 Returns a const reference to an item within the stack. More...
 
QgsComposerMapItemitem (const QString &itemId) const
 Returns a reference to an item within the stack. More...
 
QgsComposerMapItemitem (const int index) const
 Returns a reference to an item within the stack. More...
 
void moveItemDown (const QString &itemId)
 Moves an item up the stack, causing it to be rendered above other items. More...
 
void moveItemUp (const QString &itemId)
 Moves an item up the stack, causing it to be rendered above other items. More...
 
QgsComposerMapItemoperator[] (int idx)
 Returns a reference to an item within the stack. More...
 
void removeItem (const QString &itemId)
 Removes an item from the stack and deletes the corresponding QgsComposerMapItem. More...
 
void removeItems ()
 Clears the item stack and deletes all QgsComposerMapItems contained by the stack. More...
 

Protected Attributes

QgsComposerMapmComposerMap
 
QList< QgsComposerMapItem *> mItems
 

Detailed Description

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

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

Note
added in QGIS 2.5
See also
QgsComposerMapItem

Definition at line 133 of file qgscomposermapitem.h.

Constructor & Destructor Documentation

◆ QgsComposerMapItemStack()

QgsComposerMapItemStack::QgsComposerMapItemStack ( QgsComposerMap map)

Constructor for QgsComposerMapItemStack.

Parameters
mapQgsComposerMap the item stack is attached to

Definition at line 64 of file qgscomposermapitem.cpp.

◆ ~QgsComposerMapItemStack()

QgsComposerMapItemStack::~QgsComposerMapItemStack ( )
virtual

Definition at line 70 of file qgscomposermapitem.cpp.

Member Function Documentation

◆ addItem()

void QgsComposerMapItemStack::addItem ( QgsComposerMapItem 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.

Parameters
itemQgsComposerMapItem to add to the stack
Note
after adding an item to the stack update() should be called for the QgsComposerMap to prevent rendering artifacts
See also
removeItem

Definition at line 75 of file qgscomposermapitem.cpp.

◆ asList()

QList< QgsComposerMapItem * > QgsComposerMapItemStack::asList ( ) const
protected

Returns a list of QgsComposerMapItems contained by the stack.

Returns
list of items

Definition at line 167 of file qgscomposermapitem.cpp.

◆ constItem()

const QgsComposerMapItem * QgsComposerMapItemStack::constItem ( const QString itemId) const
protected

Returns a const reference to an item within the stack.

Parameters
itemIdid for the QgsComposerMapItem to find
Returns
const reference to item, if found
See also
item

Definition at line 124 of file qgscomposermapitem.cpp.

◆ containsAdvancedEffects()

bool QgsComposerMapItemStack::containsAdvancedEffects ( ) const

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

Returns
true if item stack contains advanced effects

Definition at line 204 of file qgscomposermapitem.cpp.

◆ drawItems()

void QgsComposerMapItemStack::drawItems ( QPainter painter)

Draws the items from the stack on a specified painter.

Parameters
painterdestination QPainter

Definition at line 190 of file qgscomposermapitem.cpp.

◆ item() [1/2]

QgsComposerMapItem * QgsComposerMapItemStack::item ( const QString itemId) const
protected

Returns a reference to an item within the stack.

Parameters
itemIdid for the QgsComposerMapItem to find
Returns
reference to item if found
See also
constItem

Definition at line 138 of file qgscomposermapitem.cpp.

◆ item() [2/2]

QgsComposerMapItem * QgsComposerMapItemStack::item ( const int  index) const
protected

Returns a reference to an item within the stack.

Parameters
indexitem position in the stack
Returns
reference to item if found
See also
constItem

Definition at line 152 of file qgscomposermapitem.cpp.

◆ moveItemDown()

void QgsComposerMapItemStack::moveItemDown ( const QString itemId)
protected

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

Parameters
itemIdid for the QgsComposerMapItem to move down
Note
after moving an item within the stack, update() should be called for the QgsComposerMap to redraw the map with the new item stack order
See also
moveItemUp

Definition at line 108 of file qgscomposermapitem.cpp.

◆ moveItemUp()

void QgsComposerMapItemStack::moveItemUp ( const QString itemId)
protected

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

Parameters
itemIdid for the QgsComposerMapItem to move up
Note
after moving an item within the stack, update() should be called for the QgsComposerMap to redraw the map with the new item stack order
See also
moveItemDown

Definition at line 92 of file qgscomposermapitem.cpp.

◆ operator[]()

QgsComposerMapItem & QgsComposerMapItemStack::operator[] ( int  idx)
protected

Returns a reference to an item within the stack.

Parameters
idxitem position in the stack
Returns
reference to item if found
See also
constItem
item
Note
not available in python bindings

Definition at line 162 of file qgscomposermapitem.cpp.

◆ readXML()

virtual bool QgsComposerMapItemStack::readXML ( const QDomElement elem,
const QDomDocument doc 
)
pure virtual

Sets the item stack's state from a DOM document.

Parameters
elemis DOM node corresponding to 'a ComposerMap' tag
docDOM document
Returns
true if read was successful
See also
writeXML

Implemented in QgsComposerMapGridStack, and QgsComposerMapOverviewStack.

◆ removeItem()

void QgsComposerMapItemStack::removeItem ( const QString itemId)
protected

Removes an item from the stack and deletes the corresponding QgsComposerMapItem.

Parameters
itemIdid for the QgsComposerMapItem to remove
Note
after removing an item from the stack, update() should be called for the QgsComposerMap to prevent rendering artifacts
See also
addItem

Definition at line 80 of file qgscomposermapitem.cpp.

◆ removeItems()

void QgsComposerMapItemStack::removeItems ( )
protected

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

Definition at line 217 of file qgscomposermapitem.cpp.

◆ size()

int QgsComposerMapItemStack::size ( ) const
inline

Returns the number of items in the stack.

Returns
number of items in the stack

Definition at line 147 of file qgscomposermapitem.h.

◆ writeXML()

bool QgsComposerMapItemStack::writeXML ( QDomElement elem,
QDomDocument doc 
) const
virtual

Stores the state of the item stack in a DOM node.

Parameters
elemis DOM element corresponding to a 'ComposerMap' tag
docDOM document
Returns
true if write was successful
See also
readXML

Definition at line 178 of file qgscomposermapitem.cpp.

Member Data Documentation

◆ mComposerMap

QgsComposerMap* QgsComposerMapItemStack::mComposerMap
protected

Definition at line 251 of file qgscomposermapitem.h.

◆ mItems

QList< QgsComposerMapItem* > QgsComposerMapItemStack::mItems
protected

Definition at line 249 of file qgscomposermapitem.h.


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