QCPLayerable

Search for usage in LXR

Inheritance diagram for QCPLayerable:

Signals

void layerChanged (QCPLayer *newLayer)
 

Public Member Functions

 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr)
 
bool antialiased () const
 
QCPLayerlayer () const
 
QCPLayerableparentLayerable () const
 
QCustomPlotparentPlot () const
 
bool realVisibility () const
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const
 
void setAntialiased (bool enabled)
 
bool setLayer (const QString &layerName)
 
Q_SLOT bool setLayer (QCPLayer *layer)
 
void setVisible (bool on)
 
bool visible () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const =0
 
virtual QRect clipRect () const
 
virtual void deselectEvent (bool *selectionStateChanged)
 
virtual void draw (QCPPainter *painter)=0
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details)
 
virtual void mouseMoveEvent (QMouseEvent *event, const QPointF &startPos)
 
virtual void mousePressEvent (QMouseEvent *event, const QVariant &details)
 
virtual void mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual QCP::Interaction selectionCategory () const
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

bool mAntialiased
 
QCPLayermLayer
 
QPointer< QCPLayerablemParentLayerable
 
QCustomPlotmParentPlot
 
bool mVisible
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 

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 694 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPLayerable()

QCPLayerable::QCPLayerable ( QCustomPlot plot,
QString  targetLayer = QString(),
QCPLayerable parentLayerable = nullptr 
)

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 nullptr 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. It is not uncommon to set the QObject-parent to something else in the constructors of QCPLayerable subclasses, to guarantee a working destruction hierarchy.

Definition at line 1348 of file qcustomplot.cpp.

Member Function Documentation

◆ applyAntialiasingHint()

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

Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.

Definition at line 1580 of file qcustomplot.cpp.

◆ applyDefaultAntialiasingHint()

void QCPLayerable::applyDefaultAntialiasingHint ( QCPPainter painter) const
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 and scatters. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill and QCPGraph::setAntialiasedScatters. 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 QCPPolarGraph, QCPPolarGrid, QCPPolarAxisAngular, QCPPolarAxisRadial, QCPColorScale, QCPTextElement, QCPLegend, QCPAbstractLegendItem, QCPAxisRect, QCPAbstractItem, QCPAbstractPlottable, QCPAxis, QCPGrid, QCPLayoutElement, and QCPSelectionRect.

◆ clipRect()

QRect QCPLayerable::clipRect ( ) const
protectedvirtual

Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

The returned clipping rect is set on the painter before the draw function of the respective object is called.

Reimplemented in QCPPolarGraph, QCPAbstractLegendItem, QCPAbstractItem, and QCPAbstractPlottable.

Definition at line 1636 of file qcustomplot.cpp.

◆ deselectEvent()

void QCPLayerable::deselectEvent ( bool *  selectionStateChanged)
protectedvirtual

This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

See also
selectTest, selectEvent

Reimplemented in QCPPolarGraph, QCPPolarAxisRadial, QCPTextElement, QCPLegend, QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, and QCPAxis.

Definition at line 1692 of file qcustomplot.cpp.

◆ draw()

void QCPLayerable::draw ( QCPPainter painter)
protectedpure virtual

This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).

Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.

Implemented in QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, QCPPolarGraph, QCPPolarLegendItem, QCPPolarGrid, QCPPolarAxisAngular, QCPPolarAxisRadial, QCPItemBracket, QCPItemTracer, QCPItemPixmap, QCPItemEllipse, QCPItemText, QCPItemRect, QCPItemCurve, QCPItemLine, QCPItemStraightLine, QCPErrorBars, QCPFinancial, QCPColorMap, QCPStatisticalBox, QCPBars, QCPCurve, QCPGraph, QCPColorScaleAxisRectPrivate, QCPTextElement, QCPLegend, QCPPlottableLegendItem, QCPAxisRect, QCPAxis, QCPGrid, QCPLayoutElement, and QCPSelectionRect.

◆ initializeParentPlot()

void QCPLayerable::initializeParentPlot ( QCustomPlot parentPlot)
protected

Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed nullptr in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.

Note that, unlike when passing a non nullptr parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.

Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.

The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).

Definition at line 1510 of file qcustomplot.cpp.

◆ 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

◆ mouseDoubleClickEvent()

void QCPLayerable::mouseDoubleClickEvent ( QMouseEvent event,
const QVariant details 
)
protectedvirtual

This event gets called when the user presses the mouse button a second time in a double-click, while the cursor is over the layerable. Whether a cursor is over the layerable is decided by a preceding call to selectTest.

The mouseDoubleClickEvent is called instead of the second mousePressEvent. So in the case of a double-click, the event succession is pressEvent – releaseEvent – doubleClickEvent – releaseEvent.

The current pixel position of the cursor on the QCustomPlot widget is accessible via event->pos(). The parameter details contains layerable-specific details about the hit, which were generated in the previous call to selectTest. For example, One-dimensional plottables like QCPGraph or QCPBars convey the clicked data point in the details parameter, as QCPDataSelection packed as QVariant. Multi-part objects convey the specific SelectablePart that was hit (e.g. QCPAxis::SelectablePart in the case of axes).

Similarly to mousePressEvent, once a layerable has accepted the mouseDoubleClickEvent, it is considered the mouse grabber and will receive all following calls to mouseMoveEvent and mouseReleaseEvent for this mouse interaction (a "mouse interaction" in this context ends with the release).

The default implementation does nothing except explicitly ignoring the event with event->ignore().

See also
mousePressEvent, mouseMoveEvent, mouseReleaseEvent, wheelEvent

Reimplemented in QCPTextElement.

Definition at line 1790 of file qcustomplot.cpp.

◆ mouseMoveEvent()

void QCPLayerable::mouseMoveEvent ( QMouseEvent event,
const QPointF startPos 
)
protectedvirtual

This event gets called when the user moves the mouse while holding a mouse button, after this layerable has become the mouse grabber by accepting the preceding mousePressEvent.

The current pixel position of the cursor on the QCustomPlot widget is accessible via event->pos(). The parameter startPos indicates the position where the initial mousePressEvent occurred, that started the mouse interaction.

The default implementation does nothing.

See also
mousePressEvent, mouseReleaseEvent, mouseDoubleClickEvent, wheelEvent

Reimplemented in QCPPolarAxisAngular, QCPPolarAxisRadial, QCPColorScale, QCPAxisRect, and QCPAxis.

Definition at line 1740 of file qcustomplot.cpp.

◆ mousePressEvent()

void QCPLayerable::mousePressEvent ( QMouseEvent event,
const QVariant details 
)
protectedvirtual

This event gets called when the user presses a mouse button while the cursor is over the layerable. Whether a cursor is over the layerable is decided by a preceding call to selectTest.

The current pixel position of the cursor on the QCustomPlot widget is accessible via event->pos(). The parameter details contains layerable-specific details about the hit, which were generated in the previous call to selectTest. For example, One-dimensional plottables like QCPGraph or QCPBars convey the clicked data point in the details parameter, as QCPDataSelection packed as QVariant. Multi-part objects convey the specific SelectablePart that was hit (e.g. QCPAxis::SelectablePart in the case of axes).

QCustomPlot uses an event propagation system that works the same as Qt's system. If your layerable doesn't reimplement the mousePressEvent or explicitly calls event->ignore() in its reimplementation, the event will be propagated to the next layerable in the stacking order.

Once a layerable has accepted the mousePressEvent, it is considered the mouse grabber and will receive all following calls to mouseMoveEvent or mouseReleaseEvent for this mouse interaction (a "mouse interaction" in this context ends with the release).

The default implementation does nothing except explicitly ignoring the event with event->ignore().

See also
mouseMoveEvent, mouseReleaseEvent, mouseDoubleClickEvent, wheelEvent

Reimplemented in QCPPolarAxisAngular, QCPPolarAxisRadial, QCPColorScale, QCPTextElement, QCPAxisRect, and QCPAxis.

Definition at line 1722 of file qcustomplot.cpp.

◆ mouseReleaseEvent()

void QCPLayerable::mouseReleaseEvent ( QMouseEvent event,
const QPointF startPos 
)
protectedvirtual

This event gets called when the user releases the mouse button, after this layerable has become the mouse grabber by accepting the preceding mousePressEvent.

The current pixel position of the cursor on the QCustomPlot widget is accessible via event->pos(). The parameter startPos indicates the position where the initial mousePressEvent occurred, that started the mouse interaction.

The default implementation does nothing.

See also
mousePressEvent, mouseMoveEvent, mouseDoubleClickEvent, wheelEvent

Reimplemented in QCPPolarAxisAngular, QCPPolarAxisRadial, QCPColorScale, QCPTextElement, QCPAxisRect, and QCPAxis.

Definition at line 1758 of file qcustomplot.cpp.

◆ moveToLayer()

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

Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.

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

Definition at line 1549 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 nullptr.

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

Definition at line 711 of file qcustomplot.h.

◆ parentPlotInitialized()

void QCPLayerable::parentPlotInitialized ( QCustomPlot parentPlot)
protectedvirtual

This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when nullptr was passed as parent plot in the constructor, and the parent plot is set at a later time.

For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.

The default implementation does nothing.

See also
initializeParentPlot

Reimplemented in QCPLegend, and QCPLayoutElement.

Definition at line 1606 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 this layerable's layer 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.

Definition at line 1441 of file qcustomplot.cpp.

◆ selectEvent()

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

This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

See also
selectTest, deselectEvent

Reimplemented in QCPPolarGraph, QCPPolarAxisRadial, QCPTextElement, QCPLegend, QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, and QCPAxis.

Definition at line 1672 of file qcustomplot.cpp.

◆ selectionCategory()

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

Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

See also
QCustomPlot::setInteractions

Reimplemented in QCPPolarGraph, QCPPolarAxisAngular, QCPPolarAxisRadial, QCPLegend, QCPAbstractLegendItem, QCPAbstractItem, QCPAbstractPlottable, and QCPAxis.

Definition at line 1622 of file qcustomplot.cpp.

◆ selectTest()

double QCPLayerable::selectTest ( const QPointF pos,
bool  onlySelectable,
QVariant details = nullptr 
) 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 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.

In the case of 1D Plottables (QCPAbstractPlottable1D, like QCPGraph or QCPBars) details will be set to a QCPDataSelection, describing the closest data point to pos.

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

See also
selectEvent, deselectEvent, mousePressEvent, wheelEvent, QCustomPlot::setInteractions, QCPAbstractPlottable1D::selectTestRect

Reimplemented in QCPAbstractItem, QCPAbstractPlottable, QCPItemBracket, QCPItemTracer, QCPItemPixmap, QCPItemEllipse, QCPItemText, QCPItemRect, QCPItemCurve, QCPItemLine, QCPItemStraightLine, QCPErrorBars, QCPFinancial, QCPColorMap, QCPStatisticalBox, QCPBars, QCPCurve, QCPGraph, QCPTextElement, QCPLegend, QCPAbstractLegendItem, QCPAbstractPlottable1D< DataType >, QCPAbstractPlottable1D< QCPFinancialData >, QCPAbstractPlottable1D< QCPGraphData >, QCPAbstractPlottable1D< QCPStatisticalBoxData >, QCPAbstractPlottable1D< QCPBarsData >, QCPAbstractPlottable1D< QCPCurveData >, QCPAxis, QCPLayoutInset, QCPLayoutElement, QCPPolarGraph, QCPPolarAxisAngular, and QCPPolarAxisRadial.

Definition at line 1485 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 1426 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 1403 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.

If layer is 0, this layerable will not be on any layer and thus not appear in the plot (or interact/receive events).

Returns true if the layer of this layerable was successfully changed to layer.

Definition at line 1393 of file qcustomplot.cpp.

◆ setParentLayerable()

void QCPLayerable::setParentLayerable ( QCPLayerable parentLayerable)
protected

Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.

The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.

See also
realVisibility

Definition at line 1536 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 1379 of file qcustomplot.cpp.

◆ wheelEvent()

void QCPLayerable::wheelEvent ( QWheelEvent event)
protectedvirtual

This event gets called when the user turns the mouse scroll wheel while the cursor is over the layerable. Whether a cursor is over the layerable is decided by a preceding call to selectTest.

The current pixel position of the cursor on the QCustomPlot widget is accessible via event->pos().

The event->angleDelta() indicates how far the mouse wheel was turned, which is usually +/- 120 for single rotation steps. However, if the mouse wheel is turned rapidly, multiple steps may accumulate to one event, making the delta larger. On the other hand, if the wheel has very smooth steps or none at all, the delta may be smaller.

The default implementation does nothing.

See also
mousePressEvent, mouseMoveEvent, mouseReleaseEvent, mouseDoubleClickEvent

Reimplemented in QCPPolarAxisAngular, QCPPolarAxisRadial, QCPColorScale, QCPAxisRect, and QCPAxis.

Definition at line 1813 of file qcustomplot.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Dec 1 2022 03:58:22 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.