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