ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QCPItemAnchor Class Reference

An anchor of an item to which positions can be attached to. More...

#include <qcustomplot.h>

Inheritance diagram for QCPItemAnchor:
Collaboration diagram for QCPItemAnchor:

Public Member Functions

 QCPItemAnchor (QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId=-1)
 
virtual ~QCPItemAnchor ()
 
QString name () const
 
virtual QPointF pixelPosition () const
 
 QCPItemAnchor (QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId=-1)
 
virtual ~QCPItemAnchor ()
 
QString name () const
 
virtual QPointF pixelPoint () const
 

Protected Member Functions

virtual QCPItemPositiontoQCPItemPosition ()
 
void addChildX (QCPItemPosition *pos)
 
void removeChildX (QCPItemPosition *pos)
 
void addChildY (QCPItemPosition *pos)
 
void removeChildY (QCPItemPosition *pos)
 
virtual QCPItemPositiontoQCPItemPosition ()
 
void addChildX (QCPItemPosition *pos)
 
void removeChildX (QCPItemPosition *pos)
 
void addChildY (QCPItemPosition *pos)
 
void removeChildY (QCPItemPosition *pos)
 

Protected Attributes

QString mName
 
QCustomPlotmParentPlot
 
QCPAbstractItemmParentItem
 
int mAnchorId
 
QSet< QCPItemPosition * > mChildrenX
 
QSet< QCPItemPosition * > mChildrenY
 

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

Constructor & Destructor Documentation

◆ QCPItemAnchor() [1/2]

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 11748 of file qcustomplot.cpp.

◆ ~QCPItemAnchor() [1/2]

◆ QCPItemAnchor() [2/2]

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 7700 of file qcustomplot.cpp.

◆ ~QCPItemAnchor() [2/2]

virtual QCPItemAnchor::~QCPItemAnchor ( )
virtual

Member Function Documentation

◆ addChildX() [1/2]

void QCPItemAnchor::addChildX ( QCPItemPosition pos)
protected

Definition at line 11801 of file qcustomplot.cpp.

References mChildrenX.

Referenced by QCPItemPosition::setParentAnchorX().

◆ addChildX() [2/2]

void QCPItemAnchor::addChildX ( QCPItemPosition pos)
protected

◆ addChildY() [1/2]

void QCPItemAnchor::addChildY ( QCPItemPosition pos)
protected

Definition at line 11829 of file qcustomplot.cpp.

References mChildrenY.

Referenced by QCPItemPosition::setParentAnchorY().

◆ addChildY() [2/2]

void QCPItemAnchor::addChildY ( QCPItemPosition pos)
protected

◆ name() [1/2]

QString QCPItemAnchor::name ( ) const
inline

Definition at line 3958 of file qcustomplot.h.

◆ name() [2/2]

QString QCPItemAnchor::name ( ) const
inline

Definition at line 1821 of file qcustomplot.h.

◆ pixelPoint()

QPointF QCPItemAnchor::pixelPoint ( ) const
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 7731 of file qcustomplot.cpp.

References QCPAbstractItem::anchorPixelPoint(), mAnchorId, and mParentItem.

Referenced by QCPItemPosition::pixelPoint(), and QCPItemPosition::setPixelPoint().

◆ pixelPosition()

QPointF QCPItemAnchor::pixelPosition ( ) const
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 11779 of file qcustomplot.cpp.

References QCPAbstractItem::anchorPixelPosition(), mAnchorId, and mParentItem.

Referenced by QCPItemPosition::pixelPosition(), and QCPItemPosition::setPixelPosition().

◆ removeChildX() [1/2]

void QCPItemAnchor::removeChildX ( QCPItemPosition pos)
protected

◆ removeChildX() [2/2]

void QCPItemAnchor::removeChildX ( QCPItemPosition pos)
protected

◆ removeChildY() [1/2]

void QCPItemAnchor::removeChildY ( QCPItemPosition pos)
protected

◆ removeChildY() [2/2]

void QCPItemAnchor::removeChildY ( QCPItemPosition pos)
protected

◆ toQCPItemPosition() [1/2]

QCPItemPosition * QCPItemAnchor::toQCPItemPosition ( )
inlineprotectedvirtual

Returns 0 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, and QCPItemPosition.

Definition at line 3972 of file qcustomplot.h.

Referenced by QCPItemPosition::setParentAnchorX(), and QCPItemPosition::setParentAnchorY().

◆ toQCPItemPosition() [2/2]

virtual QCPItemPosition* QCPItemAnchor::toQCPItemPosition ( )
inlineprotectedvirtual

Reimplemented in QCPItemPosition, and QCPItemPosition.

Definition at line 1835 of file qcustomplot.h.

Member Data Documentation

◆ mAnchorId

int QCPItemAnchor::mAnchorId
protected

Definition at line 3968 of file qcustomplot.h.

Referenced by pixelPoint(), and pixelPosition().

◆ mChildrenX

QSet< QCPItemPosition * > QCPItemAnchor::mChildrenX
protected

◆ mChildrenY

QSet< QCPItemPosition * > QCPItemAnchor::mChildrenY
protected

◆ mName

QString QCPItemAnchor::mName
protected

Definition at line 3963 of file qcustomplot.h.

◆ mParentItem

QCPAbstractItem * QCPItemAnchor::mParentItem
protected

◆ mParentPlot


The documentation for this class was generated from the following files: