@@ -33,12 +33,20 MainWidget::MainWidget(QWidget *parent) : | |||||
33 | this, SLOT(chartTypeChanged(int))); |
|
33 | this, SLOT(chartTypeChanged(int))); | |
34 |
|
34 | |||
35 | // Test data selector |
|
35 | // Test data selector | |
36 | QPushButton *fileButton = new QPushButton("From file"); |
|
36 | QComboBox *testDataCombo = new QComboBox(this); | |
37 | QPushButton *urlButton = new QPushButton("From URL"); |
|
37 | testDataCombo->addItem("linear"); | |
|
38 | testDataCombo->addItem("SIN"); | |||
|
39 | testDataCombo->addItem("SIN + random component"); | |||
|
40 | testDataCombo->addItem("TODO From file..."); | |||
|
41 | testDataCombo->addItem("TODO From URL..."); | |||
|
42 | connect(testDataCombo, SIGNAL(currentIndexChanged(int)), | |||
|
43 | this, SLOT(testDataChanged(int))); | |||
38 |
|
44 | |||
39 | // Chart background |
|
45 | // Chart background | |
40 | QComboBox *backgroundCombo = new QComboBox(this); |
|
46 | QComboBox *backgroundCombo = new QComboBox(this); | |
41 |
backgroundCombo->addItem(" |
|
47 | backgroundCombo->addItem("None"); | |
|
48 | backgroundCombo->addItem("TODO Grid"); | |||
|
49 | backgroundCombo->addItem("TODO Image"); | |||
42 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), |
|
50 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), | |
43 | this, SLOT(backgroundChanged(int))); |
|
51 | this, SLOT(backgroundChanged(int))); | |
44 |
|
52 | |||
@@ -71,21 +79,20 MainWidget::MainWidget(QWidget *parent) : | |||||
71 | QGridLayout *grid = new QGridLayout(); |
|
79 | QGridLayout *grid = new QGridLayout(); | |
72 | QHBoxLayout *hbox = new QHBoxLayout(); |
|
80 | QHBoxLayout *hbox = new QHBoxLayout(); | |
73 | grid->addWidget(new QLabel("Chart type:"), 0, 0); |
|
81 | grid->addWidget(new QLabel("Chart type:"), 0, 0); | |
74 |
grid->addWidget(chartTypeCombo, 0, 1 |
|
82 | grid->addWidget(chartTypeCombo, 0, 1); | |
75 | grid->addWidget(new QLabel("Data:"), 1, 0); |
|
83 | grid->addWidget(new QLabel("Data:"), 1, 0); | |
76 |
grid->addWidget( |
|
84 | grid->addWidget(testDataCombo, 1, 1); | |
77 | grid->addWidget(urlButton, 1, 2); |
|
|||
78 | grid->addWidget(new QLabel("Background:"), 2, 0); |
|
85 | grid->addWidget(new QLabel("Background:"), 2, 0); | |
79 |
grid->addWidget(backgroundCombo, 2, 1 |
|
86 | grid->addWidget(backgroundCombo, 2, 1); | |
80 | grid->addWidget(m_autoScaleCheck, 3, 0); |
|
87 | grid->addWidget(m_autoScaleCheck, 3, 0); | |
81 | grid->addWidget(new QLabel("x min:"), 4, 0); |
|
88 | grid->addWidget(new QLabel("x min:"), 4, 0); | |
82 |
grid->addWidget(m_xMinSpin, 4, 1 |
|
89 | grid->addWidget(m_xMinSpin, 4, 1); | |
83 | grid->addWidget(new QLabel("x max:"), 5, 0); |
|
90 | grid->addWidget(new QLabel("x max:"), 5, 0); | |
84 |
grid->addWidget(m_xMaxSpin, 5, 1 |
|
91 | grid->addWidget(m_xMaxSpin, 5, 1); | |
85 | grid->addWidget(new QLabel("y min:"), 6, 0); |
|
92 | grid->addWidget(new QLabel("y min:"), 6, 0); | |
86 |
grid->addWidget(m_yMinSpin, 6, 1 |
|
93 | grid->addWidget(m_yMinSpin, 6, 1); | |
87 | grid->addWidget(new QLabel("y max:"), 7, 0); |
|
94 | grid->addWidget(new QLabel("y max:"), 7, 0); | |
88 |
grid->addWidget(m_yMaxSpin, 7, 1 |
|
95 | grid->addWidget(m_yMaxSpin, 7, 1); | |
89 | // add row with empty label to make all the other rows static |
|
96 | // add row with empty label to make all the other rows static | |
90 | grid->addWidget(new QLabel(""), 8, 0); |
|
97 | grid->addWidget(new QLabel(""), 8, 0); | |
91 | grid->setRowStretch(8, 1); |
|
98 | grid->setRowStretch(8, 1); | |
@@ -98,23 +105,16 MainWidget::MainWidget(QWidget *parent) : | |||||
98 |
|
105 | |||
99 | m_autoScaleCheck->setChecked(true); |
|
106 | m_autoScaleCheck->setChecked(true); | |
100 | chartTypeChanged(4); |
|
107 | chartTypeChanged(4); | |
|
108 | testDataChanged(0); | |||
101 | } |
|
109 | } | |
102 |
|
110 | |||
103 | void MainWidget::chartTypeChanged(int itemIndex) |
|
111 | void MainWidget::chartTypeChanged(int itemIndex) | |
104 | { |
|
112 | { | |
105 | // TODO: change chart type |
|
113 | // TODO: change chart type | |
106 | switch (itemIndex) { |
|
114 | switch (itemIndex) { | |
107 |
case 4: |
|
115 | case 4: | |
108 | QList<QChartDataPoint> data; |
|
|||
109 | for (int x = 0; x < 1000; ++x) { |
|
|||
110 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
|||
111 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
|||
112 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
|||
113 | } |
|
|||
114 | m_chartWidget->setType(4); |
|
116 | m_chartWidget->setType(4); | |
115 | m_chartWidget->setData(data); |
|
|||
116 | break; |
|
117 | break; | |
117 | } |
|
|||
118 | default: { |
|
118 | default: { | |
119 | m_chartWidget->setType(0); |
|
119 | m_chartWidget->setType(0); | |
120 | break; |
|
120 | break; | |
@@ -122,9 +122,41 void MainWidget::chartTypeChanged(int itemIndex) | |||||
122 | } |
|
122 | } | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 |
void MainWidget:: |
|
125 | void MainWidget::testDataChanged(int itemIndex) | |
126 | { |
|
126 | { | |
127 |
qDebug() << " |
|
127 | qDebug() << "testDataChanged: " << itemIndex; | |
|
128 | ||||
|
129 | switch (itemIndex) { | |||
|
130 | case 0: { | |||
|
131 | QList<QChartDataPoint> data; | |||
|
132 | for (int x = 0; x < 20; x++) { | |||
|
133 | data.append(QChartDataPoint() << x << x / 2); | |||
|
134 | } | |||
|
135 | m_chartWidget->setData(data); | |||
|
136 | break; | |||
|
137 | } | |||
|
138 | case 1: { | |||
|
139 | QList<QChartDataPoint> data; | |||
|
140 | for (int x = 0; x < 100; x++) { | |||
|
141 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); | |||
|
142 | } | |||
|
143 | m_chartWidget->setData(data); | |||
|
144 | break; | |||
|
145 | } | |||
|
146 | case 2: { | |||
|
147 | QList<QChartDataPoint> data; | |||
|
148 | for (int x = 0; x < 1000; x++) { | |||
|
149 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |||
|
150 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |||
|
151 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |||
|
152 | } | |||
|
153 | m_chartWidget->setData(data); | |||
|
154 | break; | |||
|
155 | } | |||
|
156 | default: | |||
|
157 | break; | |||
|
158 | } | |||
|
159 | ||||
128 | } |
|
160 | } | |
129 |
|
161 | |||
130 | void MainWidget::backgroundChanged(int itemIndex) |
|
162 | void MainWidget::backgroundChanged(int itemIndex) |
@@ -17,7 +17,7 signals: | |||||
17 |
|
17 | |||
18 | private slots: |
|
18 | private slots: | |
19 | void chartTypeChanged(int itemIndex); |
|
19 | void chartTypeChanged(int itemIndex); | |
20 |
void |
|
20 | void testDataChanged(int itemIndex); | |
21 | void backgroundChanged(int itemIndex); |
|
21 | void backgroundChanged(int itemIndex); | |
22 | void autoScaleChanged(int value); |
|
22 | void autoScaleChanged(int value); | |
23 | void xMinChanged(int value); |
|
23 | void xMinChanged(int value); |
General Comments 0
You need to be logged in to leave comments.
Login now