@@ -1,24 +1,54 | |||||
1 | #include "dataseriedialog.h" |
|
1 | #include "dataseriedialog.h" | |
2 | #include <QDialogButtonBox> |
|
2 | #include <QDialogButtonBox> | |
3 |
#include <Q |
|
3 | #include <QGridLayout> | |
|
4 | #include <QComboBox> | |||
|
5 | #include <QPushButton> | |||
|
6 | #include <QLabel> | |||
4 | #include <QDebug> |
|
7 | #include <QDebug> | |
5 |
|
8 | |||
6 | DataSerieDialog::DataSerieDialog(QWidget *parent) : |
|
9 | DataSerieDialog::DataSerieDialog(QWidget *parent) : | |
7 | QDialog(parent) |
|
10 | QDialog(parent) | |
8 | { |
|
11 | { | |
9 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Vertical, this); |
|
12 | // Combo box for selecting the series type | |
10 | addSeriesBox->addButton("Line", QDialogButtonBox::AcceptRole); |
|
13 | m_seriesTypeCombo = new QComboBox(this); | |
11 | addSeriesBox->addButton("Area", QDialogButtonBox::AcceptRole); |
|
14 | m_seriesTypeCombo->addItem("Line"); | |
12 | addSeriesBox->addButton("Bar", QDialogButtonBox::AcceptRole); |
|
15 | m_seriesTypeCombo->addItem("Area"); | |
13 | addSeriesBox->addButton("Pie", QDialogButtonBox::AcceptRole); |
|
16 | m_seriesTypeCombo->addItem("Bar"); | |
14 | addSeriesBox->addButton("Scatter", QDialogButtonBox::AcceptRole); |
|
17 | m_seriesTypeCombo->addItem("Pie"); | |
15 | addSeriesBox->addButton("Spline", QDialogButtonBox::AcceptRole); |
|
18 | m_seriesTypeCombo->addItem("Scatter"); | |
16 | connect(addSeriesBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(addSeries(QAbstractButton *))); |
|
19 | m_seriesTypeCombo->addItem("Spline"); | |
17 | this->setFixedSize(addSeriesBox->sizeHint()); |
|
20 | ||
|
21 | // Combo box for selecting data for the new series | |||
|
22 | m_testDataCombo = new QComboBox(this); | |||
|
23 | m_testDataCombo->addItem("linear"); | |||
|
24 | m_testDataCombo->addItem("SIN"); | |||
|
25 | m_testDataCombo->addItem("SIN + random"); | |||
|
26 | m_testDataCombo->addItem("TODO From file..."); | |||
|
27 | m_testDataCombo->addItem("TODO From URL..."); | |||
|
28 | ||||
|
29 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal); | |||
|
30 | QPushButton *b = addSeriesBox->addButton(QDialogButtonBox::Ok); | |||
|
31 | connect(b, SIGNAL(clicked()), this, SLOT(accept())); | |||
|
32 | b = addSeriesBox->addButton(QDialogButtonBox::Cancel); | |||
|
33 | connect(b, SIGNAL(clicked()), this, SLOT(reject())); | |||
|
34 | ||||
|
35 | QGridLayout *grid = new QGridLayout(); | |||
|
36 | grid->addWidget(new QLabel("Series type:"), 0, 0); | |||
|
37 | grid->addWidget(m_seriesTypeCombo, 0, 1); | |||
|
38 | grid->addWidget(new QLabel("Data:"), 1, 0); | |||
|
39 | grid->addWidget(m_testDataCombo, 1, 1); | |||
|
40 | grid->addWidget(addSeriesBox, 2, 1); | |||
|
41 | ||||
|
42 | setLayout(grid); | |||
18 | } |
|
43 | } | |
19 |
|
44 | |||
20 |
void DataSerieDialog::a |
|
45 | void DataSerieDialog::accept() | |
21 | { |
|
46 | { | |
22 | addSeries(button->text().toAscii()); |
|
47 | accepted(m_seriesTypeCombo->currentText(), m_testDataCombo->currentText()); | |
23 | accept(); |
|
48 | QDialog::accept(); | |
24 | } |
|
49 | } | |
|
50 | //void DataSerieDialog::addSeries(QAbstractButton *button) | |||
|
51 | //{ | |||
|
52 | // addSeries(button->text().toAscii()); | |||
|
53 | // accept(); | |||
|
54 | //} |
@@ -1,21 +1,25 | |||||
1 | #ifndef DATASERIEDIALOG_H |
|
1 | #ifndef DATASERIEDIALOG_H | |
2 | #define DATASERIEDIALOG_H |
|
2 | #define DATASERIEDIALOG_H | |
3 |
|
3 | |||
4 | #include <QDialog> |
|
4 | #include <QDialog> | |
5 |
|
5 | |||
6 | class QAbstractButton; |
|
6 | class QComboBox; | |
7 |
|
7 | |||
8 | class DataSerieDialog : public QDialog |
|
8 | class DataSerieDialog : public QDialog | |
9 | { |
|
9 | { | |
10 | Q_OBJECT |
|
10 | Q_OBJECT | |
11 | public: |
|
11 | public: | |
12 | explicit DataSerieDialog(QWidget *parent = 0); |
|
12 | explicit DataSerieDialog(QWidget *parent = 0); | |
13 |
|
13 | |||
14 | signals: |
|
14 | signals: | |
15 |
void a |
|
15 | void accepted(QString series, QString data); | |
16 |
|
16 | |||
17 | public slots: |
|
17 | public slots: | |
18 | void addSeries(QAbstractButton *button); |
|
18 | void accept(); | |
|
19 | ||||
|
20 | private: | |||
|
21 | QComboBox *m_seriesTypeCombo; | |||
|
22 | QComboBox *m_testDataCombo; | |||
19 | }; |
|
23 | }; | |
20 |
|
24 | |||
21 | #endif // DATASERIEDIALOG_H |
|
25 | #endif // DATASERIEDIALOG_H |
@@ -1,229 +1,222 | |||||
1 | #include "mainwidget.h" |
|
1 | #include "mainwidget.h" | |
2 | #include "dataseriedialog.h" |
|
2 | #include "dataseriedialog.h" | |
3 | #include <qxyseries.h> |
|
3 | #include <qxyseries.h> | |
4 | #include <QPushButton> |
|
4 | #include <QPushButton> | |
5 | #include <QComboBox> |
|
5 | #include <QComboBox> | |
6 | #include <QSpinBox> |
|
6 | #include <QSpinBox> | |
7 | #include <QCheckBox> |
|
7 | #include <QCheckBox> | |
8 | #include <QGridLayout> |
|
8 | #include <QGridLayout> | |
9 | #include <QHBoxLayout> |
|
9 | #include <QHBoxLayout> | |
10 | #include <QLabel> |
|
10 | #include <QLabel> | |
11 | #include <QSpacerItem> |
|
11 | #include <QSpacerItem> | |
12 | #include <QMessageBox> |
|
12 | #include <QMessageBox> | |
13 | #include <cmath> |
|
13 | #include <cmath> | |
14 | #include <QDebug> |
|
14 | #include <QDebug> | |
15 |
|
15 | |||
16 | QCHART_USE_NAMESPACE |
|
16 | QCHART_USE_NAMESPACE | |
17 |
|
17 | |||
18 | MainWidget::MainWidget(QWidget *parent) : |
|
18 | MainWidget::MainWidget(QWidget *parent) : | |
19 | QWidget(parent) |
|
19 | QWidget(parent) | |
20 | { |
|
20 | { | |
21 | m_chartWidget = new QChartWidget(this); |
|
21 | m_chartWidget = new QChartWidget(this); | |
22 | // m_chartWidget->resize(QSize(200,200)); |
|
22 | // m_chartWidget->resize(QSize(200,200)); | |
23 | // m_chartWidget->setColor(Qt::red); |
|
23 | // m_chartWidget->setColor(Qt::red); | |
24 | // Chart type |
|
|||
25 | // TODO: How about multiple types? |
|
|||
26 | // Should the type be a property of a graph instead of the chart? |
|
|||
27 | // QComboBox *chartTypeCombo = new QComboBox(this); |
|
|||
28 | // chartTypeCombo->addItem("Line"); |
|
|||
29 | // chartTypeCombo->addItem("Area"); |
|
|||
30 | // chartTypeCombo->addItem("Bar"); |
|
|||
31 | // chartTypeCombo->addItem("Pie"); |
|
|||
32 | // chartTypeCombo->addItem("Scatter"); |
|
|||
33 | // chartTypeCombo->addItem("Spline"); |
|
|||
34 | // connect(chartTypeCombo, SIGNAL(currentIndexChanged(int)), |
|
|||
35 | // this, SLOT(chartTypeChanged(int))); |
|
|||
36 |
|
24 | |||
37 | QPushButton *addSeriesButton = new QPushButton("Add series"); |
|
25 | QPushButton *addSeriesButton = new QPushButton("Add series"); | |
38 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); |
|
26 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); | |
39 |
|
27 | |||
40 | // Test data selector |
|
|||
41 | QComboBox *testDataCombo = new QComboBox(this); |
|
|||
42 | testDataCombo->addItem("linear"); |
|
|||
43 | testDataCombo->addItem("SIN"); |
|
|||
44 | testDataCombo->addItem("SIN + random component"); |
|
|||
45 | testDataCombo->addItem("TODO From file..."); |
|
|||
46 | testDataCombo->addItem("TODO From URL..."); |
|
|||
47 | connect(testDataCombo, SIGNAL(currentIndexChanged(int)), |
|
|||
48 | this, SLOT(testDataChanged(int))); |
|
|||
49 |
|
||||
50 | // Chart background |
|
28 | // Chart background | |
51 | QComboBox *backgroundCombo = new QComboBox(this); |
|
29 | QComboBox *backgroundCombo = new QComboBox(this); | |
52 | backgroundCombo->addItem("None"); |
|
30 | backgroundCombo->addItem("None"); | |
53 | backgroundCombo->addItem("TODO Grid"); |
|
31 | backgroundCombo->addItem("TODO Grid"); | |
54 | backgroundCombo->addItem("TODO Image"); |
|
32 | backgroundCombo->addItem("TODO Image"); | |
55 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), |
|
33 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), | |
56 | this, SLOT(backgroundChanged(int))); |
|
34 | this, SLOT(backgroundChanged(int))); | |
57 |
|
35 | |||
58 | // Axis |
|
36 | // Axis | |
59 | // TODO: multiple axes? |
|
37 | // TODO: multiple axes? | |
60 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); |
|
38 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); | |
61 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); |
|
39 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); | |
62 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
40 | // Allow setting also non-sense values (like -2147483648 and 2147483647) | |
63 | m_xMinSpin = new QSpinBox(); |
|
41 | m_xMinSpin = new QSpinBox(); | |
64 | m_xMinSpin->setMinimum(INT_MIN); |
|
42 | m_xMinSpin->setMinimum(INT_MIN); | |
65 | m_xMinSpin->setMaximum(INT_MAX); |
|
43 | m_xMinSpin->setMaximum(INT_MAX); | |
66 | m_xMinSpin->setValue(0); |
|
44 | m_xMinSpin->setValue(0); | |
67 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); |
|
45 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
68 | m_xMaxSpin = new QSpinBox(); |
|
46 | m_xMaxSpin = new QSpinBox(); | |
69 | m_xMaxSpin->setMinimum(INT_MIN); |
|
47 | m_xMaxSpin->setMinimum(INT_MIN); | |
70 | m_xMaxSpin->setMaximum(INT_MAX); |
|
48 | m_xMaxSpin->setMaximum(INT_MAX); | |
71 | m_xMaxSpin->setValue(10); |
|
49 | m_xMaxSpin->setValue(10); | |
72 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); |
|
50 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
73 | m_yMinSpin = new QSpinBox(); |
|
51 | m_yMinSpin = new QSpinBox(); | |
74 | m_yMinSpin->setMinimum(INT_MIN); |
|
52 | m_yMinSpin->setMinimum(INT_MIN); | |
75 | m_yMinSpin->setMaximum(INT_MAX); |
|
53 | m_yMinSpin->setMaximum(INT_MAX); | |
76 | m_yMinSpin->setValue(0); |
|
54 | m_yMinSpin->setValue(0); | |
77 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); |
|
55 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
78 | m_yMaxSpin = new QSpinBox(); |
|
56 | m_yMaxSpin = new QSpinBox(); | |
79 | m_yMaxSpin->setMinimum(INT_MIN); |
|
57 | m_yMaxSpin->setMinimum(INT_MIN); | |
80 | m_yMaxSpin->setMaximum(INT_MAX); |
|
58 | m_yMaxSpin->setMaximum(INT_MAX); | |
81 | m_yMaxSpin->setValue(10); |
|
59 | m_yMaxSpin->setValue(10); | |
82 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); |
|
60 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
83 |
|
61 | |||
84 | QGridLayout *grid = new QGridLayout(); |
|
62 | QGridLayout *grid = new QGridLayout(); | |
85 | QHBoxLayout *hbox = new QHBoxLayout(); |
|
63 | QHBoxLayout *hbox = new QHBoxLayout(); | |
86 | //grid->addWidget(new QLabel("Add series:"), 0, 0); |
|
64 | //grid->addWidget(new QLabel("Add series:"), 0, 0); | |
87 | grid->addWidget(addSeriesButton, 0, 1); |
|
65 | grid->addWidget(addSeriesButton, 0, 1); | |
88 | // grid->addWidget(new QLabel("Chart type:"), 0, 0); |
|
|||
89 | // grid->addWidget(chartTypeCombo, 0, 1); |
|
|||
90 | grid->addWidget(new QLabel("Data:"), 1, 0); |
|
|||
91 | grid->addWidget(testDataCombo, 1, 1); |
|
|||
92 | grid->addWidget(new QLabel("Background:"), 2, 0); |
|
66 | grid->addWidget(new QLabel("Background:"), 2, 0); | |
93 | grid->addWidget(backgroundCombo, 2, 1); |
|
67 | grid->addWidget(backgroundCombo, 2, 1); | |
94 | grid->addWidget(m_autoScaleCheck, 3, 0); |
|
68 | grid->addWidget(m_autoScaleCheck, 3, 0); | |
95 | grid->addWidget(new QLabel("x min:"), 4, 0); |
|
69 | grid->addWidget(new QLabel("x min:"), 4, 0); | |
96 | grid->addWidget(m_xMinSpin, 4, 1); |
|
70 | grid->addWidget(m_xMinSpin, 4, 1); | |
97 | grid->addWidget(new QLabel("x max:"), 5, 0); |
|
71 | grid->addWidget(new QLabel("x max:"), 5, 0); | |
98 | grid->addWidget(m_xMaxSpin, 5, 1); |
|
72 | grid->addWidget(m_xMaxSpin, 5, 1); | |
99 | grid->addWidget(new QLabel("y min:"), 6, 0); |
|
73 | grid->addWidget(new QLabel("y min:"), 6, 0); | |
100 | grid->addWidget(m_yMinSpin, 6, 1); |
|
74 | grid->addWidget(m_yMinSpin, 6, 1); | |
101 | grid->addWidget(new QLabel("y max:"), 7, 0); |
|
75 | grid->addWidget(new QLabel("y max:"), 7, 0); | |
102 | grid->addWidget(m_yMaxSpin, 7, 1); |
|
76 | grid->addWidget(m_yMaxSpin, 7, 1); | |
103 | // add row with empty label to make all the other rows static |
|
77 | // add row with empty label to make all the other rows static | |
104 | grid->addWidget(new QLabel(""), 8, 0); |
|
78 | grid->addWidget(new QLabel(""), 8, 0); | |
105 | grid->setRowStretch(8, 1); |
|
79 | grid->setRowStretch(8, 1); | |
106 |
|
80 | |||
107 | hbox->addLayout(grid); |
|
81 | hbox->addLayout(grid); | |
108 | hbox->addWidget(m_chartWidget); |
|
82 | hbox->addWidget(m_chartWidget); | |
109 | hbox->setStretch(1, 1); |
|
83 | hbox->setStretch(1, 1); | |
110 |
|
84 | |||
111 | setLayout(hbox); |
|
85 | setLayout(hbox); | |
112 |
|
86 | |||
113 | m_autoScaleCheck->setChecked(true); |
|
87 | m_autoScaleCheck->setChecked(true); | |
114 | chartTypeChanged(4); |
|
88 | chartTypeChanged(4); | |
115 | testDataChanged(0); |
|
89 | testDataChanged(0); | |
116 | } |
|
90 | } | |
117 |
|
91 | |||
118 | void MainWidget::addSeries() |
|
92 | void MainWidget::addSeries() | |
119 | { |
|
93 | { | |
120 | DataSerieDialog dialog(this); |
|
94 | DataSerieDialog dialog(this); | |
121 |
connect(&dialog, SIGNAL(a |
|
95 | connect(&dialog, SIGNAL(accepted(QString, QString)), this, SLOT(addSeries(QString, QString))); | |
122 | dialog.exec(); |
|
96 | dialog.exec(); | |
123 | } |
|
97 | } | |
124 |
|
98 | |||
125 | void MainWidget::addSeries(QString series) |
|
99 | void MainWidget::addSeries(QString series, QString data) | |
126 | { |
|
100 | { | |
127 | if (series == "Scatter") { |
|
101 | qDebug() << "addSeries: " << series << " data: " << data; | |
128 | QXYSeries* series0 = new QXYSeries(); |
|
102 | ||
|
103 | QXYSeries* series0 = new QXYSeries(); | |||
|
104 | ||||
|
105 | if (data == "linear") { | |||
|
106 | // TODO | |||
|
107 | } else if (data == "SIN") { | |||
129 | series0->setColor(Qt::blue); |
|
108 | series0->setColor(Qt::blue); | |
130 | for (int x = 0; x < 100; x++) |
|
109 | for (int x = 0; x < 100; x++) | |
131 | series0->add(x, abs(sin(3.14159265358979 / 50 * x) * 100)); |
|
110 | series0->add(x, abs(sin(3.14159265358979 / 50 * x) * 100)); | |
132 | QList<QXYSeries*> dataset; |
|
111 | QList<QXYSeries*> dataset; | |
133 | dataset << series0; |
|
112 | dataset << series0; | |
|
113 | } else if (data == "SIN + random") { | |||
|
114 | series0->setColor(Qt::blue); | |||
|
115 | for (qreal x = 0; x < 100; x += 0.1) { | |||
|
116 | series0->add(x + (rand() % 5), | |||
|
117 | abs(sin(3.14159265358979 / 50 * x) * 100) + (rand() % 5)); | |||
|
118 | } | |||
|
119 | } else { | |||
|
120 | // TODO: check if data has a valid file name | |||
|
121 | } | |||
|
122 | ||||
|
123 | QList<QXYSeries*> dataset; | |||
|
124 | dataset << series0; | |||
|
125 | ||||
|
126 | if (series == "Scatter") { | |||
134 | m_chartWidget->addDataSeries(QChart::DataSeriesTypeScatter, dataset); |
|
127 | m_chartWidget->addDataSeries(QChart::DataSeriesTypeScatter, dataset); | |
135 | //m_chartWidget->addDataSeries(dataset); |
|
128 | } else if (series == "Line") { | |
|
129 | m_chartWidget->addDataSeries(QChart::DataSeriesTypeLine, dataset); | |||
136 | } else { |
|
130 | } else { | |
137 | // TODO |
|
131 | // TODO | |
138 | qDebug() << "addSeries: " << series; |
|
|||
139 | } |
|
132 | } | |
140 | } |
|
133 | } | |
141 |
|
134 | |||
142 | void MainWidget::chartTypeChanged(int itemIndex) |
|
135 | void MainWidget::chartTypeChanged(int itemIndex) | |
143 | { |
|
136 | { | |
144 | // TODO: change chart type |
|
137 | // TODO: change chart type | |
145 | switch (itemIndex) { |
|
138 | switch (itemIndex) { | |
146 | case 4: |
|
139 | case 4: | |
147 | //m_chartWidget->setType(4); |
|
140 | //m_chartWidget->setType(4); | |
148 | break; |
|
141 | break; | |
149 | default: { |
|
142 | default: { | |
150 | //m_chartWidget->setType(0); |
|
143 | //m_chartWidget->setType(0); | |
151 | break; |
|
144 | break; | |
152 | } |
|
145 | } | |
153 | } |
|
146 | } | |
154 | } |
|
147 | } | |
155 |
|
148 | |||
156 | void MainWidget::testDataChanged(int itemIndex) |
|
149 | void MainWidget::testDataChanged(int itemIndex) | |
157 | { |
|
150 | { | |
158 | qDebug() << "testDataChanged: " << itemIndex; |
|
151 | qDebug() << "testDataChanged: " << itemIndex; | |
159 |
|
152 | |||
160 | // switch (itemIndex) { |
|
153 | // switch (itemIndex) { | |
161 | // case 0: { |
|
154 | // case 0: { | |
162 | // QList<QChartDataPoint> data; |
|
155 | // QList<QChartDataPoint> data; | |
163 | // for (int x = 0; x < 20; x++) { |
|
156 | // for (int x = 0; x < 20; x++) { | |
164 | // data.append(QChartDataPoint() << x << x / 2); |
|
157 | // data.append(QChartDataPoint() << x << x / 2); | |
165 | // } |
|
158 | // } | |
166 | // m_chartWidget->setData(data); |
|
159 | // m_chartWidget->setData(data); | |
167 | // break; |
|
160 | // break; | |
168 | // } |
|
161 | // } | |
169 | // case 1: { |
|
162 | // case 1: { | |
170 | // QList<QChartDataPoint> data; |
|
163 | // QList<QChartDataPoint> data; | |
171 | // for (int x = 0; x < 100; x++) { |
|
164 | // for (int x = 0; x < 100; x++) { | |
172 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); |
|
165 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); | |
173 | // } |
|
166 | // } | |
174 | // m_chartWidget->setData(data); |
|
167 | // m_chartWidget->setData(data); | |
175 | // break; |
|
168 | // break; | |
176 | // } |
|
169 | // } | |
177 | // case 2: { |
|
170 | // case 2: { | |
178 | // QList<QChartDataPoint> data; |
|
171 | // QList<QChartDataPoint> data; | |
179 | // for (int x = 0; x < 1000; x++) { |
|
172 | // for (int x = 0; x < 1000; x++) { | |
180 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
173 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
181 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
174 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
182 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
175 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
183 | // } |
|
176 | // } | |
184 | // m_chartWidget->setData(data); |
|
177 | // m_chartWidget->setData(data); | |
185 | // break; |
|
178 | // break; | |
186 | // } |
|
179 | // } | |
187 | // default: |
|
180 | // default: | |
188 | // break; |
|
181 | // break; | |
189 | // } |
|
182 | // } | |
190 | } |
|
183 | } | |
191 |
|
184 | |||
192 | void MainWidget::backgroundChanged(int itemIndex) |
|
185 | void MainWidget::backgroundChanged(int itemIndex) | |
193 | { |
|
186 | { | |
194 | qDebug() << "backgroundChanged: " << itemIndex; |
|
187 | qDebug() << "backgroundChanged: " << itemIndex; | |
195 | } |
|
188 | } | |
196 |
|
189 | |||
197 | void MainWidget::autoScaleChanged(int value) |
|
190 | void MainWidget::autoScaleChanged(int value) | |
198 | { |
|
191 | { | |
199 | if (value) { |
|
192 | if (value) { | |
200 | // TODO: enable auto scaling |
|
193 | // TODO: enable auto scaling | |
201 | } else { |
|
194 | } else { | |
202 | // TODO: set scaling manually (and disable auto scaling) |
|
195 | // TODO: set scaling manually (and disable auto scaling) | |
203 | } |
|
196 | } | |
204 |
|
197 | |||
205 | m_xMinSpin->setEnabled(!value); |
|
198 | m_xMinSpin->setEnabled(!value); | |
206 | m_xMaxSpin->setEnabled(!value); |
|
199 | m_xMaxSpin->setEnabled(!value); | |
207 | m_yMinSpin->setEnabled(!value); |
|
200 | m_yMinSpin->setEnabled(!value); | |
208 | m_yMaxSpin->setEnabled(!value); |
|
201 | m_yMaxSpin->setEnabled(!value); | |
209 | } |
|
202 | } | |
210 |
|
203 | |||
211 | void MainWidget::xMinChanged(int value) |
|
204 | void MainWidget::xMinChanged(int value) | |
212 | { |
|
205 | { | |
213 | qDebug() << "xMinChanged: " << value; |
|
206 | qDebug() << "xMinChanged: " << value; | |
214 | } |
|
207 | } | |
215 |
|
208 | |||
216 | void MainWidget::xMaxChanged(int value) |
|
209 | void MainWidget::xMaxChanged(int value) | |
217 | { |
|
210 | { | |
218 | qDebug() << "xMaxChanged: " << value; |
|
211 | qDebug() << "xMaxChanged: " << value; | |
219 | } |
|
212 | } | |
220 |
|
213 | |||
221 | void MainWidget::yMinChanged(int value) |
|
214 | void MainWidget::yMinChanged(int value) | |
222 | { |
|
215 | { | |
223 | qDebug() << "yMinChanged: " << value; |
|
216 | qDebug() << "yMinChanged: " << value; | |
224 | } |
|
217 | } | |
225 |
|
218 | |||
226 | void MainWidget::yMaxChanged(int value) |
|
219 | void MainWidget::yMaxChanged(int value) | |
227 | { |
|
220 | { | |
228 | qDebug() << "yMaxChanged: " << value; |
|
221 | qDebug() << "yMaxChanged: " << value; | |
229 | } |
|
222 | } |
@@ -1,42 +1,42 | |||||
1 | #ifndef MAINWIDGET_H |
|
1 | #ifndef MAINWIDGET_H | |
2 | #define MAINWIDGET_H |
|
2 | #define MAINWIDGET_H | |
3 |
|
3 | |||
4 | #include <qchartconfig.h> |
|
4 | #include <qchartconfig.h> | |
5 | #include <qchartwidget.h> |
|
5 | #include <qchartwidget.h> | |
6 | #include <QWidget> |
|
6 | #include <QWidget> | |
7 |
|
7 | |||
8 | class QSpinBox; |
|
8 | class QSpinBox; | |
9 | class QCheckBox; |
|
9 | class QCheckBox; | |
10 |
|
10 | |||
11 | QCHART_USE_NAMESPACE |
|
11 | QCHART_USE_NAMESPACE | |
12 |
|
12 | |||
13 | class MainWidget : public QWidget |
|
13 | class MainWidget : public QWidget | |
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 | public: |
|
16 | public: | |
17 | explicit MainWidget(QWidget *parent = 0); |
|
17 | explicit MainWidget(QWidget *parent = 0); | |
18 |
|
18 | |||
19 | signals: |
|
19 | signals: | |
20 |
|
20 | |||
21 | private slots: |
|
21 | private slots: | |
22 | void chartTypeChanged(int itemIndex); |
|
22 | void chartTypeChanged(int itemIndex); | |
23 | void addSeries(); |
|
23 | void addSeries(); | |
24 | void addSeries(QString series); |
|
24 | void addSeries(QString series, QString data); | |
25 | void testDataChanged(int itemIndex); |
|
25 | void testDataChanged(int itemIndex); | |
26 | void backgroundChanged(int itemIndex); |
|
26 | void backgroundChanged(int itemIndex); | |
27 | void autoScaleChanged(int value); |
|
27 | void autoScaleChanged(int value); | |
28 | void xMinChanged(int value); |
|
28 | void xMinChanged(int value); | |
29 | void xMaxChanged(int value); |
|
29 | void xMaxChanged(int value); | |
30 | void yMinChanged(int value); |
|
30 | void yMinChanged(int value); | |
31 | void yMaxChanged(int value); |
|
31 | void yMaxChanged(int value); | |
32 |
|
32 | |||
33 | private: |
|
33 | private: | |
34 | QChartWidget *m_chartWidget; |
|
34 | QChartWidget *m_chartWidget; | |
35 | QCheckBox *m_autoScaleCheck; |
|
35 | QCheckBox *m_autoScaleCheck; | |
36 | QSpinBox *m_xMinSpin; |
|
36 | QSpinBox *m_xMinSpin; | |
37 | QSpinBox *m_xMaxSpin; |
|
37 | QSpinBox *m_xMaxSpin; | |
38 | QSpinBox *m_yMinSpin; |
|
38 | QSpinBox *m_yMinSpin; | |
39 | QSpinBox *m_yMaxSpin; |
|
39 | QSpinBox *m_yMaxSpin; | |
40 | }; |
|
40 | }; | |
41 |
|
41 | |||
42 | #endif // MAINWIDGET_H |
|
42 | #endif // MAINWIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now