QCPAbstractPlottable

Search for usage in LXR

Inheritance diagram for QCPAbstractPlottable:

Signals

void selectableChanged (QCP::SelectionType selectable)
 
void selectionChanged (bool selected)
 
void selectionChanged (const QCPDataSelection &selection)
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 

Public Member Functions

 QCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis)
 
bool addToLegend ()
 
bool addToLegend (QCPLegend *legend)
 
bool antialiasedFill () const
 
bool antialiasedScatters () const
 
QBrush brush () const
 
const QPointF coordsToPixels (double key, double value) const
 
void coordsToPixels (double key, double value, double &x, double &y) const
 
virtual QCPRange getKeyRange (bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const =0
 
virtual QCPRange getValueRange (bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const =0
 
virtual QCPPlottableInterface1Dinterface1D ()
 
QCPAxiskeyAxis () const
 
QString name () const
 
QPen pen () const
 
void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
 
void pixelsToCoords (double x, double y, double &key, double &value) const
 
bool removeFromLegend () const
 
bool removeFromLegend (QCPLegend *legend) const
 
void rescaleAxes (bool onlyEnlarge=false) const
 
void rescaleKeyAxis (bool onlyEnlarge=false) const
 
void rescaleValueAxis (bool onlyEnlarge=false, bool inKeyRange=false) const
 
QCP::SelectionType selectable () const
 
bool selected () const
 
QCPDataSelection selection () const
 
QCPSelectionDecoratorselectionDecorator () const
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const override=0
 
void setAntialiasedFill (bool enabled)
 
void setAntialiasedScatters (bool enabled)
 
void setBrush (const QBrush &brush)
 
void setKeyAxis (QCPAxis *axis)
 
void setName (const QString &name)
 
void setPen (const QPen &pen)
 
Q_SLOT void setSelectable (QCP::SelectionType selectable)
 
Q_SLOT void setSelection (QCPDataSelection selection)
 
void setSelectionDecorator (QCPSelectionDecorator *decorator)
 
void setValueAxis (QCPAxis *axis)
 
QCPAxisvalueAxis () const
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr)
 
bool antialiased () const
 
QCPLayerlayer () const
 
QCPLayerableparentLayerable () const
 
QCustomPlotparentPlot () const
 
bool realVisibility () 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)
 
QBindable< QStringbindableObjectName ()
 
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 () const const
 
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 QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
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_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 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
 
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 setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

void applyDefaultAntialiasingHint (QCPPainter *painter) const override
 
void applyFillAntialiasingHint (QCPPainter *painter) const
 
void applyScattersAntialiasingHint (QCPPainter *painter) const
 
virtual QRect clipRect () const override
 
virtual void deselectEvent (bool *selectionStateChanged) override
 
virtual void draw (QCPPainter *painter) override=0
 
virtual void drawLegendIcon (QCPPainter *painter, const QRectF &rect) const =0
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) override
 
virtual QCP::Interaction selectionCategory () const override
 
- Protected Member Functions inherited from QCPLayerable
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 
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)
 
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 mAntialiasedFill
 
bool mAntialiasedScatters
 
QBrush mBrush
 
QPointer< QCPAxismKeyAxis
 
QString mName
 
QPen mPen
 
QCP::SelectionType mSelectable
 
QCPDataSelection mSelection
 
QCPSelectionDecoratormSelectionDecorator
 
QPointer< QCPAxismValueAxis
 
- Protected Attributes inherited from QCPLayerable
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)
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

The abstract base class for all data representing objects in a plot.

It defines a very basic interface like name, pen, brush, visibility etc. Since this class is abstract, it can't be instantiated. Use one of the subclasses or create a subclass yourself to create new ways of displaying data (see "Creating own plottables" below). Plottables that display one-dimensional data (i.e. data points have a single key dimension and one or multiple values at each key) are based off of the template subclass QCPAbstractPlottable1D, see details there.

All further specifics are in the subclasses, for example:

Creating own plottables

Subclassing directly from QCPAbstractPlottable is only recommended if you wish to display two-dimensional data like QCPColorMap, i.e. two logical key dimensions and one (or more) data dimensions. If you want to display data with only one logical key dimension, you should rather derive from QCPAbstractPlottable1D.

If subclassing QCPAbstractPlottable directly, these are the pure virtual functions you must implement:

See the documentation of those functions for what they need to do.

For drawing your plot, you can use the coordsToPixels functions to translate a point in plot coordinates to pixel coordinates. This function is quite convenient, because it takes the orientation of the key and value axes into account for you (x and y are swapped when the key axis is vertical and the value axis horizontal). If you are worried about performance (i.e. you need to translate many points in a loop like QCPGraph), you can directly use QCPAxis::coordToPixel. However, you must then take care about the orientation of the axis yourself.

Here are some important members you inherit from QCPAbstractPlottable:

QCustomPlot *mParentPlot A pointer to the parent QCustomPlot instance. The parent plot is inferred from the axes that are passed in the constructor.
QString mName The name of the plottable.
QPen mPen The generic pen of the plottable. You should use this pen for the most prominent data representing lines in the plottable (e.g QCPGraph uses this pen for its graph lines and scatters)
QBrush mBrush The generic brush of the plottable. You should use this brush for the most prominent fillable structures in the plottable (e.g. QCPGraph uses this brush to control filling under the graph)
QPointer<QCPAxis> mKeyAxis, mValueAxis The key and value axes this plottable is attached to. Call their QCPAxis::coordToPixel functions to translate coordinates to pixels in either the key or value dimension. Make sure to check whether the pointer is nullptr before using it. If one of the axes is null, don't draw the plottable.
QCPSelectionDecorator mSelectionDecorator The currently set selection decorator which specifies how selected data of the plottable shall be drawn and decorated. When drawing your data, you must consult this decorator for the appropriate pen/brush before drawing unselected/selected data segments. Finally, you should call its QCPSelectionDecorator::drawDecoration method at the end of your draw implementation.
QCP::SelectionType mSelectable In which composition, if at all, this plottable's data may be selected. Enforcing this setting on the data selection is done by QCPAbstractPlottable automatically.
QCPDataSelection mSelection Holds the current selection state of the plottable's data, i.e. the selected data ranges (QCPDataRange).

Definition at line 3436 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPAbstractPlottable()

QCPAbstractPlottable::QCPAbstractPlottable ( QCPAxis * keyAxis,
QCPAxis * valueAxis )

Constructs an abstract plottable which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y"). keyAxis and valueAxis must reside in the same QCustomPlot instance and have perpendicular orientations. If either of these restrictions is violated, a corresponding message is printed to the debug output (qDebug), the construction is not aborted, though.

Since QCPAbstractPlottable is an abstract class that defines the basic interface to plottables, it can't be directly instantiated.

You probably want one of the subclasses like QCPGraph or QCPCurve instead.

Definition at line 11402 of file qcustomplot.cpp.

◆ ~QCPAbstractPlottable()

QCPAbstractPlottable::~QCPAbstractPlottable ( )
overridevirtual

Definition at line 11423 of file qcustomplot.cpp.

Member Function Documentation

◆ addToLegend() [1/2]

bool QCPAbstractPlottable::addToLegend ( )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).

See also
removeFromLegend

Definition at line 11821 of file qcustomplot.cpp.

◆ addToLegend() [2/2]

bool QCPAbstractPlottable::addToLegend ( QCPLegend * legend)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Adds this plottable to the specified legend.

Creates a QCPPlottableLegendItem which is inserted into the legend. Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in the legend.

If the plottable needs a more specialized representation in the legend, you can create a corresponding subclass of QCPPlottableLegendItem and add it to the legend manually instead of calling this method.

See also
removeFromLegend, QCPLegend::addItem

Definition at line 11794 of file qcustomplot.cpp.

◆ antialiasedFill()

bool QCPAbstractPlottable::antialiasedFill ( ) const
inline

Definition at line 3457 of file qcustomplot.h.

◆ antialiasedScatters()

bool QCPAbstractPlottable::antialiasedScatters ( ) const
inline

Definition at line 3458 of file qcustomplot.h.

◆ applyDefaultAntialiasingHint()

void QCPAbstractPlottable::applyDefaultAntialiasingHint ( QCPPainter * painter) const
overrideprotectedvirtual

A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable lines.

This is the antialiasing state the painter passed to the draw method is in by default.

This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

\seebaseclassmethod

See also
setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint

Implements QCPLayerable.

Definition at line 11897 of file qcustomplot.cpp.

◆ applyFillAntialiasingHint()

void QCPAbstractPlottable::applyFillAntialiasingHint ( QCPPainter * painter) const
protected

A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable fills.

This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

See also
setAntialiased, applyDefaultAntialiasingHint, applyScattersAntialiasingHint

Definition at line 11913 of file qcustomplot.cpp.

◆ applyScattersAntialiasingHint()

void QCPAbstractPlottable::applyScattersAntialiasingHint ( QCPPainter * painter) const
protected

A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing plottable scatter points.

This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

See also
setAntialiased, applyFillAntialiasingHint, applyDefaultAntialiasingHint

Definition at line 11929 of file qcustomplot.cpp.

◆ brush()

QBrush QCPAbstractPlottable::brush ( ) const
inline

Definition at line 3460 of file qcustomplot.h.

◆ clipRect()

QRect QCPAbstractPlottable::clipRect ( ) const
overrideprotectedvirtual

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 from QCPLayerable.

Definition at line 11868 of file qcustomplot.cpp.

◆ coordsToPixels() [1/2]

const QPointF QCPAbstractPlottable::coordsToPixels ( double key,
double value ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Transforms the given key and value to pixel coordinates and returns them in a QPointF.

Definition at line 11634 of file qcustomplot.cpp.

◆ coordsToPixels() [2/2]

void QCPAbstractPlottable::coordsToPixels ( double key,
double value,
double & x,
double & y ) const

Convenience function for transforming a key/value pair to pixels on the QCustomPlot surface, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

key and value are transformed to the coodinates in pixels and are written to x and y.

See also
pixelsToCoords, QCPAxis::coordToPixel

Definition at line 11613 of file qcustomplot.cpp.

◆ deselectEvent()

void QCPAbstractPlottable::deselectEvent ( bool * selectionStateChanged)
overrideprotectedvirtual

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 from QCPLayerable.

Definition at line 11966 of file qcustomplot.cpp.

◆ draw()

virtual void QCPAbstractPlottable::draw ( QCPPainter * painter)
overrideprotectedpure 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.

Implements QCPLayerable.

Implemented in QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox, QCPColorMap, QCPFinancial, and QCPErrorBars.

◆ drawLegendIcon()

void QCPAbstractPlottable::drawLegendIcon ( QCPPainter * painter,
const QRectF & rect ) const
protectedpure virtual

called by QCPLegend::draw (via QCPPlottableLegendItem::draw) to create a graphical representation of this plottable inside rect, next to the plottable name.

The passed painter has its cliprect set to rect, so painting outside of rect won't appear outside the legend icon border.

Implemented in QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox, QCPColorMap, QCPFinancial, and QCPErrorBars.

◆ getKeyRange()

QCPRange QCPAbstractPlottable::getKeyRange ( bool & foundRange,
QCP::SignDomain inSignDomain = QCP::sdBoth ) const
pure virtual

Returns the coordinate range that all data in this plottable span in the key axis dimension. For logarithmic plots, one can set inSignDomain to either QCP::sdNegative or QCP::sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to QCP::sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to QCP::sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero (e.g. when there is only one data point). In this case foundRange would return true, but the returned range is not a valid range in terms of QCPRange::validRange.

See also
rescaleAxes, getValueRange

Implemented in QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox, QCPColorMap, QCPFinancial, and QCPErrorBars.

◆ getValueRange()

QCPRange QCPAbstractPlottable::getValueRange ( bool & foundRange,
QCP::SignDomain inSignDomain = QCP::sdBoth,
const QCPRange & inKeyRange = QCPRange() ) const
pure virtual

Returns the coordinate range that the data points in the specified key range (inKeyRange) span in the value axis dimension. For logarithmic plots, one can set inSignDomain to either QCP::sdNegative or QCP::sdPositive in order to restrict the returned range to that sign domain. E.g. when only negative range is wanted, set inSignDomain to QCP::sdNegative and all positive points will be ignored for range calculation. For no restriction, just set inSignDomain to QCP::sdBoth (default). foundRange is an output parameter that indicates whether a range could be found or not. If this is false, you shouldn't use the returned range (e.g. no points in data).

If inKeyRange has both lower and upper bound set to zero (is equal to QCPRange()), all data points are considered, without any restriction on the keys.

Note that foundRange is not the same as QCPRange::validRange, since the range returned by this function may have size zero (e.g. when there is only one data point). In this case foundRange would return true, but the returned range is not a valid range in terms of QCPRange::validRange.

See also
rescaleAxes, getKeyRange

Implemented in QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox, QCPColorMap, QCPFinancial, and QCPErrorBars.

◆ interface1D()

QCPPlottableInterface1D * QCPAbstractPlottable::interface1D ( )
inlinevirtual

If this plottable is a one-dimensional plottable, i.e. it implements the QCPPlottableInterface1D, returns the this pointer with that type. Otherwise (e.g. in the case of a QCPColorMap) returns zero.

You can use this method to gain read access to data coordinates while holding a pointer to the abstract base class only.

Reimplemented in QCPAbstractPlottable1D< DataType >, QCPAbstractPlottable1D< QCPBarsData >, QCPAbstractPlottable1D< QCPCurveData >, QCPAbstractPlottable1D< QCPFinancialData >, QCPAbstractPlottable1D< QCPGraphData >, QCPAbstractPlottable1D< QCPStatisticalBoxData >, and QCPErrorBars.

Definition at line 3482 of file qcustomplot.h.

◆ keyAxis()

QCPAxis * QCPAbstractPlottable::keyAxis ( ) const
inline

Definition at line 3461 of file qcustomplot.h.

◆ name()

QString QCPAbstractPlottable::name ( ) const
inline

Definition at line 3456 of file qcustomplot.h.

◆ pen()

QPen QCPAbstractPlottable::pen ( ) const
inline

Definition at line 3459 of file qcustomplot.h.

◆ pixelsToCoords() [1/2]

void QCPAbstractPlottable::pixelsToCoords ( const QPointF & pixelPos,
double & key,
double & value ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns the pixel input pixelPos as plot coordinates key and value.

Definition at line 11676 of file qcustomplot.cpp.

◆ pixelsToCoords() [2/2]

void QCPAbstractPlottable::pixelsToCoords ( double x,
double y,
double & key,
double & value ) const

Convenience function for transforming a x/y pixel pair on the QCustomPlot surface to plot coordinates, taking the orientations of the axes associated with this plottable into account (e.g. whether key represents x or y).

x and y are transformed to the plot coodinates and are written to key and value.

See also
coordsToPixels, QCPAxis::coordToPixel

Definition at line 11655 of file qcustomplot.cpp.

◆ removeFromLegend() [1/2]

bool QCPAbstractPlottable::removeFromLegend ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Removes the plottable from the legend of the parent QCustomPlot.

See also
addToLegend

Definition at line 11859 of file qcustomplot.cpp.

◆ removeFromLegend() [2/2]

bool QCPAbstractPlottable::removeFromLegend ( QCPLegend * legend) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Removes the plottable from the specifed legend. This means the QCPPlottableLegendItem that is associated with this plottable is removed.

Returns true on success, i.e. if the legend exists and a legend item associated with this plottable was found and removed.

See also
addToLegend, QCPLegend::removeItem

Definition at line 11839 of file qcustomplot.cpp.

◆ rescaleAxes()

void QCPAbstractPlottable::rescaleAxes ( bool onlyEnlarge = false) const

Rescales the key and value axes associated with this plottable to contain all displayed data, so the whole plottable is visible. If the scaling of an axis is logarithmic, rescaleAxes will make sure not to rescale to an illegal range i.e. a range containing different signs and/or zero. Instead it will stay in the current sign domain and ignore all parts of the plottable that lie outside of that domain.

onlyEnlarge makes sure the ranges are only expanded, never reduced. So it's possible to show multiple plottables in their entirety by multiple calls to rescaleAxes where the first call has onlyEnlarge set to false (the default), and all subsequent set to true.

See also
rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes, QCPAxis::rescale

Definition at line 11694 of file qcustomplot.cpp.

◆ rescaleKeyAxis()

void QCPAbstractPlottable::rescaleKeyAxis ( bool onlyEnlarge = false) const

Rescales the key axis of the plottable so the whole plottable is visible.

See rescaleAxes for detailed behaviour.

Definition at line 11705 of file qcustomplot.cpp.

◆ rescaleValueAxis()

void QCPAbstractPlottable::rescaleValueAxis ( bool onlyEnlarge = false,
bool inKeyRange = false ) const

Rescales the value axis of the plottable so the whole plottable is visible. If inKeyRange is set to true, only the data points which are in the currently visible key axis range are considered.

Returns true if the axis was actually scaled. This might not be the case if this plottable has an invalid range, e.g. because it has no data points.

See rescaleAxes for detailed behaviour.

Definition at line 11747 of file qcustomplot.cpp.

◆ selectable()

QCP::SelectionType QCPAbstractPlottable::selectable ( ) const
inline

Definition at line 3463 of file qcustomplot.h.

◆ selectableChanged

void QCPAbstractPlottable::selectableChanged ( QCP::SelectionType selectable)
signal

This signal is emitted when the selectability of this plottable has changed.

See also
setSelectable

◆ selected()

bool QCPAbstractPlottable::selected ( ) const
inline

Returns true if there are any data points of the plottable currently selected. Use selection to retrieve the current QCPDataSelection.

Definition at line 3464 of file qcustomplot.h.

◆ selectEvent()

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

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 from QCPLayerable.

Definition at line 11935 of file qcustomplot.cpp.

◆ selection()

QCPDataSelection QCPAbstractPlottable::selection ( ) const
inline

Returns a QCPDataSelection encompassing all the data points that are currently selected on this plottable.

See also
selected, setSelection, setSelectable

Definition at line 3465 of file qcustomplot.h.

◆ selectionCategory()

QCP::Interaction QCPAbstractPlottable::selectionCategory ( ) const
overrideprotectedvirtual

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 from QCPLayerable.

Definition at line 11877 of file qcustomplot.cpp.

◆ selectionChanged [1/2]

void QCPAbstractPlottable::selectionChanged ( bool selected)
signal

This signal is emitted when the selection state of this plottable has changed, either by user interaction or by a direct call to setSelection. The parameter selected indicates whether there are any points selected or not.

See also
selectionChanged(const QCPDataSelection &selection)

◆ selectionChanged [2/2]

void QCPAbstractPlottable::selectionChanged ( const QCPDataSelection & selection)
signal

This signal is emitted when the selection state of this plottable has changed, either by user interaction or by a direct call to setSelection. The parameter selection holds the currently selected data ranges.

See also
selectionChanged(bool selected)

◆ selectionDecorator()

QCPSelectionDecorator * QCPAbstractPlottable::selectionDecorator ( ) const
inline

Provides access to the selection decorator of this plottable. The selection decorator controls how selected data ranges are drawn (e.g. their pen color and fill), see QCPSelectionDecorator for details.

If you wish to use an own QCPSelectionDecorator subclass, pass an instance of it to setSelectionDecorator.

Definition at line 3466 of file qcustomplot.h.

◆ selectTest()

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

Implemented in QCPAbstractPlottable1D< DataType >, QCPAbstractPlottable1D< QCPBarsData >, QCPAbstractPlottable1D< QCPCurveData >, QCPAbstractPlottable1D< QCPFinancialData >, QCPAbstractPlottable1D< QCPGraphData >, QCPAbstractPlottable1D< QCPStatisticalBoxData >, QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox, QCPColorMap, QCPFinancial, and QCPErrorBars.

◆ setAntialiasedFill()

void QCPAbstractPlottable::setAntialiasedFill ( bool enabled)

Sets whether fills of this plottable are drawn antialiased or not.

Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

Definition at line 11447 of file qcustomplot.cpp.

◆ setAntialiasedScatters()

void QCPAbstractPlottable::setAntialiasedScatters ( bool enabled)

Sets whether the scatter symbols of this plottable are drawn antialiased or not.

Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

Definition at line 11458 of file qcustomplot.cpp.

◆ setBrush()

void QCPAbstractPlottable::setBrush ( const QBrush & brush)

The brush is used to draw basic fills of the plottable representation in the plot. The Fill can be a color, gradient or texture, see the usage of QBrush.

For example, the QCPGraph subclass draws the fill under the graph with this brush, when it's not set to Qt::NoBrush.

See also
setPen

Definition at line 11485 of file qcustomplot.cpp.

◆ setKeyAxis()

void QCPAbstractPlottable::setKeyAxis ( QCPAxis * axis)

The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

See also
setValueAxis

Definition at line 11501 of file qcustomplot.cpp.

◆ setName()

void QCPAbstractPlottable::setName ( const QString & name)

The name is the textual representation of this plottable as it is displayed in the legend (QCPLegend). It may contain any UTF-8 characters, including newlines.

Definition at line 11436 of file qcustomplot.cpp.

◆ setPen()

void QCPAbstractPlottable::setPen ( const QPen & pen)

The pen is used to draw basic lines that make up the plottable representation in the plot.

For example, the QCPGraph subclass draws its graph lines with this pen.

See also
setBrush

Definition at line 11471 of file qcustomplot.cpp.

◆ setSelectable()

void QCPAbstractPlottable::setSelectable ( QCP::SelectionType selectable)

Sets whether and to which granularity this plottable can be selected.

A selection can happen by clicking on the QCustomPlot surface (When QCustomPlot::setInteractions contains QCP::iSelectPlottables), by dragging a selection rect (When QCustomPlot::setSelectionRectMode is QCP::srmSelect), or programmatically by calling setSelection.

See also
setSelection, QCP::SelectionType

Definition at line 11587 of file qcustomplot.cpp.

◆ setSelection()

void QCPAbstractPlottable::setSelection ( QCPDataSelection selection)

Sets which data ranges of this plottable are selected. Selected data ranges are drawn differently (e.g. color) in the plot. This can be controlled via the selection decorator (see selectionDecorator).

The entire selection mechanism for plottables is handled automatically when QCustomPlot::setInteractions contains iSelectPlottables. You only need to call this function when you wish to change the selection state programmatically.

Using setSelectable you can further specify for each plottable whether and to which granularity it is selectable. If selection is not compatible with the current QCP::SelectionType set via setSelectable, the resulting selection will be adjusted accordingly (see QCPDataSelection::enforceType).

emits the selectionChanged signal when selected is different from the previous selection state.

See also
setSelectable, selectTest

Definition at line 11541 of file qcustomplot.cpp.

◆ setSelectionDecorator()

void QCPAbstractPlottable::setSelectionDecorator ( QCPSelectionDecorator * decorator)

Use this method to set an own QCPSelectionDecorator (subclass) instance. This allows you to customize the visual representation of selected data ranges further than by using the default QCPSelectionDecorator.

The plottable takes ownership of the decorator.

The currently set decorator can be accessed via selectionDecorator.

Definition at line 11561 of file qcustomplot.cpp.

◆ setValueAxis()

void QCPAbstractPlottable::setValueAxis ( QCPAxis * axis)

The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. This function performs no checks to make sure this is the case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the y-axis (QCustomPlot::yAxis) as value axis.

Normally, the key and value axes are set in the constructor of the plottable (or QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface).

See also
setKeyAxis

Definition at line 11517 of file qcustomplot.cpp.

◆ valueAxis()

QCPAxis * QCPAbstractPlottable::valueAxis ( ) const
inline

Definition at line 3462 of file qcustomplot.h.

Member Data Documentation

◆ mAntialiasedFill

bool QCPAbstractPlottable::mAntialiasedFill
protected

Definition at line 3507 of file qcustomplot.h.

◆ mAntialiasedScatters

bool QCPAbstractPlottable::mAntialiasedScatters
protected

Definition at line 3507 of file qcustomplot.h.

◆ mBrush

QBrush QCPAbstractPlottable::mBrush
protected

Definition at line 3509 of file qcustomplot.h.

◆ mKeyAxis

QPointer<QCPAxis> QCPAbstractPlottable::mKeyAxis
protected

Definition at line 3510 of file qcustomplot.h.

◆ mName

QString QCPAbstractPlottable::mName
protected

Definition at line 3506 of file qcustomplot.h.

◆ mPen

QPen QCPAbstractPlottable::mPen
protected

Definition at line 3508 of file qcustomplot.h.

◆ mSelectable

QCP::SelectionType QCPAbstractPlottable::mSelectable
protected

Definition at line 3511 of file qcustomplot.h.

◆ mSelection

QCPDataSelection QCPAbstractPlottable::mSelection
protected

Definition at line 3512 of file qcustomplot.h.

◆ mSelectionDecorator

QCPSelectionDecorator* QCPAbstractPlottable::mSelectionDecorator
protected

Definition at line 3513 of file qcustomplot.h.

◆ mValueAxis

QPointer<QCPAxis> QCPAbstractPlottable::mValueAxis
protected

Definition at line 3510 of file qcustomplot.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.