##// END OF EJS Templates
Added test data
Tero Ahola -
r16:1913bd8fedc4
parent child
Show More
@@ -33,12 +33,20 MainWidget::MainWidget(QWidget *parent) :
33 33 this, SLOT(chartTypeChanged(int)));
34 34
35 35 // Test data selector
36 QPushButton *fileButton = new QPushButton("From file");
37 QPushButton *urlButton = new QPushButton("From URL");
36 QComboBox *testDataCombo = new QComboBox(this);
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 45 // Chart background
40 46 QComboBox *backgroundCombo = new QComboBox(this);
41 backgroundCombo->addItem("todo: add background types");
47 backgroundCombo->addItem("None");
48 backgroundCombo->addItem("TODO Grid");
49 backgroundCombo->addItem("TODO Image");
42 50 connect(backgroundCombo, SIGNAL(currentIndexChanged(int)),
43 51 this, SLOT(backgroundChanged(int)));
44 52
@@ -71,21 +79,20 MainWidget::MainWidget(QWidget *parent) :
71 79 QGridLayout *grid = new QGridLayout();
72 80 QHBoxLayout *hbox = new QHBoxLayout();
73 81 grid->addWidget(new QLabel("Chart type:"), 0, 0);
74 grid->addWidget(chartTypeCombo, 0, 1, 1, 2);
82 grid->addWidget(chartTypeCombo, 0, 1);
75 83 grid->addWidget(new QLabel("Data:"), 1, 0);
76 grid->addWidget(fileButton, 1, 1);
77 grid->addWidget(urlButton, 1, 2);
84 grid->addWidget(testDataCombo, 1, 1);
78 85 grid->addWidget(new QLabel("Background:"), 2, 0);
79 grid->addWidget(backgroundCombo, 2, 1, 1, 2);
86 grid->addWidget(backgroundCombo, 2, 1);
80 87 grid->addWidget(m_autoScaleCheck, 3, 0);
81 88 grid->addWidget(new QLabel("x min:"), 4, 0);
82 grid->addWidget(m_xMinSpin, 4, 1, 1, 2);
89 grid->addWidget(m_xMinSpin, 4, 1);
83 90 grid->addWidget(new QLabel("x max:"), 5, 0);
84 grid->addWidget(m_xMaxSpin, 5, 1, 1, 2);
91 grid->addWidget(m_xMaxSpin, 5, 1);
85 92 grid->addWidget(new QLabel("y min:"), 6, 0);
86 grid->addWidget(m_yMinSpin, 6, 1, 1, 2);
93 grid->addWidget(m_yMinSpin, 6, 1);
87 94 grid->addWidget(new QLabel("y max:"), 7, 0);
88 grid->addWidget(m_yMaxSpin, 7, 1, 1, 2);
95 grid->addWidget(m_yMaxSpin, 7, 1);
89 96 // add row with empty label to make all the other rows static
90 97 grid->addWidget(new QLabel(""), 8, 0);
91 98 grid->setRowStretch(8, 1);
@@ -98,23 +105,16 MainWidget::MainWidget(QWidget *parent) :
98 105
99 106 m_autoScaleCheck->setChecked(true);
100 107 chartTypeChanged(4);
108 testDataChanged(0);
101 109 }
102 110
103 111 void MainWidget::chartTypeChanged(int itemIndex)
104 112 {
105 113 // TODO: change chart type
106 114 switch (itemIndex) {
107 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 }
115 case 4:
114 116 m_chartWidget->setType(4);
115 m_chartWidget->setData(data);
116 117 break;
117 }
118 118 default: {
119 119 m_chartWidget->setType(0);
120 120 break;
@@ -122,9 +122,41 void MainWidget::chartTypeChanged(int itemIndex)
122 122 }
123 123 }
124 124
125 void MainWidget::dataChanged(QString itemText)
125 void MainWidget::testDataChanged(int itemIndex)
126 126 {
127 qDebug() << "dataChanged: " << itemText;
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 162 void MainWidget::backgroundChanged(int itemIndex)
@@ -17,7 +17,7 signals:
17 17
18 18 private slots:
19 19 void chartTypeChanged(int itemIndex);
20 void dataChanged(QString itemText);
20 void testDataChanged(int itemIndex);
21 21 void backgroundChanged(int itemIndex);
22 22 void autoScaleChanged(int value);
23 23 void xMinChanged(int value);
General Comments 0
You need to be logged in to leave comments. Login now