From 251cad7c49ee9aa2babbd318a54243b63a746213 2012-02-09 10:02:04 From: Michal Klocek Date: 2012-02-09 10:02:04 Subject: [PATCH] Fix previous broken commit --- diff --git a/example/colorlinechart/main.cpp b/example/colorlinechart/main.cpp index b008a02..2a313ce 100644 --- a/example/colorlinechart/main.cpp +++ b/example/colorlinechart/main.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -15,11 +15,11 @@ int main(int argc, char *argv[]) QMainWindow window; - QXYChartSeries* series0 = QXYChartSeries::create(); + QLineChartSeries* series0 = QLineChartSeries::create(); QPen blue(Qt::blue); blue.setWidth(3); series0->setPen(blue); - QXYChartSeries* series1 = QXYChartSeries::create(); + QLineChartSeries* series1 = QLineChartSeries::create(); QPen red(Qt::red); red.setWidth(3); series1->setPen(red); diff --git a/example/dynamiclinechart/dynamiclinechart.pro b/example/dynamiclinechart/dynamiclinechart.pro index bf78482..5e0d4d5 100644 --- a/example/dynamiclinechart/dynamiclinechart.pro +++ b/example/dynamiclinechart/dynamiclinechart.pro @@ -8,7 +8,7 @@ TARGET = dynamicLineChart TEMPLATE = app -QT += core gui +QT += core gui opengl SOURCES += main.cpp HEADERS += wavegenerator.h diff --git a/example/dynamiclinechart/main.cpp b/example/dynamiclinechart/main.cpp index 541a4bf..5384058 100644 --- a/example/dynamiclinechart/main.cpp +++ b/example/dynamiclinechart/main.cpp @@ -1,10 +1,11 @@ #include #include #include -#include +#include #include #include #include "wavegenerator.h" +#include int main(int argc, char *argv[]) { @@ -12,11 +13,11 @@ int main(int argc, char *argv[]) QMainWindow window; - QXYChartSeries* series0 = QXYChartSeries::create(); + QLineChartSeries* series0 = QLineChartSeries::create(); QPen blue(Qt::blue); blue.setWidth(3); series0->setPen(blue); - QXYChartSeries* series1 = QXYChartSeries::create(); + QLineChartSeries* series1 = QLineChartSeries::create(); QPen red(Qt::red); red.setWidth(3); series1->setPen(red); @@ -25,6 +26,7 @@ int main(int argc, char *argv[]) QChartView* chartView = new QChartView(&window); + chartView->setViewport( new QGLWidget() ); chartView->setRenderHint(QPainter::Antialiasing); chartView->setTitle("This is wave generator buahha."); chartView->addSeries(series0); diff --git a/example/dynamiclinechart/wavegenerator.h b/example/dynamiclinechart/wavegenerator.h index b5b4736..eca8dc9 100644 --- a/example/dynamiclinechart/wavegenerator.h +++ b/example/dynamiclinechart/wavegenerator.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include QTCOMMERCIALCHART_USE_NAMESPACE @@ -14,7 +14,7 @@ class WaveGenerator: public QObject Q_OBJECT public: - WaveGenerator(QXYChartSeries* series1, QXYChartSeries* series2) : + WaveGenerator(QLineChartSeries* series1, QLineChartSeries* series2) : m_series1(series1), m_series2(series2), m_wave(0), @@ -52,8 +52,8 @@ public slots: } private: - QXYChartSeries* m_series1; - QXYChartSeries* m_series2; + QLineChartSeries* m_series1; + QLineChartSeries* m_series2; int m_wave; qreal m_step; QTimer m_timer; diff --git a/example/linechart/main.cpp b/example/linechart/main.cpp index 642ff49..f067775 100644 --- a/example/linechart/main.cpp +++ b/example/linechart/main.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -15,11 +15,11 @@ int main(int argc, char *argv[]) QMainWindow window; - QXYChartSeries* series0 = QXYChartSeries::create(); + QLineChartSeries* series0 = QLineChartSeries::create(); QPen blue(Qt::blue); blue.setWidth(3); series0->setPen(blue); - QXYChartSeries* series1 = QXYChartSeries::create(); + QLineChartSeries* series1 = QLineChartSeries::create(); QPen red(Qt::red); red.setWidth(3); series1->setPen(red); diff --git a/example/zoomlinechart/main.cpp b/example/zoomlinechart/main.cpp index f3f0d54..1983867 100644 --- a/example/zoomlinechart/main.cpp +++ b/example/zoomlinechart/main.cpp @@ -1,7 +1,7 @@ #include "chartwidget.h" #include #include -#include +#include #include QTCOMMERCIALCHART_USE_NAMESPACE @@ -14,11 +14,11 @@ int main(int argc, char *argv[]) QMainWindow window; - QXYChartSeries* series0 = QXYChartSeries::create(); + QLineChartSeries* series0 = QLineChartSeries::create(); QPen blue(Qt::blue); blue.setWidth(3); series0->setPen(blue); - QXYChartSeries* series1 = QXYChartSeries::create(); + QLineChartSeries* series1 = QLineChartSeries::create(); QPen red(Qt::red); red.setWidth(3); series1->setPen(red); diff --git a/qmlplugin/declarativeseries.cpp b/qmlplugin/declarativeseries.cpp index fa0044d..6a131d9 100644 --- a/qmlplugin/declarativeseries.cpp +++ b/qmlplugin/declarativeseries.cpp @@ -1,6 +1,6 @@ #include "declarativeseries.h" #include "declarativechart.h" -#include +#include #include #include @@ -44,9 +44,9 @@ void DeclarativeSeries::initSeries() switch (m_seriesType) { case SeriesTypeLine: { - m_series = QXYChartSeries::create(this); + m_series = QLineChartSeries::create(this); for (qreal i(0.0); i < 100.0; i += 1.0) - ((QXYChartSeries *)m_series)->add(i, i); + ((QLineChartSeries *)m_series)->add(i, i); chart->addSeries(m_series); break; } diff --git a/src/axisitem.cpp b/src/axisitem.cpp index 57ed94c..1502323 100644 --- a/src/axisitem.cpp +++ b/src/axisitem.cpp @@ -13,27 +13,14 @@ AxisItem::AxisItem(QChartAxis* axis,AxisType type,QGraphicsItem* parent) : m_ticks(4), m_type(type) { + //initial initialization + handleAxisChanged(); } AxisItem::~AxisItem() { } -void AxisItem::setLength(int length) -{ - QPainterPath path; - path.moveTo(QPointF(0,0)); - path.lineTo(length,0); - // path.lineTo(length-4,0); - // path.lineTo(length,3); - // path.lineTo(length-4,6); - // path.lineTo(length-4,4); - // path.lineTo(0,4); - // path.lineTo(0,2); - m_path=path; - update(); -} - QRectF AxisItem::boundingRect() const { return m_rect; @@ -97,49 +84,54 @@ void AxisItem::createItems() if(!m_rect.isValid()) return; - if(m_type==X_AXIS) { - - const qreal deltaX = m_rect.width() / m_ticks; - - for (int i = 0; i <= m_ticks; ++i) { + switch (m_type) + { + case X_AXIS: + { + const qreal deltaX = m_rect.width() / m_ticks; - int x = i * deltaX + m_rect.left(); + for (int i = 0; i <= m_ticks; ++i) { - qreal label = m_domain.m_minX + (i * m_domain.spanX()/ m_ticks); + int x = i * deltaX + m_rect.left(); - m_grid<boundingRect().center(); - text->setPos(x - center.x(), m_rect.bottom() + LABEL_PADDING); - //text->rotate(-45); - m_labels<boundingRect().center(); + text->setPos(x - center.x(), m_rect.bottom() + LABEL_PADDING); + //text->rotate(-45); + m_labels<boundingRect().center(); + qreal label = m_domain.m_minY + (j * m_domain.spanY() + / m_ticks); - text->setPos(m_rect.left() - text->boundingRect().width() - LABEL_PADDING , y-center.y()); - //text->rotate(-45); - m_labels<boundingRect().center(); + text->setPos(m_rect.left() - text->boundingRect().width() - LABEL_PADDING , y-center.y()); - } - } + m_labels<drawRect(m_rect.adjusted(0, 0, -1, -1)); + } + } + break; + default: + qDebug()<<"Unknown axis type"; + break; + } } void AxisItem::clear() diff --git a/src/axisitem_p.h b/src/axisitem_p.h index 4e14878..ac4c8da 100644 --- a/src/axisitem_p.h +++ b/src/axisitem_p.h @@ -34,8 +34,6 @@ private: void clear(); public: - void setLength(int length); - void setWidth(int width); AxisType axisType() const {return m_type;}; protected: @@ -49,9 +47,6 @@ private: AxisType m_type; int m_ticks; Domain m_domain; - - - QRectF m_rect; QPainterPath m_path; diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index d41550f..1d051ad 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -1,6 +1,6 @@ #include "chartdataset_p.h" //series -#include "qxychartseries.h" +#include "qlinechartseries.h" #include "barchartseries.h" #include "stackedbarchartseries.h" #include "percentbarchartseries.h" @@ -38,7 +38,7 @@ void ChartDataSet::addSeries(QChartSeries* series) { case QChartSeries::SeriesTypeLine: { - QXYChartSeries* xyseries = static_cast(series); + QLineChartSeries* xyseries = static_cast(series); for (int i = 0; i < xyseries->count(); i++) { diff --git a/src/chartpresenter.cpp b/src/chartpresenter.cpp index 5fa61d4..1bb6320 100644 --- a/src/chartpresenter.cpp +++ b/src/chartpresenter.cpp @@ -7,20 +7,17 @@ #include "barchartseries.h" #include "stackedbarchartseries.h" #include "percentbarchartseries.h" -#include "qxychartseries.h" +#include "qlinechartseries.h" #include "qpieseries.h" //items #include "axisitem_p.h" #include "bargroup.h" #include "stackedbargroup.h" -#include "xylinechartitem_p.h" +#include "linechartitem_p.h" #include "percentbargroup.h" #include "linechartanimationitem_p.h" #include "piepresentation.h" -#include -#include - QTCOMMERCIALCHART_BEGIN_NAMESPACE ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), @@ -83,8 +80,8 @@ void ChartPresenter::handleSeriesAdded(QChartSeries* series) switch(series->type()) { case QChartSeries::SeriesTypeLine: { - QXYChartSeries* lineSeries = static_cast(series); - XYLineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart); + QLineChartSeries* lineSeries = static_cast(series); + LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart); m_chartTheme->decorate(item,lineSeries,m_chartItems.count()); QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&))); diff --git a/src/charttheme.cpp b/src/charttheme.cpp index 6957ad8..e486f44 100644 --- a/src/charttheme.cpp +++ b/src/charttheme.cpp @@ -6,12 +6,12 @@ #include "barchartseries.h" #include "stackedbarchartseries.h" #include "percentbarchartseries.h" -#include "qxychartseries.h" +#include "qlinechartseries.h" //items #include "axisitem_p.h" #include "bargroup.h" #include "stackedbargroup.h" -#include "xylinechartitem_p.h" +#include "linechartitem_p.h" #include "percentbargroup.h" //themes @@ -74,8 +74,8 @@ void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count) switch(series->type()) { case QChartSeries::SeriesTypeLine: { - QXYChartSeries* s = static_cast(series); - XYLineChartItem* i = static_cast(item); + QLineChartSeries* s = static_cast(series); + LineChartItem* i = static_cast(item); decorate(i,s,count); break; } @@ -104,7 +104,7 @@ void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count) } -void ChartTheme::decorate(XYLineChartItem* item, QXYChartSeries* series,int count) +void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count) { item->setPen(series->pen()); } diff --git a/src/charttheme_p.h b/src/charttheme_p.h index 7816604..d6f3219 100644 --- a/src/charttheme_p.h +++ b/src/charttheme_p.h @@ -9,8 +9,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartItem; class QChartSeries; -class XYLineChartItem; -class QXYChartSeries; +class LineChartItem; +class QLineChartSeries; class BarGroup; class BarChartSeries; class StackedBarGroup; @@ -26,7 +26,7 @@ public: static ChartTheme* createTheme(QChart::ChartThemeId theme); void decorate(QChart* chart); void decorate(ChartItem* item, QChartSeries* series,int count); - void decorate(XYLineChartItem* item, QXYChartSeries*, int count); + void decorate(LineChartItem* item, QLineChartSeries*, int count); void decorate(BarGroup* item, BarChartSeries* series,int count); void decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count); void decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count); diff --git a/src/linechart/linechartanimationitem.cpp b/src/linechart/linechartanimationitem.cpp index 791edbd..75ac2b8 100644 --- a/src/linechart/linechartanimationitem.cpp +++ b/src/linechart/linechartanimationitem.cpp @@ -1,5 +1,5 @@ #include "linechartanimationitem_p.h" -#include "xylinechartitem_p.h" +#include "linechartitem_p.h" #include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -7,8 +7,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE const static int duration = 500; -LineChartAnimationItem::LineChartAnimationItem(ChartPresenter* presenter, QXYChartSeries* series,QGraphicsItem *parent): -XYLineChartItem(presenter,series,parent) +LineChartAnimationItem::LineChartAnimationItem(ChartPresenter* presenter, QLineChartSeries* series,QGraphicsItem *parent): +LineChartItem(presenter,series,parent) { } @@ -44,7 +44,7 @@ void LineChartAnimationItem::aw_addPoints(int points) { int index = count(); for(int i = index;i< points ;i++){ - XYLineChartItem::addPoint(m_data.at(i)); + LineChartItem::addPoint(m_data.at(i)); } updateGeometry(); update(); @@ -52,7 +52,7 @@ void LineChartAnimationItem::aw_addPoints(int points) void LineChartAnimationItem::aw_setPoint(int index,const QPointF& point) { - XYLineChartItem::setPoint(index,point); + LineChartItem::setPoint(index,point); updateGeometry(); update(); } diff --git a/src/linechart/linechartanimationitem_p.h b/src/linechart/linechartanimationitem_p.h index 993baaf..2ac6851 100644 --- a/src/linechart/linechartanimationitem_p.h +++ b/src/linechart/linechartanimationitem_p.h @@ -1,20 +1,20 @@ -#ifndef XYLINEPRESENTER_P_H_ -#define XYLINEPRESENTER_P_H_ +#ifndef LINECHARTANIMATIONITEM_P_H_ +#define LINECHARTANIMATIONITEM_P_H_ #include "qchartglobal.h" -#include "xylinechartitem_p.h" +#include "linechartitem_p.h" #include "domain_p.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE -class XYLineChartItem; +class LineChartItem; -class LineChartAnimationItem : public XYLineChartItem { +class LineChartAnimationItem : public LineChartItem { Q_OBJECT Q_PROPERTY(int a_addPoints READ ar_addPoints WRITE aw_addPoints); // Q_PROPERTY(QPointF a_setPoint READ ar_setPoint WRITE aw_setPoint); public: - LineChartAnimationItem(ChartPresenter* presenter, QXYChartSeries *series, QGraphicsItem *parent = 0); + LineChartAnimationItem(ChartPresenter* presenter, QLineChartSeries *series, QGraphicsItem *parent = 0); virtual ~LineChartAnimationItem(); void addPoints(const QVector& points); @@ -52,4 +52,4 @@ public: QTCOMMERCIALCHART_END_NAMESPACE -#endif /* XYLINEPRESENTER_P_H_ */ +#endif diff --git a/src/linechart/qxychartseries.cpp b/src/linechart/qxychartseries.cpp deleted file mode 100644 index 274b567..0000000 --- a/src/linechart/qxychartseries.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "qxychartseries.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -QXYChartSeries::QXYChartSeries(QObject* parent):QChartSeries(parent) -{ -} - -QXYChartSeries::~QXYChartSeries() -{ -} - -QXYChartSeries* QXYChartSeries::create(QObject* parent) -{ - //TODO: here we take QChartData when it is ready - // return null if malformed; - return new QXYChartSeries(parent); -} - -int QXYChartSeries::add(qreal x,qreal y) -{ - m_x< -#include -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QTCOMMERCIALCHART_EXPORT QXYChartSeries : public QChartSeries -{ - Q_OBJECT -private: - QXYChartSeries(QObject* parent=0); -public: - virtual ~QXYChartSeries(); - -public: // from QChartSeries - static QXYChartSeries* create(QObject* parent=0); - virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;} - -public: - int add(qreal x, qreal y); - void set(int index,qreal x,qreal y); - void clear(); - - void setPen(const QPen& pen); - const QPen& pen() const { return m_pen;} - - int count() const; - qreal x(int pos) const; - qreal y(int pos) const; - friend QDebug operator<< (QDebug d, const QXYChartSeries series); - -signals: - void changed(int index); - -private: - QVector m_x; - QVector m_y; - QPen m_pen; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif diff --git a/src/linechart/xylinechartitem.cpp b/src/linechart/xylinechartitem.cpp deleted file mode 100644 index 51274de..0000000 --- a/src/linechart/xylinechartitem.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "xylinechartitem_p.h" -#include "qxychartseries.h" -#include "chartpresenter_p.h" -#include -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -XYLineChartItem::XYLineChartItem(ChartPresenter* presenter, QXYChartSeries* series,QGraphicsItem *parent):ChartItem(parent), -m_presenter(presenter), -m_series(series), -m_dirtyData(false), -m_dirtyGeometry(false), -m_dirtyDomain(false) -{ -} - -QRectF XYLineChartItem::boundingRect() const -{ - return m_rect; -} - -QPainterPath XYLineChartItem::shape() const -{ - return m_path; -} - - -void XYLineChartItem::addPoints(const QVector& points) -{ - m_data = points; - for(int i=0; isetPos(point.x()-1,point.y()-1); - m_points << item; - } -} - -void XYLineChartItem::addPoint(const QPointF& point) -{ - m_data << point; - QGraphicsRectItem* item = new QGraphicsRectItem(0,0,3,3,this); - item->setPos(point.x()-1,point.y()-1); - m_points << item; -} - -void XYLineChartItem::removePoint(const QPointF& point) -{ - Q_ASSERT(m_data.count() == m_points.count()); - int index = m_data.lastIndexOf(point,0); - m_data.remove(index); - delete(m_points.takeAt(index)); -} - -void XYLineChartItem::setPoint(const QPointF& oldPoint,const QPointF& newPoint) -{ - Q_ASSERT(m_data.count() == m_points.count()); - int index = m_data.lastIndexOf(oldPoint,0); - - if(index > -1){ - m_data.replace(index,newPoint); - QGraphicsItem* item = m_points.at(index); - item->setPos(newPoint.x()-1,newPoint.y()-1); - } -} - -void XYLineChartItem::setPoint(int index,const QPointF& point) -{ - Q_ASSERT(m_data.count() == m_points.count()); - Q_ASSERT(index>=0); - - m_data.replace(index,point); - QGraphicsItem* item = m_points.at(index); - item->setPos(point.x()-1,point.y()-1); -} - -void XYLineChartItem::clear() -{ - qDeleteAll(m_points); - m_points.clear(); - m_hash.clear(); - m_path = QPainterPath(); - m_rect = QRect(); - m_data.clear(); -} - -void XYLineChartItem::clearView() -{ - qDeleteAll(m_points); - m_points.clear(); - m_path = QPainterPath(); - m_rect = QRect(); - m_data.clear(); -} - -void XYLineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(widget); - Q_UNUSED(option); - painter->setPen(m_pen); - painter->drawPath(m_path); -} - -void XYLineChartItem::calculatePoint(QPointF& point, int index, const QXYChartSeries* series,const QSizeF& size, const Domain& domain) const -{ - const qreal deltaX = size.width()/domain.spanX(); - const qreal deltaY = size.height()/domain.spanY(); - qreal x = (series->x(index) - domain.m_minX)* deltaX; - qreal y = (series->y(index) - domain.m_minY)*-deltaY + size.height(); - point.setX(x); - point.setY(y); -} - - -void XYLineChartItem::calculatePoints(QVector& points, QHash& hash,const QXYChartSeries* series,const QSizeF& size, const Domain& domain) const -{ - const qreal deltaX = size.width()/domain.spanX(); - const qreal deltaY = size.height()/domain.spanY(); - - for (int i = 0; i < series->count(); ++i) { - qreal x = (series->x(i) - domain.m_minX)* deltaX; - if(x<0 || x > size.width()) continue; - qreal y = (series->y(i) - domain.m_minY)*-deltaY + size.height(); - if(y<0 || y > size.height()) continue; - hash[i] = points.size(); - points << QPointF(x,y); - } -} - -void XYLineChartItem::updateDomain() -{ - clear(); - calculatePoints(m_data,m_hash,m_series,m_size, m_domain); - addPoints(m_data); -} - -void XYLineChartItem::updateData() -{ - //for now the same - updateDomain(); -} - -void XYLineChartItem::updateGeometry() -{ - - if(m_data.size()==0) return; - - prepareGeometryChange(); - QPainterPath path; - const QPointF& point = m_data.at(0); - path.moveTo(point); - - foreach( const QPointF& point , m_data) { - path.lineTo(point); - } - - m_path = path; - m_rect = path.boundingRect(); -} - -void XYLineChartItem::setPen(const QPen& pen) -{ - m_pen = pen; -} - -//handlers - -void XYLineChartItem::handleModelChanged(int index) -{ - Q_ASSERT(indexcount()); - if(m_hash.contains(index)){ - int i = m_hash.value(index); - QPointF point; - calculatePoint(point,index,m_series,m_size,m_domain); - setPoint(i,point); - } - update(); -} - -void XYLineChartItem::handleDomainChanged(const Domain& domain) -{ - m_domain = domain; - updateDomain(); - update(); -} - -void XYLineChartItem::handleGeometryChanged(const QRectF& rect) -{ - Q_ASSERT(rect.isValid()); - - m_size=rect.size(); - updateDomain(); - updateGeometry(); - setPos(rect.topLeft()); - update(); -} - - -#include "moc_xylinechartitem_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/linechart/xylinechartitem_p.h b/src/linechart/xylinechartitem_p.h deleted file mode 100644 index 6bdcfba..0000000 --- a/src/linechart/xylinechartitem_p.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef XYLINECHARTITEM_H -#define XYLINECHARTITEM_H - -#include "qchartglobal.h" -#include "chartitem_p.h" -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class ChartPresenter; -class QXYChartSeries; -class LineChartAnimationItem; - -class XYLineChartItem : public QObject , public ChartItem -{ - Q_OBJECT -public: - XYLineChartItem(ChartPresenter* presenter, QXYChartSeries* series,QGraphicsItem *parent = 0); - ~ XYLineChartItem(){}; - - //from QGraphicsItem - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - QPainterPath shape() const; - - - void setPen(const QPen& pen); - - //from ChartItem - void setSize(const QSizeF& size){}; - void setPlotDomain(const PlotDomain& data){}; - - - const Domain& domain() const { return m_domain;} - - virtual void addPoint(const QPointF& ); - virtual void addPoints(const QVector& points); - virtual void removePoint(const QPointF& point); - virtual void setPoint(const QPointF& oldPoint, const QPointF& newPoint); - virtual void setPoint(int index,const QPointF& point); - void clear(); - void clearView(); - int count() const { return m_data.size();} - - const QVector& points(){ return m_data;} - -protected: - virtual void updateGeometry(); - virtual void updateData(); - virtual void updateDomain(); - //refactor - void calculatePoint(QPointF& point, int index, const QXYChartSeries* series,const QSizeF& size, const Domain& domain) const; - void calculatePoints(QVector& points,QHash& hash,const QXYChartSeries* series, const QSizeF& size, const Domain& domain) const; - -protected slots: - void handleModelChanged(int index); - void handleDomainChanged(const Domain& domain); - void handleGeometryChanged(const QRectF& size); - -private: - ChartPresenter* m_presenter; - QPainterPath m_path; - QSizeF m_size; - QRectF m_rect; - Domain m_domain; - QList m_points; - QVector m_data; - QHash m_hash; - QXYChartSeries* m_series; - QPen m_pen; - bool m_dirtyData; - bool m_dirtyGeometry; - bool m_dirtyDomain; - -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif diff --git a/src/qchart.cpp b/src/qchart.cpp index 9863dae..7fdcb8a 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -15,7 +15,7 @@ #include "barchartseries.h" #include "stackedbarchartseries.h" #include "percentbarchartseries.h" -#include "qxychartseries.h" +#include "qlinechartseries.h" #include #include @@ -47,7 +47,7 @@ QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type) switch (type) { case QChartSeries::SeriesTypeLine: { - series = QXYChartSeries::create(); + series = QLineChartSeries::create(); break; } case QChartSeries::SeriesTypeBar: { diff --git a/src/qchartseries.cpp b/src/qchartseries.cpp index b728300..47cd153 100644 --- a/src/qchartseries.cpp +++ b/src/qchartseries.cpp @@ -2,7 +2,7 @@ #include "qchartseries.h" #include "barchartseries.h" -#include "qxychartseries.h" +#include "qlinechartseries.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -12,7 +12,7 @@ QChartSeries* QChartSeries::create(QChartSeriesType type, QObject* parent) // TODO: Other types switch (type) { case QChartSeries::SeriesTypeLine: { - QXYChartSeries* s = QXYChartSeries::create(parent); // TODO: do we need create method for derived implementations? + QLineChartSeries* s = QLineChartSeries::create(parent); // TODO: do we need create method for derived implementations? return s; } case QChartSeries::SeriesTypePie: { diff --git a/src/src.pro b/src/src.pro index 92344e8..864283a 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,18 +1,12 @@ -!include( ../common.pri ) { -error( Couldn't find the common.pri file! ) -} - +!include( ../common.pri ):error( Couldn't find the common.pri file! ) TARGET = QtCommercialChart DESTDIR = $$CHART_BUILD_LIB_DIR TEMPLATE = lib QT += core \ gui - CONFIG += debug_and_release CONFIG(debug, debug|release):TARGET = QtCommercialChartd - -SOURCES += \ - barchart/barchartseries.cpp \ +SOURCES += barchart/barchartseries.cpp \ barchart/bargroup.cpp \ barchart/bar.cpp \ barchart/stackedbarchartseries.cpp \ @@ -20,12 +14,15 @@ SOURCES += \ barchart/percentbarchartseries.cpp \ barchart/percentbargroup.cpp \ barchart/barlabel.cpp \ - xylinechart/qxychartseries.cpp \ - xylinechart/xylinechartitem.cpp \ - xylinechart/linechartanimationitem.cpp \ + linechart/linechartanimationitem.cpp \ + linechart/linechartitem.cpp \ + linechart/qlinechartseries.cpp \ piechart/qpieseries.cpp \ piechart/pieslice.cpp \ piechart/piepresentation.cpp \ + barchart/separator.cpp \ + barchart/bargroupbase.cpp \ + barchart/barchartseriesbase.cpp \ plotdomain.cpp \ qscatterseries.cpp \ qchart.cpp \ @@ -34,18 +31,11 @@ SOURCES += \ qchartseries.cpp \ qchartaxis.cpp \ charttheme.cpp \ - barchart/separator.cpp \ - barchart/bargroupbase.cpp \ - barchart/barchartseriesbase.cpp \ chartdataset.cpp \ chartpresenter.cpp \ - domain.cpp - - - -PRIVATE_HEADERS += \ - xylinechart/xylinechartitem_p.h \ - xylinechart/linechartanimationitem_p.h \ + domain.cpp +PRIVATE_HEADERS += linechart/linechartitem_p.h \ + linechart/linechartanimationitem_p.h \ barchart/barlabel_p.h \ barchart/bar_p.h \ barchart/separator_p.h \ @@ -58,14 +48,8 @@ PRIVATE_HEADERS += \ charttheme_p.h \ chartdataset_p.h \ chartpresenter_p.h \ - domain_p.h - -PUBLIC_HEADERS += \ - qchartseries.h \ - qscatterseries.h \ - qchart.h \ - qchartglobal.h \ - xylinechart/qxychartseries.h \ + domain_p.h +PUBLIC_HEADERS += linechart/qlinechartseries.h \ barchart/barchartseries.h \ barchart/bargroup.h \ barchart/stackedbarchartseries.h \ @@ -75,67 +59,56 @@ PUBLIC_HEADERS += \ barchart/barchartseriesbase.h \ barchart/bargroupbase.h \ piechart/qpieseries.h \ + qchartseries.h \ + qscatterseries.h \ + qchart.h \ + qchartglobal.h \ qchartview.h \ - qchartaxis.h - -THEMES += \ - themes/chartthemeicy_p.h \ + qchartaxis.h +THEMES += themes/chartthemeicy_p.h \ themes/chartthemegrayscale_p.h \ themes/chartthemescientific_p.h \ - themes/chartthemevanilla_p.h \ - - + themes/chartthemevanilla_p.h HEADERS += $$PUBLIC_HEADERS HEADERS += $$PRIVATE_HEADERS HEADERS += $$THEMES - -INCLUDEPATH += xylinechart \ - barchart \ - piechart \ - themes \ - . - +INCLUDEPATH += linechart \ + barchart \ + piechart \ + themes \ + . OBJECTS_DIR = $$CHART_BUILD_DIR/lib MOC_DIR = $$CHART_BUILD_DIR/lib UI_DIR = $$CHART_BUILD_DIR/lib RCC_DIR = $$CHART_BUILD_DIR/lib - - DEFINES += QTCOMMERCIALCHART_LIBRARY - public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart public_headers.files = $$PUBLIC_HEADERS target.path = $$[QT_INSTALL_LIBS] INSTALLS += target \ public_headers - - install_build_headers.name = bild_headers install_build_headers.output = $$CHART_BUILD_HEADER_DIR/${QMAKE_FILE_BASE}.h install_build_headers.input = PUBLIC_HEADERS -install_build_headers.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} $$CHART_BUILD_HEADER_DIR -install_build_headers.CONFIG += target_predeps no_link +install_build_headers.commands = $$QMAKE_COPY \ + ${QMAKE_FILE_NAME} \ + $$CHART_BUILD_HEADER_DIR +install_build_headers.CONFIG += target_predeps \ + no_link QMAKE_EXTRA_COMPILERS += install_build_headers - chartversion.target = qchartversion_p.h -chartversion.commands = @echo "build_time" > $$chartversion.target; -chartversion.depends = $$HEADERS $$SOURCES +chartversion.commands = @echo \ + "build_time" \ + > \ + $$chartversion.target; +chartversion.depends = $$HEADERS \ + $$SOURCES PRE_TARGETDEPS += qchartversion_p.h -QMAKE_CLEAN+= qchartversion_p.h +QMAKE_CLEAN += qchartversion_p.h QMAKE_EXTRA_TARGETS += chartversion - -unix:QMAKE_DISTCLEAN += -r $$CHART_BUILD_HEADER_DIR $$CHART_BUILD_LIB_DIR -win32:QMAKE_DISTCLEAN += /Q $$CHART_BUILD_HEADER_DIR $$CHART_BUILD_LIB_DIR - - - - - - - - - - - - - +unix:QMAKE_DISTCLEAN += -r \ + $$CHART_BUILD_HEADER_DIR \ + $$CHART_BUILD_LIB_DIR +win32:QMAKE_DISTCLEAN += /Q \ + $$CHART_BUILD_HEADER_DIR \ + $$CHART_BUILD_LIB_DIR diff --git a/test/chartwidgettest/mainwidget.cpp b/test/chartwidgettest/mainwidget.cpp index 89d3386..390a8ce 100644 --- a/test/chartwidgettest/mainwidget.cpp +++ b/test/chartwidgettest/mainwidget.cpp @@ -2,7 +2,7 @@ #include "dataseriedialog.h" #include "qchartseries.h" #include "qpieseries.h" -#include +#include #include #include #include @@ -223,7 +223,7 @@ void MainWidget::addSeries(QString series, QString data) // lineSeries->add(x.at(i), y.at(i)); // } //Q_ASSERT(newSeries->setData(x, y)); - QXYChartSeries* series0 = QXYChartSeries::create(); + QLineChartSeries* series0 = QLineChartSeries::create(); for (int i(0); i < x.count() && i < y.count(); i++) series0->add(x.at(i), y.at(i)); m_chartWidget->addSeries(series0);