KDChartLayoutItems.h File Reference

#include <QBrush>
#include <QFont>
#include <QFontMetricsF>
#include <QLayout>
#include <QLayoutItem>
#include <QPen>
#include "KDChartTextAttributes.h"
#include "KDChartMarkerAttributes.h"

Include dependency graph for KDChartLayoutItems.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  KDChart

Classes

class  KDChart::AbstractLayoutItem
 Base class for all layout items of KD Chart. More...
class  KDChart::AutoSpacerLayoutItem
 An empty layout item. More...
class  KDChart::HorizontalLineLayoutItem
 Layout item showing a horizontal line. More...
class  KDChart::LineLayoutItem
 Layout item showing a coloured line. More...
class  KDChart::LineWithMarkerLayoutItem
 Layout item showing a coloured line and a data point marker. More...
class  KDChart::MarkerLayoutItem
 Layout item showing a data point marker. More...
class  KDChart::TextBubbleLayoutItem
class  KDChart::TextLayoutItem
 Layout item showing a text. More...
class  KDChart::VerticalLineLayoutItem
 Layout item showing a vertial line. More...

Functions

QPointF rotatedPoint (const QPointF &pt, qreal rotation, const QPointF &center=QPointF())
QRectF rotatedRect (const QRectF &pt, qreal rotation, const QPointF &center=QPointF())


Function Documentation

QPointF rotatedPoint ( const QPointF &  pt,
qreal  rotation,
const QPointF &  center = QPointF() 
)

Definition at line 334 of file KDChartLayoutItems.cpp.

References PI.

00335 {
00336     const qreal angle = PI * rotation / 180.0;
00337     const qreal cosAngle = cos( angle );
00338     const qreal sinAngle = -sin( angle );
00339     return QPointF(
00340             (cosAngle * ( pt.x() - center.x() ) + sinAngle * ( pt.y() - center.y() ) ),
00341             (cosAngle * ( pt.y() - center.y() ) - sinAngle * ( pt.x() - center.x() ) ) ) + center;
00342 }

QRectF rotatedRect ( const QRectF &  pt,
qreal  rotation,
const QPointF &  center = QPointF() 
)

Definition at line 345 of file KDChartLayoutItems.cpp.

References PI.

Referenced by KDChart::TextLayoutItem::paint().

00346 {
00347     const QRect rect( oldRect.translated( center ).toRect() );
00348     const qreal angle = PI * angleInt / 180.0;
00349     const qreal cosAngle = cos( angle );
00350     const qreal sinAngle = sin( angle );
00351     QMatrix rotationMatrix(cosAngle, sinAngle, -sinAngle, cosAngle, 0, 0);
00352     QPolygon rotPts;
00353     rotPts <<  rotationMatrix.map(rect.topLeft()) //QPoint(0,0)
00354             << rotationMatrix.map(rect.topRight())
00355             << rotationMatrix.map(rect.bottomRight())
00356             << rotationMatrix.map(rect.bottomLeft());
00357             //<< rotatedPoint(rect.topRight(), angleInt, center).toPoint()
00358             //<< rotatedPoint(rect.bottomRight(), angleInt, center).toPoint()
00359             //<< rotatedPoint(rect.bottomLeft(), angleInt, center).toPoint();
00360     return rotPts.boundingRect();
00361 /*
00362     const QPointF topLeft( rotatedPoint( oldRect.topLeft(), angle, center ) );
00363     const QPointF topRight( rotatedPoint( oldRect.topRight(), angle, center ) );
00364     const QPointF bottomLeft( rotatedPoint( oldRect.bottomLeft(), angle, center ) );
00365     const QPointF bottomRight( rotatedPoint( oldRect.bottomRight(), angle, center ) );
00366 
00367     const qreal x = qMin( qMin( topLeft.x(), topRight.x() ), qMin( bottomLeft.x(), topLeft.x() ) );
00368     const qreal y = qMin( qMin( topLeft.y(), topRight.y() ), qMin( bottomLeft.y(), topLeft.y() ) );
00369     const qreal width = qMax( qMax( topLeft.x(), topRight.x() ), qMax( bottomLeft.x(), topLeft.x() ) ) - x;
00370     const qreal height = qMax( qMax( topLeft.y(), topRight.y() ), qMax( bottomLeft.y(), topLeft.y() ) ) - y;
00371 
00372     return QRectF( x, y, width, height );
00373 */
00374 }


Generated on Thu Mar 4 23:21:07 2010 for KD Chart 2 by  doxygen 1.5.4