Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QCPItemAnchor Class Reference

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

#include <qcustomplot.h>

Inheritance diagram for QCPItemAnchor:
Inheritance graph
[legend]

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Friends

class QCPItemPosition
 

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

◆ ~QCPItemAnchor()

QCPItemAnchor::~QCPItemAnchor ( )
virtual

Definition at line 11334 of file qcustomplot.cpp.

Member Function Documentation

◆ addChildX()

void QCPItemAnchor::addChildX ( QCPItemPosition pos)
protected

Definition at line 11382 of file qcustomplot.cpp.

◆ addChildY()

void QCPItemAnchor::addChildY ( QCPItemPosition pos)
protected

Definition at line 11410 of file qcustomplot.cpp.

◆ name()

QString QCPItemAnchor::name ( ) const
inline

Definition at line 3413 of file qcustomplot.h.

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

◆ removeChildX()

void QCPItemAnchor::removeChildX ( QCPItemPosition pos)
protected

Definition at line 11396 of file qcustomplot.cpp.

◆ removeChildY()

void QCPItemAnchor::removeChildY ( QCPItemPosition pos)
protected

Definition at line 11424 of file qcustomplot.cpp.

◆ toQCPItemPosition()

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.

Definition at line 3427 of file qcustomplot.h.

Friends And Related Function Documentation

◆ QCPItemPosition

friend class QCPItemPosition
friend

Definition at line 3438 of file qcustomplot.h.

Member Data Documentation

◆ mAnchorId

int QCPItemAnchor::mAnchorId
protected

Definition at line 3423 of file qcustomplot.h.

◆ mChildrenX

QSet<QCPItemPosition*> QCPItemAnchor::mChildrenX
protected

Definition at line 3424 of file qcustomplot.h.

◆ mChildrenY

QSet<QCPItemPosition*> QCPItemAnchor::mChildrenY
protected

Definition at line 3424 of file qcustomplot.h.

◆ mName

QString QCPItemAnchor::mName
protected

Definition at line 3418 of file qcustomplot.h.

◆ mParentItem

QCPAbstractItem* QCPItemAnchor::mParentItem
protected

Definition at line 3422 of file qcustomplot.h.

◆ mParentPlot

QCustomPlot* QCPItemAnchor::mParentPlot
protected

Definition at line 3421 of file qcustomplot.h.


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


graph_rviz_plugin
Author(s): Édouard Pronier, Victor Lamoine - Institut Maupertuis
autogenerated on Mon Feb 28 2022 22:27:31