KDChartLayoutItems.cpp File Reference

#include "KDChartLayoutItems.h"
#include "KDTextDocument.h"
#include "KDChartAbstractArea.h"
#include "KDChartAbstractDiagram.h"
#include "KDChartBackgroundAttributes.h"
#include "KDChartFrameAttributes.h"
#include "KDChartPaintContext.h"
#include "KDChartPainterSaver_p.h"
#include "KDChartPrintingParameters.h"
#include <QTextCursor>
#include <QTextBlockFormat>
#include <QTextDocumentFragment>
#include <QAbstractTextDocumentLayout>
#include <QLayout>
#include <QPainter>
#include <QDebug>
#include <QCoreApplication>
#include <QApplication>
#include <QStringList>
#include <QStyle>
#include <KDABLibFakes>
#include <math.h>

Include dependency graph for KDChartLayoutItems.cpp:

Go to the source code of this file.

Defines

#define PI   3.141592653589793

Functions

QPointF rotatedPoint (const QPointF &pt, qreal rotation, const QPointF &center)
QRectF rotatedRect (const QRectF &oldRect, qreal angleInt, const QPointF &center)
static void updateCommonBrush (QBrush &commonBrush, bool &bStart, const KDChart::AbstractArea &area)


Define Documentation

#define PI   3.141592653589793

Definition at line 51 of file KDChartLayoutItems.cpp.


Function Documentation

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

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 &  oldRect,
qreal  angleInt,
const QPointF &  center 
)

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 }

static void updateCommonBrush ( QBrush &  commonBrush,
bool &  bStart,
const KDChart::AbstractArea area 
) [static]

Definition at line 1049 of file KDChartLayoutItems.cpp.

References KDChart::AbstractAreaBase::backgroundAttributes(), KDChart::BackgroundAttributes::BackgroundPixmapModeNone, and KDChart::AbstractAreaBase::frameAttributes().

Referenced by KDChart::AutoSpacerLayoutItem::sizeHint().

01050 {
01051     const KDChart::BackgroundAttributes ba( area.backgroundAttributes() );
01052     const bool hasSimpleBrush = (
01053             ! area.frameAttributes().isVisible() &&
01054             ba.isVisible() &&
01055             ba.pixmapMode() == KDChart::BackgroundAttributes::BackgroundPixmapModeNone &&
01056             ba.brush().gradient() == 0 );
01057     if( bStart ){
01058         bStart = false;
01059         commonBrush = hasSimpleBrush ? ba.brush() : QBrush();
01060     }else{
01061         if( ! hasSimpleBrush || ba.brush() != commonBrush )
01062         {
01063             commonBrush = QBrush();
01064         }
01065     }
01066 }


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