#include <KDChartRelativePosition.h>
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.
Definition at line 62 of file KDChartRelativePosition.h.
Public Member Functions | |
Qt::Alignment | alignment () const |
const QPointF | calculatedPoint (const QSizeF &autoSize) const |
Calculate a point, according to the reference area/position and horiz/vert padding. | |
Measure | horizontalPadding () const |
bool | operator!= (const RelativePosition &other) const |
RelativePosition & | operator= (const RelativePosition &other) |
bool | operator== (const RelativePosition &) const |
QObject * | referenceArea () const |
const QPointF | referencePoint () const |
Return the reference point, according to the reference area/position, but ignoring horiz/vert padding. | |
const PositionPoints | referencePoints () const |
Position | referencePosition () const |
RelativePosition (const RelativePosition &) | |
RelativePosition () | |
void | resetReferencePosition () |
Resets the position of the anchor point to the built-in default. | |
qreal | rotation () const |
void | setAlignment (Qt::Alignment flags) |
Specifies the location of the content, that is to be positioned by this RelativePosition. | |
void | setHorizontalPadding (const Measure &padding) |
Specifies the horizontal width of the gap between the anchor point and the content, that is to be positioned by this RelativePosition. | |
void | setReferenceArea (QObject *area) |
Specifies the reference area to be used to find the anchor point. | |
void | setReferencePoints (const PositionPoints &points) |
Specifies a set of points from which the anchor point will be selected. | |
void | setReferencePosition (Position position) |
Specifies the position of the anchor point. | |
void | setRotation (qreal rot) |
void | setVerticalPadding (const Measure &padding) |
Specifies the vertical width of the gap between the anchor point and the content, that is to be positioned by this RelativePosition. | |
Measure | verticalPadding () const |
~RelativePosition () |
RelativePosition::RelativePosition | ( | ) |
RelativePosition::RelativePosition | ( | const RelativePosition & | ) |
RelativePosition::~RelativePosition | ( | ) |
Qt::Alignment RelativePosition::alignment | ( | ) | const |
Definition at line 130 of file KDChartRelativePosition.cpp.
References d.
Referenced by operator<<(), and operator==().
00130 { 00131 return d->alignment; 00132 }
const QPointF RelativePosition::calculatedPoint | ( | const QSizeF & | autoSize | ) | const |
Calculate a point, according to the reference area/position and horiz/vert padding.
This method is called at drawing time: The returned point is used as anchor point. Note that calculatedPoint ignores the alignment setting, it just returns the point, so the calling code needs to take alignment into account explicitely.
Definition at line 185 of file KDChartRelativePosition.cpp.
References KDChart::Measure::calculatedValue(), horizontalPadding(), KDChartEnums::MeasureOrientationHorizontal, KDChartEnums::MeasureOrientationVertical, referencePoint(), and verticalPadding().
00186 { 00187 const QPointF pt( referencePoint() ); 00188 const qreal dx = horizontalPadding().calculatedValue( autoSize, KDChartEnums::MeasureOrientationHorizontal ); 00189 const qreal dy = verticalPadding() .calculatedValue( autoSize, KDChartEnums::MeasureOrientationVertical ); 00190 //qDebug() << "rect.center() " << rect.center(); 00191 //qDebug() << "pt.x() " << pt.x() << " pt.y() " << pt.y(); 00192 return QPointF( pt.x() + dx, pt.y() + dy ); 00193 }
Measure RelativePosition::horizontalPadding | ( | ) | const |
Definition at line 138 of file KDChartRelativePosition.cpp.
References d.
Referenced by calculatedPoint(), operator<<(), and operator==().
00138 { 00139 return d->horizontalPadding; 00140 }
bool KDChart::RelativePosition::operator!= | ( | const RelativePosition & | other | ) | const |
Definition at line 198 of file KDChartRelativePosition.h.
References operator==().
00198 { return !operator==( other ); }
RelativePosition & RelativePosition::operator= | ( | const RelativePosition & | other | ) |
Definition at line 82 of file KDChartRelativePosition.cpp.
00082 { 00083 RelativePosition copy( other ); 00084 copy.swap( *this ); 00085 return *this; 00086 }
bool RelativePosition::operator== | ( | const RelativePosition & | ) | const |
Definition at line 196 of file KDChartRelativePosition.cpp.
References alignment(), d, horizontalPadding(), referenceArea(), referencePosition(), rotation(), and verticalPadding().
Referenced by operator!=().
00197 { 00198 return d->area == r.referenceArea() && 00199 d->position == r.referencePosition() && 00200 d->alignment == r.alignment() && 00201 d->horizontalPadding == r.horizontalPadding() && 00202 d->verticalPadding == r.verticalPadding() && 00203 d->rotation == r.rotation() ; 00204 }
QObject * RelativePosition::referenceArea | ( | ) | const |
Definition at line 101 of file KDChartRelativePosition.cpp.
References d.
Referenced by operator<<(), and operator==().
00101 { 00102 return d->area; 00103 }
const QPointF RelativePosition::referencePoint | ( | ) | const |
Return the reference point, according to the reference area/position, but ignoring horiz/vert 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: labels are printed only, if their reference points are either inside or touching the coordinate plane.
Definition at line 159 of file KDChartRelativePosition.cpp.
References d.
Referenced by calculatedPoint().
00160 { 00161 bool useRect = (d->area != 0); 00162 QRect rect; 00163 if( useRect ){ 00164 const QWidget* widget = dynamic_cast<const QWidget*>(d->area); 00165 if( widget ){ 00166 const QLayout * layout = widget->layout(); 00167 rect = layout ? layout->geometry() : widget->geometry(); 00168 }else{ 00169 const AbstractArea* kdcArea = dynamic_cast<const AbstractArea*>(d->area); 00170 if( kdcArea ) 00171 rect = kdcArea->geometry(); 00172 else 00173 useRect = false; 00174 } 00175 } 00176 QPointF pt; 00177 if ( useRect ) 00178 pt = PositionPoints( rect ).point( d->position ); 00179 else 00180 pt = d->points.point( d->position ); 00181 return pt; 00182 }
const PositionPoints RelativePosition::referencePoints | ( | ) | const |
Definition at line 110 of file KDChartRelativePosition.cpp.
References d.
00110 { 00111 return d->points; 00112 }
Position RelativePosition::referencePosition | ( | ) | const |
Definition at line 122 of file KDChartRelativePosition.cpp.
References d.
Referenced by operator<<(), and operator==().
00122 { 00123 return d->position; 00124 }
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, resp.) KD Chart will choose an appropriate Position at run-time.
e.g. BarDiagrams will use Position::NorthWest / Position::SouthEast for positive / negative values.
Definition at line 118 of file KDChartRelativePosition.cpp.
References d, and KDChart::Position::Unknown.
00118 { 00119 d->position = Position::Unknown; 00120 }
qreal RelativePosition::rotation | ( | ) | const |
Definition at line 154 of file KDChartRelativePosition.cpp.
References d.
Referenced by operator<<(), and operator==().
00154 { 00155 return d->rotation; 00156 }
void RelativePosition::setAlignment | ( | Qt::Alignment | flags | ) |
Specifies the location of the content, that is to be positioned by this RelativePosition.
Aligning is applied, after horiz./vert. padding was retrieved to calculate the real reference point, so aligning is seen as relative to that point.
Definition at line 126 of file KDChartRelativePosition.cpp.
References d.
00126 { 00127 d->alignment = align; 00128 }
void RelativePosition::setHorizontalPadding | ( | const Measure & | padding | ) |
Specifies the horizontal width of the gap between the anchor point and the content, that is to be positioned by this RelativePosition.
Definition at line 134 of file KDChartRelativePosition.cpp.
References d.
00134 { 00135 d->horizontalPadding = pad; 00136 }
void RelativePosition::setReferenceArea | ( | QObject * | area | ) |
Specifies the reference area to be used to find the anchor point.
The reference area's type can be either QWidget, or be derived from KDChart::AbstractArea.
Definition at line 95 of file KDChartRelativePosition.cpp.
References d, and setReferencePoints().
Referenced by setReferencePoints().
00095 { 00096 d->area = area; 00097 if( area ) 00098 setReferencePoints( PositionPoints() ); 00099 }
void RelativePosition::setReferencePoints | ( | const PositionPoints & | points | ) |
Specifies a set of points from which the anchor point will be selected.
Definition at line 105 of file KDChartRelativePosition.cpp.
References d, KDChart::PositionPoints::isNull(), and setReferenceArea().
Referenced by setReferenceArea().
00105 { 00106 d->points = points; 00107 if( !points.isNull() ) 00108 setReferenceArea( 0 ); 00109 }
void RelativePosition::setReferencePosition | ( | Position | position | ) |
Specifies 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.
Definition at line 114 of file KDChartRelativePosition.cpp.
References d.
00114 { 00115 d->position = pos; 00116 }
void RelativePosition::setRotation | ( | qreal | rot | ) |
Definition at line 150 of file KDChartRelativePosition.cpp.
References d.
00150 { 00151 d->rotation = rot; 00152 }
void RelativePosition::setVerticalPadding | ( | const Measure & | padding | ) |
Specifies the vertical width of the gap between the anchor point and the content, that is to be positioned by this RelativePosition.
Definition at line 142 of file KDChartRelativePosition.cpp.
References d.
00142 { 00143 d->verticalPadding = pad; 00144 }
Measure RelativePosition::verticalPadding | ( | ) | const |
Definition at line 146 of file KDChartRelativePosition.cpp.
References d.
Referenced by calculatedPoint(), operator<<(), and operator==().
00146 { 00147 return d->verticalPadding; 00148 }