KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
KDChart::RelativePosition Class Reference

Defines relative position information: reference area, position in this area (reference position), horizontal / vertical padding, and rotation. More...

#include <KDChartRelativePosition.h>

Public Member Functions

 RelativePosition ()
 
 RelativePosition (const RelativePosition &)
 
 ~RelativePosition ()
 
Qt::Alignment alignment () const
 
const QPointF calculatedPoint (const QSizeF &autoSize) const
 Calculate a point, according to the reference area/position and the padding.
 
Measure horizontalPadding () const
 
bool operator!= (const RelativePosition &other) const
 
RelativePositionoperator= (const RelativePosition &other)
 
bool operator== (const RelativePosition &) const
 
QObjectreferenceArea () const
 
const QPointF referencePoint (qreal *polarDegrees=nullptr) const
 Return the reference point, according to the reference area/position, and ignoring padding.
 
const PositionPoints referencePoints () const
 
Position referencePosition () const
 
void resetReferencePosition ()
 Resets the position of the anchor point to the built-in default.
 
qreal rotation () const
 
void setAlignment (Qt::Alignment flags)
 
void setHorizontalPadding (const Measure &padding)
 
void setReferenceArea (QObject *area)
 Set the reference area to be used to find the anchor point.
 
void setReferencePoints (const PositionPoints &points)
 Set a set of points from which the anchor point will be selected.
 
void setReferencePosition (Position position)
 Set the position of the anchor point.
 
void setRotation (qreal rot)
 
void setVerticalPadding (const Measure &padding)
 
Measure verticalPadding () const
 

Detailed Description

Defines relative position information: reference area, position in this area (reference position), horizontal / vertical padding, and rotation.

See detailed description of KDChart::Position for an illustration of the different possible reference positions.

Using RelativePosition you can specify the relative parts of some position information, and you can specify the absolute parts: the reference area, and the position in this area.

Note
To get an absolute position, you have three options:
  • either you declare both, the relative and the absolute parts, using setReferenceArea for the latter,
  • or you specify a set of points, using setReferencePoints,
  • or you don't use either, leaving it to KD Chart to find a suitable reference area.

Definition at line 45 of file KDChartRelativePosition.h.

Constructor & Destructor Documentation

◆ RelativePosition() [1/2]

RelativePosition::RelativePosition ( )

Definition at line 52 of file KDChartRelativePosition.cpp.

◆ RelativePosition() [2/2]

RelativePosition::RelativePosition ( const RelativePosition r)

Definition at line 57 of file KDChartRelativePosition.cpp.

◆ ~RelativePosition()

RelativePosition::~RelativePosition ( )

Definition at line 69 of file KDChartRelativePosition.cpp.

Member Function Documentation

◆ alignment()

Qt::Alignment RelativePosition::alignment ( ) const

Definition at line 119 of file KDChartRelativePosition.cpp.

References d.

Referenced by operator<<(), and operator==().

◆ calculatedPoint()

const QPointF RelativePosition::calculatedPoint ( const QSizeF autoSize) const

Calculate a point, according to the reference area/position and the padding.

This method is called at drawing time: The returned point is used as anchor point. Note that it is the task of the calling code to place the content, taking the alignment property into account. This class does not know the size of the content so it cannot place it.

See also
referencePoint, setReferenceArea, setReferencePosition, setHorizontalPadding, setVerticalPadding

Definition at line 184 of file KDChartRelativePosition.cpp.

References KDChart::Measure::calculatedValue(), horizontalPadding(), KDChartEnums::MeasureOrientationHorizontal, KDChartEnums::MeasureOrientationVertical, referencePoint(), QPointF::setX(), QPointF::setY(), verticalPadding(), QPointF::x(), and QPointF::y().

◆ horizontalPadding()

Measure RelativePosition::horizontalPadding ( ) const

Definition at line 129 of file KDChartRelativePosition.cpp.

References d.

Referenced by calculatedPoint(), operator<<(), and operator==().

◆ operator!=()

bool KDChart::RelativePosition::operator!= ( const RelativePosition other) const
inline

Definition at line 195 of file KDChartRelativePosition.h.

References operator==().

◆ operator=()

RelativePosition & RelativePosition::operator= ( const RelativePosition other)

Definition at line 62 of file KDChartRelativePosition.cpp.

◆ operator==()

bool RelativePosition::operator== ( const RelativePosition r) const

◆ referenceArea()

QObject * RelativePosition::referenceArea ( ) const

Definition at line 83 of file KDChartRelativePosition.cpp.

References d.

Referenced by operator<<(), and operator==().

◆ referencePoint()

const QPointF RelativePosition::referencePoint ( qreal *  polarDegrees = nullptr) const

Return the reference point, according to the reference area/position, and ignoring padding.

This method is called at drawing time. The returned point is used to test if the label of a data value is to be printed: a label is printed only if its reference point is inside or touching the coordinate plane.

If polarDegrees is set, the degree information will be returned that was stored for the respective point. This is used by the PieDiagram class to determine how vertical/horizontal padding settings should affect the position of the data value texts' reference points.

See also
calculatedPoint, setReferenceArea, setReferencePosition, setHorizontalPadding, setVerticalPadding

Definition at line 154 of file KDChartRelativePosition.cpp.

References d, QLayout::geometry(), QLayout::layout(), and KDChart::PositionPoints::point().

Referenced by calculatedPoint().

◆ referencePoints()

const PositionPoints RelativePosition::referencePoints ( ) const

Definition at line 94 of file KDChartRelativePosition.cpp.

References d.

◆ referencePosition()

Position RelativePosition::referencePosition ( ) const

Definition at line 109 of file KDChartRelativePosition.cpp.

References d.

Referenced by operator<<(), and operator==().

◆ resetReferencePosition()

void RelativePosition::resetReferencePosition ( )

Resets the position of the anchor point to the built-in default.

If the anchor point of a RelativePosition is reset (or never changed from the default setting) KD Chart will choose an appropriate Position at run-time.

e.g. BarDiagrams will use Position::North / Position::South for positive / negative values.

See also
setReferencePosition, setReferenceArea, setAlignment, setHorizontalPadding, setVerticalPadding, KDChart::Position

Definition at line 104 of file KDChartRelativePosition.cpp.

References d, and KDChart::Position::Unknown.

◆ rotation()

qreal RelativePosition::rotation ( ) const

Definition at line 149 of file KDChartRelativePosition.cpp.

References d.

Referenced by operator<<(), and operator==().

◆ setAlignment()

void RelativePosition::setAlignment ( Qt::Alignment  flags)

Set the alignment of the content placed by this RelativePosition.

Padding is applied first to obtain the final reference point for the content's alignment

Note
To print centered content, besides calling setAlignment( Qt::AlignCenter ) you might also want to set zero padding to have your text centered more precisely.
See also
setReferencePosition, setReferenceArea, setHorizontalPadding, setVerticalPadding

Definition at line 114 of file KDChartRelativePosition.cpp.

References d.

◆ setHorizontalPadding()

void RelativePosition::setHorizontalPadding ( const Measure padding)

Set the width of the horizontal padding between the anchor point and the content placed by this RelativePosition.

Note
When printing data value texts this Measure is used to find the alignment point for this text, then alignment() is use to determine how to align the text relative to that point. The font height is used as reference size for both horizontal and vertical padding if the respective padding's Measure is using automatic reference area detection.
See also
setVerticalPadding, setReferencePosition, setReferenceArea

Definition at line 124 of file KDChartRelativePosition.cpp.

References d.

◆ setReferenceArea()

void RelativePosition::setReferenceArea ( QObject area)

Set the reference area to be used to find the anchor point.

The reference area's type can be either a QWidget subclass or a KDChart::AbstractArea subclass.

Note
Usage of reference area and reference points is mutually exclusive: Only one can be used, so any previously set reference points are cleared when you call setReferenceArea.

Also note: In a few cases KD Chart will ignore your area (or points, resp.) settings! Relative positioning of data value texts is an example: For these the reference area is always taken to be the data area.

See also
setReferencePosition, setAlignment, setHorizontalPadding, setVerticalPadding

Definition at line 76 of file KDChartRelativePosition.cpp.

References d, and setReferencePoints().

Referenced by setReferencePoints().

◆ setReferencePoints()

void RelativePosition::setReferencePoints ( const PositionPoints points)

Set a set of points from which the anchor point will be selected.

Note
Usage of reference area and reference points is mutually exclusive: Only one can be used, so any previously set reference area is cleared when you call setReferencePoints.

Also note: In a few cases KD Chart will ignore your points (or area, resp.) settings! Relative positioning of data value texts is an example: For these the reference area is always taken to be the data area.

See also
setReferenceArea, setReferencePosition, setAlignment, setHorizontalPadding, setVerticalPadding

Definition at line 88 of file KDChartRelativePosition.cpp.

References d, KDChart::PositionPoints::isNull(), and setReferenceArea().

Referenced by setReferenceArea().

◆ setReferencePosition()

void RelativePosition::setReferencePosition ( Position  position)

Set the position of the anchor point.

The anchor point of a RelativePosition may be one of the pre-defined points of it's reference area - for details see KDChart::Position.

See detailed description of KDChart::Position for an illustration of the different possible reference positions.

See also
resetReferencePosition, setReferenceArea, setAlignment, setHorizontalPadding, setVerticalPadding, KDChart::Position

Definition at line 99 of file KDChartRelativePosition.cpp.

References d.

◆ setRotation()

void RelativePosition::setRotation ( qreal  rot)

Definition at line 144 of file KDChartRelativePosition.cpp.

References d.

◆ setVerticalPadding()

void RelativePosition::setVerticalPadding ( const Measure padding)

Set the height of the vertical padding between the anchor point and the content placed by this RelativePosition.

Note
When printing data value texts this Measure is used to find the alignment point for this text, then alignment() is use to determine how to align the text relative to that point. The font height is used as reference size for both horizontal and vertical padding if the respective padding's Measure is using automatic reference area detection.
See also
setHorizontalPadding, setReferencePosition, setReferenceArea

Definition at line 134 of file KDChartRelativePosition.cpp.

References d.

◆ verticalPadding()

Measure RelativePosition::verticalPadding ( ) const

Definition at line 139 of file KDChartRelativePosition.cpp.

References d.

Referenced by calculatedPoint(), operator<<(), and operator==().


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

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Fri Apr 26 2024 00:04:57 for KD Chart API Documentation by doxygen 1.9.8