Aquila  2.0 prealpha
Cognitive Robotics Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QCPLayer Class Reference

A layer that may contain objects, to control the rendering order. More...

#include <plot2d.h>

Public Member Functions

 QCPLayer (QCustomPlot *parentPlot, const QString &layerName)
 
 ~QCPLayer ()
 
QCustomPlotparentPlot () const
 
QString name () const
 
int index () const
 
QList< QCPLayerable * > children () const
 

Protected Member Functions

void addChild (QCPLayerable *layerable, bool prepend)
 
void removeChild (QCPLayerable *layerable)
 

Protected Attributes

QCustomPlotmParentPlot
 
QString mName
 
QList< QCPLayerable * > mChildren
 

Friends

class QCPLayerable
 

Detailed Description

A layer that may contain objects, to control the rendering order.

The Layering system of QCustomPlot is the mechanism to control the rendering order of the elements inside the plot, e.g. that the grid is drawn behind plottables etc.

It is based on the two classes QCPLayer and QCPLayerable. A QCustomPlot contains an ordered list of one or more instances of QCPLayer (see QCustomPlot::addLayer, QCustomPlot::layer, QCustomPlot::moveLayer, etc.). The layers are drawn in the order they are in the list.

A QCPLayer itself contains an ordered list of QCPLayerable instances. QCPLayerable is an abstract base class from which almost all visible objects derive, like axes, grids, graphs, items, etc.

By default, QCustomPlot has three layers: "grid", "main" and "axes" (in that order). Initially the QCPGrid instances are on the "grid" layer, so the grid will be drawn beneath the objects on the other two layers. The top layer is "axes" and contains all four axes, so they will be drawn on top. Between these two layers, there is the "main" layer. It is initially empty and set as the current layer (see QCustomPlot::setCurrentLayer). This means, all new plottables, items etc. are created on this layer by default, and are thus drawn above the grid but below the axes.

Controlling the ordering of objects is easy: Create a new layer in the position you want it to be, e.g. above "main", with QCustomPlot::addLayer. Then set the current layer with QCustomPlot::setCurrentLayer to that new layer and finally create the objects normally. They will be placed on the new layer automatically, due to the current layer setting. Alternatively you could have also ignored the current layer setting and just moved the objects with QCPLayerable::setLayer to the desired layer after creating them.

It is also possible to move whole layers. For example, If you want the grid to be shown in front of all plottables/items on the "main" layer, just move it above "main" with QCustomPlot::moveLayer. This way the ordering might now be "main", "grid", "axes", so while the grid will still be beneath the axes, it will now be drawn above plottables/items on "main", as intended.

The rendering order within one layer is simply by order of creation. The item created last (or added last to the layer), is drawn on top of all other objects on that layer.

When a layer is deleted, the objects on it are not deleted with it, but fall on the layer below the deleted layer, see QCustomPlot::removeLayer.

Constructor & Destructor Documentation

QCPLayer::QCPLayer ( QCustomPlot parentPlot,
const QString &  layerName 
)

Creates a new QCPLayer instance.

Normally you shouldn't directly create layers like this, use QCustomPlot::addLayer instead.

Warning
It is not checked that layerName is actually an unique layer name in parentPlot. This check is only performed by QCustomPlot::addLayer.
QCPLayer::~QCPLayer ( )

Member Function Documentation

void QCPLayer::addChild ( QCPLayerable layerable,
bool  prepend 
)
protected
QList< QCPLayerable * > QCPLayer::children ( ) const
inline

Returns a list of all layerables on this layer. The order corresponds to the rendering order, i.e. layerables with higher indices are drawn above layerables with lower indices.

int QCPLayer::index ( ) const

Returns the index this layer has in the QCustomPlot. The index is the integer number by which this layer can be accessed via QCustomPlot::layer.

Layers with greater indices will be drawn above layers with smaller indices.

QString QCPLayer::name ( ) const
inline
QCustomPlot* QCPLayer::parentPlot ( ) const
inline
void QCPLayer::removeChild ( QCPLayerable layerable)
protected

Friends And Related Function Documentation

friend class QCPLayerable
friend

Member Data Documentation

QList<QCPLayerable*> QCPLayer::mChildren
protected
QString QCPLayer::mName
protected
QCustomPlot* QCPLayer::mParentPlot
protected

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