##// END OF EJS Templates
Removes PIMPL for now...
Removes PIMPL for now * removes wrongly implmented qchartprivate * removes wrongly implemented qchart * pimpl will be done before release

File last commit:

r51:73eb5fa755de
r53:c6b7296833b8
Show More
qpieseries.cpp
54 lines | 1.2 KiB | text/x-c | CppLexer
#include "qpieseries.h"
#include "pieslice.h"
#include <QGraphicsObject>
#include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
QPieSeries::QPieSeries(QList<qreal> x, QGraphicsObject *parent) :
QChartSeries(parent),
m_x(x)
{
}
QPieSeries::~QPieSeries()
{
}
void QPieSeries::chartSizeChanged(QRectF rect, qreal xscale, qreal yscale)
{
qreal fullPie = 360;
qreal total = 0;
foreach (qreal value, m_x)
total += value;
// We must have a parent for the graphics items we create
// TODO: maybe QChartSeries needs to be a QGraphicsObject to make this clear for the users?
QGraphicsItem *parentItem = qobject_cast<QGraphicsItem *>(parent());
Q_ASSERT(parentItem);
qreal angle = 0;
foreach (qreal value, m_x) {
qreal span = value / total * fullPie;
PieSlice *slice = new PieSlice(randomColor(), angle, span);
slice->setParentItem(parentItem);
m_slices.append(slice);
angle += span;
}
}
QColor QPieSeries::randomColor()
{
QColor c;
c.setRed(qrand() % 255);
c.setGreen(qrand() % 255);
c.setBlue(qrand() % 255);
return c;
}
void QPieSeries::setData(QList<int> data)
{
}
#include "moc_qpieseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE