# 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 <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)
QRectF | rotatedRect (const QRectF &rect, qreal angle)
void | updateCommonBrush (QBrush &commonBrush, bool &bStart, const KDChart::AbstractArea &area)

## Define Documentation

#define PI 3.141592653589793

| Definition at line 50 of file KDChartLayoutItems.cpp. Referenced by KDChart::TextLayoutItem::intersects(), and rotatedPoint().

## Function Documentation

QPointF rotatedPoint | ( | const QPointF & | pt,
|  | qreal | rotation
| ) | `[static]`

Definition at line 357 of file KDChartLayoutItems.cpp.

References PI.

Referenced by rotatedRect().

    00358 {
    00359     const qreal angle = PI * rotation / 180.0;
    00360     const qreal cosAngle = cos( angle );
    00361     const qreal sinAngle = sin( angle );
    00362     return QPointF(
    00363             (cosAngle * pt.x() + sinAngle * pt.y() ),
    00364             (cosAngle * pt.y() + sinAngle * pt.x() ) );
    00365 }

QRectF rotatedRect | ( | const QRectF & | rect,
|  | qreal | angle
| ) | `[static]`

Definition at line 367 of file KDChartLayoutItems.cpp.

References rotatedPoint().

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

    00368 {
    00369     const QPointF topLeft(  rotatedPoint( rect.topLeft(),  angle ) );
    00370     //const QPointF topRight( rotatedPoint( rect.topRight(), angle ) );
    00371     //const QPointF bottomLeft(  rotatedPoint( rect.bottomLeft(),  angle ) );
    00372     //const QPointF bottomRight( rotatedPoint( rect.bottomRight(), angle ) );
    00373     const QPointF siz( rotatedPoint( QPointF( rect.size().width(), rect.size().height() ), angle ) );
    00374     const QRectF result(
    00375             topLeft,
    00376             QSizeF( siz.x(), //bottomRight.x() - topLeft.x(),
    00377                     siz.y() ) ); //bottomRight.y() - topLeft.y() ) );
    00378     //qDebug() << "angle" << angle << "\nbefore:" << rect << "\n after:" << result;
    00379     return result;
    00380 }

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

Definition at line 798 of file KDChartLayoutItems.cpp.

References KDChart::AbstractAreaBase::backgroundAttributes(), KDChart::BackgroundAttributes::brush(), KDChart::AbstractAreaBase::frameAttributes(), KDChart::BackgroundAttributes::isVisible(), KDChart::FrameAttributes::isVisible(), and KDChart::BackgroundAttributes::pixmapMode().

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

    00799 {
    00800     const KDChart::BackgroundAttributes ba( area.backgroundAttributes() );
    00801     const bool hasSimpleBrush = (
    00802             ! area.frameAttributes().isVisible() &&
    00803             ba.isVisible() &&
    00804             ba.pixmapMode() == KDChart::BackgroundAttributes::BackgroundPixmapModeNone &&
    00805             ba.brush().gradient() == 0 );
    00806     if( bStart ){
    00807         bStart = false;
    00808         commonBrush = hasSimpleBrush ? ba.brush() : QBrush();
    00809     }else{
    00810         if( ! hasSimpleBrush || ba.brush() != commonBrush )
    00811         {
    00812             commonBrush = QBrush();
    00813         }
    00814     }
    00815 }