QCPItemAnchor
Public Member Functions | |
QCPItemAnchor (QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId=-1) | |
QString | name () const |
virtual QPointF | pixelPosition () const |
Protected Member Functions | |
void | addChildX (QCPItemPosition *pos) |
void | addChildY (QCPItemPosition *pos) |
void | removeChildX (QCPItemPosition *pos) |
void | removeChildY (QCPItemPosition *pos) |
virtual QCPItemPosition * | toQCPItemPosition () |
Protected Attributes | |
int | mAnchorId |
QSet< QCPItemPosition * > | mChildrenX |
QSet< QCPItemPosition * > | mChildrenY |
QString | mName |
QCPAbstractItem * | mParentItem |
QCustomPlot * | mParentPlot |
Detailed Description
An anchor of an item to which positions can be attached to.
An item (QCPAbstractItem) may have one or more anchors. Unlike QCPItemPosition, an anchor doesn't control anything on its item, but provides a way to tie other items via their positions to the anchor.
For example, a QCPItemRect is defined by its positions topLeft and bottomRight. Additionally it has various anchors like top, topRight or bottomLeft etc. So you can attach the start (which is a QCPItemPosition) of a QCPItemLine to one of the anchors by calling QCPItemPosition::setParentAnchor on start, passing the wanted anchor of the QCPItemRect. This way the start of the line will now always follow the respective anchor location on the rect item.
Note that QCPItemPosition derives from QCPItemAnchor, so every position can also serve as an anchor to other positions.
To learn how to provide anchors in your own item subclasses, see the subclassing section of the QCPAbstractItem documentation.
Definition at line 3605 of file qcustomplot.h.
Constructor & Destructor Documentation
◆ QCPItemAnchor()
QCPItemAnchor::QCPItemAnchor | ( | QCustomPlot * | parentPlot, |
QCPAbstractItem * | parentItem, | ||
const QString & | name, | ||
int | anchorId = -1 ) |
Creates a new QCPItemAnchor. You shouldn't create QCPItemAnchor instances directly, even if you want to make a new item subclass. Use QCPAbstractItem::createAnchor instead, as explained in the subclassing section of the QCPAbstractItem documentation.
Definition at line 12044 of file qcustomplot.cpp.
◆ ~QCPItemAnchor()
|
virtual |
Definition at line 12052 of file qcustomplot.cpp.
Member Function Documentation
◆ addChildX()
|
protected |
Adds pos to the childX list of this anchor, which keeps track of which children use this anchor as parent anchor for the respective coordinate. This is necessary to notify the children prior to destruction of the anchor.
Note that this function does not change the parent setting in pos.
Definition at line 12100 of file qcustomplot.cpp.
◆ addChildY()
|
protected |
Adds pos to the childY list of this anchor, which keeps track of which children use this anchor as parent anchor for the respective coordinate. This is necessary to notify the children prior to destruction of the anchor.
Note that this function does not change the parent setting in pos.
Definition at line 12128 of file qcustomplot.cpp.
◆ name()
|
inline |
Definition at line 3613 of file qcustomplot.h.
◆ pixelPosition()
|
virtual |
Returns the final absolute pixel position of the QCPItemAnchor on the QCustomPlot surface.
The pixel information is internally retrieved via QCPAbstractItem::anchorPixelPosition of the parent item, QCPItemAnchor is just an intermediary.
Reimplemented in QCPItemPosition.
Definition at line 12073 of file qcustomplot.cpp.
◆ removeChildX()
|
protected |
Removes pos from the childX list of this anchor.
Note that this function does not change the parent setting in pos.
Definition at line 12114 of file qcustomplot.cpp.
◆ removeChildY()
|
protected |
Removes pos from the childY list of this anchor.
Note that this function does not change the parent setting in pos.
Definition at line 12142 of file qcustomplot.cpp.
◆ toQCPItemPosition()
|
inlineprotectedvirtual |
Returns nullptr
if this instance is merely a QCPItemAnchor, and a valid pointer of type QCPItemPosition* if it actually is a QCPItemPosition (which is a subclass of QCPItemAnchor).
This safe downcast functionality could also be achieved with a dynamic_cast. However, QCustomPlot avoids dynamic_cast to work with projects that don't have RTTI support enabled (e.g. -fno-rtti flag with gcc compiler).
Reimplemented in QCPItemPosition.
Definition at line 3627 of file qcustomplot.h.
Member Data Documentation
◆ mAnchorId
|
protected |
Definition at line 3623 of file qcustomplot.h.
◆ mChildrenX
|
protected |
Definition at line 3624 of file qcustomplot.h.
◆ mChildrenY
|
protected |
Definition at line 3624 of file qcustomplot.h.
◆ mName
|
protected |
Definition at line 3618 of file qcustomplot.h.
◆ mParentItem
|
protected |
Definition at line 3622 of file qcustomplot.h.
◆ mParentPlot
|
protected |
Definition at line 3621 of file qcustomplot.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:57:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.