@@ -0,0 +1,54 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Charts module. | |
|
8 | ** | |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
|
12 | ** agreement between you and The Qt Company. | |
|
13 | ** | |
|
14 | ** If you have questions regarding the use of this file, please use | |
|
15 | ** contact form at http://qt.io | |
|
16 | ** | |
|
17 | ****************************************************************************/ | |
|
18 | ||
|
19 | #include "chartview.h" | |
|
20 | #include <QtGui/QMouseEvent> | |
|
21 | ||
|
22 | QT_CHARTS_USE_NAMESPACE | |
|
23 | ||
|
24 | ChartView::ChartView(QWidget *parent) : | |
|
25 | QChartView(parent) | |
|
26 | { | |
|
27 | } | |
|
28 | ||
|
29 | void ChartView::keyPressEvent(QKeyEvent *event) | |
|
30 | { | |
|
31 | switch (event->key()) { | |
|
32 | case Qt::Key_Plus: | |
|
33 | chart()->zoomIn(); | |
|
34 | break; | |
|
35 | case Qt::Key_Minus: | |
|
36 | chart()->zoomOut(); | |
|
37 | break; | |
|
38 | case Qt::Key_Left: | |
|
39 | chart()->scroll(-1.0, 0); | |
|
40 | break; | |
|
41 | case Qt::Key_Right: | |
|
42 | chart()->scroll(1.0, 0); | |
|
43 | break; | |
|
44 | case Qt::Key_Up: | |
|
45 | chart()->scroll(0, 1.0); | |
|
46 | break; | |
|
47 | case Qt::Key_Down: | |
|
48 | chart()->scroll(0, -1.0); | |
|
49 | break; | |
|
50 | default: | |
|
51 | QGraphicsView::keyPressEvent(event); | |
|
52 | break; | |
|
53 | } | |
|
54 | } |
@@ -0,0 +1,35 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Charts module. | |
|
8 | ** | |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
|
12 | ** agreement between you and The Qt Company. | |
|
13 | ** | |
|
14 | ** If you have questions regarding the use of this file, please use | |
|
15 | ** contact form at http://qt.io | |
|
16 | ** | |
|
17 | ****************************************************************************/ | |
|
18 | ||
|
19 | #ifndef CHARTVIEW_H | |
|
20 | #define CHARTVIEW_H | |
|
21 | ||
|
22 | #include <QtCharts/QChartView> | |
|
23 | ||
|
24 | QT_CHARTS_USE_NAMESPACE | |
|
25 | ||
|
26 | class ChartView : public QChartView | |
|
27 | { | |
|
28 | public: | |
|
29 | ChartView(QWidget *parent = 0); | |
|
30 | ||
|
31 | protected: | |
|
32 | void keyPressEvent(QKeyEvent *event); | |
|
33 | }; | |
|
34 | ||
|
35 | #endif |
@@ -0,0 +1,112 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Charts module. | |
|
8 | ** | |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
|
12 | ** agreement between you and The Qt Company. | |
|
13 | ** | |
|
14 | ** If you have questions regarding the use of this file, please use | |
|
15 | ** contact form at http://qt.io | |
|
16 | ** | |
|
17 | ****************************************************************************/ | |
|
18 | ||
|
19 | #include "datasource.h" | |
|
20 | #include <QtCore/QtMath> | |
|
21 | ||
|
22 | QT_CHARTS_USE_NAMESPACE | |
|
23 | ||
|
24 | DataSource::DataSource(QObject *parent) : | |
|
25 | QObject(parent), | |
|
26 | m_index(-1) | |
|
27 | { | |
|
28 | } | |
|
29 | ||
|
30 | void DataSource::update(QXYSeries *series, int seriesIndex) | |
|
31 | { | |
|
32 | if (series) { | |
|
33 | const QVector<QVector<QPointF> > &seriesData = m_data.at(seriesIndex); | |
|
34 | if (seriesIndex == 0) | |
|
35 | m_index++; | |
|
36 | if (m_index > seriesData.count() - 1) | |
|
37 | m_index = 0; | |
|
38 | ||
|
39 | QVector<QPointF> points = seriesData.at(m_index); | |
|
40 | // Use replace instead of clear + append, it's optimized for performance | |
|
41 | series->replace(points); | |
|
42 | } | |
|
43 | } | |
|
44 | ||
|
45 | void DataSource::handleSceneChanged() | |
|
46 | { | |
|
47 | m_dataUpdater.start(); | |
|
48 | } | |
|
49 | ||
|
50 | void DataSource::updateAllSeries() | |
|
51 | { | |
|
52 | static int frameCount = 0; | |
|
53 | static QString labelText = QStringLiteral("FPS: %1"); | |
|
54 | ||
|
55 | for (int i = 0; i < m_seriesList->size(); i++) | |
|
56 | update(m_seriesList->value(i), i); | |
|
57 | ||
|
58 | frameCount++; | |
|
59 | int elapsed = m_fpsTimer.elapsed(); | |
|
60 | if (elapsed >= 1000) { | |
|
61 | elapsed = m_fpsTimer.restart(); | |
|
62 | qreal fps = qreal(0.1 * int(10000.0 * (qreal(frameCount) / qreal(elapsed)))); | |
|
63 | m_fpsLabel->setText(labelText.arg(QString::number(fps, 'f', 1))); | |
|
64 | m_fpsLabel->adjustSize(); | |
|
65 | frameCount = 0; | |
|
66 | } | |
|
67 | } | |
|
68 | ||
|
69 | void DataSource::startUpdates(QList<QXYSeries *> &seriesList, QLabel *fpsLabel) | |
|
70 | { | |
|
71 | m_seriesList = &seriesList; | |
|
72 | m_fpsLabel = fpsLabel; | |
|
73 | ||
|
74 | m_dataUpdater.setInterval(0); | |
|
75 | m_dataUpdater.setSingleShot(true); | |
|
76 | QObject::connect(&m_dataUpdater, &QTimer::timeout, | |
|
77 | this, &DataSource::updateAllSeries); | |
|
78 | ||
|
79 | m_fpsTimer.start(); | |
|
80 | ||
|
81 | m_data.resize(maxSeriesCount); | |
|
82 | updateAllSeries(); | |
|
83 | } | |
|
84 | ||
|
85 | void DataSource::generateData(int seriesIndex, int rowCount, int colCount) | |
|
86 | { | |
|
87 | // Remove previous data | |
|
88 | QVector<QVector<QPointF> > &seriesData = m_data[seriesIndex]; | |
|
89 | seriesData.clear(); | |
|
90 | seriesData.reserve(rowCount); | |
|
91 | ||
|
92 | qreal xAdjustment = 20.0 / (colCount * rowCount); | |
|
93 | qreal yMultiplier = 3.0 / qreal(maxSeriesCount); | |
|
94 | ||
|
95 | // Append the new data depending on the type | |
|
96 | qreal height = qreal(seriesIndex) * (10.0 / qreal(maxSeriesCount)) + 0.3; | |
|
97 | for (int i(0); i < rowCount; i++) { | |
|
98 | QVector<QPointF> points; | |
|
99 | points.reserve(colCount); | |
|
100 | for (int j(0); j < colCount; j++) { | |
|
101 | qreal x(0); | |
|
102 | qreal y(0); | |
|
103 | // data with sin + random component | |
|
104 | y = height + (yMultiplier * qSin(3.14159265358979 / 50 * j) | |
|
105 | + (yMultiplier * (qreal) rand() / (qreal) RAND_MAX)); | |
|
106 | // 0.000001 added to make values logaxis compatible | |
|
107 | x = 0.000001 + 20.0 * (qreal(j) / qreal(colCount)) + (xAdjustment * qreal(i)); | |
|
108 | points.append(QPointF(x, y)); | |
|
109 | } | |
|
110 | seriesData.append(points); | |
|
111 | } | |
|
112 | } |
@@ -0,0 +1,55 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Charts module. | |
|
8 | ** | |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
|
12 | ** agreement between you and The Qt Company. | |
|
13 | ** | |
|
14 | ** If you have questions regarding the use of this file, please use | |
|
15 | ** contact form at http://qt.io | |
|
16 | ** | |
|
17 | ****************************************************************************/ | |
|
18 | ||
|
19 | #ifndef DATASOURCE_H | |
|
20 | #define DATASOURCE_H | |
|
21 | ||
|
22 | #include <QtCore/QObject> | |
|
23 | #include <QtCharts/QXYSeries> | |
|
24 | #include <QtWidgets/QLabel> | |
|
25 | #include <QtCore/QElapsedTimer> | |
|
26 | #include <QtCore/QTimer> | |
|
27 | ||
|
28 | QT_CHARTS_USE_NAMESPACE | |
|
29 | ||
|
30 | const int maxSeriesCount = 10; | |
|
31 | ||
|
32 | class DataSource : public QObject | |
|
33 | { | |
|
34 | Q_OBJECT | |
|
35 | public: | |
|
36 | explicit DataSource(QObject *parent = 0); | |
|
37 | ||
|
38 | void startUpdates(QList<QXYSeries *> &seriesList, QLabel *fpsLabel); | |
|
39 | ||
|
40 | public slots: | |
|
41 | void generateData(int seriesIndex, int rowCount, int colCount); | |
|
42 | void update(QXYSeries *series, int seriesIndex); | |
|
43 | void handleSceneChanged(); | |
|
44 | void updateAllSeries(); | |
|
45 | ||
|
46 | private: | |
|
47 | QVector<QVector<QVector<QPointF> > > m_data; | |
|
48 | int m_index; | |
|
49 | QList<QXYSeries *> *m_seriesList; | |
|
50 | QLabel *m_fpsLabel; | |
|
51 | QElapsedTimer m_fpsTimer; | |
|
52 | QTimer m_dataUpdater; | |
|
53 | }; | |
|
54 | ||
|
55 | #endif // DATASOURCE_H |
@@ -0,0 +1,29 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Charts module. | |
|
8 | ** | |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
|
12 | ** agreement between you and The Qt Company. | |
|
13 | ** | |
|
14 | ** If you have questions regarding the use of this file, please use | |
|
15 | ** contact form at http://qt.io | |
|
16 | ** | |
|
17 | ****************************************************************************/ | |
|
18 | ||
|
19 | #include "mainwindow.h" | |
|
20 | #include <QtWidgets/QApplication> | |
|
21 | ||
|
22 | int main(int argc, char *argv[]) | |
|
23 | { | |
|
24 | QApplication a(argc, argv); | |
|
25 | MainWindow w; | |
|
26 | w.show(); | |
|
27 | ||
|
28 | return a.exec(); | |
|
29 | } |
This diff has been collapsed as it changes many lines, (515 lines changed) Show them Hide them | |||
@@ -0,0 +1,515 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Charts module. | |
|
8 | ** | |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
|
12 | ** agreement between you and The Qt Company. | |
|
13 | ** | |
|
14 | ** If you have questions regarding the use of this file, please use | |
|
15 | ** contact form at http://qt.io | |
|
16 | ** | |
|
17 | ****************************************************************************/ | |
|
18 | ||
|
19 | #include "mainwindow.h" | |
|
20 | #include "chartview.h" | |
|
21 | #include <QtCharts/QScatterSeries> | |
|
22 | #include <QtCharts/QLineSeries> | |
|
23 | #include <QtCharts/QValueAxis> | |
|
24 | #include <QtCharts/QLogValueAxis> | |
|
25 | #include <QtCharts/QDateTimeAxis> | |
|
26 | #include <QtCharts/QCategoryAxis> | |
|
27 | #include <QtCharts/QChart> | |
|
28 | #include <QtCore/QDebug> | |
|
29 | #include <QtCore/QDateTime> | |
|
30 | ||
|
31 | QT_CHARTS_USE_NAMESPACE | |
|
32 | #include "ui_mainwindow.h" | |
|
33 | ||
|
34 | MainWindow::MainWindow(QWidget *parent) : | |
|
35 | QMainWindow(parent), | |
|
36 | ui(new Ui::MainWindow), | |
|
37 | m_xMin(0.0), | |
|
38 | m_xMax(20.0), | |
|
39 | m_yMin(0.0), | |
|
40 | m_yMax(10.0), | |
|
41 | m_backgroundBrush(new QBrush(Qt::white)), | |
|
42 | m_plotAreaBackgroundBrush(new QBrush(Qt::NoBrush)), | |
|
43 | m_backgroundPen(new QPen(Qt::NoPen)), | |
|
44 | m_plotAreaBackgroundPen(new QPen(Qt::NoPen)), | |
|
45 | m_animationOptions(QChart::NoAnimation), | |
|
46 | m_chart(0), | |
|
47 | m_xAxis(0), | |
|
48 | m_yAxis(0), | |
|
49 | m_xAxisMode(AxisModeValue), | |
|
50 | m_yAxisMode(AxisModeValue), | |
|
51 | m_pointCount(100) | |
|
52 | { | |
|
53 | ui->setupUi(this); | |
|
54 | ||
|
55 | ui->yMinSpin->setValue(m_yMin); | |
|
56 | ui->yMaxSpin->setValue(m_yMax); | |
|
57 | ui->xMinSpin->setValue(m_xMin); | |
|
58 | ui->xMaxSpin->setValue(m_xMax); | |
|
59 | ||
|
60 | initXYValueChart(); | |
|
61 | setXAxis(AxisModeValue); | |
|
62 | setYAxis(AxisModeValue); | |
|
63 | ||
|
64 | connect(ui->yMinSpin, SIGNAL(valueChanged(double)), | |
|
65 | this, SLOT(yMinChanged(double))); | |
|
66 | connect(ui->yMaxSpin, SIGNAL(valueChanged(double)), | |
|
67 | this, SLOT(yMaxChanged(double))); | |
|
68 | connect(ui->xMinSpin, SIGNAL(valueChanged(double)), | |
|
69 | this, SLOT(xMinChanged(double))); | |
|
70 | connect(ui->xMaxSpin, SIGNAL(valueChanged(double)), | |
|
71 | this, SLOT(xMaxChanged(double))); | |
|
72 | connect(ui->animationsComboBox, SIGNAL(currentIndexChanged(int)), | |
|
73 | this, SLOT(animationIndexChanged(int))); | |
|
74 | connect(ui->xAxisComboBox, SIGNAL(currentIndexChanged(int)), | |
|
75 | this, SLOT(xAxisIndexChanged(int))); | |
|
76 | connect(ui->yAxisComboBox, SIGNAL(currentIndexChanged(int)), | |
|
77 | this, SLOT(yAxisIndexChanged(int))); | |
|
78 | connect(ui->backgroundComboBox, SIGNAL(currentIndexChanged(int)), | |
|
79 | this, SLOT(backgroundIndexChanged(int))); | |
|
80 | connect(ui->plotAreaComboBox, SIGNAL(currentIndexChanged(int)), | |
|
81 | this, SLOT(plotAreaIndexChanged(int))); | |
|
82 | connect(ui->themeComboBox, SIGNAL(currentIndexChanged(int)), | |
|
83 | this, SLOT(themeIndexChanged(int))); | |
|
84 | connect(ui->addSeriesButton, SIGNAL(clicked(bool)), | |
|
85 | this, SLOT(addSeriesClicked())); | |
|
86 | connect(ui->addGLSeriesButton, SIGNAL(clicked(bool)), | |
|
87 | this, SLOT(addGLSeriesClicked())); | |
|
88 | connect(ui->removeSeriesButton, SIGNAL(clicked(bool)), | |
|
89 | this, SLOT(removeSeriesClicked())); | |
|
90 | connect(ui->countComboBox, SIGNAL(currentIndexChanged(int)), | |
|
91 | this, SLOT(countIndexChanged(int))); | |
|
92 | connect(ui->colorsComboBox, SIGNAL(currentIndexChanged(int)), | |
|
93 | this, SLOT(colorIndexChanged(int))); | |
|
94 | connect(ui->widthComboBox, SIGNAL(currentIndexChanged(int)), | |
|
95 | this, SLOT(widthIndexChanged(int))); | |
|
96 | ||
|
97 | ui->chartView->setChart(m_chart); | |
|
98 | ui->chartView->setRenderHint(QPainter::Antialiasing); | |
|
99 | ||
|
100 | QObject::connect(m_chart->scene(), &QGraphicsScene::changed, | |
|
101 | &m_dataSource, &DataSource::handleSceneChanged); | |
|
102 | ||
|
103 | m_dataSource.startUpdates(m_seriesList, ui->fpsLabel); | |
|
104 | } | |
|
105 | ||
|
106 | MainWindow::~MainWindow() | |
|
107 | { | |
|
108 | delete ui; | |
|
109 | } | |
|
110 | ||
|
111 | void MainWindow::initXYValueChart() | |
|
112 | { | |
|
113 | m_chart = new QChart(); | |
|
114 | m_chart->setTitle("Use arrow keys to scroll and +/- to zoom"); | |
|
115 | m_chart->setAnimationOptions(m_animationOptions); | |
|
116 | m_chart->setBackgroundBrush(*m_backgroundBrush); | |
|
117 | m_chart->setBackgroundPen(*m_backgroundPen); | |
|
118 | m_chart->setPlotAreaBackgroundBrush(*m_plotAreaBackgroundBrush); | |
|
119 | m_chart->setPlotAreaBackgroundPen(*m_plotAreaBackgroundPen); | |
|
120 | } | |
|
121 | ||
|
122 | void MainWindow::setXAxis(MainWindow::AxisMode mode) | |
|
123 | { | |
|
124 | if (m_xAxis) { | |
|
125 | m_chart->removeAxis(m_xAxis); | |
|
126 | delete m_xAxis; | |
|
127 | m_xAxis = 0; | |
|
128 | } | |
|
129 | ||
|
130 | m_xAxisMode = mode; | |
|
131 | ||
|
132 | switch (m_xAxisMode) { | |
|
133 | case AxisModeNone: | |
|
134 | return; | |
|
135 | case AxisModeValue: | |
|
136 | m_xAxis = new QValueAxis(); | |
|
137 | break; | |
|
138 | case AxisModeLogValue: | |
|
139 | m_xAxis = new QLogValueAxis(); | |
|
140 | break; | |
|
141 | case AxisModeDateTime: | |
|
142 | m_xAxis = new QDateTimeAxis(); | |
|
143 | break; | |
|
144 | case AxisModeCategory: | |
|
145 | m_xAxis = new QCategoryAxis(); | |
|
146 | applyCategories(); | |
|
147 | break; | |
|
148 | default: | |
|
149 | qWarning() << "Unsupported AxisMode"; | |
|
150 | return; | |
|
151 | } | |
|
152 | ||
|
153 | m_chart->addAxis(m_xAxis, Qt::AlignBottom); | |
|
154 | ||
|
155 | foreach (QAbstractSeries *series, m_seriesList) | |
|
156 | series->attachAxis(m_xAxis); | |
|
157 | ||
|
158 | applyRanges(); | |
|
159 | } | |
|
160 | ||
|
161 | void MainWindow::setYAxis(MainWindow::AxisMode mode) | |
|
162 | { | |
|
163 | if (m_yAxis) { | |
|
164 | m_chart->removeAxis(m_yAxis); | |
|
165 | delete m_yAxis; | |
|
166 | m_yAxis = 0; | |
|
167 | } | |
|
168 | ||
|
169 | m_yAxisMode = mode; | |
|
170 | ||
|
171 | switch (m_yAxisMode) { | |
|
172 | case AxisModeNone: | |
|
173 | return; | |
|
174 | case AxisModeValue: | |
|
175 | m_yAxis = new QValueAxis(); | |
|
176 | break; | |
|
177 | case AxisModeLogValue: | |
|
178 | m_yAxis = new QLogValueAxis(); | |
|
179 | break; | |
|
180 | case AxisModeDateTime: | |
|
181 | m_yAxis = new QDateTimeAxis(); | |
|
182 | break; | |
|
183 | case AxisModeCategory: | |
|
184 | m_yAxis = new QCategoryAxis(); | |
|
185 | applyCategories(); | |
|
186 | break; | |
|
187 | default: | |
|
188 | qWarning() << "Unsupported AxisMode"; | |
|
189 | return; | |
|
190 | } | |
|
191 | ||
|
192 | m_chart->addAxis(m_yAxis, Qt::AlignLeft); | |
|
193 | ||
|
194 | foreach (QAbstractSeries *series, m_seriesList) | |
|
195 | series->attachAxis(m_yAxis); | |
|
196 | ||
|
197 | applyRanges(); | |
|
198 | } | |
|
199 | ||
|
200 | void MainWindow::applyRanges() | |
|
201 | { | |
|
202 | if (m_xAxis) { | |
|
203 | if (m_xAxisMode == AxisModeLogValue) { | |
|
204 | if (m_xMin <= 0) | |
|
205 | m_xMin = 1.0; | |
|
206 | if (m_xMax <= m_xMin) | |
|
207 | m_xMax = m_xMin + 1.0; | |
|
208 | } | |
|
209 | if (m_xAxisMode == AxisModeDateTime) { | |
|
210 | QDateTime dateTimeMin; | |
|
211 | QDateTime dateTimeMax; | |
|
212 | dateTimeMin.setMSecsSinceEpoch(qint64(m_xMin)); | |
|
213 | dateTimeMax.setMSecsSinceEpoch(qint64(m_xMax)); | |
|
214 | m_xAxis->setRange(dateTimeMin, dateTimeMax); | |
|
215 | } else { | |
|
216 | m_xAxis->setRange(m_xMin, m_xMax); | |
|
217 | } | |
|
218 | ui->xMinSpin->setValue(m_xMin); | |
|
219 | ui->xMaxSpin->setValue(m_xMax); | |
|
220 | } | |
|
221 | if (m_yAxis) { | |
|
222 | if (m_yAxisMode == AxisModeLogValue) { | |
|
223 | if (m_yMin <= 0) | |
|
224 | m_yMin = 1.0; | |
|
225 | if (m_yMax <= m_yMin) | |
|
226 | m_yMax = m_yMin + 1.0; | |
|
227 | } | |
|
228 | if (m_yAxisMode == AxisModeDateTime) { | |
|
229 | QDateTime dateTimeMin; | |
|
230 | QDateTime dateTimeMax; | |
|
231 | dateTimeMin.setMSecsSinceEpoch(qint64(m_yMin)); | |
|
232 | dateTimeMax.setMSecsSinceEpoch(qint64(m_yMax)); | |
|
233 | m_yAxis->setRange(dateTimeMin, dateTimeMax); | |
|
234 | } else { | |
|
235 | m_yAxis->setRange(m_yMin, m_yMax); | |
|
236 | } | |
|
237 | ui->yMinSpin->setValue(m_yMin); | |
|
238 | ui->yMaxSpin->setValue(m_yMax); | |
|
239 | } | |
|
240 | } | |
|
241 | ||
|
242 | void MainWindow::xMinChanged(double value) | |
|
243 | { | |
|
244 | m_xMin = value; | |
|
245 | applyRanges(); | |
|
246 | } | |
|
247 | ||
|
248 | void MainWindow::xMaxChanged(double value) | |
|
249 | { | |
|
250 | m_xMax = value; | |
|
251 | applyRanges(); | |
|
252 | } | |
|
253 | ||
|
254 | void MainWindow::yMinChanged(double value) | |
|
255 | { | |
|
256 | m_yMin = value; | |
|
257 | applyRanges(); | |
|
258 | } | |
|
259 | ||
|
260 | void MainWindow::yMaxChanged(double value) | |
|
261 | { | |
|
262 | m_yMax = value; | |
|
263 | applyRanges(); | |
|
264 | } | |
|
265 | ||
|
266 | void MainWindow::animationIndexChanged(int index) | |
|
267 | { | |
|
268 | switch (index) { | |
|
269 | case 0: | |
|
270 | m_animationOptions = QChart::NoAnimation; | |
|
271 | break; | |
|
272 | case 1: | |
|
273 | m_animationOptions = QChart::SeriesAnimations; | |
|
274 | break; | |
|
275 | case 2: | |
|
276 | m_animationOptions = QChart::GridAxisAnimations; | |
|
277 | break; | |
|
278 | case 3: | |
|
279 | m_animationOptions = QChart::AllAnimations; | |
|
280 | break; | |
|
281 | default: | |
|
282 | break; | |
|
283 | } | |
|
284 | ||
|
285 | m_chart->setAnimationOptions(m_animationOptions); | |
|
286 | } | |
|
287 | ||
|
288 | void MainWindow::xRangeChanged(qreal min, qreal max) | |
|
289 | { | |
|
290 | if (!qFuzzyCompare(qreal(ui->xMinSpin->value()), min)) | |
|
291 | ui->xMinSpin->setValue(min); | |
|
292 | if (!qFuzzyCompare(qreal(ui->xMaxSpin->value()), max)) | |
|
293 | ui->xMaxSpin->setValue(max); | |
|
294 | } | |
|
295 | ||
|
296 | void MainWindow::yRangeChanged(qreal min, qreal max) | |
|
297 | { | |
|
298 | if (!qFuzzyCompare(qreal(ui->yMinSpin->value()), min)) | |
|
299 | ui->yMinSpin->setValue(min); | |
|
300 | if (!qFuzzyCompare(qreal(ui->yMaxSpin->value()), max)) | |
|
301 | ui->yMaxSpin->setValue(max); | |
|
302 | } | |
|
303 | ||
|
304 | void MainWindow::xAxisIndexChanged(int index) | |
|
305 | { | |
|
306 | switch (index) { | |
|
307 | case 0: | |
|
308 | setXAxis(AxisModeNone); | |
|
309 | break; | |
|
310 | case 1: | |
|
311 | setXAxis(AxisModeValue); | |
|
312 | break; | |
|
313 | case 2: | |
|
314 | setXAxis(AxisModeLogValue); | |
|
315 | break; | |
|
316 | case 3: | |
|
317 | setXAxis(AxisModeDateTime); | |
|
318 | break; | |
|
319 | case 4: | |
|
320 | setXAxis(AxisModeCategory); | |
|
321 | break; | |
|
322 | default: | |
|
323 | qWarning("Invalid Index!"); | |
|
324 | } | |
|
325 | } | |
|
326 | ||
|
327 | void MainWindow::yAxisIndexChanged(int index) | |
|
328 | { | |
|
329 | switch (index) { | |
|
330 | case 0: | |
|
331 | setYAxis(AxisModeNone); | |
|
332 | break; | |
|
333 | case 1: | |
|
334 | setYAxis(AxisModeValue); | |
|
335 | break; | |
|
336 | case 2: | |
|
337 | setYAxis(AxisModeLogValue); | |
|
338 | break; | |
|
339 | case 3: | |
|
340 | setYAxis(AxisModeDateTime); | |
|
341 | break; | |
|
342 | case 4: | |
|
343 | setYAxis(AxisModeCategory); | |
|
344 | break; | |
|
345 | default: | |
|
346 | qWarning("Invalid Index!"); | |
|
347 | } | |
|
348 | } | |
|
349 | ||
|
350 | void MainWindow::themeIndexChanged(int index) | |
|
351 | { | |
|
352 | m_chart->setTheme(QChart::ChartTheme(index)); | |
|
353 | } | |
|
354 | ||
|
355 | void MainWindow::addSeriesClicked() | |
|
356 | { | |
|
357 | addSeries(false); | |
|
358 | } | |
|
359 | ||
|
360 | void MainWindow::removeSeriesClicked() | |
|
361 | { | |
|
362 | if (m_seriesList.size()) { | |
|
363 | QXYSeries *series = m_seriesList.takeAt(m_seriesList.size() - 1); | |
|
364 | m_chart->removeSeries(series); | |
|
365 | delete series; | |
|
366 | } | |
|
367 | } | |
|
368 | ||
|
369 | void MainWindow::addGLSeriesClicked() | |
|
370 | { | |
|
371 | addSeries(true); | |
|
372 | } | |
|
373 | ||
|
374 | void MainWindow::countIndexChanged(int index) | |
|
375 | { | |
|
376 | m_pointCount = ui->countComboBox->itemText(index).toInt(); | |
|
377 | for (int i = 0; i < m_seriesList.size(); i++) { | |
|
378 | m_dataSource.generateData(i, 2, m_pointCount); | |
|
379 | } | |
|
380 | } | |
|
381 | ||
|
382 | void MainWindow::colorIndexChanged(int index) | |
|
383 | { | |
|
384 | QColor color = QColor(ui->colorsComboBox->itemText(index).toLower()); | |
|
385 | foreach (QXYSeries *series, m_seriesList) { | |
|
386 | if (series->type() == QAbstractSeries::SeriesTypeScatter) { | |
|
387 | QScatterSeries *scatterSeries = static_cast<QScatterSeries *>(series); | |
|
388 | scatterSeries->setBorderColor(color); | |
|
389 | scatterSeries->setColor(color); | |
|
390 | } else { | |
|
391 | series->setColor(color); | |
|
392 | } | |
|
393 | } | |
|
394 | } | |
|
395 | ||
|
396 | void MainWindow::widthIndexChanged(int index) | |
|
397 | { | |
|
398 | int width = ui->widthComboBox->itemText(index).toInt(); | |
|
399 | foreach (QXYSeries *series, m_seriesList) { | |
|
400 | if (series->type() == QAbstractSeries::SeriesTypeScatter) { | |
|
401 | QScatterSeries *scatterSeries = static_cast<QScatterSeries *>(series); | |
|
402 | scatterSeries->setMarkerSize(width); | |
|
403 | } else { | |
|
404 | QColor color = QColor(ui->colorsComboBox->itemText( | |
|
405 | ui->colorsComboBox->currentIndex()).toLower()); | |
|
406 | series->setPen(QPen(QBrush(color), width)); | |
|
407 | } | |
|
408 | } | |
|
409 | } | |
|
410 | ||
|
411 | void MainWindow::backgroundIndexChanged(int index) | |
|
412 | { | |
|
413 | delete m_backgroundBrush; | |
|
414 | delete m_backgroundPen; | |
|
415 | ||
|
416 | switch (index) { | |
|
417 | case 0: | |
|
418 | m_backgroundBrush = new QBrush(Qt::white); | |
|
419 | m_backgroundPen = new QPen(Qt::NoPen); | |
|
420 | break; | |
|
421 | case 1: | |
|
422 | m_backgroundBrush = new QBrush(Qt::blue); | |
|
423 | m_backgroundPen = new QPen(Qt::NoPen); | |
|
424 | break; | |
|
425 | case 2: | |
|
426 | m_backgroundBrush = new QBrush(Qt::yellow); | |
|
427 | m_backgroundPen = new QPen(Qt::black, 2); | |
|
428 | break; | |
|
429 | default: | |
|
430 | break; | |
|
431 | } | |
|
432 | m_chart->setBackgroundBrush(*m_backgroundBrush); | |
|
433 | m_chart->setBackgroundPen(*m_backgroundPen); | |
|
434 | } | |
|
435 | ||
|
436 | void MainWindow::plotAreaIndexChanged(int index) | |
|
437 | { | |
|
438 | delete m_plotAreaBackgroundBrush; | |
|
439 | delete m_plotAreaBackgroundPen; | |
|
440 | ||
|
441 | switch (index) { | |
|
442 | case 0: | |
|
443 | m_plotAreaBackgroundBrush = new QBrush(Qt::green); | |
|
444 | m_plotAreaBackgroundPen = new QPen(Qt::green); | |
|
445 | m_chart->setPlotAreaBackgroundVisible(false); | |
|
446 | break; | |
|
447 | case 1: | |
|
448 | m_plotAreaBackgroundBrush = new QBrush(Qt::magenta); | |
|
449 | m_plotAreaBackgroundPen = new QPen(Qt::NoPen); | |
|
450 | m_chart->setPlotAreaBackgroundVisible(true); | |
|
451 | break; | |
|
452 | case 2: | |
|
453 | m_plotAreaBackgroundBrush = new QBrush(Qt::lightGray); | |
|
454 | m_plotAreaBackgroundPen = new QPen(Qt::red, 6); | |
|
455 | m_chart->setPlotAreaBackgroundVisible(true); | |
|
456 | break; | |
|
457 | default: | |
|
458 | break; | |
|
459 | } | |
|
460 | m_chart->setPlotAreaBackgroundBrush(*m_plotAreaBackgroundBrush); | |
|
461 | m_chart->setPlotAreaBackgroundPen(*m_plotAreaBackgroundPen); | |
|
462 | } | |
|
463 | ||
|
464 | void MainWindow::applyCategories() | |
|
465 | { | |
|
466 | // Basic layout is three categories, extended has five | |
|
467 | if (m_xAxisMode == AxisModeCategory) { | |
|
468 | QCategoryAxis *angCatAxis = static_cast<QCategoryAxis *>(m_xAxis); | |
|
469 | if (angCatAxis->count() == 0) { | |
|
470 | angCatAxis->setStartValue(2); | |
|
471 | angCatAxis->append("Category A", 6); | |
|
472 | angCatAxis->append("Category B", 12); | |
|
473 | angCatAxis->append("Category C", 18); | |
|
474 | } | |
|
475 | } | |
|
476 | ||
|
477 | if (m_yAxisMode == AxisModeCategory) { | |
|
478 | QCategoryAxis *radCatAxis = static_cast<QCategoryAxis *>(m_yAxis); | |
|
479 | if (radCatAxis->count() == 0) { | |
|
480 | radCatAxis->setStartValue(1); | |
|
481 | radCatAxis->append("Category 1", 3); | |
|
482 | radCatAxis->append("Category 2", 4); | |
|
483 | radCatAxis->append("Category 3", 8); | |
|
484 | } | |
|
485 | } | |
|
486 | } | |
|
487 | ||
|
488 | void MainWindow::addSeries(bool gl) | |
|
489 | { | |
|
490 | QColor color = QColor(ui->colorsComboBox->itemText(ui->colorsComboBox->currentIndex()).toLower()); | |
|
491 | int width = ui->widthComboBox->itemText(ui->widthComboBox->currentIndex()).toInt(); | |
|
492 | ||
|
493 | if (m_seriesList.size() < maxSeriesCount) { | |
|
494 | QXYSeries *series; | |
|
495 | if (qrand() % 2) { | |
|
496 | series = new QLineSeries; | |
|
497 | series->setPen(QPen(QBrush(color), width)); | |
|
498 | } else { | |
|
499 | QScatterSeries *scatterSeries = new QScatterSeries; | |
|
500 | scatterSeries->setMarkerSize(width); | |
|
501 | scatterSeries->setBorderColor(color); | |
|
502 | scatterSeries->setBrush(QBrush(color)); | |
|
503 | series = scatterSeries; | |
|
504 | } | |
|
505 | series->setUseOpenGL(gl); | |
|
506 | m_dataSource.generateData(m_seriesList.size(), 2, m_pointCount); | |
|
507 | m_seriesList.append(series); | |
|
508 | m_chart->addSeries(series); | |
|
509 | if (m_xAxis) | |
|
510 | series->attachAxis(m_xAxis); | |
|
511 | if (m_yAxis) | |
|
512 | series->attachAxis(m_yAxis); | |
|
513 | applyRanges(); | |
|
514 | } | |
|
515 | } |
@@ -0,0 +1,106 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Charts module. | |
|
8 | ** | |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
|
12 | ** agreement between you and The Qt Company. | |
|
13 | ** | |
|
14 | ** If you have questions regarding the use of this file, please use | |
|
15 | ** contact form at http://qt.io | |
|
16 | ** | |
|
17 | ****************************************************************************/ | |
|
18 | ||
|
19 | #ifndef MAINWINDOW_H | |
|
20 | #define MAINWINDOW_H | |
|
21 | ||
|
22 | #include "datasource.h" | |
|
23 | #include <QtWidgets/QMainWindow> | |
|
24 | #include <QtCharts/QChart> | |
|
25 | ||
|
26 | QT_BEGIN_NAMESPACE | |
|
27 | class QBrush; | |
|
28 | class QPen; | |
|
29 | ||
|
30 | namespace Ui { | |
|
31 | class MainWindow; | |
|
32 | } | |
|
33 | QT_END_NAMESPACE | |
|
34 | ||
|
35 | ||
|
36 | QT_CHARTS_USE_NAMESPACE | |
|
37 | ||
|
38 | class MainWindow : public QMainWindow | |
|
39 | { | |
|
40 | Q_OBJECT | |
|
41 | ||
|
42 | public: | |
|
43 | explicit MainWindow(QWidget *parent = 0); | |
|
44 | ~MainWindow(); | |
|
45 | ||
|
46 | public slots: | |
|
47 | void xMinChanged(double value); | |
|
48 | void xMaxChanged(double value); | |
|
49 | void yMinChanged(double value); | |
|
50 | void yMaxChanged(double value); | |
|
51 | void animationIndexChanged(int index); | |
|
52 | void xRangeChanged(qreal min, qreal max); | |
|
53 | void yRangeChanged(qreal min, qreal max); | |
|
54 | void xAxisIndexChanged(int index); | |
|
55 | void yAxisIndexChanged(int index); | |
|
56 | void backgroundIndexChanged(int index); | |
|
57 | void plotAreaIndexChanged(int index); | |
|
58 | void themeIndexChanged(int index); | |
|
59 | void addSeriesClicked(); | |
|
60 | void removeSeriesClicked(); | |
|
61 | void addGLSeriesClicked(); | |
|
62 | void countIndexChanged(int index); | |
|
63 | void colorIndexChanged(int index); | |
|
64 | void widthIndexChanged(int index); | |
|
65 | ||
|
66 | private: | |
|
67 | enum AxisMode { | |
|
68 | AxisModeNone, | |
|
69 | AxisModeValue, | |
|
70 | AxisModeLogValue, | |
|
71 | AxisModeDateTime, | |
|
72 | AxisModeCategory | |
|
73 | }; | |
|
74 | ||
|
75 | void initXYValueChart(); | |
|
76 | void setXAxis(AxisMode mode); | |
|
77 | void setYAxis(AxisMode mode); | |
|
78 | ||
|
79 | void applyRanges(); | |
|
80 | void applyCategories(); | |
|
81 | void addSeries(bool gl); | |
|
82 | ||
|
83 | Ui::MainWindow *ui; | |
|
84 | ||
|
85 | qreal m_xMin; | |
|
86 | qreal m_xMax; | |
|
87 | qreal m_yMin; | |
|
88 | qreal m_yMax; | |
|
89 | QBrush *m_backgroundBrush; | |
|
90 | QBrush *m_plotAreaBackgroundBrush; | |
|
91 | QPen *m_backgroundPen; | |
|
92 | QPen *m_plotAreaBackgroundPen; | |
|
93 | QChart::AnimationOptions m_animationOptions; | |
|
94 | ||
|
95 | QChart *m_chart; | |
|
96 | QAbstractAxis *m_xAxis; | |
|
97 | QAbstractAxis *m_yAxis; | |
|
98 | AxisMode m_xAxisMode; | |
|
99 | AxisMode m_yAxisMode; | |
|
100 | ||
|
101 | QList<QXYSeries *> m_seriesList; | |
|
102 | DataSource m_dataSource; | |
|
103 | int m_pointCount; | |
|
104 | }; | |
|
105 | ||
|
106 | #endif // MAINWINDOW_H |
This diff has been collapsed as it changes many lines, (582 lines changed) Show them Hide them | |||
@@ -0,0 +1,582 | |||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
|
2 | <ui version="4.0"> | |
|
3 | <class>MainWindow</class> | |
|
4 | <widget class="QMainWindow" name="MainWindow"> | |
|
5 | <property name="geometry"> | |
|
6 | <rect> | |
|
7 | <x>0</x> | |
|
8 | <y>0</y> | |
|
9 | <width>1047</width> | |
|
10 | <height>643</height> | |
|
11 | </rect> | |
|
12 | </property> | |
|
13 | <property name="windowTitle"> | |
|
14 | <string>MainWindow</string> | |
|
15 | </property> | |
|
16 | <widget class="QWidget" name="centralWidget"> | |
|
17 | <layout class="QHBoxLayout" name="horizontalLayout"> | |
|
18 | <item> | |
|
19 | <widget class="ChartView" name="chartView"/> | |
|
20 | </item> | |
|
21 | <item> | |
|
22 | <widget class="QGroupBox" name="settingsBox"> | |
|
23 | <property name="sizePolicy"> | |
|
24 | <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> | |
|
25 | <horstretch>0</horstretch> | |
|
26 | <verstretch>0</verstretch> | |
|
27 | </sizepolicy> | |
|
28 | </property> | |
|
29 | <property name="minimumSize"> | |
|
30 | <size> | |
|
31 | <width>200</width> | |
|
32 | <height>0</height> | |
|
33 | </size> | |
|
34 | </property> | |
|
35 | <property name="title"> | |
|
36 | <string>Settings</string> | |
|
37 | </property> | |
|
38 | <widget class="QComboBox" name="animationsComboBox"> | |
|
39 | <property name="geometry"> | |
|
40 | <rect> | |
|
41 | <x>10</x> | |
|
42 | <y>170</y> | |
|
43 | <width>181</width> | |
|
44 | <height>20</height> | |
|
45 | </rect> | |
|
46 | </property> | |
|
47 | <item> | |
|
48 | <property name="text"> | |
|
49 | <string>No animations</string> | |
|
50 | </property> | |
|
51 | </item> | |
|
52 | <item> | |
|
53 | <property name="text"> | |
|
54 | <string>Series animation</string> | |
|
55 | </property> | |
|
56 | </item> | |
|
57 | <item> | |
|
58 | <property name="text"> | |
|
59 | <string>Grid animation</string> | |
|
60 | </property> | |
|
61 | </item> | |
|
62 | <item> | |
|
63 | <property name="text"> | |
|
64 | <string>All animations</string> | |
|
65 | </property> | |
|
66 | </item> | |
|
67 | </widget> | |
|
68 | <widget class="QComboBox" name="xAxisComboBox"> | |
|
69 | <property name="geometry"> | |
|
70 | <rect> | |
|
71 | <x>10</x> | |
|
72 | <y>23</y> | |
|
73 | <width>181</width> | |
|
74 | <height>20</height> | |
|
75 | </rect> | |
|
76 | </property> | |
|
77 | <property name="editable"> | |
|
78 | <bool>false</bool> | |
|
79 | </property> | |
|
80 | <property name="currentText"> | |
|
81 | <string>X Value Axis</string> | |
|
82 | </property> | |
|
83 | <property name="currentIndex"> | |
|
84 | <number>1</number> | |
|
85 | </property> | |
|
86 | <item> | |
|
87 | <property name="text"> | |
|
88 | <string>No X Axis</string> | |
|
89 | </property> | |
|
90 | </item> | |
|
91 | <item> | |
|
92 | <property name="text"> | |
|
93 | <string>X Value Axis</string> | |
|
94 | </property> | |
|
95 | </item> | |
|
96 | <item> | |
|
97 | <property name="text"> | |
|
98 | <string>X Log Axis</string> | |
|
99 | </property> | |
|
100 | </item> | |
|
101 | <item> | |
|
102 | <property name="text"> | |
|
103 | <string>X DateTime Axis</string> | |
|
104 | </property> | |
|
105 | </item> | |
|
106 | <item> | |
|
107 | <property name="text"> | |
|
108 | <string>X Category Axis</string> | |
|
109 | </property> | |
|
110 | </item> | |
|
111 | </widget> | |
|
112 | <widget class="QComboBox" name="yAxisComboBox"> | |
|
113 | <property name="geometry"> | |
|
114 | <rect> | |
|
115 | <x>10</x> | |
|
116 | <y>49</y> | |
|
117 | <width>181</width> | |
|
118 | <height>20</height> | |
|
119 | </rect> | |
|
120 | </property> | |
|
121 | <property name="editable"> | |
|
122 | <bool>false</bool> | |
|
123 | </property> | |
|
124 | <property name="currentText"> | |
|
125 | <string>Y Value Axis</string> | |
|
126 | </property> | |
|
127 | <property name="currentIndex"> | |
|
128 | <number>1</number> | |
|
129 | </property> | |
|
130 | <item> | |
|
131 | <property name="text"> | |
|
132 | <string>No Y Axis</string> | |
|
133 | </property> | |
|
134 | </item> | |
|
135 | <item> | |
|
136 | <property name="text"> | |
|
137 | <string>Y Value Axis</string> | |
|
138 | </property> | |
|
139 | </item> | |
|
140 | <item> | |
|
141 | <property name="text"> | |
|
142 | <string>Y Log Axis</string> | |
|
143 | </property> | |
|
144 | </item> | |
|
145 | <item> | |
|
146 | <property name="text"> | |
|
147 | <string>Y DateTime Axis</string> | |
|
148 | </property> | |
|
149 | </item> | |
|
150 | <item> | |
|
151 | <property name="text"> | |
|
152 | <string>Y Category Axis</string> | |
|
153 | </property> | |
|
154 | </item> | |
|
155 | </widget> | |
|
156 | <widget class="QComboBox" name="backgroundComboBox"> | |
|
157 | <property name="geometry"> | |
|
158 | <rect> | |
|
159 | <x>10</x> | |
|
160 | <y>190</y> | |
|
161 | <width>181</width> | |
|
162 | <height>20</height> | |
|
163 | </rect> | |
|
164 | </property> | |
|
165 | <property name="sizePolicy"> | |
|
166 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | |
|
167 | <horstretch>0</horstretch> | |
|
168 | <verstretch>0</verstretch> | |
|
169 | </sizepolicy> | |
|
170 | </property> | |
|
171 | <property name="currentIndex"> | |
|
172 | <number>0</number> | |
|
173 | </property> | |
|
174 | <item> | |
|
175 | <property name="text"> | |
|
176 | <string>Background: White</string> | |
|
177 | </property> | |
|
178 | </item> | |
|
179 | <item> | |
|
180 | <property name="text"> | |
|
181 | <string>Background: Blue</string> | |
|
182 | </property> | |
|
183 | </item> | |
|
184 | <item> | |
|
185 | <property name="text"> | |
|
186 | <string>Background: Yellow + Black Border</string> | |
|
187 | </property> | |
|
188 | </item> | |
|
189 | </widget> | |
|
190 | <widget class="QComboBox" name="plotAreaComboBox"> | |
|
191 | <property name="geometry"> | |
|
192 | <rect> | |
|
193 | <x>10</x> | |
|
194 | <y>210</y> | |
|
195 | <width>181</width> | |
|
196 | <height>20</height> | |
|
197 | </rect> | |
|
198 | </property> | |
|
199 | <property name="sizePolicy"> | |
|
200 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | |
|
201 | <horstretch>0</horstretch> | |
|
202 | <verstretch>0</verstretch> | |
|
203 | </sizepolicy> | |
|
204 | </property> | |
|
205 | <property name="currentIndex"> | |
|
206 | <number>0</number> | |
|
207 | </property> | |
|
208 | <item> | |
|
209 | <property name="text"> | |
|
210 | <string>PlotArea: Transparent</string> | |
|
211 | </property> | |
|
212 | </item> | |
|
213 | <item> | |
|
214 | <property name="text"> | |
|
215 | <string>PlotArea: Magenta</string> | |
|
216 | </property> | |
|
217 | </item> | |
|
218 | <item> | |
|
219 | <property name="text"> | |
|
220 | <string>PlotArea: Gray + Red Border</string> | |
|
221 | </property> | |
|
222 | </item> | |
|
223 | </widget> | |
|
224 | <widget class="QWidget" name="layoutWidget"> | |
|
225 | <property name="geometry"> | |
|
226 | <rect> | |
|
227 | <x>10</x> | |
|
228 | <y>70</y> | |
|
229 | <width>185</width> | |
|
230 | <height>100</height> | |
|
231 | </rect> | |
|
232 | </property> | |
|
233 | <layout class="QGridLayout" name="gridLayout_2"> | |
|
234 | <item row="2" column="1"> | |
|
235 | <widget class="QDoubleSpinBox" name="yMinSpin"> | |
|
236 | <property name="decimals"> | |
|
237 | <number>5</number> | |
|
238 | </property> | |
|
239 | <property name="minimum"> | |
|
240 | <double>-999999999.000000000000000</double> | |
|
241 | </property> | |
|
242 | <property name="maximum"> | |
|
243 | <double>999999999.000000000000000</double> | |
|
244 | </property> | |
|
245 | <property name="singleStep"> | |
|
246 | <double>1.000000000000000</double> | |
|
247 | </property> | |
|
248 | </widget> | |
|
249 | </item> | |
|
250 | <item row="3" column="0"> | |
|
251 | <widget class="QLabel" name="label_11"> | |
|
252 | <property name="text"> | |
|
253 | <string>Y max</string> | |
|
254 | </property> | |
|
255 | </widget> | |
|
256 | </item> | |
|
257 | <item row="2" column="0"> | |
|
258 | <widget class="QLabel" name="label_12"> | |
|
259 | <property name="text"> | |
|
260 | <string>Y min</string> | |
|
261 | </property> | |
|
262 | </widget> | |
|
263 | </item> | |
|
264 | <item row="1" column="0"> | |
|
265 | <widget class="QLabel" name="label_5"> | |
|
266 | <property name="text"> | |
|
267 | <string>X max</string> | |
|
268 | </property> | |
|
269 | </widget> | |
|
270 | </item> | |
|
271 | <item row="0" column="1"> | |
|
272 | <widget class="QDoubleSpinBox" name="xMinSpin"> | |
|
273 | <property name="decimals"> | |
|
274 | <number>5</number> | |
|
275 | </property> | |
|
276 | <property name="minimum"> | |
|
277 | <double>-999999999.000000000000000</double> | |
|
278 | </property> | |
|
279 | <property name="maximum"> | |
|
280 | <double>999999999.000000000000000</double> | |
|
281 | </property> | |
|
282 | <property name="singleStep"> | |
|
283 | <double>1.000000000000000</double> | |
|
284 | </property> | |
|
285 | </widget> | |
|
286 | </item> | |
|
287 | <item row="0" column="0"> | |
|
288 | <widget class="QLabel" name="label_4"> | |
|
289 | <property name="text"> | |
|
290 | <string>X min</string> | |
|
291 | </property> | |
|
292 | </widget> | |
|
293 | </item> | |
|
294 | <item row="3" column="1"> | |
|
295 | <widget class="QDoubleSpinBox" name="yMaxSpin"> | |
|
296 | <property name="decimals"> | |
|
297 | <number>5</number> | |
|
298 | </property> | |
|
299 | <property name="minimum"> | |
|
300 | <double>-999999999.000000000000000</double> | |
|
301 | </property> | |
|
302 | <property name="maximum"> | |
|
303 | <double>999999999.000000000000000</double> | |
|
304 | </property> | |
|
305 | <property name="singleStep"> | |
|
306 | <double>1.000000000000000</double> | |
|
307 | </property> | |
|
308 | </widget> | |
|
309 | </item> | |
|
310 | <item row="1" column="1"> | |
|
311 | <widget class="QDoubleSpinBox" name="xMaxSpin"> | |
|
312 | <property name="decimals"> | |
|
313 | <number>5</number> | |
|
314 | </property> | |
|
315 | <property name="minimum"> | |
|
316 | <double>-999999999.000000000000000</double> | |
|
317 | </property> | |
|
318 | <property name="maximum"> | |
|
319 | <double>999999999.000000000000000</double> | |
|
320 | </property> | |
|
321 | <property name="singleStep"> | |
|
322 | <double>1.000000000000000</double> | |
|
323 | </property> | |
|
324 | </widget> | |
|
325 | </item> | |
|
326 | </layout> | |
|
327 | </widget> | |
|
328 | <widget class="QComboBox" name="themeComboBox"> | |
|
329 | <property name="geometry"> | |
|
330 | <rect> | |
|
331 | <x>10</x> | |
|
332 | <y>230</y> | |
|
333 | <width>181</width> | |
|
334 | <height>20</height> | |
|
335 | </rect> | |
|
336 | </property> | |
|
337 | <property name="sizePolicy"> | |
|
338 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | |
|
339 | <horstretch>0</horstretch> | |
|
340 | <verstretch>0</verstretch> | |
|
341 | </sizepolicy> | |
|
342 | </property> | |
|
343 | <property name="currentIndex"> | |
|
344 | <number>0</number> | |
|
345 | </property> | |
|
346 | <item> | |
|
347 | <property name="text"> | |
|
348 | <string>Theme: Light</string> | |
|
349 | </property> | |
|
350 | </item> | |
|
351 | <item> | |
|
352 | <property name="text"> | |
|
353 | <string>Theme: Blue Cerulean</string> | |
|
354 | </property> | |
|
355 | </item> | |
|
356 | <item> | |
|
357 | <property name="text"> | |
|
358 | <string>Theme: Dark</string> | |
|
359 | </property> | |
|
360 | </item> | |
|
361 | <item> | |
|
362 | <property name="text"> | |
|
363 | <string>Theme: Brown Sand</string> | |
|
364 | </property> | |
|
365 | </item> | |
|
366 | <item> | |
|
367 | <property name="text"> | |
|
368 | <string>Theme: Blue Ncs</string> | |
|
369 | </property> | |
|
370 | </item> | |
|
371 | <item> | |
|
372 | <property name="text"> | |
|
373 | <string>Theme: High Contrast</string> | |
|
374 | </property> | |
|
375 | </item> | |
|
376 | <item> | |
|
377 | <property name="text"> | |
|
378 | <string>Theme: Blue Icy</string> | |
|
379 | </property> | |
|
380 | </item> | |
|
381 | <item> | |
|
382 | <property name="text"> | |
|
383 | <string>Theme: Qt</string> | |
|
384 | </property> | |
|
385 | </item> | |
|
386 | </widget> | |
|
387 | <widget class="QPushButton" name="addSeriesButton"> | |
|
388 | <property name="geometry"> | |
|
389 | <rect> | |
|
390 | <x>100</x> | |
|
391 | <y>280</y> | |
|
392 | <width>91</width> | |
|
393 | <height>23</height> | |
|
394 | </rect> | |
|
395 | </property> | |
|
396 | <property name="text"> | |
|
397 | <string>Add Series</string> | |
|
398 | </property> | |
|
399 | </widget> | |
|
400 | <widget class="QPushButton" name="removeSeriesButton"> | |
|
401 | <property name="geometry"> | |
|
402 | <rect> | |
|
403 | <x>50</x> | |
|
404 | <y>300</y> | |
|
405 | <width>91</width> | |
|
406 | <height>23</height> | |
|
407 | </rect> | |
|
408 | </property> | |
|
409 | <property name="text"> | |
|
410 | <string>Remove Series</string> | |
|
411 | </property> | |
|
412 | </widget> | |
|
413 | <widget class="QComboBox" name="countComboBox"> | |
|
414 | <property name="geometry"> | |
|
415 | <rect> | |
|
416 | <x>10</x> | |
|
417 | <y>250</y> | |
|
418 | <width>181</width> | |
|
419 | <height>20</height> | |
|
420 | </rect> | |
|
421 | </property> | |
|
422 | <property name="editable"> | |
|
423 | <bool>false</bool> | |
|
424 | </property> | |
|
425 | <property name="currentText"> | |
|
426 | <string>100</string> | |
|
427 | </property> | |
|
428 | <property name="currentIndex"> | |
|
429 | <number>0</number> | |
|
430 | </property> | |
|
431 | <item> | |
|
432 | <property name="text"> | |
|
433 | <string>100</string> | |
|
434 | </property> | |
|
435 | </item> | |
|
436 | <item> | |
|
437 | <property name="text"> | |
|
438 | <string>1000</string> | |
|
439 | </property> | |
|
440 | </item> | |
|
441 | <item> | |
|
442 | <property name="text"> | |
|
443 | <string>10000</string> | |
|
444 | </property> | |
|
445 | </item> | |
|
446 | <item> | |
|
447 | <property name="text"> | |
|
448 | <string>100000</string> | |
|
449 | </property> | |
|
450 | </item> | |
|
451 | <item> | |
|
452 | <property name="text"> | |
|
453 | <string>1000000</string> | |
|
454 | </property> | |
|
455 | </item> | |
|
456 | <item> | |
|
457 | <property name="text"> | |
|
458 | <string>10000000</string> | |
|
459 | </property> | |
|
460 | </item> | |
|
461 | </widget> | |
|
462 | <widget class="QLabel" name="fpsLabel"> | |
|
463 | <property name="geometry"> | |
|
464 | <rect> | |
|
465 | <x>10</x> | |
|
466 | <y>550</y> | |
|
467 | <width>47</width> | |
|
468 | <height>13</height> | |
|
469 | </rect> | |
|
470 | </property> | |
|
471 | <property name="text"> | |
|
472 | <string>FPS:</string> | |
|
473 | </property> | |
|
474 | </widget> | |
|
475 | <widget class="QPushButton" name="addGLSeriesButton"> | |
|
476 | <property name="geometry"> | |
|
477 | <rect> | |
|
478 | <x>10</x> | |
|
479 | <y>280</y> | |
|
480 | <width>91</width> | |
|
481 | <height>23</height> | |
|
482 | </rect> | |
|
483 | </property> | |
|
484 | <property name="text"> | |
|
485 | <string>Add GL Series</string> | |
|
486 | </property> | |
|
487 | </widget> | |
|
488 | <widget class="QComboBox" name="colorsComboBox"> | |
|
489 | <property name="geometry"> | |
|
490 | <rect> | |
|
491 | <x>10</x> | |
|
492 | <y>330</y> | |
|
493 | <width>181</width> | |
|
494 | <height>20</height> | |
|
495 | </rect> | |
|
496 | </property> | |
|
497 | <item> | |
|
498 | <property name="text"> | |
|
499 | <string>Black</string> | |
|
500 | </property> | |
|
501 | </item> | |
|
502 | <item> | |
|
503 | <property name="text"> | |
|
504 | <string>Red</string> | |
|
505 | </property> | |
|
506 | </item> | |
|
507 | <item> | |
|
508 | <property name="text"> | |
|
509 | <string>Green</string> | |
|
510 | </property> | |
|
511 | </item> | |
|
512 | <item> | |
|
513 | <property name="text"> | |
|
514 | <string>Blue</string> | |
|
515 | </property> | |
|
516 | </item> | |
|
517 | </widget> | |
|
518 | <widget class="QComboBox" name="widthComboBox"> | |
|
519 | <property name="geometry"> | |
|
520 | <rect> | |
|
521 | <x>10</x> | |
|
522 | <y>350</y> | |
|
523 | <width>181</width> | |
|
524 | <height>20</height> | |
|
525 | </rect> | |
|
526 | </property> | |
|
527 | <item> | |
|
528 | <property name="text"> | |
|
529 | <string>1</string> | |
|
530 | </property> | |
|
531 | </item> | |
|
532 | <item> | |
|
533 | <property name="text"> | |
|
534 | <string>2</string> | |
|
535 | </property> | |
|
536 | </item> | |
|
537 | <item> | |
|
538 | <property name="text"> | |
|
539 | <string>3</string> | |
|
540 | </property> | |
|
541 | </item> | |
|
542 | <item> | |
|
543 | <property name="text"> | |
|
544 | <string>4</string> | |
|
545 | </property> | |
|
546 | </item> | |
|
547 | </widget> | |
|
548 | </widget> | |
|
549 | </item> | |
|
550 | </layout> | |
|
551 | </widget> | |
|
552 | <widget class="QMenuBar" name="menuBar"> | |
|
553 | <property name="geometry"> | |
|
554 | <rect> | |
|
555 | <x>0</x> | |
|
556 | <y>0</y> | |
|
557 | <width>1047</width> | |
|
558 | <height>21</height> | |
|
559 | </rect> | |
|
560 | </property> | |
|
561 | </widget> | |
|
562 | <widget class="QToolBar" name="mainToolBar"> | |
|
563 | <attribute name="toolBarArea"> | |
|
564 | <enum>TopToolBarArea</enum> | |
|
565 | </attribute> | |
|
566 | <attribute name="toolBarBreak"> | |
|
567 | <bool>false</bool> | |
|
568 | </attribute> | |
|
569 | </widget> | |
|
570 | <widget class="QStatusBar" name="statusBar"/> | |
|
571 | </widget> | |
|
572 | <layoutdefault spacing="6" margin="11"/> | |
|
573 | <customwidgets> | |
|
574 | <customwidget> | |
|
575 | <class>ChartView</class> | |
|
576 | <extends>QGraphicsView</extends> | |
|
577 | <header>chartview.h</header> | |
|
578 | </customwidget> | |
|
579 | </customwidgets> | |
|
580 | <resources/> | |
|
581 | <connections/> | |
|
582 | </ui> |
@@ -0,0 +1,19 | |||
|
1 | !include( ../../tests.pri ) { | |
|
2 | error( "Couldn't find the test.pri file!" ) | |
|
3 | } | |
|
4 | ||
|
5 | QT += core gui widgets | |
|
6 | ||
|
7 | TARGET = openglseriestest | |
|
8 | TEMPLATE = app | |
|
9 | ||
|
10 | SOURCES += main.cpp \ | |
|
11 | mainwindow.cpp \ | |
|
12 | chartview.cpp \ | |
|
13 | datasource.cpp | |
|
14 | ||
|
15 | HEADERS += mainwindow.h \ | |
|
16 | chartview.h \ | |
|
17 | datasource.h | |
|
18 | ||
|
19 | FORMS += mainwindow.ui |
General Comments 0
You need to be logged in to leave comments.
Login now