![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Base class for all drawable objects. More...
#include <qcustomplot.h>
Signals | |
| void | layerChanged (QCPLayer *newLayer) |
Public Member Functions | |
| QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0) | |
| ~QCPLayerable () | |
| bool | visible () const |
| QCustomPlot * | parentPlot () const |
| QCPLayerable * | parentLayerable () const |
| QCPLayer * | layer () const |
| bool | antialiased () const |
| void | setVisible (bool on) |
| Q_SLOT bool | setLayer (QCPLayer *layer) |
| bool | setLayer (const QString &layerName) |
| void | setAntialiased (bool enabled) |
| virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const |
| bool | realVisibility () const |
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 |
| QCustomPlot * | mParentPlot |
| QPointer< QCPLayerable > | mParentLayerable |
| QCPLayer * | mLayer |
| bool | mAntialiased |
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.
| QCPLayerable::QCPLayerable | ( | QCustomPlot * | plot, |
| QString | targetLayer = QString(), |
||
| 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.
References QCustomPlot::currentLayer(), mParentPlot, and setLayer().
| QCPLayerable::~QCPLayerable | ( | ) |
References mLayer, and QCPLayer::removeChild().
|
inline |
|
protected |
References QCustomPlot::antialiasedElements(), mParentPlot, QCustomPlot::notAntialiasedElements(), and QCPPainter::setAntialiasing().
Referenced by QCPGrid::applyDefaultAntialiasingHint(), QCPAxis::applyDefaultAntialiasingHint(), QCPAbstractPlottable::applyDefaultAntialiasingHint(), QCPAbstractItem::applyDefaultAntialiasingHint(), QCPAbstractLegendItem::applyDefaultAntialiasingHint(), QCPLegend::applyDefaultAntialiasingHint(), QCPPlotTitle::applyDefaultAntialiasingHint(), QCPAbstractPlottable::applyErrorBarsAntialiasingHint(), QCPAbstractPlottable::applyFillAntialiasingHint(), QCPAbstractPlottable::applyScattersAntialiasingHint(), QCPGrid::drawGridLines(), and QCPGrid::drawSubGridLines().
|
protectedpure virtual |
This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.
First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.
Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.
Implemented in QCPColorScale, QCPPlotTitle, QCPLegend, QCPAbstractLegendItem, QCPAxisRect, QCPAbstractItem, QCPAbstractPlottable, QCPAxis, QCPGrid, and QCPLayoutElement.
Referenced by QCustomPlot::draw().
|
protectedvirtual |
Reimplemented in QCPAbstractLegendItem, QCPAbstractItem, and QCPAbstractPlottable.
References mParentPlot, and QCustomPlot::viewport().
Referenced by QCustomPlot::draw().
|
protectedvirtual |
Reimplemented in QCPPlotTitle, QCPLegend, QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, and QCPAxis.
Referenced by QCustomPlot::deselectAll(), and QCustomPlot::mouseReleaseEvent().
|
protectedpure virtual |
Implemented in QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, QCPItemBracket, QCPItemTracer, QCPItemPixmap, QCPItemEllipse, QCPItemText, QCPItemRect, QCPItemCurve, QCPItemLine, QCPItemStraightLine, QCPFinancial, QCPColorMap, QCPStatisticalBox, QCPBars, QCPCurve, QCPGraph, QCPPlotTitle, QCPLegend, QCPPlottableLegendItem, QCPAxisRect, QCPAxis, QCPGrid, QCPLayoutElement, QCPArrow, QCPHiddenArea, QCPColoredBars, QCPBarsWithText, and QCPBarsWithText.
Referenced by QCustomPlot::draw().
|
protected |
References mParentPlot, parentPlot(), and parentPlotInitialized().
Referenced by QCPLayout::adoptElement(), QCPLayoutElement::parentPlotInitialized(), QCPAxisRect::QCPAxisRect(), and QCustomPlot::QCustomPlot().
|
inline |
Referenced by QCustomPlot::addPlottable(), moveToLayer(), and setLayer().
|
signal |
This signal is emitted when the layer of this layerable changes, i.e. this layerable is moved to a different layer.
Referenced by moveToLayer().
|
protected |
References QCPLayer::addChild(), layer(), layerChanged(), mLayer, mParentPlot, QCPLayer::name(), QCPLayer::parentPlot(), and QCPLayer::removeChild().
Referenced by setLayer().
|
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.
Referenced by setParentLayerable().
|
inline |
Referenced by QCustomPlot::addGraph(), QCustomPlot::addItem(), QCustomPlot::addPlottable(), QCPLayout::adoptElement(), initializeParentPlot(), parentPlotInitialized(), QCPLayoutElement::parentPlotInitialized(), QCPLegend::parentPlotInitialized(), QCPAbstractItem::QCPAbstractItem(), QCPAbstractPlottable::QCPAbstractPlottable(), QCPPlotTitle::QCPPlotTitle(), QCPAxisRect::removeAxis(), and QCPItemTracer::setGraph().
|
protectedvirtual |
Reimplemented in QCPLegend, and QCPLayoutElement.
References parentPlot().
Referenced by initializeParentPlot().
| 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.
References mLayer, mParentLayerable, mVisible, and QCPLayer::visible().
Referenced by QCustomPlot::draw(), and QCustomPlot::layoutElementAt().
|
protectedvirtual |
Reimplemented in QCPPlotTitle, QCPLegend, QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, and QCPAxis.
References event.
Referenced by QCustomPlot::mouseReleaseEvent().
|
protectedvirtual |
Reimplemented in QCPLegend, QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, and QCPAxis.
References QCP::iSelectOther.
Referenced by QCustomPlot::mouseReleaseEvent().
|
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 object is represented not by single lines but by an area like a QCPItemText or the bars of a QCPBars plottable, a click inside the area should also be considered a hit. In these cases this function thus returns a constant value greater zero but still below the parent plot's selection tolerance. (typically the selectionTolerance multiplied by 0.99).
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.
Reimplemented in QCPSelectableCursor, QCPAbstractItem, QCPAbstractPlottable, QCPItemBracket, QCPItemTracer, QCPItemPixmap, QCPItemEllipse, QCPItemText, QCPItemRect, QCPItemCurve, QCPItemLine, QCPItemStraightLine, QCPFinancial, QCPColorMap, QCPStatisticalBox, QCPBars, QCPCurve, QCPGraph, QCPPlotTitle, QCPLegend, QCPAbstractLegendItem, QCPAxis, QCPLayoutInset, and QCPLayoutElement.
Referenced by QCustomPlot::layerableAt().
| 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.
References mAntialiased.
Referenced by AnglesCustomPlot::createQCPBars(), QCPAxis::QCPAxis(), QCPGrid::QCPGrid(), QCPLegend::QCPLegend(), and ccHistogramWindow::refresh().
| 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.
References layer(), QCustomPlot::layer(), mParentPlot, and setLayer().
| 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.
References layer(), and moveToLayer().
Referenced by QCustomPlot::addPlottable(), QCPAbstractLegendItem::QCPAbstractLegendItem(), QCPAxis::QCPAxis(), QCPLayerable(), QCPPlotTitle::QCPPlotTitle(), QCustomPlot::QCustomPlot(), and setLayer().
|
protected |
References mParentLayerable, and parentLayerable().
Referenced by QCPLayout::adoptElement(), QCPAxisRect::QCPAxisRect(), QCPLayout::releaseElement(), QCPAbstractItem::setClipAxisRect(), and QCPAbstractItem::setClipToAxisRect().
| 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.
References mVisible.
Referenced by cvProbeFilter::createUi(), QCPItemEllipse::draw(), QCPAxis::QCPAxis(), QCPAxisRect::QCPAxisRect(), QCustomPlot::QCustomPlot(), ccHistogramWindow::refresh(), ccHistogramWindow::setAxisLabels(), ccWaveWidget::setAxisLabels(), and QCPAxisRect::setupFullAxesBox().
|
inline |
Referenced by QCPGrid::setSubGridVisible(), and QCPAxis::setupTickVectors().
|
protected |
Referenced by QCPGrid::applyDefaultAntialiasingHint(), QCPAxis::applyDefaultAntialiasingHint(), QCPAbstractPlottable::applyDefaultAntialiasingHint(), QCPAbstractItem::applyDefaultAntialiasingHint(), QCPAbstractLegendItem::applyDefaultAntialiasingHint(), QCPLegend::applyDefaultAntialiasingHint(), QCPPlotTitle::applyDefaultAntialiasingHint(), and setAntialiased().
|
protected |
Referenced by moveToLayer(), realVisibility(), and ~QCPLayerable().
|
protected |
Referenced by realVisibility(), and setParentLayerable().
|
protected |
Referenced by QCPAbstractPlottable::addToLegend(), QCPLayout::adoptElement(), applyAntialiasingHint(), QCPAxis::calculateMargin(), QCPFinancial::candlestickSelectTest(), clipRect(), QCPAbstractItem::clipRect(), QCPColorScale::colorMaps(), QCPAbstractItem::createAnchor(), QCPAbstractItem::createPosition(), QCPAxis::draw(), QCPCurve::draw(), QCPGraph::drawLinePlot(), QCPAxis::graphs(), QCPAxisRect::graphs(), initializeParentPlot(), QCPAxis::items(), QCPAxisRect::items(), QCPAxisRect::mouseMoveEvent(), QCPAxisRect::mousePressEvent(), QCPAxisRect::mouseReleaseEvent(), moveToLayer(), QCPAxis::plottables(), QCPAxisRect::plottables(), QCPAxis::QCPAxis(), QCPAxisRect::QCPAxisRect(), QCPLayerable(), QCPAbstractItem::rectSelectTest(), QCPLayout::releaseElement(), QCPAbstractPlottable::removeFromLegend(), QCPLayoutElement::selectTest(), QCPLayoutInset::selectTest(), QCPAxis::selectTest(), QCPAbstractLegendItem::selectTest(), QCPLegend::selectTest(), QCPPlotTitle::selectTest(), QCPBars::selectTest(), QCPStatisticalBox::selectTest(), QCPColorMap::selectTest(), QCPItemEllipse::selectTest(), QCPItemTracer::selectTest(), QCPGraph::setChannelFillGraph(), QCPItemTracer::setGraph(), setLayer(), QCPAxis::setupTickVectors(), QCPItemTracer::updatePosition(), QCPAxisRect::wheelEvent(), and QCPLegend::~QCPLegend().
|
protected |
Referenced by QCPAxis::calculateMargin(), QCPAxis::getPartAt(), realVisibility(), and setVisible().