Gra zręcznościowa „Straszna Epidemia"  V1.2
Projekt Wizualizacja Danych Sensorycznych Kewin Gałuszka rok akademicki 2019/2020
Dokumentacja klasy QCPLayer

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

#include <qcustomplot.h>

Diagram dziedziczenia dla QCPLayer
Diagram współpracy dla QCPLayer:

Typy publiczne

enum  LayerMode { lmLogical, lmBuffered }
 

Metody publiczne

 QCPLayer (QCustomPlot *parentPlot, const QString &layerName)
 
virtual ~QCPLayer ()
 
QCustomPlotparentPlot () const
 
QString name () const
 
int index () const
 
QList< QCPLayerable * > children () const
 
bool visible () const
 
LayerMode mode () const
 
void setVisible (bool visible)
 
void setMode (LayerMode mode)
 
void replot ()
 

Metody chronione

void draw (QCPPainter *painter)
 
void drawToPaintBuffer ()
 
void addChild (QCPLayerable *layerable, bool prepend)
 
void removeChild (QCPLayerable *layerable)
 

Atrybuty chronione

QCustomPlotmParentPlot
 
QString mName
 
int mIndex
 
QList< QCPLayerable * > mChildren
 
bool mVisible
 
LayerMode mMode
 
QWeakPointer< QCPAbstractPaintBuffermPaintBuffer
 

Przyjaciele

class QCustomPlot
 
class QCPLayerable
 

Opis szczegółowy

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.

It is based on the two classes QCPLayer and QCPLayerable. QCustomPlot holds an ordered list of one or more instances of QCPLayer (see QCustomPlot::addLayer, QCustomPlot::layer, QCustomPlot::moveLayer, etc.). When replotting, QCustomPlot goes through the list of layers bottom to top and successively draws the layerables of the layers into the paint buffer(s).

A QCPLayer 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.

Default layers

Initially, QCustomPlot has six layers: "background", "grid", "main", "axes", "legend" and "overlay" (in that order). On top is the "overlay" layer, which only contains the QCustomPlot's selection rect (QCustomPlot::selectionRect). The next two layers "axes" and "legend" contain the default axes and legend, so they will be drawn above plottables. In the middle, 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. Then comes the "grid" layer which contains the QCPGrid instances (which belong tightly to QCPAxis, see QCPAxis::grid). The Axis rect background shall be drawn behind everything else, thus the default QCPAxisRect instance is placed on the "background" layer. Of course, the layer affiliation of the individual objects can be changed as required (QCPLayerable::setLayer).

Controlling the rendering order via layers

Controlling the ordering of layerables in the plot is easy: Create a new layer in the position you want the layerable to be in, 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.

The rendering order within one layer is simply by order of creation or insertion. 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.

Replotting only a specific layer

If the layer mode (setMode) is set to lmBuffered, you can replot only this specific layer by calling replot. In certain situations this can provide better replot performance, compared with a full replot of all layers. Upon creation of a new layer, the layer mode is initialized to lmLogical. The only layer that is set to lmBuffered in a new QCustomPlot instance is the "overlay" layer, containing the selection rect.

Definicja w linii 628 pliku qcustomplot.h.

Dokumentacja składowych wyliczanych

◆ LayerMode

Defines the different rendering modes of a layer. Depending on the mode, certain layers can be replotted individually, without the need to replot (possibly complex) layerables on other layers.

Zobacz również
setMode
Wartości wyliczeń
lmLogical 

Layer is used only for rendering order, and shares paint buffer with all other adjacent logical layers.

lmBuffered 

Layer has its own paint buffer and may be replotted individually (see replot).

Definicja w linii 648 pliku qcustomplot.h.

Dokumentacja konstruktora i destruktora

◆ QCPLayer()

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

Creates a new QCPLayer instance.

Normally you shouldn't directly instantiate layers, use QCustomPlot::addLayer instead.

Ostrzeżenie
It is not checked that layerName is actually a unique layer name in parentPlot. This check is only performed by QCustomPlot::addLayer.

Definicja w linii 1042 pliku qcustomplot.cpp.

◆ ~QCPLayer()

QCPLayer::~QCPLayer ( )
virtual

Definicja w linii 1054 pliku qcustomplot.cpp.

Oto graf wywołań dla tej funkcji:

Dokumentacja funkcji składowych

◆ addChild()

void QCPLayer::addChild ( QCPLayerable layerable,
bool  prepend 
)
protected

Definicja w linii 1198 pliku qcustomplot.cpp.

Oto graf wywoływań tej funkcji:

◆ children()

QList< QCPLayerable * > QCPLayer::children ( ) const
inline

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

Definicja w linii 660 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ draw()

void QCPLayer::draw ( QCPPainter painter)
protected

Definicja w linii 1118 pliku qcustomplot.cpp.

Oto graf wywołań dla tej funkcji:
Oto graf wywoływań tej funkcji:

◆ drawToPaintBuffer()

void QCPLayer::drawToPaintBuffer ( )
protected

Definicja w linii 1141 pliku qcustomplot.cpp.

Oto graf wywołań dla tej funkcji:
Oto graf wywoływań tej funkcji:

◆ index()

int QCPLayer::index ( ) const
inline

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 higher indices will be drawn above layers with lower indices.

Definicja w linii 659 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ mode()

LayerMode QCPLayer::mode ( ) const
inline

Definicja w linii 662 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ name()

QString QCPLayer::name ( ) const
inline

Definicja w linii 658 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ parentPlot()

QCustomPlot* QCPLayer::parentPlot ( ) const
inline

Definicja w linii 657 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ removeChild()

void QCPLayer::removeChild ( QCPLayerable layerable)
protected

Definicja w linii 1221 pliku qcustomplot.cpp.

Oto graf wywoływań tej funkcji:

◆ replot()

void QCPLayer::replot ( )

If the layer mode (setMode) is set to lmBuffered, this method allows replotting only the layerables on this specific layer, without the need to replot all other layers (as a call to QCustomPlot::replot would do).

If the layer mode is lmLogical however, this method simply calls QCustomPlot::replot on the parent QCustomPlot instance.

QCustomPlot also makes sure to replot all layers instead of only this one, if the layer ordering has changed since the last full replot and the other paint buffers were thus invalidated.

Zobacz również
draw

Definicja w linii 1172 pliku qcustomplot.cpp.

Oto graf wywołań dla tej funkcji:
Oto graf wywoływań tej funkcji:

◆ setMode()

void QCPLayer::setMode ( QCPLayer::LayerMode  mode)

Sets the rendering mode of this layer.

If mode is set to lmBuffered for a layer, it will be given a dedicated paint buffer by the parent QCustomPlot instance. This means it may be replotted individually by calling QCPLayer::replot, without needing to replot all other layers.

Layers which are set to lmLogical (the default) are used only to define the rendering order and can't be replotted individually.

Note that each layer which is set to lmBuffered requires additional paint buffers for the layers below, above and for the layer itself. This increases the memory consumption and (slightly) decreases the repainting speed because multiple paint buffers need to be joined. So you should carefully choose which layers benefit from having their own paint buffer. A typical example would be a layer which contains certain layerables (e.g. items) that need to be changed and thus replotted regularly, while all other layerables on other layers stay static. By default, only the topmost layer called "overlay" is in mode lmBuffered, and contains the selection rect.

Zobacz również
replot

Definicja w linii 1102 pliku qcustomplot.cpp.

Oto graf wywołań dla tej funkcji:
Oto graf wywoływań tej funkcji:

◆ setVisible()

void QCPLayer::setVisible ( bool  visible)

Sets whether this layer is visible or not. If visible is set to false, all layerables on this layer will be invisible.

This function doesn't change the visibility property of the layerables (QCPLayerable::setVisible), but the QCPLayerable::realVisibility of each layerable takes the visibility of the parent layer into account.

Definicja w linii 1076 pliku qcustomplot.cpp.

Oto graf wywołań dla tej funkcji:

◆ visible()

bool QCPLayer::visible ( ) const
inline

Definicja w linii 661 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

Dokumentacja przyjaciół i funkcji związanych

◆ QCPLayerable

friend class QCPLayerable
friend

Definicja w linii 693 pliku qcustomplot.h.

◆ QCustomPlot

friend class QCustomPlot
friend

Definicja w linii 692 pliku qcustomplot.h.

Dokumentacja atrybutów składowych

◆ mChildren

QList<QCPLayerable*> QCPLayer::mChildren
protected

Definicja w linii 676 pliku qcustomplot.h.

◆ mIndex

int QCPLayer::mIndex
protected

Definicja w linii 675 pliku qcustomplot.h.

◆ mMode

LayerMode QCPLayer::mMode
protected

Definicja w linii 678 pliku qcustomplot.h.

◆ mName

QString QCPLayer::mName
protected

Definicja w linii 674 pliku qcustomplot.h.

◆ mPaintBuffer

QWeakPointer<QCPAbstractPaintBuffer> QCPLayer::mPaintBuffer
protected

Definicja w linii 681 pliku qcustomplot.h.

◆ mParentPlot

QCustomPlot* QCPLayer::mParentPlot
protected

Definicja w linii 673 pliku qcustomplot.h.

◆ mVisible

bool QCPLayer::mVisible
protected

Definicja w linii 677 pliku qcustomplot.h.


Dokumentacja dla tej klasy została wygenerowana z plików: