iCub-main
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QCPLayerable Class Referenceabstract

Base class for all drawable objects. More...

#include <qcustomplot.h>

+ Inheritance diagram for QCPLayerable:

Signals

void layerChanged (QCPLayer *newLayer)
 This signal is emitted when the layer of this layerable changes, i.e. More...
 

Public Member Functions

 QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
 Creates a new QCPLayerable instance. More...
 
 ~QCPLayerable ()
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 Returns the parent layerable of this layerable. More...
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 Sets the visibility of this layerable object. More...
 
Q_SLOT bool setLayer (QCPLayer *layer)
 Sets the layer of this layerable object. More...
 
bool setLayer (const QString &layerName)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the layer of this layerable object by name. More...
 
void setAntialiased (bool enabled)
 Sets whether this object will be drawn antialiased or not. More...
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 This function is used to decide whether a click hits a layerable object or not. More...
 
bool realVisibility () const
 Returns whether this layerable is visible, taking the visibility of the layerable parent and the visibility of the layer this layerable is on into account. More...
 

Protected Member Functions

virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
virtual QCP::Interaction selectionCategory () const
 
virtual QRect clipRect () const
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const =0
 
virtual void draw (QCPPainter *painter)=0
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Protected Attributes

bool mVisible
 
QCustomPlotmParentPlot
 
QPointer< QCPLayerablemParentLayerable
 
QCPLayermLayer
 
bool mAntialiased
 

Friends

class QCustomPlot
 
class QCPAxisRect
 

Detailed Description

Base class for all drawable objects.

This is the abstract base class most visible objects derive from, e.g. plottables, axes, grid etc.

Every layerable is on a layer (QCPLayer) which allows controlling the rendering order by stacking the layers accordingly.

For details about the layering mechanism, see the QCPLayer documentation.

Definition at line 407 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPLayerable()

QCPLayerable::QCPLayerable ( QCustomPlot plot,
QString  targetLayer = "",
QCPLayerable parentLayerable = 0 
)

Creates a new QCPLayerable instance.

Since QCPLayerable is an abstract base class, it can't be instantiated directly. Use one of the derived classes.

If plot is provided, it automatically places itself on the layer named targetLayer. If targetLayer is an empty string, it places itself on the current layer of the plot (see QCustomPlot::setCurrentLayer).

It is possible to provide 0 as plot. In that case, you should assign a parent plot at a later time with initializeParentPlot.

The layerable's parent layerable is set to parentLayerable, if provided. Direct layerable parents are mainly used to control visibility in a hierarchy of layerables. This means a layerable is only drawn, if all its ancestor layerables are also visible. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable, plot does.

Definition at line 932 of file qcustomplot.cpp.

◆ ~QCPLayerable()

QCPLayerable::~QCPLayerable ( )

Definition at line 949 of file qcustomplot.cpp.

Member Function Documentation

◆ antialiased()

bool QCPLayerable::antialiased ( ) const
inline

Definition at line 426 of file qcustomplot.h.

◆ applyAntialiasingHint()

void QCPLayerable::applyAntialiasingHint ( QCPPainter painter,
bool  localAntialiased,
QCP::AntialiasedElement  overrideElement 
) const
protected

Definition at line 1159 of file qcustomplot.cpp.

◆ applyDefaultAntialiasingHint()

void QCPLayerable::applyDefaultAntialiasingHint ( QCPPainter painter) const
protectedpure virtual

◆ clipRect()

QRect QCPLayerable::clipRect ( ) const
protectedvirtual

Reimplemented in QCPAbstractLegendItem, QCPAbstractItem, and QCPAbstractPlottable.

Definition at line 1215 of file qcustomplot.cpp.

◆ deselectEvent()

void QCPLayerable::deselectEvent ( bool *  selectionStateChanged)
protectedvirtual

◆ draw()

void QCPLayerable::draw ( QCPPainter painter)
protectedpure virtual

◆ initializeParentPlot()

void QCPLayerable::initializeParentPlot ( QCustomPlot parentPlot)
protected

Definition at line 1089 of file qcustomplot.cpp.

◆ layer()

QCPLayer* QCPLayerable::layer ( ) const
inline

Definition at line 425 of file qcustomplot.h.

◆ layerChanged

void QCPLayerable::layerChanged ( QCPLayer newLayer)
signal

This signal is emitted when the layer of this layerable changes, i.e.

this layerable is moved to a different layer.

See also
setLayer

◆ moveToLayer()

bool QCPLayerable::moveToLayer ( QCPLayer layer,
bool  prepend 
)
protected

Definition at line 1128 of file qcustomplot.cpp.

◆ parentLayerable()

QCPLayerable * QCPLayerable::parentLayerable ( ) const
inline

Returns the parent layerable of this layerable.

The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.

Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.

A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.

Definition at line 424 of file qcustomplot.h.

◆ parentPlot()

QCustomPlot* QCPLayerable::parentPlot ( ) const
inline

Definition at line 423 of file qcustomplot.h.

◆ parentPlotInitialized()

void QCPLayerable::parentPlotInitialized ( QCustomPlot parentPlot)
protectedvirtual

Reimplemented in QCPLegend, and QCPLayoutElement.

Definition at line 1185 of file qcustomplot.cpp.

◆ realVisibility()

bool QCPLayerable::realVisibility ( ) const

Returns whether this layerable is visible, taking the visibility of the layerable parent and the visibility of the layer this layerable is on into account.

This is the method that is consulted to decide whether a layerable shall be drawn or not.

If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.

If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.

Definition at line 1025 of file qcustomplot.cpp.

◆ selectEvent()

void QCPLayerable::selectEvent ( QMouseEvent *  event,
bool  additive,
const QVariant &  details,
bool *  selectionStateChanged 
)
protectedvirtual

◆ selectionCategory()

QCP::Interaction QCPLayerable::selectionCategory ( ) const
protectedvirtual

Reimplemented in QCPLegend, QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, and QCPAxis.

Definition at line 1201 of file qcustomplot.cpp.

◆ selectTest()

double QCPLayerable::selectTest ( const QPointF &  pos,
bool  onlySelectable,
QVariant *  details = 0 
) const
virtual

This function is used to decide whether a click hits a layerable object or not.

pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the shortest pixel distance of this point to the object. If the object is either invisible or the distance couldn't be determined, -1.0 is returned. Further, if onlySelectable is true and the object is not selectable, -1.0 is returned, too.

If the item is represented not by single lines but by an area like QCPItemRect or QCPItemText, a click inside the area returns a constant value greater zero (typically the selectionTolerance of the parent QCustomPlot multiplied by 0.99). If the click lies outside the area, this function returns -1.0.

Providing a constant value for area objects allows selecting line objects even when they are obscured by such area objects, by clicking close to the lines (i.e. closer than 0.99*selectionTolerance).

The actual setting of the selection state is not done by this function. This is handled by the parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified via the selectEvent/deselectEvent methods.

details is an optional output parameter. Every layerable subclass may place any information in details. This information will be passed to selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The subsequent call to selectEvent will carry the details. This is useful for multi-part objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked is only done once in selectTest. The result (i.e. the actually clicked part) can then be placed in details. So in the subsequent selectEvent, the decision which part was selected doesn't have to be done a second time for a single selection operation.

You may pass 0 as details to indicate that you are not interested in those selection details.

See also
selectEvent, deselectEvent, QCustomPlot::setInteractions

Reimplemented in QCPAbstractItem, QCPAbstractPlottable, QCPItemBracket, QCPItemTracer, QCPItemPixmap, QCPItemEllipse, QCPItemText, QCPItemRect, QCPItemCurve, QCPItemLine, QCPItemStraightLine, QCPColorMap, QCPStatisticalBox, QCPBars, QCPCurve, QCPGraph, QCPPlotTitle, QCPLegend, QCPAbstractLegendItem, QCPAxis, QCPLayoutInset, and QCPLayoutElement.

Definition at line 1064 of file qcustomplot.cpp.

◆ setAntialiased()

void QCPLayerable::setAntialiased ( bool  enabled)

Sets whether this object will be drawn antialiased or not.

Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

Definition at line 1007 of file qcustomplot.cpp.

◆ setLayer() [1/2]

bool QCPLayerable::setLayer ( const QString &  layerName)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the layer of this layerable object by name.

Returns true on success, i.e. if layerName is a valid layer name.

Definition at line 984 of file qcustomplot.cpp.

◆ setLayer() [2/2]

bool QCPLayerable::setLayer ( QCPLayer layer)

Sets the layer of this layerable object.

The object will be placed on top of the other objects already on layer.

Returns true on success, i.e. if layer is a valid layer.

Definition at line 974 of file qcustomplot.cpp.

◆ setParentLayerable()

void QCPLayerable::setParentLayerable ( QCPLayerable parentLayerable)
protected

Definition at line 1115 of file qcustomplot.cpp.

◆ setVisible()

void QCPLayerable::setVisible ( bool  on)

Sets the visibility of this layerable object.

If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.

Definition at line 963 of file qcustomplot.cpp.

◆ visible()

bool QCPLayerable::visible ( ) const
inline

Definition at line 422 of file qcustomplot.h.

Friends And Related Function Documentation

◆ QCPAxisRect

friend class QCPAxisRect
friend

Definition at line 471 of file qcustomplot.h.

◆ QCustomPlot

friend class QCustomPlot
friend

Definition at line 470 of file qcustomplot.h.

Member Data Documentation

◆ mAntialiased

bool QCPLayerable::mAntialiased
protected

Definition at line 449 of file qcustomplot.h.

◆ mLayer

QCPLayer* QCPLayerable::mLayer
protected

Definition at line 448 of file qcustomplot.h.

◆ mParentLayerable

QPointer<QCPLayerable> QCPLayerable::mParentLayerable
protected

Definition at line 447 of file qcustomplot.h.

◆ mParentPlot

QCustomPlot* QCPLayerable::mParentPlot
protected

Definition at line 446 of file qcustomplot.h.

◆ mVisible

bool QCPLayerable::mVisible
protected

Definition at line 445 of file qcustomplot.h.


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