##// END OF EJS Templates
Renamed SplinePresenter to SplineChartItem
Marek Rosa -
r460:c1b7acf3f56f
parent child
Show More
@@ -48,14 +48,8 SplineWidget::SplineWidget(QWidget *parent)
48 48 chart->addSeries(series);
49 49
50 50 chart->setChartTitle("Spline chart example");
51
52 // chart->setMinimumSize(800,600);
53 // chart->axisX()->setRange(0, 1500);
54
55 // chart->axisX()->setMax(1500);
56 // chart->axisY()->setRange(0, 400);
57 chart->axisX()->setMax(1500);
58 // chart->
51 chart->axisX()->setMax(1500);
52 chart->axisY()->setMax(500);
59 53
60 54 chart->setMinimumSize(800,600);
61 55 //! [3]
@@ -88,7 +82,7 SplineWidget::SplineWidget(QWidget *parent)
88 82 void SplineWidget::addNewPoint()
89 83 {
90 84 if (series->count() > 0)
91 series->add(QPointF(series->x(series->count() - 1) + 20 + qrand()%40, qAbs(series->y(series->count() - 1) - 50 + qrand()%100)));
85 series->add(QPointF(series->x(series->count() - 1) + 40 + qrand()%40, qAbs(series->y(series->count() - 1) - 50 + qrand()%100)));
92 86 else
93 87 series->add(QPointF(50, 50 + qrand()%50));
94 88 }
@@ -23,7 +23,7
23 23 #include "linechartanimationitem_p.h"
24 24 #include "piepresenter_p.h"
25 25 #include "scatterpresenter_p.h"
26 #include "splinepresenter_p.h"
26 #include "splinechartitem_p.h"
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
@@ -257,7 +257,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
257 257
258 258 case QSeries::SeriesTypeSpline: {
259 259 QSplineSeries* splineSeries = qobject_cast<QSplineSeries*>(series);
260 SplinePresenter* splinePresenter = new SplinePresenter(splineSeries, m_chart);
260 SplineChartItem* splinePresenter = new SplineChartItem(splineSeries, m_chart);
261 261 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), splinePresenter, SLOT(handleGeometryChanged(const QRectF&)));
262 262 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),splinePresenter,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
263 263 //initialize
@@ -24,7 +24,7
24 24 #include "areachartitem_p.h"
25 25 #include "scatterpresenter_p.h"
26 26 #include "piepresenter_p.h"
27 #include "splinepresenter_p.h"
27 #include "splinechartitem_p.h"
28 28
29 29 //themes
30 30 #include "chartthemevanilla_p.h"
@@ -299,19 +299,19 void ChartTheme::decorate(QChartAxis* axis,AxisItem* item)
299 299 axis->setShadesOpacity(0.5);
300 300 }
301 301
302 void ChartTheme::decorate(SplinePresenter* presenter, QSplineSeries* series, int count)
302 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int count)
303 303 {
304 Q_ASSERT(presenter);
304 Q_ASSERT(item);
305 305 Q_ASSERT(series);
306 306
307 307 QPen pen;
308 308 if(pen != series->pen()){
309 presenter->setPen(series->pen());
309 item->setPen(series->pen());
310 310 return;
311 311 }
312 312 pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
313 313 pen.setWidthF(series->pen().widthF());
314 presenter->setPen(pen);
314 item->setPen(pen);
315 315
316 316 // QColor color = m_seriesColor.at(count % m_seriesColor.size());
317 317 // TODO: define alpha in the theme? or in the series?
@@ -21,7 +21,7 class QScatterSeries;
21 21 class ScatterPresenter;
22 22 class PiePresenter;
23 23 class QPieSeries;
24 class SplinePresenter;
24 class SplineChartItem;
25 25 class QSplineSeries;
26 26 class AreaChartItem;
27 27 class QAreaSeries;
@@ -43,7 +43,7 public:
43 43 void decorate(ScatterPresenter* presenter, QScatterSeries* series, int count);
44 44 void decorate(PiePresenter* item, QPieSeries* series, int count);
45 45 void decorate(QChartAxis* axis,AxisItem* item);
46 void decorate(SplinePresenter* presenter, QSplineSeries* series, int count);
46 void decorate(SplineChartItem* presenter, QSplineSeries* series, int count);
47 47
48 48 protected:
49 49 QChart::ChartTheme m_id;
@@ -3,10 +3,10 DEPENDPATH += $$PWD
3 3
4 4 SOURCES += \
5 5 $$PWD/qsplineseries.cpp \
6 $$PWD/splinepresenter.cpp
6 $$PWD/splinechartitem.cpp
7 7
8 8 PRIVATE_HEADERS += \
9 $$PWD/splinepresenter_p.h
9 $$PWD/splinechartitem_p.h
10 10
11 11 PUBLIC_HEADERS += \
12 12 $$PWD/qsplineseries.h
@@ -1,9 +1,9
1 #include "splinepresenter_p.h"
1 #include "splinechartitem_p.h"
2 2 #include <QPainter>
3 3
4 4 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5 5
6 SplinePresenter::SplinePresenter(QSplineSeries* series, QGraphicsObject *parent) :
6 SplineChartItem::SplineChartItem(QSplineSeries* series, QGraphicsObject *parent) :
7 7 LineChartItem(series, parent)//,m_boundingRect()
8 8 {
9 9 //
@@ -11,7 +11,7 SplinePresenter::SplinePresenter(QSplineSeries* series, QGraphicsObject *parent)
11 11
12 12
13 13
14 QPointF SplinePresenter::calculateGeometryControlPoint(int index) const
14 QPointF SplineChartItem::calculateGeometryControlPoint(int index) const
15 15 {
16 16 QSplineSeries* splineSeries = qobject_cast<QSplineSeries*>(m_series);
17 17 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
@@ -21,7 +21,7 QPointF SplinePresenter::calculateGeometryControlPoint(int index) const
21 21 return QPointF(x,y);
22 22 }
23 23
24 void SplinePresenter::applyGeometry(QVector<QPointF>& points)
24 void SplineChartItem::applyGeometry(QVector<QPointF>& points)
25 25 {
26 26 if(points.size()==0) return;
27 27
@@ -41,7 +41,7 void SplinePresenter::applyGeometry(QVector<QPointF>& points)
41 41 m_rect = splinePath.boundingRect();
42 42 }
43 43
44 void SplinePresenter::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
44 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
45 45 {
46 46 Q_UNUSED(widget);
47 47 Q_UNUSED(option);
@@ -70,6 +70,6 void SplinePresenter::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
70 70 painter->restore();
71 71 }
72 72
73 #include "moc_splinepresenter_p.cpp"
73 #include "moc_splinechartitem_p.cpp"
74 74
75 75 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,5 +1,5
1 #ifndef SPLINEPRESENTER_P_H
2 #define SPLINEPRESENTER_P_H
1 #ifndef SPLINECHARTITEM_P_H
2 #define SPLINECHARTITEM_P_H
3 3
4 4 #include "chartitem_p.h"
5 5 #include <QObject>
@@ -8,11 +8,11
8 8
9 9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 10
11 class SplinePresenter : public LineChartItem
11 class SplineChartItem : public LineChartItem
12 12 {
13 13 Q_OBJECT
14 14 public:
15 SplinePresenter(QSplineSeries* series, QGraphicsObject *parent = 0);
15 SplineChartItem(QSplineSeries* series, QGraphicsObject *parent = 0);
16 16
17 17 void updateGeometry();
18 18
@@ -25,4 +25,4 public:
25 25
26 26 QTCOMMERCIALCHART_END_NAMESPACE
27 27
28 #endif // SPLINEPRESENTER_P_H
28 #endif // SPLINECHARTITEM_P_H
General Comments 0
You need to be logged in to leave comments. Login now