QCPColorScale
Signals | |
void | dataRangeChanged (const QCPRange &newRange) |
void | dataScaleTypeChanged (QCPAxis::ScaleType scaleType) |
void | gradientChanged (const QCPColorGradient &newGradient) |
Signals inherited from QCPLayerable | |
void | layerChanged (QCPLayer *newLayer) |
Public Member Functions | |
QCPColorScale (QCustomPlot *parentPlot) | |
QCPAxis * | axis () const |
int | barWidth () const |
QList< QCPColorMap * > | colorMaps () const |
QCPRange | dataRange () const |
QCPAxis::ScaleType | dataScaleType () const |
QCPColorGradient | gradient () const |
QString | label () const |
bool | rangeDrag () const |
bool | rangeZoom () const |
void | rescaleDataRange (bool onlyVisibleMaps) |
void | setBarWidth (int width) |
Q_SLOT void | setDataRange (const QCPRange &dataRange) |
Q_SLOT void | setDataScaleType (QCPAxis::ScaleType scaleType) |
Q_SLOT void | setGradient (const QCPColorGradient &gradient) |
void | setLabel (const QString &str) |
void | setRangeDrag (bool enabled) |
void | setRangeZoom (bool enabled) |
void | setType (QCPAxis::AxisType type) |
QCPAxis::AxisType | type () const |
virtual void | update (UpdatePhase phase) override |
Public Member Functions inherited from QCPLayoutElement | |
QCPLayoutElement (QCustomPlot *parentPlot=nullptr) | |
QCP::MarginSides | autoMargins () const |
virtual QList< QCPLayoutElement * > | elements (bool recursive) const |
QCPLayout * | layout () const |
QCPMarginGroup * | marginGroup (QCP::MarginSide side) const |
QHash< QCP::MarginSide, QCPMarginGroup * > | marginGroups () const |
QMargins | margins () const |
virtual QSize | maximumOuterSizeHint () const |
QSize | maximumSize () const |
QMargins | minimumMargins () const |
virtual QSize | minimumOuterSizeHint () const |
QSize | minimumSize () const |
QRect | outerRect () const |
QRect | rect () const |
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const override |
void | setAutoMargins (QCP::MarginSides sides) |
void | setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group) |
void | setMargins (const QMargins &margins) |
void | setMaximumSize (const QSize &size) |
void | setMaximumSize (int width, int height) |
void | setMinimumMargins (const QMargins &margins) |
void | setMinimumSize (const QSize &size) |
void | setMinimumSize (int width, int height) |
void | setOuterRect (const QRect &rect) |
void | setSizeConstraintRect (SizeConstraintRect constraintRect) |
SizeConstraintRect | sizeConstraintRect () const |
Public Member Functions inherited from QCPLayerable | |
QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr) | |
bool | antialiased () const |
QCPLayer * | layer () const |
QCPLayerable * | parentLayerable () const |
QCustomPlot * | parentPlot () 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< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () 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< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | 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 QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () 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 | |
T | qobject_cast (const QObject *object) |
T | 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) |
QThread * | thread () const const |
Protected Member Functions | |
virtual void | applyDefaultAntialiasingHint (QCPPainter *painter) const override |
virtual void | mouseMoveEvent (QMouseEvent *event, const QPointF &startPos) override |
virtual void | mousePressEvent (QMouseEvent *event, const QVariant &details) override |
virtual void | mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos) override |
virtual void | wheelEvent (QWheelEvent *event) override |
Protected Member Functions inherited from QCPLayoutElement | |
virtual int | calculateAutoMargin (QCP::MarginSide side) |
virtual void | draw (QCPPainter *painter) override |
virtual void | layoutChanged () |
virtual void | parentPlotInitialized (QCustomPlot *parentPlot) override |
Protected Member Functions inherited from QCPLayerable | |
void | applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const |
virtual QRect | clipRect () const |
virtual void | deselectEvent (bool *selectionStateChanged) |
void | initializeParentPlot (QCustomPlot *parentPlot) |
virtual void | mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details) |
bool | moveToLayer (QCPLayer *layer, bool prepend) |
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) |
virtual QCP::Interaction | selectionCategory () const |
void | setParentLayerable (QCPLayerable *parentLayerable) |
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 |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
QPointer< QCPColorScaleAxisRectPrivate > | mAxisRect |
int | mBarWidth |
QPointer< QCPAxis > | mColorAxis |
QCPRange | mDataRange |
QCPAxis::ScaleType | mDataScaleType |
QCPColorGradient | mGradient |
QCPAxis::AxisType | mType |
Protected Attributes inherited from QCPLayoutElement | |
QCP::MarginSides | mAutoMargins |
QHash< QCP::MarginSide, QCPMarginGroup * > | mMarginGroups |
QMargins | mMargins |
QSize | mMaximumSize |
QMargins | mMinimumMargins |
QSize | mMinimumSize |
QRect | mOuterRect |
QCPLayout * | mParentLayout |
QRect | mRect |
SizeConstraintRect | mSizeConstraintRect |
Protected Attributes inherited from QCPLayerable | |
bool | mAntialiased |
QCPLayer * | mLayer |
QPointer< QCPLayerable > | mParentLayerable |
QCustomPlot * | mParentPlot |
bool | mVisible |
Additional Inherited Members | |
Public Types inherited from QCPLayoutElement | |
enum | SizeConstraintRect { scrInnerRect , scrOuterRect } |
enum | UpdatePhase { upPreparation , upMargins , upLayout } |
Public Types inherited from QObject | |
typedef | QObjectList |
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) |
Detailed Description
A color scale for use with color coding data such as QCPColorMap.
This layout element can be placed on the plot to correlate a color gradient with data values. It is usually used in combination with one or multiple QCPColorMaps.
The color scale can be either horizontal or vertical, as shown in the image above. The orientation and the side where the numbers appear is controlled with setType.
Use QCPColorMap::setColorScale to connect a color map with a color scale. Once they are connected, they share their gradient, data range and data scale type (setGradient, setDataRange, setDataScaleType). Multiple color maps may be associated with a single color scale, to make them all synchronize these properties.
To have finer control over the number display and axis behaviour, you can directly access the axis. See the documentation of QCPAxis for details about configuring axes. For example, if you want to change the number of automatically generated ticks, call
Placing a color scale next to the main axis rect works like with any other layout element:
In this case we have placed it to the right of the default axis rect, so it wasn't necessary to call setType, since QCPAxis::atRight is already the default. The text next to the color scale can be set with setLabel.
For optimum appearance (like in the image above), it may be desirable to line up the axis rect and the borders of the color scale. Use a QCPMarginGroup to achieve this:
Color scales are initialized with a non-zero minimum top and bottom margin (setMinimumMargins), because vertical color scales are most common and the minimum top/bottom margin makes sure it keeps some distance to the top/bottom widget border. So if you change to a horizontal color scale by setting setType to QCPAxis::atBottom or QCPAxis::atTop, you might want to also change the minimum margins accordingly, e.g. setMinimumMargins(QMargins(6, 0, 6, 0))
.
Definition at line 5380 of file qcustomplot.h.
Constructor & Destructor Documentation
◆ QCPColorScale()
|
explicit |
Constructs a new QCPColorScale.
Definition at line 20129 of file qcustomplot.cpp.
◆ ~QCPColorScale()
|
overridevirtual |
Definition at line 20142 of file qcustomplot.cpp.
Member Function Documentation
◆ applyDefaultAntialiasingHint()
|
overrideprotectedvirtual |
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.
Reimplemented from QCPLayoutElement.
Definition at line 20504 of file qcustomplot.cpp.
◆ axis()
|
inline |
Returns the internal QCPAxis instance of this color scale. You can access it to alter the appearance and behaviour of the axis. QCPColorScale duplicates some properties in its interface for convenience. Those are setDataRange (QCPAxis::setRange), setDataScaleType (QCPAxis::setScaleType), and the method setLabel (QCPAxis::setLabel). As they each are connected, it does not matter whether you use the method on the QCPColorScale or on its QCPAxis.
If the type of the color scale is changed with setType, the axis returned by this method will change, too, to either the left, right, bottom or top axis, depending on which type was set.
Definition at line 5398 of file qcustomplot.h.
◆ barWidth()
|
inline |
Definition at line 5404 of file qcustomplot.h.
◆ colorMaps()
QList< QCPColorMap * > QCPColorScale::colorMaps | ( | ) | const |
Returns a list of all the color maps associated with this color scale.
Definition at line 20390 of file qcustomplot.cpp.
◆ dataRange()
|
inline |
Definition at line 5400 of file qcustomplot.h.
◆ dataRangeChanged
|
signal |
This signal is emitted when the data range changes.
- See also
- setDataRange
◆ dataScaleType()
|
inline |
Definition at line 5401 of file qcustomplot.h.
◆ dataScaleTypeChanged
|
signal |
This signal is emitted when the data scale type changes.
- See also
- setDataScaleType
◆ gradient()
|
inline |
Definition at line 5402 of file qcustomplot.h.
◆ gradientChanged
|
signal |
This signal is emitted when the gradient changes.
- See also
- setGradient
◆ label()
QString QCPColorScale::label | ( | ) | const |
Definition at line 20148 of file qcustomplot.cpp.
◆ mouseMoveEvent()
|
overrideprotectedvirtual |
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.
Reimplemented from QCPLayerable.
Definition at line 20521 of file qcustomplot.cpp.
◆ mousePressEvent()
|
overrideprotectedvirtual |
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()
.
Reimplemented from QCPLayerable.
Definition at line 20510 of file qcustomplot.cpp.
◆ mouseReleaseEvent()
|
overrideprotectedvirtual |
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.
Reimplemented from QCPLayerable.
Definition at line 20532 of file qcustomplot.cpp.
◆ rangeDrag()
bool QCPColorScale::rangeDrag | ( | ) | const |
Definition at line 20160 of file qcustomplot.cpp.
◆ rangeZoom()
bool QCPColorScale::rangeZoom | ( | ) | const |
Definition at line 20174 of file qcustomplot.cpp.
◆ rescaleDataRange()
void QCPColorScale::rescaleDataRange | ( | bool | onlyVisibleMaps | ) |
Changes the data range such that all color maps associated with this color scale are fully mapped to the gradient in the data dimension.
- See also
- setDataRange
Definition at line 20408 of file qcustomplot.cpp.
◆ setBarWidth()
void QCPColorScale::setBarWidth | ( | int | width | ) |
Sets the width (or height, for horizontal color scales) the bar where the gradient is displayed will have.
Definition at line 20328 of file qcustomplot.cpp.
◆ setDataRange()
void QCPColorScale::setDataRange | ( | const QCPRange & | dataRange | ) |
Sets the range spanned by the color gradient and that is shown by the axis in the color scale.
It is equivalent to calling QCPColorMap::setDataRange on any of the connected color maps. It is also equivalent to directly accessing the axis and setting its range with QCPAxis::setRange.
- See also
- setDataScaleType, setGradient, rescaleDataRange
Definition at line 20248 of file qcustomplot.cpp.
◆ setDataScaleType()
void QCPColorScale::setDataScaleType | ( | QCPAxis::ScaleType | scaleType | ) |
Sets the scale type of the color scale, i.e. whether values are associated with colors linearly or logarithmically.
It is equivalent to calling QCPColorMap::setDataScaleType on any of the connected color maps. It is also equivalent to directly accessing the axis and setting its scale type with QCPAxis::setScaleType.
Note that this method controls the coordinate transformation. For logarithmic scales, you will likely also want to use a logarithmic tick spacing and labeling, which can be achieved by setting the color scale's axis ticker to an instance of QCPAxisTickerLog :
See the documentation of QCPAxisTickerLog about the details of logarithmic axis tick creation.
- See also
- setDataRange, setGradient
Definition at line 20278 of file qcustomplot.cpp.
◆ setGradient()
void QCPColorScale::setGradient | ( | const QCPColorGradient & | gradient | ) |
Sets the color gradient that will be used to represent data values.
It is equivalent to calling QCPColorMap::setGradient on any of the connected color maps.
- See also
- setDataRange, setDataScaleType
Definition at line 20298 of file qcustomplot.cpp.
◆ setLabel()
void QCPColorScale::setLabel | ( | const QString & | str | ) |
Sets the axis label of the color scale. This is equivalent to calling QCPAxis::setLabel on the internal axis.
Definition at line 20313 of file qcustomplot.cpp.
◆ setRangeDrag()
void QCPColorScale::setRangeDrag | ( | bool | enabled | ) |
Sets whether the user can drag the data range (setDataRange).
Note that QCP::iRangeDrag must be in the QCustomPlot's interactions (QCustomPlot::setInteractions) to allow range dragging.
Definition at line 20339 of file qcustomplot.cpp.
◆ setRangeZoom()
void QCPColorScale::setRangeZoom | ( | bool | enabled | ) |
Sets whether the user can zoom the data range (setDataRange) by scrolling the mouse wheel.
Note that QCP::iRangeZoom must be in the QCustomPlot's interactions (QCustomPlot::setInteractions) to allow range dragging.
Definition at line 20366 of file qcustomplot.cpp.
◆ setType()
void QCPColorScale::setType | ( | QCPAxis::AxisType | type | ) |
Sets at which side of the color scale the axis is placed, and thus also its orientation.
Note that after setting type to a different value, the axis returned by axis() will be a different one. The new axis will adopt the following properties from the previous axis: The range, scale type, label and ticker (the latter will be shared and not copied).
Definition at line 20194 of file qcustomplot.cpp.
◆ type()
|
inline |
Definition at line 5399 of file qcustomplot.h.
◆ update()
|
overridevirtual |
Updates the layout element and sub-elements. This function is automatically called before every replot by the parent layout element. It is called multiple times, once for every UpdatePhase. The phases are run through in the order of the enum values. For details about what happens at the different phases, see the documentation of UpdatePhase.
Layout elements that have child elements should call the Update your custom dialog method of their child elements, and pass the current phase unchanged.
The default implementation executes the automatic margin mechanism in the upMargins phase. Subclasses should make sure to call the base class implementation.
Reimplemented from QCPLayoutElement.
Definition at line 20468 of file qcustomplot.cpp.
◆ wheelEvent()
|
overrideprotectedvirtual |
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.
Reimplemented from QCPLayerable.
Definition at line 20543 of file qcustomplot.cpp.
Member Data Documentation
◆ mAxisRect
|
protected |
Definition at line 5439 of file qcustomplot.h.
◆ mBarWidth
|
protected |
Definition at line 5436 of file qcustomplot.h.
◆ mColorAxis
Definition at line 5440 of file qcustomplot.h.
◆ mDataRange
|
protected |
Definition at line 5433 of file qcustomplot.h.
◆ mDataScaleType
|
protected |
Definition at line 5434 of file qcustomplot.h.
◆ mGradient
|
protected |
Definition at line 5435 of file qcustomplot.h.
◆ mType
|
protected |
Definition at line 5432 of file qcustomplot.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.