##// END OF EJS Templates
Added size factor property to pie
Added size factor property to pie

File last commit:

r56:c2f871dd8e7e
r60:0be2c26f8dc1
Show More
qchart.cpp
166 lines | 4.5 KiB | text/x-c | CppLexer
Michal Klocek
adds missing files form previous commit
r12 #include "qchart.h"
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include "qchartseries.h"
Tero Ahola
Integrated scatter type series...
r42 #include "qscatterseries.h"
#include "qscatterseries_p.h"
Tero Ahola
Integrated draft version of pie series
r51 #include "qpieseries.h"
Michal Klocek
Changes reinterpret_cast to static_cast
r45 #include "qxychartseries.h"
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56
#include "barchartseries.h"
#include "bargroup.h"
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include "xylinechartitem_p.h"
Michal Klocek
Refactor xyplotdata...
r25 #include "xyplotdomain_p.h"
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include "axis_p.h"
#include "xygrid_p.h"
Tero Ahola
Integrated scatter type series...
r42 #include <QGraphicsScene>
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include <QDebug>
Michal Klocek
adds missing files form previous commit
r12
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
adds missing files form previous commit
r12
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 QChart::QChart(QGraphicsObject* parent) : QGraphicsObject(parent),
Michal Klocek
Removes PIMPL for now...
r53 m_axisX(new Axis(this)),
m_axisY(new Axis(this)),
m_grid(new XYGrid(this)),
m_plotDataIndex(0),
m_marginSize(0)
Michal Klocek
adds missing files form previous commit
r12 {
Michal Klocek
Adds pimpl to qchart class
r28 // setFlags(QGraphicsItem::ItemClipsChildrenToShape);
Michal Klocek
Refactor current draft to fit int current design specs...
r21 // set axis
Michal Klocek
Removes PIMPL for now...
r53 m_axisY->rotate(90);
Michal Klocek
adds missing files form previous commit
r12 }
QChart::~QChart(){}
Michal Klocek
Refactor current draft to fit int current design specs...
r21 QRectF QChart::boundingRect() const
{
Michal Klocek
Removes PIMPL for now...
r53 return m_rect;
Michal Klocek
Refactor current draft to fit int current design specs...
r21 }
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 void QChart::addSeries(QChartSeries* series)
Michal Klocek
adds missing files form previous commit
r12 {
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 // TODO: we should check the series not already added
Michal Klocek
Changes reinterpret_cast to static_cast
r45
Michal Klocek
Removes PIMPL for now...
r53 m_series<<series;
Michal Klocek
Refactor current draft to fit int current design specs...
r21
switch(series->type())
{
Tero Ahola
Renamed to QtCommercialChart
r30 case QChartSeries::SeriesTypeLine: {
Michal Klocek
Removes hardcoded values for xydomain
r47
QXYChartSeries* xyseries = static_cast<QXYChartSeries*>(series);
XYPlotDomain domain;
//TODO "nice numbers algorithm"
domain.m_ticksX=4;
domain.m_ticksY=4;
for (int i = 0 ; i < xyseries->count() ; i++)
{
qreal x = xyseries->x(i);
qreal y = xyseries->y(i);
domain.m_minX = qMin(domain.m_minX,x);
domain.m_minY = qMin(domain.m_minY,y);
domain.m_maxX = qMax(domain.m_maxX,x);
domain.m_maxY = qMax(domain.m_maxY,y);
}
XYLineChartItem* item = new XYLineChartItem(xyseries,this);
item->updateXYPlotDomain(domain);
Michal Klocek
Removes PIMPL for now...
r53 m_plotDomainList<<domain;
m_xyLineChartItems<<item;
Michal Klocek
Refactor current draft to fit int current design specs...
r21 break;
Michal Klocek
adds missing files form previous commit
r12 }
Tero Ahola
Integrated draft version of pie series
r51 // TODO: Not tested:
// case QChartSeries::SeriesTypeScatter: {
// QScatterSeries *scatter = qobject_cast<QScatterSeries *>(series);
// if (scatter) {
// scatter->d->setParentItem(this);
// scene()->addItem(scatter->d);
// }
// break;
// }
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56
case QChartSeries::SeriesTypeBar: {
qDebug() << "barSeries added";
BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
// Who owns the series?
BarGroup* group = new BarGroup(*barSeries, this);
scene()->addItem(group);
m_BarGroupItems.append(group); // If we need to access group later
break;
}
Tero Ahola
Renamed to QtCommercialChart
r30 }
Michal Klocek
Refactor current draft to fit int current design specs...
r21 }
Tero Ahola
Integrated scatter type series...
r42 QChartSeries* QChart::createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type)
{
Tero Ahola
Integrated draft version of pie series
r51 // TODO: support also other types; not only scatter and pie
Q_ASSERT(type == QChartSeries::SeriesTypeScatter
|| type == QChartSeries::SeriesTypePie);
Tero Ahola
Integrated scatter type series...
r42
switch (type) {
case QChartSeries::SeriesTypeScatter: {
QScatterSeries *scatterSeries = new QScatterSeries(x, y, this);
Tero Ahola
Removed scale from chart's sizeChanged signals
r54 connect(this, SIGNAL(sizeChanged(QRectF)),
scatterSeries, SLOT(chartSizeChanged(QRectF)));
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 scatterSeries->d->setParentItem(this);
Tero Ahola
Integrated draft version of pie series
r51 return scatterSeries;
}
case QChartSeries::SeriesTypePie: {
// TODO: we now have also a list of y values as a parameter, it is ignored
// we should use a generic data class instead of list of x and y values
QPieSeries *pieSeries = new QPieSeries(x, this);
Tero Ahola
Removed scale from chart's sizeChanged signals
r54 connect(this, SIGNAL(sizeChanged(QRectF)),
pieSeries, SLOT(chartSizeChanged(QRectF)));
Tero Ahola
Integrated draft version of pie series
r51 return pieSeries;
Tero Ahola
Integrated scatter type series...
r42 }
default:
break;
}
Tero Ahola
Integrated draft version of pie series
r51 return 0;
Tero Ahola
Integrated scatter type series...
r42 }
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48
Michal Klocek
Adds pimpl to qchart class
r28 void QChart::setSize(const QSizeF& size)
{
Michal Klocek
Removes PIMPL for now...
r53 m_rect = QRect(QPoint(0,0),size.toSize());
m_rect.adjust(margin(),margin(), -margin(), -margin());
m_grid->setPos(m_rect.topLeft());
m_grid->setSize(m_rect.size());
Michal Klocek
Removes hardcoded values for xydomain
r47
Tero Ahola
Removed scale from chart's sizeChanged signals
r54 // TODO: TTD for setting scale
//emit scaleChanged(100, 100);
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 // TODO: calculate the origo
// TODO: not sure if emitting a signal here is the best from performance point of view
Tero Ahola
Removed scale from chart's sizeChanged signals
r54 emit sizeChanged(QRectF(0, 0, size.width(), size.height()));
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48
Michal Klocek
Removes PIMPL for now...
r53 for (int i(0); i < m_plotDomainList.size(); i++)
m_plotDomainList[i].m_viewportRect = m_rect;
Michal Klocek
Removes hardcoded values for xydomain
r47
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 // TODO: line chart items are updated separately as they don't support update
// via sizeChanged signal
Michal Klocek
Removes PIMPL for now...
r53 foreach(XYLineChartItem* item ,m_xyLineChartItems)
item->updateXYPlotDomain(m_plotDomainList.at(m_plotDataIndex));
if (m_plotDomainList.count())
m_grid->setXYPlotData(m_plotDomainList.at(m_plotDataIndex));
Michal Klocek
Removes hardcoded values for xydomain
r47
Michal Klocek
Refactor current draft to fit int current design specs...
r21 update();
Michal Klocek
adds missing files form previous commit
r12 }
Michal Klocek
Adds pimpl to qchart class
r28 int QChart::margin() const
{
Michal Klocek
Removes PIMPL for now...
r53 return m_marginSize;
Michal Klocek
Adds pimpl to qchart class
r28 }
Michal Klocek
adds missing files form previous commit
r12 void QChart::setMargin(int margin)
{
Michal Klocek
Removes PIMPL for now...
r53 m_marginSize = margin;
Michal Klocek
adds missing files form previous commit
r12 }
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 #include "moc_qchart.cpp"
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_END_NAMESPACE