@@ -1,34 +1,34 | |||||
1 | #include <QtGui/QApplication> |
|
1 | #include <QtGui/QApplication> | |
2 | #include <QMainWindow> |
|
2 | #include <QMainWindow> | |
3 | #include <cmath> |
|
3 | #include <cmath> | |
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 |
#include <qchart |
|
5 | #include <qchartview.h> | |
6 | #include <qpieseries.h> |
|
6 | #include <qpieseries.h> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | QTCOMMERCIALCHART_USE_NAMESPACE | |
9 |
|
9 | |||
10 | int main(int argc, char *argv[]) |
|
10 | int main(int argc, char *argv[]) | |
11 | { |
|
11 | { | |
12 | QApplication a(argc, argv); |
|
12 | QApplication a(argc, argv); | |
13 |
|
13 | |||
14 | // Create widget and scatter series |
|
14 | // Create widget and scatter series | |
15 |
QChart |
|
15 | QChartView *chartWidget = new QChartView(); | |
16 | QPieSeries *series = qobject_cast<QPieSeries *>(chartWidget->createSeries(QChartSeries::SeriesTypePie)); |
|
16 | QPieSeries *series = qobject_cast<QPieSeries *>(chartWidget->createSeries(QChartSeries::SeriesTypePie)); | |
17 | Q_ASSERT(series); |
|
17 | Q_ASSERT(series); | |
18 |
|
18 | |||
19 | // Add test data to the series |
|
19 | // Add test data to the series | |
20 | QList<qreal> x; |
|
20 | QList<qreal> x; | |
21 | for (qreal i(0.0); i < 20; i += 0.5) { |
|
21 | for (qreal i(0.0); i < 20; i += 0.5) { | |
22 | // Linear data with random component |
|
22 | // Linear data with random component | |
23 | x.append(i + ((qreal)(rand() % 100)) / 100 ); |
|
23 | x.append(i + ((qreal)(rand() % 100)) / 100 ); | |
24 | } |
|
24 | } | |
25 | series->setData(x); |
|
25 | series->setData(x); | |
26 |
|
26 | |||
27 | // Use the chart widget as the central widget |
|
27 | // Use the chart widget as the central widget | |
28 | QMainWindow w; |
|
28 | QMainWindow w; | |
29 | w.resize(640, 480); |
|
29 | w.resize(640, 480); | |
30 | w.setCentralWidget(chartWidget); |
|
30 | w.setCentralWidget(chartWidget); | |
31 | w.show(); |
|
31 | w.show(); | |
32 |
|
32 | |||
33 | return a.exec(); |
|
33 | return a.exec(); | |
34 | } |
|
34 | } |
@@ -1,37 +1,37 | |||||
1 | #include <QtGui/QApplication> |
|
1 | #include <QtGui/QApplication> | |
2 | #include <QMainWindow> |
|
2 | #include <QMainWindow> | |
3 | #include <cmath> |
|
3 | #include <cmath> | |
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 |
#include <qchart |
|
5 | #include <qchartview.h> | |
6 | #include <qscatterseries.h> |
|
6 | #include <qscatterseries.h> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | QTCOMMERCIALCHART_USE_NAMESPACE | |
9 |
|
9 | |||
10 | int main(int argc, char *argv[]) |
|
10 | int main(int argc, char *argv[]) | |
11 | { |
|
11 | { | |
12 | QApplication a(argc, argv); |
|
12 | QApplication a(argc, argv); | |
13 |
|
13 | |||
14 | // Create widget and scatter series |
|
14 | // Create widget and scatter series | |
15 |
QChart |
|
15 | QChartView *chartWidget = new QChartView(); | |
16 | QScatterSeries *scatter = |
|
16 | QScatterSeries *scatter = | |
17 | qobject_cast<QScatterSeries *>(chartWidget->createSeries(QChartSeries::SeriesTypeScatter)); |
|
17 | qobject_cast<QScatterSeries *>(chartWidget->createSeries(QChartSeries::SeriesTypeScatter)); | |
18 | Q_ASSERT(scatter); |
|
18 | Q_ASSERT(scatter); | |
19 |
|
19 | |||
20 | // Add test data to the series |
|
20 | // Add test data to the series | |
21 | QList<qreal> x; |
|
21 | QList<qreal> x; | |
22 | QList<qreal> y; |
|
22 | QList<qreal> y; | |
23 | for (qreal i(0.0); i < 20; i += 0.5) { |
|
23 | for (qreal i(0.0); i < 20; i += 0.5) { | |
24 | // Linear data with random component |
|
24 | // Linear data with random component | |
25 | x.append(i + ((qreal)(rand() % 100)) / 100 ); |
|
25 | x.append(i + ((qreal)(rand() % 100)) / 100 ); | |
26 | y.append(i + ((qreal)(rand() % 100)) / 100 ); |
|
26 | y.append(i + ((qreal)(rand() % 100)) / 100 ); | |
27 | } |
|
27 | } | |
28 | scatter->setData(x, y); |
|
28 | scatter->setData(x, y); | |
29 |
|
29 | |||
30 | // Use the chart widget as the central widget |
|
30 | // Use the chart widget as the central widget | |
31 | QMainWindow w; |
|
31 | QMainWindow w; | |
32 | w.resize(640, 480); |
|
32 | w.resize(640, 480); | |
33 | w.setCentralWidget(chartWidget); |
|
33 | w.setCentralWidget(chartWidget); | |
34 | w.show(); |
|
34 | w.show(); | |
35 |
|
35 | |||
36 | return a.exec(); |
|
36 | return a.exec(); | |
37 | } |
|
37 | } |
@@ -1,85 +1,202 | |||||
1 | #include "qchartview.h" |
|
1 | #include "qchartview.h" | |
2 | #include "qchart.h" |
|
2 | #include "qchart.h" | |
3 | #include <QGraphicsView> |
|
3 | #include <QGraphicsView> | |
4 | #include <QGraphicsScene> |
|
4 | #include <QGraphicsScene> | |
5 | #include <QRubberBand> |
|
5 | #include <QRubberBand> | |
6 | #include <QResizeEvent> |
|
6 | #include <QResizeEvent> | |
7 | #include <QDebug> |
|
7 | #include <QDebug> | |
8 |
|
8 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
10 | |||
11 | QChartView::QChartView(QWidget *parent) : |
|
11 | QChartView::QChartView(QWidget *parent) : | |
12 | QGraphicsView(parent), |
|
12 | QGraphicsView(parent), | |
13 | m_scene(new QGraphicsScene()), |
|
13 | m_scene(new QGraphicsScene()), | |
14 | m_chart(new QChart()) |
|
14 | m_chart(new QChart()), | |
|
15 | m_rubberBand(0), | |||
|
16 | m_verticalRubberBand(false), | |||
|
17 | m_horizonalRubberBand(false) | |||
15 | { |
|
18 | { | |
16 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
19 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
17 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
20 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
18 | setScene(m_scene); |
|
21 | setScene(m_scene); | |
19 | m_chart->setMargin(50); |
|
22 | m_chart->setMargin(50); | |
20 | m_scene->addItem(m_chart); |
|
23 | m_scene->addItem(m_chart); | |
21 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
24 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
22 | } |
|
25 | } | |
23 |
|
26 | |||
24 | QChartView::~QChartView() |
|
27 | QChartView::~QChartView() | |
25 | { |
|
28 | { | |
26 | } |
|
29 | } | |
27 |
|
30 | |||
28 | void QChartView::resizeEvent(QResizeEvent *event) |
|
31 | void QChartView::resizeEvent(QResizeEvent *event) | |
29 | { |
|
32 | { | |
30 | m_scene->setSceneRect(0,0,size().width(),size().height()); |
|
33 | m_scene->setSceneRect(0,0,size().width(),size().height()); | |
31 | m_chart->resize(size()); |
|
34 | m_chart->resize(size()); | |
32 | QWidget::resizeEvent(event); |
|
35 | QWidget::resizeEvent(event); | |
33 | } |
|
36 | } | |
34 |
|
37 | |||
35 |
|
38 | |||
36 | void QChartView::addSeries(QChartSeries* series) |
|
39 | void QChartView::addSeries(QChartSeries* series) | |
37 | { |
|
40 | { | |
38 | m_chart->addSeries(series); |
|
41 | m_chart->addSeries(series); | |
39 | } |
|
42 | } | |
40 |
|
43 | |||
41 | QChartSeries* QChartView::createSeries(QChartSeries::QChartSeriesType type) |
|
44 | QChartSeries* QChartView::createSeries(QChartSeries::QChartSeriesType type) | |
42 | { |
|
45 | { | |
43 |
|
46 | |||
44 | return m_chart->createSeries(type); |
|
47 | return m_chart->createSeries(type); | |
45 | } |
|
48 | } | |
46 |
|
49 | |||
47 | void QChartView::zoomInToRect(const QRect& rectangle) |
|
50 | void QChartView::zoomInToRect(const QRect& rectangle) | |
48 | { |
|
51 | { | |
49 | m_chart->zoomInToRect(rectangle); |
|
52 | m_chart->zoomInToRect(rectangle); | |
50 | } |
|
53 | } | |
51 |
|
54 | |||
52 | void QChartView::zoomIn() |
|
55 | void QChartView::zoomIn() | |
53 | { |
|
56 | { | |
54 | m_chart->zoomIn(); |
|
57 | m_chart->zoomIn(); | |
55 | } |
|
58 | } | |
56 |
|
59 | |||
57 | void QChartView::zoomOut() |
|
60 | void QChartView::zoomOut() | |
58 | { |
|
61 | { | |
59 | m_chart->zoomOut(); |
|
62 | m_chart->zoomOut(); | |
60 | } |
|
63 | } | |
61 |
|
64 | |||
62 | int QChartView::margin() const |
|
65 | int QChartView::margin() const | |
63 | { |
|
66 | { | |
64 | return m_chart->margin(); |
|
67 | return m_chart->margin(); | |
65 | } |
|
68 | } | |
66 |
|
69 | |||
67 | void QChartView::setTitle(const QString& title) |
|
70 | void QChartView::setTitle(const QString& title) | |
68 | { |
|
71 | { | |
69 | m_chart->setTitle(title); |
|
72 | m_chart->setTitle(title); | |
70 | } |
|
73 | } | |
71 |
|
74 | |||
72 | void QChartView::setBackground(const QColor& startColor, const QColor& endColor, QChart::GradientOrientation orientation) |
|
75 | void QChartView::setBackground(const QColor& startColor, const QColor& endColor, QChart::GradientOrientation orientation) | |
73 | { |
|
76 | { | |
74 | m_chart->setBackground(startColor,endColor,orientation); |
|
77 | m_chart->setBackground(startColor,endColor,orientation); | |
75 | } |
|
78 | } | |
76 |
|
79 | |||
77 | void QChartView::setChartBackgroundBrush(const QBrush& brush) |
|
80 | void QChartView::setChartBackgroundBrush(const QBrush& brush) | |
78 | { |
|
81 | { | |
79 | m_chart->setChartBackgroundBrush(brush); |
|
82 | m_chart->setChartBackgroundBrush(brush); | |
80 | } |
|
83 | } | |
81 | void QChartView::setChartBackgroundPen(const QPen& pen) |
|
84 | void QChartView::setChartBackgroundPen(const QPen& pen) | |
82 | { |
|
85 | { | |
83 | m_chart->setChartBackgroundPen(pen); |
|
86 | m_chart->setChartBackgroundPen(pen); | |
84 | } |
|
87 | } | |
|
88 | ||||
|
89 | ||||
|
90 | void QChartView::setRubberBandPolicy(const RubberBandPolicy policy) | |||
|
91 | { | |||
|
92 | switch(policy){ | |||
|
93 | case VerticalRubberBand: | |||
|
94 | m_verticalRubberBand = true; | |||
|
95 | m_horizonalRubberBand = false; | |||
|
96 | break; | |||
|
97 | case HorizonalRubberBand: | |||
|
98 | m_verticalRubberBand = false; | |||
|
99 | m_horizonalRubberBand = true; | |||
|
100 | break; | |||
|
101 | case RectangleRubberBand: | |||
|
102 | m_verticalRubberBand = true; | |||
|
103 | m_horizonalRubberBand = true; | |||
|
104 | break; | |||
|
105 | case NoRubberBand: | |||
|
106 | default: | |||
|
107 | delete m_rubberBand; | |||
|
108 | m_rubberBand=0; | |||
|
109 | m_horizonalRubberBand = false; | |||
|
110 | m_verticalRubberBand = false; | |||
|
111 | return; | |||
|
112 | } | |||
|
113 | ||||
|
114 | m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this); | |||
|
115 | m_rubberBand->setEnabled(true); | |||
|
116 | } | |||
|
117 | ||||
|
118 | QChartView::RubberBandPolicy QChartView::rubberBandPolicy() const | |||
|
119 | { | |||
|
120 | if(m_horizonalRubberBand && m_verticalRubberBand) return RectangleRubberBand; | |||
|
121 | if(m_horizonalRubberBand) return HorizonalRubberBand; | |||
|
122 | if(m_verticalRubberBand) return VerticalRubberBand; | |||
|
123 | return NoRubberBand; | |||
|
124 | } | |||
|
125 | ||||
|
126 | ||||
|
127 | void QChartView::mousePressEvent(QMouseEvent *event) | |||
|
128 | { | |||
|
129 | if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) { | |||
|
130 | ||||
|
131 | int margin = m_chart->margin(); | |||
|
132 | QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin); | |||
|
133 | ||||
|
134 | if (rect.contains(event->pos())) { | |||
|
135 | m_rubberBandOrigin = event->pos(); | |||
|
136 | m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, QSize())); | |||
|
137 | m_rubberBand->show(); | |||
|
138 | event->accept(); | |||
|
139 | } | |||
|
140 | } | |||
|
141 | } | |||
|
142 | ||||
|
143 | void QChartView::mouseMoveEvent(QMouseEvent *event) | |||
|
144 | { | |||
|
145 | if(m_rubberBand && m_rubberBand->isVisible()){ | |||
|
146 | int margin = m_chart->margin(); | |||
|
147 | QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin); | |||
|
148 | int width = event->pos().x() - m_rubberBandOrigin.x(); | |||
|
149 | int height = event->pos().y() - m_rubberBandOrigin.y(); | |||
|
150 | if(!m_verticalRubberBand) { | |||
|
151 | m_rubberBandOrigin.setY(rect.top()); | |||
|
152 | height = rect.height(); | |||
|
153 | } | |||
|
154 | if(!m_horizonalRubberBand) { | |||
|
155 | m_rubberBandOrigin.setX(rect.left()); | |||
|
156 | width= rect.width(); | |||
|
157 | } | |||
|
158 | m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized()); | |||
|
159 | } else { | |||
|
160 | QGraphicsView::mouseMoveEvent(event); | |||
|
161 | } | |||
|
162 | } | |||
|
163 | ||||
|
164 | void QChartView::mouseReleaseEvent(QMouseEvent *event) | |||
|
165 | { | |||
|
166 | if(m_rubberBand){ | |||
|
167 | if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) { | |||
|
168 | m_rubberBand->hide(); | |||
|
169 | QRect rect = m_rubberBand->geometry(); | |||
|
170 | m_chart->zoomInToRect(rect); | |||
|
171 | event->accept(); | |||
|
172 | } | |||
|
173 | ||||
|
174 | if(event->button()==Qt::RightButton) | |||
|
175 | m_chart->zoomReset(); | |||
|
176 | }else{ | |||
|
177 | QGraphicsView::mouseReleaseEvent(event); | |||
|
178 | } | |||
|
179 | } | |||
|
180 | ||||
|
181 | void QChartView::keyPressEvent(QKeyEvent *event) | |||
|
182 | { | |||
|
183 | switch (event->key()) { | |||
|
184 | case Qt::Key_Plus: | |||
|
185 | zoomIn(); | |||
|
186 | break; | |||
|
187 | case Qt::Key_Minus: | |||
|
188 | zoomOut(); | |||
|
189 | break; | |||
|
190 | default: | |||
|
191 | QGraphicsView::keyPressEvent(event); | |||
|
192 | break; | |||
|
193 | } | |||
|
194 | } | |||
|
195 | ||||
|
196 | void QChartView::setTheme(QChart::ChartThemeId theme) | |||
|
197 | { | |||
|
198 | m_chart->setTheme(theme); | |||
|
199 | } | |||
|
200 | ||||
|
201 | ||||
85 | QTCOMMERCIALCHART_END_NAMESPACE |
|
202 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,53 +1,72 | |||||
1 | #ifndef QCHARTWIDGET_H |
|
1 | #ifndef QCHARTWIDGET_H | |
2 | #define QCHARTWIDGET_H |
|
2 | #define QCHARTWIDGET_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include "qchartseries.h" |
|
5 | #include "qchartseries.h" | |
6 | #include "qchart.h" |
|
6 | #include "qchart.h" | |
7 | #include <QGraphicsView> |
|
7 | #include <QGraphicsView> | |
8 |
|
8 | |||
9 | class QGraphicsScene; |
|
9 | class QGraphicsScene; | |
|
10 | class QRubberBand; | |||
10 |
|
11 | |||
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
12 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
12 |
|
13 | |||
13 | class QChart; |
|
14 | class QChart; | |
14 |
|
15 | |||
15 | class QTCOMMERCIALCHART_EXPORT QChartView : public QGraphicsView |
|
16 | class QTCOMMERCIALCHART_EXPORT QChartView : public QGraphicsView | |
16 | { |
|
17 | { | |
17 | public: |
|
18 | public: | |
|
19 | enum RubberBandPolicy { NoRubberBand, VerticalRubberBand, HorizonalRubberBand, RectangleRubberBand }; | |||
|
20 | ||||
18 | explicit QChartView(QWidget *parent = 0); |
|
21 | explicit QChartView(QWidget *parent = 0); | |
19 | ~QChartView(); |
|
22 | ~QChartView(); | |
20 |
|
23 | |||
21 | //implement from QWidget |
|
24 | //implement from QWidget | |
22 | void resizeEvent(QResizeEvent *event); |
|
25 | void resizeEvent(QResizeEvent *event); | |
23 |
|
26 | |||
24 | void addSeries(QChartSeries* series); |
|
27 | void addSeries(QChartSeries* series); | |
|
28 | ||||
25 | // Convenience function |
|
29 | // Convenience function | |
26 | QChartSeries* createSeries(QChartSeries::QChartSeriesType type); |
|
30 | QChartSeries* createSeries(QChartSeries::QChartSeriesType type); | |
27 |
|
31 | |||
28 | int margin() const; |
|
32 | int margin() const; | |
|
33 | ||||
29 | void setTitle(const QString& title); |
|
34 | void setTitle(const QString& title); | |
30 |
|
35 | |||
31 | //Obsolete interface |
|
36 | //Obsolete interface | |
32 | void setBackground(const QColor& startColor, const QColor& endColor = Qt::white, QChart::GradientOrientation orientation = QChart::VerticalGradientOrientation); |
|
37 | void setBackground(const QColor& startColor, const QColor& endColor = Qt::white, QChart::GradientOrientation orientation = QChart::VerticalGradientOrientation); | |
33 |
|
38 | |||
34 |
|
||||
35 | void setChartBackgroundBrush(const QBrush& brush); |
|
39 | void setChartBackgroundBrush(const QBrush& brush); | |
36 | void setChartBackgroundPen(const QPen& pen); |
|
40 | void setChartBackgroundPen(const QPen& pen); | |
37 |
|
41 | |||
38 | void zoomInToRect(const QRect& rectangle); |
|
42 | void zoomInToRect(const QRect& rectangle); | |
39 | void zoomIn(); |
|
43 | void zoomIn(); | |
40 | void zoomOut(); |
|
44 | void zoomOut(); | |
41 |
|
45 | |||
|
46 | void setRubberBandPolicy(const RubberBandPolicy ); | |||
|
47 | RubberBandPolicy rubberBandPolicy() const; | |||
|
48 | ||||
|
49 | void setTheme(QChart::ChartThemeId theme); | |||
|
50 | ||||
|
51 | protected: | |||
|
52 | void mousePressEvent(QMouseEvent *event); | |||
|
53 | void mouseMoveEvent(QMouseEvent *event); | |||
|
54 | void mouseReleaseEvent(QMouseEvent *event); | |||
|
55 | void keyPressEvent(QKeyEvent *event); | |||
|
56 | ||||
|
57 | ||||
42 | private: |
|
58 | private: | |
43 | QGraphicsScene *m_scene; |
|
59 | QGraphicsScene *m_scene; | |
44 | QChart* m_chart; |
|
60 | QChart* m_chart; | |
45 |
QPoint m_ |
|
61 | QPoint m_rubberBandOrigin; | |
|
62 | QRubberBand* m_rubberBand; | |||
|
63 | bool m_verticalRubberBand; | |||
|
64 | bool m_horizonalRubberBand; | |||
46 | Q_DISABLE_COPY(QChartView) |
|
65 | Q_DISABLE_COPY(QChartView) | |
47 |
|
66 | |||
48 |
|
67 | |||
49 | }; |
|
68 | }; | |
50 |
|
69 | |||
51 | QTCOMMERCIALCHART_END_NAMESPACE |
|
70 | QTCOMMERCIALCHART_END_NAMESPACE | |
52 |
|
71 | |||
53 | #endif // QCHARTWIDGET_H |
|
72 | #endif // QCHARTWIDGET_H |
@@ -1,130 +1,128 | |||||
1 | !include( ../common.pri ) { |
|
1 | !include( ../common.pri ) { | |
2 | error( Couldn't find the common.pri file! ) |
|
2 | error( Couldn't find the common.pri file! ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | TARGET = QtCommercialChart |
|
5 | TARGET = QtCommercialChart | |
6 | DESTDIR = $$CHART_BUILD_LIB_DIR |
|
6 | DESTDIR = $$CHART_BUILD_LIB_DIR | |
7 | TEMPLATE = lib |
|
7 | TEMPLATE = lib | |
8 | QT += core \ |
|
8 | QT += core \ | |
9 | gui |
|
9 | gui | |
10 |
|
10 | |||
11 | CONFIG += debug_and_release |
|
11 | CONFIG += debug_and_release | |
12 | CONFIG(debug, debug|release):TARGET = QtCommercialChartd |
|
12 | CONFIG(debug, debug|release):TARGET = QtCommercialChartd | |
13 |
|
13 | |||
14 | SOURCES += \ |
|
14 | SOURCES += \ | |
15 | barchart/barchartseries.cpp \ |
|
15 | barchart/barchartseries.cpp \ | |
16 | barchart/bargroup.cpp \ |
|
16 | barchart/bargroup.cpp \ | |
17 | barchart/bar.cpp \ |
|
17 | barchart/bar.cpp \ | |
18 | barchart/stackedbarchartseries.cpp \ |
|
18 | barchart/stackedbarchartseries.cpp \ | |
19 | barchart/stackedbargroup.cpp \ |
|
19 | barchart/stackedbargroup.cpp \ | |
20 | barchart/percentbarchartseries.cpp \ |
|
20 | barchart/percentbarchartseries.cpp \ | |
21 | barchart/percentbargroup.cpp \ |
|
21 | barchart/percentbargroup.cpp \ | |
22 | barchart/barlabel.cpp \ |
|
22 | barchart/barlabel.cpp \ | |
23 | xylinechart/qxychartseries.cpp \ |
|
23 | xylinechart/qxychartseries.cpp \ | |
24 | xylinechart/xylinechartitem.cpp \ |
|
24 | xylinechart/xylinechartitem.cpp \ | |
25 | xylinechart/linechartanimationitem.cpp \ |
|
25 | xylinechart/linechartanimationitem.cpp \ | |
26 | plotdomain.cpp \ |
|
26 | plotdomain.cpp \ | |
27 | qscatterseries.cpp \ |
|
27 | qscatterseries.cpp \ | |
28 | qpieseries.cpp \ |
|
28 | qpieseries.cpp \ | |
29 | qchart.cpp \ |
|
29 | qchart.cpp \ | |
30 | axisitem.cpp \ |
|
30 | axisitem.cpp \ | |
31 | qchartwidget.cpp \ |
|
|||
32 | pieslice.cpp \ |
|
31 | pieslice.cpp \ | |
33 | qchartview.cpp \ |
|
32 | qchartview.cpp \ | |
34 | qchartseries.cpp \ |
|
33 | qchartseries.cpp \ | |
35 | qchartaxis.cpp \ |
|
34 | qchartaxis.cpp \ | |
36 | charttheme.cpp \ |
|
35 | charttheme.cpp \ | |
37 | barchart/separator.cpp \ |
|
36 | barchart/separator.cpp \ | |
38 | barchart/bargroupbase.cpp \ |
|
37 | barchart/bargroupbase.cpp \ | |
39 | barchart/barchartseriesbase.cpp \ |
|
38 | barchart/barchartseriesbase.cpp \ | |
40 | chartdataset.cpp \ |
|
39 | chartdataset.cpp \ | |
41 | chartpresenter.cpp \ |
|
40 | chartpresenter.cpp \ | |
42 | domain.cpp |
|
41 | domain.cpp | |
43 |
|
42 | |||
44 | PRIVATE_HEADERS += \ |
|
43 | PRIVATE_HEADERS += \ | |
45 | xylinechart/xylinechartitem_p.h \ |
|
44 | xylinechart/xylinechartitem_p.h \ | |
46 | xylinechart/linechartanimationitem_p.h \ |
|
45 | xylinechart/linechartanimationitem_p.h \ | |
47 | barchart/barlabel_p.h \ |
|
46 | barchart/barlabel_p.h \ | |
48 | barchart/bar_p.h \ |
|
47 | barchart/bar_p.h \ | |
49 | barchart/separator_p.h \ |
|
48 | barchart/separator_p.h \ | |
50 | plotdomain_p.h \ |
|
49 | plotdomain_p.h \ | |
51 | qscatterseries_p.h \ |
|
50 | qscatterseries_p.h \ | |
52 | qpieseries_p.h \ |
|
51 | qpieseries_p.h \ | |
53 | pieslice.h \ |
|
52 | pieslice.h \ | |
54 | axisitem_p.h \ |
|
53 | axisitem_p.h \ | |
55 | chartitem_p.h \ |
|
54 | chartitem_p.h \ | |
56 | charttheme_p.h \ |
|
55 | charttheme_p.h \ | |
57 | chartdataset_p.h \ |
|
56 | chartdataset_p.h \ | |
58 | chartpresenter_p.h \ |
|
57 | chartpresenter_p.h \ | |
59 | domain_p.h |
|
58 | domain_p.h | |
60 |
|
59 | |||
61 | PUBLIC_HEADERS += \ |
|
60 | PUBLIC_HEADERS += \ | |
62 | qchartseries.h \ |
|
61 | qchartseries.h \ | |
63 | qscatterseries.h \ |
|
62 | qscatterseries.h \ | |
64 | qpieseries.h \ |
|
63 | qpieseries.h \ | |
65 | qchart.h \ |
|
64 | qchart.h \ | |
66 | qchartwidget.h \ |
|
|||
67 | qchartglobal.h \ |
|
65 | qchartglobal.h \ | |
68 | xylinechart/qxychartseries.h \ |
|
66 | xylinechart/qxychartseries.h \ | |
69 | barchart/barchartseries.h \ |
|
67 | barchart/barchartseries.h \ | |
70 | barchart/bargroup.h \ |
|
68 | barchart/bargroup.h \ | |
71 | barchart/stackedbarchartseries.h \ |
|
69 | barchart/stackedbarchartseries.h \ | |
72 | barchart/stackedbargroup.h \ |
|
70 | barchart/stackedbargroup.h \ | |
73 | barchart/percentbarchartseries.h \ |
|
71 | barchart/percentbarchartseries.h \ | |
74 | barchart/percentbargroup.h \ |
|
72 | barchart/percentbargroup.h \ | |
75 | barchart/barchartseriesbase.h \ |
|
73 | barchart/barchartseriesbase.h \ | |
76 | barchart/bargroupbase.h \ |
|
74 | barchart/bargroupbase.h \ | |
77 | qchartview.h \ |
|
75 | qchartview.h \ | |
78 | qchartaxis.h |
|
76 | qchartaxis.h | |
79 |
|
77 | |||
80 | HEADERS += $$PUBLIC_HEADERS |
|
78 | HEADERS += $$PUBLIC_HEADERS | |
81 | HEADERS += $$PRIVATE_HEADERS |
|
79 | HEADERS += $$PRIVATE_HEADERS | |
82 |
|
80 | |||
83 | INCLUDEPATH += xylinechart \ |
|
81 | INCLUDEPATH += xylinechart \ | |
84 | barchart \ |
|
82 | barchart \ | |
85 | . |
|
83 | . | |
86 |
|
84 | |||
87 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib |
|
85 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib | |
88 | MOC_DIR = $$CHART_BUILD_DIR/lib |
|
86 | MOC_DIR = $$CHART_BUILD_DIR/lib | |
89 | UI_DIR = $$CHART_BUILD_DIR/lib |
|
87 | UI_DIR = $$CHART_BUILD_DIR/lib | |
90 | RCC_DIR = $$CHART_BUILD_DIR/lib |
|
88 | RCC_DIR = $$CHART_BUILD_DIR/lib | |
91 |
|
89 | |||
92 |
|
90 | |||
93 | DEFINES += QTCOMMERCIALCHART_LIBRARY |
|
91 | DEFINES += QTCOMMERCIALCHART_LIBRARY | |
94 |
|
92 | |||
95 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart |
|
93 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart | |
96 | public_headers.files = $$PUBLIC_HEADERS |
|
94 | public_headers.files = $$PUBLIC_HEADERS | |
97 | target.path = $$[QT_INSTALL_LIBS] |
|
95 | target.path = $$[QT_INSTALL_LIBS] | |
98 | INSTALLS += target \ |
|
96 | INSTALLS += target \ | |
99 | public_headers |
|
97 | public_headers | |
100 |
|
98 | |||
101 |
|
99 | |||
102 | install_build_headers.name = bild_headers |
|
100 | install_build_headers.name = bild_headers | |
103 | install_build_headers.output = $$CHART_BUILD_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
101 | install_build_headers.output = $$CHART_BUILD_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
104 | install_build_headers.input = PUBLIC_HEADERS |
|
102 | install_build_headers.input = PUBLIC_HEADERS | |
105 | install_build_headers.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} $$CHART_BUILD_HEADER_DIR |
|
103 | install_build_headers.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} $$CHART_BUILD_HEADER_DIR | |
106 | install_build_headers.CONFIG += target_predeps no_link |
|
104 | install_build_headers.CONFIG += target_predeps no_link | |
107 | QMAKE_EXTRA_COMPILERS += install_build_headers |
|
105 | QMAKE_EXTRA_COMPILERS += install_build_headers | |
108 |
|
106 | |||
109 | chartversion.target = qchartversion_p.h |
|
107 | chartversion.target = qchartversion_p.h | |
110 | chartversion.commands = @echo "build_time" > $$chartversion.target; |
|
108 | chartversion.commands = @echo "build_time" > $$chartversion.target; | |
111 | chartversion.depends = $$HEADERS $$SOURCES |
|
109 | chartversion.depends = $$HEADERS $$SOURCES | |
112 | PRE_TARGETDEPS += qchartversion_p.h |
|
110 | PRE_TARGETDEPS += qchartversion_p.h | |
113 | QMAKE_CLEAN+= qchartversion_p.h |
|
111 | QMAKE_CLEAN+= qchartversion_p.h | |
114 | QMAKE_EXTRA_TARGETS += chartversion |
|
112 | QMAKE_EXTRA_TARGETS += chartversion | |
115 |
|
113 | |||
116 | unix:QMAKE_DISTCLEAN += -r $$CHART_BUILD_HEADER_DIR $$CHART_BUILD_LIB_DIR |
|
114 | unix:QMAKE_DISTCLEAN += -r $$CHART_BUILD_HEADER_DIR $$CHART_BUILD_LIB_DIR | |
117 | win32:QMAKE_DISTCLEAN += /Q $$CHART_BUILD_HEADER_DIR $$CHART_BUILD_LIB_DIR |
|
115 | win32:QMAKE_DISTCLEAN += /Q $$CHART_BUILD_HEADER_DIR $$CHART_BUILD_LIB_DIR | |
118 |
|
116 | |||
119 |
|
117 | |||
120 |
|
118 | |||
121 |
|
119 | |||
122 |
|
120 | |||
123 |
|
121 | |||
124 |
|
122 | |||
125 |
|
123 | |||
126 |
|
124 | |||
127 |
|
125 | |||
128 |
|
126 | |||
129 |
|
127 | |||
130 |
|
128 |
@@ -1,380 +1,381 | |||||
1 | #include "mainwidget.h" |
|
1 | #include "mainwidget.h" | |
2 | #include "dataseriedialog.h" |
|
2 | #include "dataseriedialog.h" | |
3 | #include "qchartseries.h" |
|
3 | #include "qchartseries.h" | |
4 | #include "qpieseries.h" |
|
4 | #include "qpieseries.h" | |
5 | #include <qxychartseries.h> |
|
5 | #include <qxychartseries.h> | |
6 | #include <barchartseries.h> |
|
6 | #include <barchartseries.h> | |
7 | #include <QPushButton> |
|
7 | #include <QPushButton> | |
8 | #include <QComboBox> |
|
8 | #include <QComboBox> | |
9 | #include <QSpinBox> |
|
9 | #include <QSpinBox> | |
10 | #include <QCheckBox> |
|
10 | #include <QCheckBox> | |
11 | #include <QGridLayout> |
|
11 | #include <QGridLayout> | |
12 | #include <QHBoxLayout> |
|
12 | #include <QHBoxLayout> | |
13 | #include <QLabel> |
|
13 | #include <QLabel> | |
14 | #include <QSpacerItem> |
|
14 | #include <QSpacerItem> | |
15 | #include <QMessageBox> |
|
15 | #include <QMessageBox> | |
16 | #include <cmath> |
|
16 | #include <cmath> | |
17 | #include <QDebug> |
|
17 | #include <QDebug> | |
18 | #include <QStandardItemModel> |
|
18 | #include <QStandardItemModel> | |
19 |
|
19 | |||
20 |
|
20 | |||
21 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
21 | QTCOMMERCIALCHART_USE_NAMESPACE | |
22 |
|
22 | |||
23 | MainWidget::MainWidget(QWidget *parent) : |
|
23 | MainWidget::MainWidget(QWidget *parent) : | |
24 | QWidget(parent) |
|
24 | QWidget(parent) | |
25 | { |
|
25 | { | |
26 |
m_chartWidget = new QChart |
|
26 | m_chartWidget = new QChartView(this); | |
|
27 | m_chartWidget->setRubberBandPolicy(QChartView::HorizonalRubberBand); | |||
27 |
|
28 | |||
28 | // Grid layout for the controls for configuring the chart widget |
|
29 | // Grid layout for the controls for configuring the chart widget | |
29 | QGridLayout *grid = new QGridLayout(); |
|
30 | QGridLayout *grid = new QGridLayout(); | |
30 | QPushButton *addSeriesButton = new QPushButton("Add series"); |
|
31 | QPushButton *addSeriesButton = new QPushButton("Add series"); | |
31 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); |
|
32 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); | |
32 | grid->addWidget(addSeriesButton, 0, 1); |
|
33 | grid->addWidget(addSeriesButton, 0, 1); | |
33 | initBackroundCombo(grid); |
|
34 | initBackroundCombo(grid); | |
34 | initScaleControls(grid); |
|
35 | initScaleControls(grid); | |
35 | initThemeCombo(grid); |
|
36 | initThemeCombo(grid); | |
36 | QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom"); |
|
37 | QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom"); | |
37 | connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartWidget, SLOT(setZoomEnabled(bool))); |
|
38 | connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartWidget, SLOT(setZoomEnabled(bool))); | |
38 | zoomCheckBox->setChecked(true); |
|
39 | zoomCheckBox->setChecked(true); | |
39 | grid->addWidget(zoomCheckBox, grid->rowCount(), 0); |
|
40 | grid->addWidget(zoomCheckBox, grid->rowCount(), 0); | |
40 | // add row with empty label to make all the other rows static |
|
41 | // add row with empty label to make all the other rows static | |
41 | grid->addWidget(new QLabel(""), grid->rowCount(), 0); |
|
42 | grid->addWidget(new QLabel(""), grid->rowCount(), 0); | |
42 | grid->setRowStretch(grid->rowCount() - 1, 1); |
|
43 | grid->setRowStretch(grid->rowCount() - 1, 1); | |
43 |
|
44 | |||
44 | // Another grid layout as a main layout |
|
45 | // Another grid layout as a main layout | |
45 | QGridLayout *mainLayout = new QGridLayout(); |
|
46 | QGridLayout *mainLayout = new QGridLayout(); | |
46 | mainLayout->addLayout(grid, 0, 0); |
|
47 | mainLayout->addLayout(grid, 0, 0); | |
47 |
|
48 | |||
48 | // Init series type specific controls |
|
49 | // Init series type specific controls | |
49 | initPieControls(); |
|
50 | initPieControls(); | |
50 | mainLayout->addLayout(m_pieLayout, 2, 0); |
|
51 | mainLayout->addLayout(m_pieLayout, 2, 0); | |
51 | // Scatter series specific settings |
|
52 | // Scatter series specific settings | |
52 | // m_scatterLayout = new QGridLayout(); |
|
53 | // m_scatterLayout = new QGridLayout(); | |
53 | // m_scatterLayout->addWidget(new QLabel("scatter"), 0, 0); |
|
54 | // m_scatterLayout->addWidget(new QLabel("scatter"), 0, 0); | |
54 | // m_scatterLayout->setEnabled(false); |
|
55 | // m_scatterLayout->setEnabled(false); | |
55 | // mainLayout->addLayout(m_scatterLayout, 1, 0); |
|
56 | // mainLayout->addLayout(m_scatterLayout, 1, 0); | |
56 |
|
57 | |||
57 | // Add layouts and the chart widget to the main layout |
|
58 | // Add layouts and the chart widget to the main layout | |
58 | mainLayout->addWidget(m_chartWidget, 0, 1, 3, 1); |
|
59 | mainLayout->addWidget(m_chartWidget, 0, 1, 3, 1); | |
59 | setLayout(mainLayout); |
|
60 | setLayout(mainLayout); | |
60 |
|
61 | |||
61 | // force an update to test data |
|
62 | // force an update to test data | |
62 | testDataChanged(0); |
|
63 | testDataChanged(0); | |
63 | } |
|
64 | } | |
64 |
|
65 | |||
65 | // Combo box for selecting the chart's background |
|
66 | // Combo box for selecting the chart's background | |
66 | void MainWidget::initBackroundCombo(QGridLayout *grid) |
|
67 | void MainWidget::initBackroundCombo(QGridLayout *grid) | |
67 | { |
|
68 | { | |
68 | QComboBox *backgroundCombo = new QComboBox(this); |
|
69 | QComboBox *backgroundCombo = new QComboBox(this); | |
69 | backgroundCombo->addItem("Color"); |
|
70 | backgroundCombo->addItem("Color"); | |
70 | backgroundCombo->addItem("Gradient"); |
|
71 | backgroundCombo->addItem("Gradient"); | |
71 | backgroundCombo->addItem("Image"); |
|
72 | backgroundCombo->addItem("Image"); | |
72 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), |
|
73 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), | |
73 | this, SLOT(backgroundChanged(int))); |
|
74 | this, SLOT(backgroundChanged(int))); | |
74 |
|
75 | |||
75 | grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); |
|
76 | grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); | |
76 | grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); |
|
77 | grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); | |
77 | } |
|
78 | } | |
78 |
|
79 | |||
79 | // Scale related controls (auto-scale vs. manual min-max values) |
|
80 | // Scale related controls (auto-scale vs. manual min-max values) | |
80 | void MainWidget::initScaleControls(QGridLayout *grid) |
|
81 | void MainWidget::initScaleControls(QGridLayout *grid) | |
81 | { |
|
82 | { | |
82 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); |
|
83 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); | |
83 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); |
|
84 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); | |
84 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
85 | // Allow setting also non-sense values (like -2147483648 and 2147483647) | |
85 | m_xMinSpin = new QSpinBox(); |
|
86 | m_xMinSpin = new QSpinBox(); | |
86 | m_xMinSpin->setMinimum(INT_MIN); |
|
87 | m_xMinSpin->setMinimum(INT_MIN); | |
87 | m_xMinSpin->setMaximum(INT_MAX); |
|
88 | m_xMinSpin->setMaximum(INT_MAX); | |
88 | m_xMinSpin->setValue(0); |
|
89 | m_xMinSpin->setValue(0); | |
89 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); |
|
90 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
90 | m_xMaxSpin = new QSpinBox(); |
|
91 | m_xMaxSpin = new QSpinBox(); | |
91 | m_xMaxSpin->setMinimum(INT_MIN); |
|
92 | m_xMaxSpin->setMinimum(INT_MIN); | |
92 | m_xMaxSpin->setMaximum(INT_MAX); |
|
93 | m_xMaxSpin->setMaximum(INT_MAX); | |
93 | m_xMaxSpin->setValue(10); |
|
94 | m_xMaxSpin->setValue(10); | |
94 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); |
|
95 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
95 | m_yMinSpin = new QSpinBox(); |
|
96 | m_yMinSpin = new QSpinBox(); | |
96 | m_yMinSpin->setMinimum(INT_MIN); |
|
97 | m_yMinSpin->setMinimum(INT_MIN); | |
97 | m_yMinSpin->setMaximum(INT_MAX); |
|
98 | m_yMinSpin->setMaximum(INT_MAX); | |
98 | m_yMinSpin->setValue(0); |
|
99 | m_yMinSpin->setValue(0); | |
99 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); |
|
100 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
100 | m_yMaxSpin = new QSpinBox(); |
|
101 | m_yMaxSpin = new QSpinBox(); | |
101 | m_yMaxSpin->setMinimum(INT_MIN); |
|
102 | m_yMaxSpin->setMinimum(INT_MIN); | |
102 | m_yMaxSpin->setMaximum(INT_MAX); |
|
103 | m_yMaxSpin->setMaximum(INT_MAX); | |
103 | m_yMaxSpin->setValue(10); |
|
104 | m_yMaxSpin->setValue(10); | |
104 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); |
|
105 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
105 |
|
106 | |||
106 | grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); |
|
107 | grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); | |
107 | grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); |
|
108 | grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); | |
108 | grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); |
|
109 | grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); | |
109 | grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); |
|
110 | grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); | |
110 | grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); |
|
111 | grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); | |
111 | grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); |
|
112 | grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); | |
112 | grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); |
|
113 | grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); | |
113 | grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); |
|
114 | grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); | |
114 | grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); |
|
115 | grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); | |
115 |
|
116 | |||
116 | m_autoScaleCheck->setChecked(true); |
|
117 | m_autoScaleCheck->setChecked(true); | |
117 | } |
|
118 | } | |
118 |
|
119 | |||
119 | // Combo box for selecting theme |
|
120 | // Combo box for selecting theme | |
120 | void MainWidget::initThemeCombo(QGridLayout *grid) |
|
121 | void MainWidget::initThemeCombo(QGridLayout *grid) | |
121 | { |
|
122 | { | |
122 | QComboBox *chartTheme = new QComboBox(); |
|
123 | QComboBox *chartTheme = new QComboBox(); | |
123 | chartTheme->addItem("Default"); |
|
124 | chartTheme->addItem("Default"); | |
124 | chartTheme->addItem("Vanilla"); |
|
125 | chartTheme->addItem("Vanilla"); | |
125 | chartTheme->addItem("Icy"); |
|
126 | chartTheme->addItem("Icy"); | |
126 | chartTheme->addItem("Grayscale"); |
|
127 | chartTheme->addItem("Grayscale"); | |
127 | chartTheme->addItem("Scientific"); |
|
128 | chartTheme->addItem("Scientific"); | |
128 | chartTheme->addItem("Unnamed1"); |
|
129 | chartTheme->addItem("Unnamed1"); | |
129 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), |
|
130 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), | |
130 | this, SLOT(changeChartTheme(int))); |
|
131 | this, SLOT(changeChartTheme(int))); | |
131 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); |
|
132 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); | |
132 | grid->addWidget(chartTheme, 8, 1); |
|
133 | grid->addWidget(chartTheme, 8, 1); | |
133 | } |
|
134 | } | |
134 |
|
135 | |||
135 | void MainWidget::initPieControls() |
|
136 | void MainWidget::initPieControls() | |
136 | { |
|
137 | { | |
137 | // Pie series specific settings |
|
138 | // Pie series specific settings | |
138 | // Pie size factory |
|
139 | // Pie size factory | |
139 | QDoubleSpinBox *pieSizeSpin = new QDoubleSpinBox(); |
|
140 | QDoubleSpinBox *pieSizeSpin = new QDoubleSpinBox(); | |
140 | pieSizeSpin->setMinimum(LONG_MIN); |
|
141 | pieSizeSpin->setMinimum(LONG_MIN); | |
141 | pieSizeSpin->setMaximum(LONG_MAX); |
|
142 | pieSizeSpin->setMaximum(LONG_MAX); | |
142 | pieSizeSpin->setValue(1.0); |
|
143 | pieSizeSpin->setValue(1.0); | |
143 | pieSizeSpin->setSingleStep(0.1); |
|
144 | pieSizeSpin->setSingleStep(0.1); | |
144 | connect(pieSizeSpin, SIGNAL(valueChanged(double)), this, SLOT(setPieSizeFactor(double))); |
|
145 | connect(pieSizeSpin, SIGNAL(valueChanged(double)), this, SLOT(setPieSizeFactor(double))); | |
145 | // Pie position |
|
146 | // Pie position | |
146 | QComboBox *piePosCombo = new QComboBox(this); |
|
147 | QComboBox *piePosCombo = new QComboBox(this); | |
147 | piePosCombo->addItem("Maximized"); |
|
148 | piePosCombo->addItem("Maximized"); | |
148 | piePosCombo->addItem("Top left"); |
|
149 | piePosCombo->addItem("Top left"); | |
149 | piePosCombo->addItem("Top right"); |
|
150 | piePosCombo->addItem("Top right"); | |
150 | piePosCombo->addItem("Bottom left"); |
|
151 | piePosCombo->addItem("Bottom left"); | |
151 | piePosCombo->addItem("Bottom right"); |
|
152 | piePosCombo->addItem("Bottom right"); | |
152 | connect(piePosCombo, SIGNAL(currentIndexChanged(int)), |
|
153 | connect(piePosCombo, SIGNAL(currentIndexChanged(int)), | |
153 | this, SLOT(setPiePosition(int))); |
|
154 | this, SLOT(setPiePosition(int))); | |
154 | m_pieLayout = new QGridLayout(); |
|
155 | m_pieLayout = new QGridLayout(); | |
155 | m_pieLayout->setEnabled(false); |
|
156 | m_pieLayout->setEnabled(false); | |
156 | m_pieLayout->addWidget(new QLabel("Pie size factor"), 0, 0); |
|
157 | m_pieLayout->addWidget(new QLabel("Pie size factor"), 0, 0); | |
157 | m_pieLayout->addWidget(pieSizeSpin, 0, 1); |
|
158 | m_pieLayout->addWidget(pieSizeSpin, 0, 1); | |
158 | m_pieLayout->addWidget(new QLabel("Pie position"), 1, 0); |
|
159 | m_pieLayout->addWidget(new QLabel("Pie position"), 1, 0); | |
159 | m_pieLayout->addWidget(piePosCombo, 1, 1); |
|
160 | m_pieLayout->addWidget(piePosCombo, 1, 1); | |
160 | } |
|
161 | } | |
161 |
|
162 | |||
162 | void MainWidget::addSeries() |
|
163 | void MainWidget::addSeries() | |
163 | { |
|
164 | { | |
164 | DataSerieDialog dialog(m_defaultSeriesName, this); |
|
165 | DataSerieDialog dialog(m_defaultSeriesName, this); | |
165 | connect(&dialog, SIGNAL(accepted(QString, QString)), this, SLOT(addSeries(QString, QString))); |
|
166 | connect(&dialog, SIGNAL(accepted(QString, QString)), this, SLOT(addSeries(QString, QString))); | |
166 | dialog.exec(); |
|
167 | dialog.exec(); | |
167 | } |
|
168 | } | |
168 |
|
169 | |||
169 | void MainWidget::addSeries(QString series, QString data) |
|
170 | void MainWidget::addSeries(QString series, QString data) | |
170 | { |
|
171 | { | |
171 | qDebug() << "addSeries: " << series << " data: " << data; |
|
172 | qDebug() << "addSeries: " << series << " data: " << data; | |
172 | m_defaultSeriesName = series; |
|
173 | m_defaultSeriesName = series; | |
173 |
|
174 | |||
174 | // TODO: a dedicated data class for storing x and y values |
|
175 | // TODO: a dedicated data class for storing x and y values | |
175 | QList<qreal> x; |
|
176 | QList<qreal> x; | |
176 | QList<qreal> y; |
|
177 | QList<qreal> y; | |
177 |
|
178 | |||
178 | if (data == "linear") { |
|
179 | if (data == "linear") { | |
179 | for (int i = 0; i < 20; i++) { |
|
180 | for (int i = 0; i < 20; i++) { | |
180 | x.append(i); |
|
181 | x.append(i); | |
181 | y.append(i); |
|
182 | y.append(i); | |
182 | } |
|
183 | } | |
183 | } else if (data == "linear, 1M") { |
|
184 | } else if (data == "linear, 1M") { | |
184 | // 1 million data points from 0.0001 to 100 |
|
185 | // 1 million data points from 0.0001 to 100 | |
185 | // TODO: What is the requirement? Should we be able to show this kind of data with |
|
186 | // TODO: What is the requirement? Should we be able to show this kind of data with | |
186 | // reasonable performance, or can we expect the application developer to do "data mining" |
|
187 | // reasonable performance, or can we expect the application developer to do "data mining" | |
187 | // for us, so that the count of data points given to QtCommercial Chart is always |
|
188 | // for us, so that the count of data points given to QtCommercial Chart is always | |
188 | // reasonable? |
|
189 | // reasonable? | |
189 | for (qreal i = 0; i < 100; i += 0.0001) { |
|
190 | for (qreal i = 0; i < 100; i += 0.0001) { | |
190 | x.append(i); |
|
191 | x.append(i); | |
191 | y.append(20); |
|
192 | y.append(20); | |
192 | } |
|
193 | } | |
193 | } else if (data == "SIN") { |
|
194 | } else if (data == "SIN") { | |
194 | for (int i = 0; i < 100; i++) { |
|
195 | for (int i = 0; i < 100; i++) { | |
195 | x.append(i); |
|
196 | x.append(i); | |
196 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100)); |
|
197 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100)); | |
197 | } |
|
198 | } | |
198 | } else if (data == "SIN + random") { |
|
199 | } else if (data == "SIN + random") { | |
199 | for (qreal i = 0; i < 100; i += 0.1) { |
|
200 | for (qreal i = 0; i < 100; i += 0.1) { | |
200 | x.append(i + (rand() % 5)); |
|
201 | x.append(i + (rand() % 5)); | |
201 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); |
|
202 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); | |
202 | } |
|
203 | } | |
203 | } else { |
|
204 | } else { | |
204 | // TODO: check if data has a valid file name |
|
205 | // TODO: check if data has a valid file name | |
205 | Q_ASSERT(false); |
|
206 | Q_ASSERT(false); | |
206 | } |
|
207 | } | |
207 |
|
208 | |||
208 | // TODO: color of the series |
|
209 | // TODO: color of the series | |
209 | QChartSeries *newSeries = 0; |
|
210 | QChartSeries *newSeries = 0; | |
210 | if (series == "Scatter") { |
|
211 | if (series == "Scatter") { | |
211 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeScatter); |
|
212 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeScatter); | |
212 | Q_ASSERT(newSeries->setData(x, y)); |
|
213 | Q_ASSERT(newSeries->setData(x, y)); | |
213 | } else if (series == "Pie") { |
|
214 | } else if (series == "Pie") { | |
214 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypePie); |
|
215 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypePie); | |
215 | Q_ASSERT(newSeries->setData(y)); |
|
216 | Q_ASSERT(newSeries->setData(y)); | |
216 | } else if (series == "Line") { |
|
217 | } else if (series == "Line") { | |
217 | // TODO: adding data to an existing line series does not give any visuals for some reason |
|
218 | // TODO: adding data to an existing line series does not give any visuals for some reason | |
218 | // newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeLine); |
|
219 | // newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeLine); | |
219 | // QXYChartSeries *lineSeries = static_cast<QXYChartSeries *>(newSeries); |
|
220 | // QXYChartSeries *lineSeries = static_cast<QXYChartSeries *>(newSeries); | |
220 | // lineSeries->setColor(Qt::blue); |
|
221 | // lineSeries->setColor(Qt::blue); | |
221 | // for (int i(0); i < x.count() && i < y.count(); i++) { |
|
222 | // for (int i(0); i < x.count() && i < y.count(); i++) { | |
222 | // lineSeries->add(x.at(i), y.at(i)); |
|
223 | // lineSeries->add(x.at(i), y.at(i)); | |
223 | // } |
|
224 | // } | |
224 | //Q_ASSERT(newSeries->setData(x, y)); |
|
225 | //Q_ASSERT(newSeries->setData(x, y)); | |
225 | QXYChartSeries* series0 = QXYChartSeries::create(); |
|
226 | QXYChartSeries* series0 = QXYChartSeries::create(); | |
226 | for (int i(0); i < x.count() && i < y.count(); i++) |
|
227 | for (int i(0); i < x.count() && i < y.count(); i++) | |
227 | series0->add(x.at(i), y.at(i)); |
|
228 | series0->add(x.at(i), y.at(i)); | |
228 | m_chartWidget->addSeries(series0); |
|
229 | m_chartWidget->addSeries(series0); | |
229 | newSeries = series0; |
|
230 | newSeries = series0; | |
230 | } else { |
|
231 | } else { | |
231 | // TODO |
|
232 | // TODO | |
232 | } |
|
233 | } | |
233 |
|
234 | |||
234 | // BarChart |
|
235 | // BarChart | |
235 | if (series == "Bar") { |
|
236 | if (series == "Bar") { | |
236 | // This is the another way of creating series. Should we create test cases for both ways, if we support them? |
|
237 | // This is the another way of creating series. Should we create test cases for both ways, if we support them? | |
237 | qDebug() << "Bar chart series"; |
|
238 | qDebug() << "Bar chart series"; | |
238 | newSeries = QChartSeries::create(QChartSeries::SeriesTypeBar, this); |
|
239 | newSeries = QChartSeries::create(QChartSeries::SeriesTypeBar, this); | |
239 |
|
240 | |||
240 | // Create some test data to chart |
|
241 | // Create some test data to chart | |
241 | QStandardItemModel dataModel(2,10,this); |
|
242 | QStandardItemModel dataModel(2,10,this); | |
242 | QModelIndex index; |
|
243 | QModelIndex index; | |
243 | index = dataModel.index(0,0); |
|
244 | index = dataModel.index(0,0); | |
244 | // Series 1, items 6 to 9 missing. |
|
245 | // Series 1, items 6 to 9 missing. | |
245 | dataModel.setData(dataModel.index(0,0),1); |
|
246 | dataModel.setData(dataModel.index(0,0),1); | |
246 | dataModel.setData(dataModel.index(0,1),12); |
|
247 | dataModel.setData(dataModel.index(0,1),12); | |
247 | dataModel.setData(dataModel.index(0,2),5); |
|
248 | dataModel.setData(dataModel.index(0,2),5); | |
248 | dataModel.setData(dataModel.index(0,3),8); |
|
249 | dataModel.setData(dataModel.index(0,3),8); | |
249 | dataModel.setData(dataModel.index(0,4),17); |
|
250 | dataModel.setData(dataModel.index(0,4),17); | |
250 | dataModel.setData(dataModel.index(0,5),9); |
|
251 | dataModel.setData(dataModel.index(0,5),9); | |
251 |
|
252 | |||
252 | // Series 2, some other items missing |
|
253 | // Series 2, some other items missing | |
253 | dataModel.setData(dataModel.index(1,0),5); |
|
254 | dataModel.setData(dataModel.index(1,0),5); | |
254 | dataModel.setData(dataModel.index(1,3),4); |
|
255 | dataModel.setData(dataModel.index(1,3),4); | |
255 | dataModel.setData(dataModel.index(1,5),7); |
|
256 | dataModel.setData(dataModel.index(1,5),7); | |
256 | dataModel.setData(dataModel.index(1,6),8); |
|
257 | dataModel.setData(dataModel.index(1,6),8); | |
257 | dataModel.setData(dataModel.index(1,8),9); |
|
258 | dataModel.setData(dataModel.index(1,8),9); | |
258 | dataModel.setData(dataModel.index(1,9),9); |
|
259 | dataModel.setData(dataModel.index(1,9),9); | |
259 |
|
260 | |||
260 | newSeries->setData(&dataModel); |
|
261 | newSeries->setData(&dataModel); | |
261 |
|
262 | |||
262 | m_chartWidget->addSeries(newSeries); |
|
263 | m_chartWidget->addSeries(newSeries); | |
263 | } |
|
264 | } | |
264 |
|
265 | |||
265 | setCurrentSeries(newSeries); |
|
266 | setCurrentSeries(newSeries); | |
266 | } |
|
267 | } | |
267 |
|
268 | |||
268 | void MainWidget::setCurrentSeries(QChartSeries *series) |
|
269 | void MainWidget::setCurrentSeries(QChartSeries *series) | |
269 | { |
|
270 | { | |
270 | m_currentSeries = series; |
|
271 | m_currentSeries = series; | |
271 | switch (m_currentSeries->type()) { |
|
272 | switch (m_currentSeries->type()) { | |
272 | case QChartSeries::SeriesTypeLine: |
|
273 | case QChartSeries::SeriesTypeLine: | |
273 | break; |
|
274 | break; | |
274 | case QChartSeries::SeriesTypeScatter: |
|
275 | case QChartSeries::SeriesTypeScatter: | |
275 | break; |
|
276 | break; | |
276 | case QChartSeries::SeriesTypePie: |
|
277 | case QChartSeries::SeriesTypePie: | |
277 | break; |
|
278 | break; | |
278 | case QChartSeries::SeriesTypeBar: |
|
279 | case QChartSeries::SeriesTypeBar: | |
279 | qDebug() << "setCurrentSeries (bar)"; |
|
280 | qDebug() << "setCurrentSeries (bar)"; | |
280 | break; |
|
281 | break; | |
281 | default: |
|
282 | default: | |
282 | Q_ASSERT(false); |
|
283 | Q_ASSERT(false); | |
283 | break; |
|
284 | break; | |
284 | } |
|
285 | } | |
285 | } |
|
286 | } | |
286 |
|
287 | |||
287 | void MainWidget::testDataChanged(int itemIndex) |
|
288 | void MainWidget::testDataChanged(int itemIndex) | |
288 | { |
|
289 | { | |
289 | qDebug() << "testDataChanged: " << itemIndex; |
|
290 | qDebug() << "testDataChanged: " << itemIndex; | |
290 |
|
291 | |||
291 | // switch (itemIndex) { |
|
292 | // switch (itemIndex) { | |
292 | // case 0: { |
|
293 | // case 0: { | |
293 | // QList<QChartDataPoint> data; |
|
294 | // QList<QChartDataPoint> data; | |
294 | // for (int x = 0; x < 20; x++) { |
|
295 | // for (int x = 0; x < 20; x++) { | |
295 | // data.append(QChartDataPoint() << x << x / 2); |
|
296 | // data.append(QChartDataPoint() << x << x / 2); | |
296 | // } |
|
297 | // } | |
297 | // m_chartWidget->setData(data); |
|
298 | // m_chartWidget->setData(data); | |
298 | // break; |
|
299 | // break; | |
299 | // } |
|
300 | // } | |
300 | // case 1: { |
|
301 | // case 1: { | |
301 | // QList<QChartDataPoint> data; |
|
302 | // QList<QChartDataPoint> data; | |
302 | // for (int x = 0; x < 100; x++) { |
|
303 | // for (int x = 0; x < 100; x++) { | |
303 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); |
|
304 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); | |
304 | // } |
|
305 | // } | |
305 | // m_chartWidget->setData(data); |
|
306 | // m_chartWidget->setData(data); | |
306 | // break; |
|
307 | // break; | |
307 | // } |
|
308 | // } | |
308 | // case 2: { |
|
309 | // case 2: { | |
309 | // QList<QChartDataPoint> data; |
|
310 | // QList<QChartDataPoint> data; | |
310 | // for (int x = 0; x < 1000; x++) { |
|
311 | // for (int x = 0; x < 1000; x++) { | |
311 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
312 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
312 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
313 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
313 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
314 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
314 | // } |
|
315 | // } | |
315 | // m_chartWidget->setData(data); |
|
316 | // m_chartWidget->setData(data); | |
316 | // break; |
|
317 | // break; | |
317 | // } |
|
318 | // } | |
318 | // default: |
|
319 | // default: | |
319 | // break; |
|
320 | // break; | |
320 | // } |
|
321 | // } | |
321 | } |
|
322 | } | |
322 |
|
323 | |||
323 | void MainWidget::backgroundChanged(int itemIndex) |
|
324 | void MainWidget::backgroundChanged(int itemIndex) | |
324 | { |
|
325 | { | |
325 | qDebug() << "backgroundChanged: " << itemIndex; |
|
326 | qDebug() << "backgroundChanged: " << itemIndex; | |
326 | } |
|
327 | } | |
327 |
|
328 | |||
328 | void MainWidget::autoScaleChanged(int value) |
|
329 | void MainWidget::autoScaleChanged(int value) | |
329 | { |
|
330 | { | |
330 | if (value) { |
|
331 | if (value) { | |
331 | // TODO: enable auto scaling |
|
332 | // TODO: enable auto scaling | |
332 | } else { |
|
333 | } else { | |
333 | // TODO: set scaling manually (and disable auto scaling) |
|
334 | // TODO: set scaling manually (and disable auto scaling) | |
334 | } |
|
335 | } | |
335 |
|
336 | |||
336 | m_xMinSpin->setEnabled(!value); |
|
337 | m_xMinSpin->setEnabled(!value); | |
337 | m_xMaxSpin->setEnabled(!value); |
|
338 | m_xMaxSpin->setEnabled(!value); | |
338 | m_yMinSpin->setEnabled(!value); |
|
339 | m_yMinSpin->setEnabled(!value); | |
339 | m_yMaxSpin->setEnabled(!value); |
|
340 | m_yMaxSpin->setEnabled(!value); | |
340 | } |
|
341 | } | |
341 |
|
342 | |||
342 | void MainWidget::xMinChanged(int value) |
|
343 | void MainWidget::xMinChanged(int value) | |
343 | { |
|
344 | { | |
344 | qDebug() << "xMinChanged: " << value; |
|
345 | qDebug() << "xMinChanged: " << value; | |
345 | } |
|
346 | } | |
346 |
|
347 | |||
347 | void MainWidget::xMaxChanged(int value) |
|
348 | void MainWidget::xMaxChanged(int value) | |
348 | { |
|
349 | { | |
349 | qDebug() << "xMaxChanged: " << value; |
|
350 | qDebug() << "xMaxChanged: " << value; | |
350 | } |
|
351 | } | |
351 |
|
352 | |||
352 | void MainWidget::yMinChanged(int value) |
|
353 | void MainWidget::yMinChanged(int value) | |
353 | { |
|
354 | { | |
354 | qDebug() << "yMinChanged: " << value; |
|
355 | qDebug() << "yMinChanged: " << value; | |
355 | } |
|
356 | } | |
356 |
|
357 | |||
357 | void MainWidget::yMaxChanged(int value) |
|
358 | void MainWidget::yMaxChanged(int value) | |
358 | { |
|
359 | { | |
359 | qDebug() << "yMaxChanged: " << value; |
|
360 | qDebug() << "yMaxChanged: " << value; | |
360 | } |
|
361 | } | |
361 |
|
362 | |||
362 | void MainWidget::changeChartTheme(int themeIndex) |
|
363 | void MainWidget::changeChartTheme(int themeIndex) | |
363 | { |
|
364 | { | |
364 | qDebug() << "changeChartTheme: " << themeIndex; |
|
365 | qDebug() << "changeChartTheme: " << themeIndex; | |
365 | m_chartWidget->setTheme((QChart::ChartThemeId) themeIndex); |
|
366 | m_chartWidget->setTheme((QChart::ChartThemeId) themeIndex); | |
366 | } |
|
367 | } | |
367 |
|
368 | |||
368 | void MainWidget::setPieSizeFactor(double size) |
|
369 | void MainWidget::setPieSizeFactor(double size) | |
369 | { |
|
370 | { | |
370 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); |
|
371 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); | |
371 | if (pie) |
|
372 | if (pie) | |
372 | pie->setSizeFactor(qreal(size)); |
|
373 | pie->setSizeFactor(qreal(size)); | |
373 | } |
|
374 | } | |
374 |
|
375 | |||
375 | void MainWidget::setPiePosition(int position) |
|
376 | void MainWidget::setPiePosition(int position) | |
376 | { |
|
377 | { | |
377 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); |
|
378 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); | |
378 | if (pie) |
|
379 | if (pie) | |
379 | pie->setPosition((QPieSeries::PiePosition) position); |
|
380 | pie->setPosition((QPieSeries::PiePosition) position); | |
380 | } |
|
381 | } |
@@ -1,56 +1,56 | |||||
1 | #ifndef MAINWIDGET_H |
|
1 | #ifndef MAINWIDGET_H | |
2 | #define MAINWIDGET_H |
|
2 | #define MAINWIDGET_H | |
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 |
#include <qchart |
|
5 | #include <qchartview.h> | |
6 | #include <QWidget> |
|
6 | #include <QWidget> | |
7 |
|
7 | |||
8 | class QSpinBox; |
|
8 | class QSpinBox; | |
9 | class QCheckBox; |
|
9 | class QCheckBox; | |
10 | class QGridLayout; |
|
10 | class QGridLayout; | |
11 |
|
11 | |||
12 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
12 | QTCOMMERCIALCHART_USE_NAMESPACE | |
13 |
|
13 | |||
14 | class MainWidget : public QWidget |
|
14 | class MainWidget : public QWidget | |
15 | { |
|
15 | { | |
16 | Q_OBJECT |
|
16 | Q_OBJECT | |
17 | public: |
|
17 | public: | |
18 | explicit MainWidget(QWidget *parent = 0); |
|
18 | explicit MainWidget(QWidget *parent = 0); | |
19 |
|
19 | |||
20 | signals: |
|
20 | signals: | |
21 |
|
21 | |||
22 | private: |
|
22 | private: | |
23 | void initBackroundCombo(QGridLayout *grid); |
|
23 | void initBackroundCombo(QGridLayout *grid); | |
24 | void initScaleControls(QGridLayout *grid); |
|
24 | void initScaleControls(QGridLayout *grid); | |
25 | void initThemeCombo(QGridLayout *grid); |
|
25 | void initThemeCombo(QGridLayout *grid); | |
26 | void initPieControls(); |
|
26 | void initPieControls(); | |
27 |
|
27 | |||
28 | private slots: |
|
28 | private slots: | |
29 | void addSeries(); |
|
29 | void addSeries(); | |
30 | void addSeries(QString series, QString data); |
|
30 | void addSeries(QString series, QString data); | |
31 | void testDataChanged(int itemIndex); |
|
31 | void testDataChanged(int itemIndex); | |
32 | void backgroundChanged(int itemIndex); |
|
32 | void backgroundChanged(int itemIndex); | |
33 | void autoScaleChanged(int value); |
|
33 | void autoScaleChanged(int value); | |
34 | void xMinChanged(int value); |
|
34 | void xMinChanged(int value); | |
35 | void xMaxChanged(int value); |
|
35 | void xMaxChanged(int value); | |
36 | void yMinChanged(int value); |
|
36 | void yMinChanged(int value); | |
37 | void yMaxChanged(int value); |
|
37 | void yMaxChanged(int value); | |
38 | void setCurrentSeries(QChartSeries *series); |
|
38 | void setCurrentSeries(QChartSeries *series); | |
39 | void changeChartTheme(int themeIndex); |
|
39 | void changeChartTheme(int themeIndex); | |
40 | void setPieSizeFactor(double margin); |
|
40 | void setPieSizeFactor(double margin); | |
41 | void setPiePosition(int position); |
|
41 | void setPiePosition(int position); | |
42 |
|
42 | |||
43 | private: |
|
43 | private: | |
44 |
QChart |
|
44 | QChartView *m_chartWidget; | |
45 | QCheckBox *m_autoScaleCheck; |
|
45 | QCheckBox *m_autoScaleCheck; | |
46 | QSpinBox *m_xMinSpin; |
|
46 | QSpinBox *m_xMinSpin; | |
47 | QSpinBox *m_xMaxSpin; |
|
47 | QSpinBox *m_xMaxSpin; | |
48 | QSpinBox *m_yMinSpin; |
|
48 | QSpinBox *m_yMinSpin; | |
49 | QSpinBox *m_yMaxSpin; |
|
49 | QSpinBox *m_yMaxSpin; | |
50 | QString m_defaultSeriesName; |
|
50 | QString m_defaultSeriesName; | |
51 | QChartSeries *m_currentSeries; |
|
51 | QChartSeries *m_currentSeries; | |
52 | QGridLayout *m_scatterLayout; |
|
52 | QGridLayout *m_scatterLayout; | |
53 | QGridLayout *m_pieLayout; |
|
53 | QGridLayout *m_pieLayout; | |
54 | }; |
|
54 | }; | |
55 |
|
55 | |||
56 | #endif // MAINWIDGET_H |
|
56 | #endif // MAINWIDGET_H |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now