QCPSelectionRect
Signals | |
void | accepted (const QRect &rect, QMouseEvent *event) |
void | canceled (const QRect &rect, QInputEvent *event) |
void | changed (const QRect &rect, QMouseEvent *event) |
void | started (QMouseEvent *event) |
Signals inherited from QCPLayerable | |
void | layerChanged (QCPLayer *newLayer) |
Public Member Functions | |
QCPSelectionRect (QCustomPlot *parentPlot) | |
QBrush | brush () const |
Q_SLOT void | cancel () |
bool | isActive () const |
QPen | pen () const |
QCPRange | range (const QCPAxis *axis) const |
QRect | rect () const |
void | setBrush (const QBrush &brush) |
void | setPen (const QPen &pen) |
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 |
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) | |
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 | draw (QCPPainter *painter) override |
virtual void | endSelection (QMouseEvent *event) |
virtual void | keyPressEvent (QKeyEvent *event) |
virtual void | moveSelection (QMouseEvent *event) |
virtual void | startSelection (QMouseEvent *event) |
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) |
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 |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
bool | mActive |
QBrush | mBrush |
QPen | mPen |
QRect | mRect |
Protected Attributes inherited from QCPLayerable | |
bool | mAntialiased |
QCPLayer * | mLayer |
QPointer< QCPLayerable > | mParentLayerable |
QCustomPlot * | mParentPlot |
bool | mVisible |
Additional Inherited Members | |
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
Provides rect/rubber-band data selection and range zoom interaction.
QCPSelectionRect is used by QCustomPlot when the QCustomPlot::setSelectionRectMode is not QCP::srmNone. When the user drags the mouse across the plot, the current selection rect instance (QCustomPlot::setSelectionRect) is forwarded these events and makes sure an according rect shape is drawn. At the begin, during, and after completion of the interaction, it emits the corresponding signals started, changed, canceled, and accepted.
The QCustomPlot instance connects own slots to the current selection rect instance, in order to react to an accepted selection rect interaction accordingly.
isActive can be used to check whether the selection rect is currently active. An ongoing selection interaction can be cancelled programmatically via calling cancel at any time.
The appearance of the selection rect can be controlled via setPen and setBrush.
If you wish to provide custom behaviour, e.g. a different visual representation of the selection rect (QCPSelectionRect::draw), you can subclass QCPSelectionRect and pass an instance of your subclass to QCustomPlot::setSelectionRect.
Definition at line 1153 of file qcustomplot.h.
Constructor & Destructor Documentation
◆ QCPSelectionRect()
|
explicit |
Creates a new QCPSelectionRect instance. To make QCustomPlot use the selection rect instance, pass it to QCustomPlot::setSelectionRect. parentPlot should be set to the same QCustomPlot widget.
Definition at line 2846 of file qcustomplot.cpp.
◆ ~QCPSelectionRect()
|
overridevirtual |
Definition at line 2854 of file qcustomplot.cpp.
Member Function Documentation
◆ accepted
|
signal |
This signal is emitted when the selection interaction was completed by the user releasing the mouse button.
Note that rect may have a negative width or height, if the selection is being dragged to the upper or left side of the selection rect origin.
◆ 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.
Implements QCPLayerable.
Definition at line 2967 of file qcustomplot.cpp.
◆ brush()
|
inline |
Definition at line 1164 of file qcustomplot.h.
◆ cancel()
void QCPSelectionRect::cancel | ( | ) |
If there is currently a selection interaction going on (isActive), the interaction is canceled. The selection rect will emit the canceled signal.
Definition at line 2903 of file qcustomplot.cpp.
◆ canceled
|
signal |
This signal is emitted when the selection interaction was cancelled. Note that event is nullptr
if the selection interaction was cancelled programmatically, by a call to cancel.
The user may cancel the selection interaction by pressing the escape key. In this case, event holds the respective input event.
Note that rect may have a negative width or height, if the selection is being dragged to the upper or left side of the selection rect origin.
◆ changed
|
signal |
This signal is emitted while the selection rect interaction is ongoing and the rect has changed its size due to the user moving the mouse.
Note that rect may have a negative width or height, if the selection is being dragged to the upper or left side of the selection rect origin.
◆ draw()
|
overrideprotectedvirtual |
If the selection rect is active (isActive), draws the selection rect defined by mRect.
\seebaseclassmethod
Implements QCPLayerable.
Definition at line 2978 of file qcustomplot.cpp.
◆ endSelection()
|
protectedvirtual |
This method is called by QCustomPlot to indicate that an ongoing selection rect interaction has finished by the user releasing the mouse button. The default implementation deactivates the selection rect and emits the accepted signal.
Definition at line 2944 of file qcustomplot.cpp.
◆ isActive()
|
inline |
Returns true if there is currently a selection going on, i.e. the user has started dragging a selection rect, but hasn't released the mouse button yet.
- See also
- cancel
Definition at line 1165 of file qcustomplot.h.
◆ keyPressEvent()
|
protectedvirtual |
This method is called by QCustomPlot when a key has been pressed by the user while the selection rect interaction is active. The default implementation allows to cancel the interaction by hitting the escape key.
Definition at line 2957 of file qcustomplot.cpp.
◆ moveSelection()
|
protectedvirtual |
This method is called by QCustomPlot to indicate that an ongoing selection rect interaction needs to update its geometry. The default implementation updates the rect and emits the changed signal.
Definition at line 2931 of file qcustomplot.cpp.
◆ pen()
|
inline |
Definition at line 1163 of file qcustomplot.h.
◆ range()
A convenience function which returns the coordinate range of the provided axis, that this selection rect currently encompasses.
Definition at line 2863 of file qcustomplot.cpp.
◆ rect()
|
inline |
Definition at line 1161 of file qcustomplot.h.
◆ setBrush()
void QCPSelectionRect::setBrush | ( | const QBrush & | brush | ) |
Sets the brush that will be used to fill the selection rect. By default the selection rect is not filled, i.e. brush is Qt::NoBrush
.
- See also
- setPen
Definition at line 2894 of file qcustomplot.cpp.
◆ setPen()
void QCPSelectionRect::setPen | ( | const QPen & | pen | ) |
Sets the pen that will be used to draw the selection rect outline.
- See also
- setBrush
Definition at line 2883 of file qcustomplot.cpp.
◆ started
|
signal |
This signal is emitted when a selection rect interaction was initiated, i.e. the user just started dragging the selection rect with the mouse.
◆ startSelection()
|
protectedvirtual |
This method is called by QCustomPlot to indicate that a selection rect interaction was initiated. The default implementation sets the selection rect to active, initializes the selection rect geometry and emits the started signal.
Definition at line 2918 of file qcustomplot.cpp.
Member Data Documentation
◆ mActive
|
protected |
Definition at line 1186 of file qcustomplot.h.
◆ mBrush
|
protected |
Definition at line 1184 of file qcustomplot.h.
◆ mPen
|
protected |
Definition at line 1183 of file qcustomplot.h.
◆ mRect
|
protected |
Definition at line 1182 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:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.