@@ -1,93 +1,91 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "datasource.h" |
|
21 | #include "datasource.h" | |
22 | #include <QXYSeries> |
|
22 | #include <QXYSeries> | |
23 | #include <QAreaSeries> |
|
23 | #include <QAreaSeries> | |
24 | #include <QDeclarativeView> |
|
24 | #include <QDeclarativeView> | |
25 | #include <QGLWidget> |
|
25 | #include <QGLWidget> | |
26 | #include <QDebug> |
|
26 | #include <QDebug> | |
27 | #include <cmath> |
|
27 | #include <cmath> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 | |||
31 | DataSource::DataSource(QDeclarativeView *appViewer, QObject *parent) : |
|
31 | DataSource::DataSource(QDeclarativeView *appViewer, QObject *parent) : | |
32 | QObject(parent), |
|
32 | QObject(parent), | |
33 | m_appViewer(appViewer), |
|
33 | m_appViewer(appViewer), | |
34 | m_index(-1) |
|
34 | m_index(-1) | |
35 | { |
|
35 | { | |
36 | // generate |
|
36 | // generate | |
37 | generateData(0, 5, 1024); |
|
37 | generateData(0, 5, 1024); | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | void DataSource::update(QAbstractSeries *series) |
|
40 | void DataSource::update(QAbstractSeries *series) | |
41 | { |
|
41 | { | |
42 | QXYSeries *xySeries = qobject_cast<QXYSeries *>(series); |
|
42 | QXYSeries *xySeries = qobject_cast<QXYSeries *>(series); | |
43 | Q_ASSERT(xySeries); |
|
43 | Q_ASSERT(xySeries); | |
44 |
|
44 | |||
45 | m_index++; |
|
45 | m_index++; | |
46 | if (m_index > m_data.count() - 1) |
|
46 | if (m_index > m_data.count() - 1) | |
47 | m_index = 0; |
|
47 | m_index = 0; | |
48 |
|
48 | |||
49 | QList<QPointF> points = m_data.at(m_index); |
|
49 | QList<QPointF> points = m_data.at(m_index); | |
50 | // Use replace instead of clear + append, it's optimized for performance |
|
50 | // Use replace instead of clear + append, it's optimized for performance | |
51 | xySeries->replace(points); |
|
51 | xySeries->replace(points); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | void DataSource::generateData(int type, int rowCount, int colCount) |
|
54 | void DataSource::generateData(int type, int rowCount, int colCount) | |
55 | { |
|
55 | { | |
56 | qDebug() << "DataSource::generateData:" << type << rowCount << colCount; |
|
|||
57 |
|
||||
58 | // Remove previous data |
|
56 | // Remove previous data | |
59 | foreach (QList<QPointF> row, m_data) |
|
57 | foreach (QList<QPointF> row, m_data) | |
60 | row.clear(); |
|
58 | row.clear(); | |
61 | m_data.clear(); |
|
59 | m_data.clear(); | |
62 |
|
60 | |||
63 | // Append the new data depending on the type |
|
61 | // Append the new data depending on the type | |
64 | for (int i(0); i < rowCount; i++) { |
|
62 | for (int i(0); i < rowCount; i++) { | |
65 | QList<QPointF> points; |
|
63 | QList<QPointF> points; | |
66 | for (int j(0); j < colCount; j++) { |
|
64 | for (int j(0); j < colCount; j++) { | |
67 | qreal x(0); |
|
65 | qreal x(0); | |
68 | qreal y(0); |
|
66 | qreal y(0); | |
69 | switch (type) { |
|
67 | switch (type) { | |
70 | case 0: |
|
68 | case 0: | |
71 | // data with sin + random component |
|
69 | // data with sin + random component | |
72 | y = sin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; |
|
70 | y = sin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; | |
73 | x = j; |
|
71 | x = j; | |
74 | break; |
|
72 | break; | |
75 | case 1: |
|
73 | case 1: | |
76 | // linear data |
|
74 | // linear data | |
77 | x = j; |
|
75 | x = j; | |
78 | y = (qreal) i / 10; |
|
76 | y = (qreal) i / 10; | |
79 | break; |
|
77 | break; | |
80 | default: |
|
78 | default: | |
81 | // unknown, do nothing |
|
79 | // unknown, do nothing | |
82 | break; |
|
80 | break; | |
83 | } |
|
81 | } | |
84 | points.append(QPointF(x, y)); |
|
82 | points.append(QPointF(x, y)); | |
85 | } |
|
83 | } | |
86 | m_data.append(points); |
|
84 | m_data.append(points); | |
87 | } |
|
85 | } | |
88 | } |
|
86 | } | |
89 |
|
87 | |||
90 | void DataSource::setAntialiasing(bool enabled) |
|
88 | void DataSource::setAntialiasing(bool enabled) | |
91 | { |
|
89 | { | |
92 | m_appViewer->setRenderHint(QPainter::Antialiasing, enabled); |
|
90 | m_appViewer->setRenderHint(QPainter::Antialiasing, enabled); | |
93 | } |
|
91 | } |
@@ -1,85 +1,86 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 |
|
22 | |||
23 | Column { |
|
23 | Column { | |
24 |
spacing: |
|
24 | spacing: 8 | |
25 | signal animationsEnabled(bool enabled) |
|
25 | signal animationsEnabled(bool enabled) | |
26 | signal seriesTypeChanged(string type) |
|
26 | signal seriesTypeChanged(string type) | |
27 | signal refreshRateChanged(variant rate); |
|
27 | signal refreshRateChanged(variant rate); | |
28 | signal signalSourceChanged(string source, int signalCount, int sampleCount); |
|
28 | signal signalSourceChanged(string source, int signalCount, int sampleCount); | |
29 | signal antialiasingEnabled(bool enabled) |
|
29 | signal antialiasingEnabled(bool enabled) | |
30 |
|
30 | |||
31 | Text { |
|
31 | Text { | |
32 |
text: " |
|
32 | text: "Scope-PAS2" | |
33 | font.pointSize: 18 |
|
33 | font.pointSize: 18 | |
|
34 | color: "white" | |||
34 | } |
|
35 | } | |
35 |
|
36 | |||
36 | MultiButton { |
|
37 | MultiButton { | |
37 | text: "Graph: " |
|
38 | text: "Graph: " | |
38 | items: ["line", "spline", "scatter"] |
|
39 | items: ["line", "spline", "scatter"] | |
39 | currentSelection: 0 |
|
40 | currentSelection: 0 | |
40 | onSelectionChanged: seriesTypeChanged(items[currentSelection]); |
|
41 | onSelectionChanged: seriesTypeChanged(items[currentSelection]); | |
41 | } |
|
42 | } | |
42 |
|
43 | |||
43 | MultiButton { |
|
44 | MultiButton { | |
44 | id: signalSourceButton |
|
45 | id: signalSourceButton | |
45 | text: "Source: " |
|
46 | text: "Source: " | |
46 | items: ["sin", "linear"] |
|
47 | items: ["sin", "linear"] | |
47 | currentSelection: 0 |
|
48 | currentSelection: 0 | |
48 | onSelectionChanged: signalSourceChanged( |
|
49 | onSelectionChanged: signalSourceChanged( | |
49 | selection, |
|
50 | selection, | |
50 | 5, |
|
51 | 5, | |
51 | sampleCountButton.items[sampleCountButton.currentSelection]); |
|
52 | sampleCountButton.items[sampleCountButton.currentSelection]); | |
52 | } |
|
53 | } | |
53 |
|
54 | |||
54 | MultiButton { |
|
55 | MultiButton { | |
55 | id: sampleCountButton |
|
56 | id: sampleCountButton | |
56 | text: "Samples: " |
|
57 | text: "Samples: " | |
57 | items: [6, 128, 1024, 10000] |
|
58 | items: [6, 128, 1024, 10000] | |
58 | currentSelection: 2 |
|
59 | currentSelection: 2 | |
59 | onSelectionChanged: signalSourceChanged( |
|
60 | onSelectionChanged: signalSourceChanged( | |
60 | signalSourceButton.items[signalSourceButton.currentSelection], |
|
61 | signalSourceButton.items[signalSourceButton.currentSelection], | |
61 | 5, |
|
62 | 5, | |
62 | selection); |
|
63 | selection); | |
63 | } |
|
64 | } | |
64 |
|
65 | |||
65 | MultiButton { |
|
66 | MultiButton { | |
66 | text: "Refresh rate: " |
|
67 | text: "Refresh rate: " | |
67 | items: [1, 24, 60, 100] |
|
68 | items: [1, 24, 60, 100] | |
68 | currentSelection: 2 |
|
69 | currentSelection: 2 | |
69 | onSelectionChanged: refreshRateChanged(items[currentSelection]); |
|
70 | onSelectionChanged: refreshRateChanged(items[currentSelection]); | |
70 | } |
|
71 | } | |
71 |
|
72 | |||
72 | MultiButton { |
|
73 | MultiButton { | |
73 | text: "Animations: " |
|
74 | text: "Animations: " | |
74 | items: ["OFF", "ON"] |
|
75 | items: ["OFF", "ON"] | |
75 | currentSelection: 0 |
|
76 | currentSelection: 0 | |
76 | onSelectionChanged: animationsEnabled(currentSelection == 1); |
|
77 | onSelectionChanged: animationsEnabled(currentSelection == 1); | |
77 | } |
|
78 | } | |
78 |
|
79 | |||
79 | MultiButton { |
|
80 | MultiButton { | |
80 | text: "Antialias: " |
|
81 | text: "Antialias: " | |
81 | items: ["OFF", "ON"] |
|
82 | items: ["OFF", "ON"] | |
82 | currentSelection: 0 |
|
83 | currentSelection: 0 | |
83 | onSelectionChanged: antialiasingEnabled(currentSelection == 1); |
|
84 | onSelectionChanged: antialiasingEnabled(currentSelection == 1); | |
84 | } |
|
85 | } | |
85 | } |
|
86 | } |
@@ -1,47 +1,54 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 |
|
22 | |||
23 | Rectangle { |
|
23 | Rectangle { | |
24 | id: button |
|
24 | id: button | |
25 |
width: 1 |
|
25 | width: 115 | |
26 |
height: 3 |
|
26 | height: 31 | |
27 | border.color: "gray" |
|
27 | gradient: Gradient { | |
|
28 | GradientStop { position: mouseArea.pressed ? 1.0 : 0.0; color: "#A09090" } | |||
|
29 | GradientStop { position: mouseArea.pressed ? 0.0 : 1.0; color: "#505050" } | |||
|
30 | } | |||
|
31 | smooth: true | |||
|
32 | ||||
28 | radius: 7 |
|
33 | radius: 7 | |
29 | property string text: "Option: " |
|
34 | property string text: "Option: " | |
30 | property variant items: ["first"] |
|
35 | property variant items: ["first"] | |
31 | property int currentSelection: 0 |
|
36 | property int currentSelection: 0 | |
32 | signal selectionChanged(variant selection) |
|
37 | signal selectionChanged(variant selection) | |
33 |
|
38 | |||
34 | Text { |
|
39 | Text { | |
35 | id: buttonText |
|
40 | id: buttonText | |
36 | anchors.centerIn: parent |
|
41 | anchors.centerIn: parent | |
|
42 | color: "#FFFFFF" | |||
37 | text: button.text + button.items[currentSelection] |
|
43 | text: button.text + button.items[currentSelection] | |
38 | } |
|
44 | } | |
39 |
|
45 | |||
40 | MouseArea { |
|
46 | MouseArea { | |
|
47 | id: mouseArea | |||
41 | anchors.fill: parent |
|
48 | anchors.fill: parent | |
42 | onClicked: { |
|
49 | onClicked: { | |
43 | currentSelection = (currentSelection + 1) % items.length; |
|
50 | currentSelection = (currentSelection + 1) % items.length; | |
44 | selectionChanged(button.items[currentSelection]); |
|
51 | selectionChanged(button.items[currentSelection]); | |
45 | } |
|
52 | } | |
46 | } |
|
53 | } | |
47 | } |
|
54 | } |
@@ -1,116 +1,116 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 |
import QtCommercial.Chart 1. |
|
22 | import QtCommercial.Chart 1.2 | |
23 |
|
23 | |||
24 | //![1] |
|
24 | //![1] | |
25 | ChartView { |
|
25 | ChartView { | |
26 | id: chartView |
|
26 | id: chartView | |
27 | animationOptions: ChartView.NoAnimation |
|
27 | animationOptions: ChartView.NoAnimation | |
28 | theme: ChartView.ChartThemeDark |
|
28 | theme: ChartView.ChartThemeDark | |
29 |
|
29 | |||
30 | ValueAxis { |
|
30 | ValueAxis { | |
31 | id: axisY1 |
|
31 | id: axisY1 | |
32 | min: -1 |
|
32 | min: -1 | |
33 | max: 4 |
|
33 | max: 4 | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | ValueAxis { |
|
36 | ValueAxis { | |
37 | id: axisY2 |
|
37 | id: axisY2 | |
38 | min: -10 |
|
38 | min: -10 | |
39 | max: 5 |
|
39 | max: 5 | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | ValueAxis { |
|
42 | ValueAxis { | |
43 | id: axisX |
|
43 | id: axisX | |
44 | min: 0 |
|
44 | min: 0 | |
45 | max: 1000 |
|
45 | max: 1000 | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | LineSeries { |
|
48 | LineSeries { | |
49 | id: lineSeries1 |
|
49 | id: lineSeries1 | |
50 | name: "signal 1" |
|
50 | name: "signal 1" | |
51 | axisX: axisX |
|
51 | axisX: axisX | |
52 | axisY: axisY1 |
|
52 | axisY: axisY1 | |
53 | } |
|
53 | } | |
54 | LineSeries { |
|
54 | LineSeries { | |
55 | id: lineSeries2 |
|
55 | id: lineSeries2 | |
56 | name: "signal 2" |
|
56 | name: "signal 2" | |
57 | axisX: axisX |
|
57 | axisX: axisX | |
58 | axisY: axisY2 |
|
58 | axisYRight: axisY2 | |
59 | } |
|
59 | } | |
60 | // ... |
|
60 | // ... | |
61 | //![1] |
|
61 | //![1] | |
62 |
|
62 | |||
63 | //![2] |
|
63 | //![2] | |
64 | Timer { |
|
64 | Timer { | |
65 | id: refreshTimer |
|
65 | id: refreshTimer | |
66 | interval: 1 / 60 * 1000 // 60 Hz |
|
66 | interval: 1 / 60 * 1000 // 60 Hz | |
67 | running: true |
|
67 | running: true | |
68 | repeat: true |
|
68 | repeat: true | |
69 | onTriggered: { |
|
69 | onTriggered: { | |
70 | dataSource.update(chartView.series(0)); |
|
70 | dataSource.update(chartView.series(0)); | |
71 | dataSource.update(chartView.series(1)); |
|
71 | dataSource.update(chartView.series(1)); | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 | //![2] |
|
74 | //![2] | |
75 |
|
75 | |||
76 | //![3] |
|
76 | //![3] | |
77 | function changeSeriesType(type) { |
|
77 | function changeSeriesType(type) { | |
78 | chartView.removeAllSeries(); |
|
78 | chartView.removeAllSeries(); | |
79 |
|
79 | |||
80 | // Create two new series of the correct type. Axis x is the same for both of the series, |
|
80 | // Create two new series of the correct type. Axis x is the same for both of the series, | |
81 | // but the series have their own y-axes to make it possible to control the y-offset |
|
81 | // but the series have their own y-axes to make it possible to control the y-offset | |
82 | // of the "signal sources". |
|
82 | // of the "signal sources". | |
83 | if (type == "line") { |
|
83 | if (type == "line") { | |
84 | scopeView.createSeries(ChartView.SeriesTypeLine, "signal 1", axisX, axisY1); |
|
84 | scopeView.createSeries(ChartView.SeriesTypeLine, "signal 1", axisX, axisY1); | |
85 | scopeView.createSeries(ChartView.SeriesTypeLine, "signal 2", axisX, axisY2); |
|
85 | scopeView.createSeries(ChartView.SeriesTypeLine, "signal 2", axisX, axisY2); | |
86 | } else if (type == "spline") { |
|
86 | } else if (type == "spline") { | |
87 | scopeView.createSeries(ChartView.SeriesTypeSpline, "signal 1", axisX, axisY1); |
|
87 | scopeView.createSeries(ChartView.SeriesTypeSpline, "signal 1", axisX, axisY1); | |
88 | scopeView.createSeries(ChartView.SeriesTypeSpline, "signal 2", axisX, axisY2); |
|
88 | scopeView.createSeries(ChartView.SeriesTypeSpline, "signal 2", axisX, axisY2); | |
89 | } else { |
|
89 | } else { | |
90 | var series1 = scopeView.createSeries(ChartView.SeriesTypeScatter, "signal 1", axisX, axisY1); |
|
90 | var series1 = scopeView.createSeries(ChartView.SeriesTypeScatter, "signal 1", axisX, axisY1); | |
91 | series1.markerSize = 3; |
|
91 | series1.markerSize = 3; | |
92 | series1.borderColor = "transparent"; |
|
92 | series1.borderColor = "transparent"; | |
93 | var series2 = scopeView.createSeries(ChartView.SeriesTypeScatter, "signal 2", axisX, axisY2); |
|
93 | var series2 = scopeView.createSeries(ChartView.SeriesTypeScatter, "signal 2", axisX, axisY2); | |
94 | series2.markerSize = 3; |
|
94 | series2.markerSize = 3; | |
95 | series2.borderColor = "transparent"; |
|
95 | series2.borderColor = "transparent"; | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | function createAxis(min, max) { |
|
99 | function createAxis(min, max) { | |
100 | // The following creates a ValueAxis object that can be then set as a x or y axis for a series |
|
100 | // The following creates a ValueAxis object that can be then set as a x or y axis for a series | |
101 | return Qt.createQmlObject("import QtQuick 1.1; import QtCommercial.Chart 1.1; ValueAxis { min: " |
|
101 | return Qt.createQmlObject("import QtQuick 1.1; import QtCommercial.Chart 1.1; ValueAxis { min: " | |
102 | + min + "; max: " + max + " }", chartView); |
|
102 | + min + "; max: " + max + " }", chartView); | |
103 | } |
|
103 | } | |
104 | //![3] |
|
104 | //![3] | |
105 |
|
105 | |||
106 | function setAnimations(enabled) { |
|
106 | function setAnimations(enabled) { | |
107 | if (enabled) |
|
107 | if (enabled) | |
108 | scopeView.animationOptions = ChartView.SeriesAnimations; |
|
108 | scopeView.animationOptions = ChartView.SeriesAnimations; | |
109 | else |
|
109 | else | |
110 | scopeView.animationOptions = ChartView.NoAnimation; |
|
110 | scopeView.animationOptions = ChartView.NoAnimation; | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | function changeRefreshRate(rate) { |
|
113 | function changeRefreshRate(rate) { | |
114 | refreshTimer.interval = 1 / Number(rate) * 1000; |
|
114 | refreshTimer.interval = 1 / Number(rate) * 1000; | |
115 | } |
|
115 | } | |
116 | } |
|
116 | } |
@@ -1,61 +1,62 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 |
|
22 | |||
23 | //![1] |
|
23 | //![1] | |
24 | Rectangle { |
|
24 | Rectangle { | |
25 | id: main |
|
25 | id: main | |
26 | width: 400 |
|
26 | width: 400 | |
27 | height: 300 |
|
27 | height: 300 | |
|
28 | color: "#404040" | |||
28 |
|
29 | |||
29 | ControlPanel { |
|
30 | ControlPanel { | |
30 | id: controlPanel |
|
31 | id: controlPanel | |
31 | anchors.top: parent.top |
|
32 | anchors.top: parent.top | |
32 | anchors.topMargin: 10 |
|
33 | anchors.topMargin: 10 | |
33 | anchors.bottom: parent.bottom |
|
34 | anchors.bottom: parent.bottom | |
34 | anchors.left: parent.left |
|
35 | anchors.left: parent.left | |
35 | anchors.leftMargin: 10 |
|
36 | anchors.leftMargin: 10 | |
36 | // ... |
|
37 | // ... | |
37 | //![1] |
|
38 | //![1] | |
38 |
|
39 | |||
39 | onSignalSourceChanged: { |
|
40 | onSignalSourceChanged: { | |
40 | if (source == "sin") |
|
41 | if (source == "sin") | |
41 | dataSource.generateData(0, signalCount, sampleCount); |
|
42 | dataSource.generateData(0, signalCount, sampleCount); | |
42 | else |
|
43 | else | |
43 | dataSource.generateData(1, signalCount, sampleCount); |
|
44 | dataSource.generateData(1, signalCount, sampleCount); | |
44 | } |
|
45 | } | |
45 | onAnimationsEnabled: scopeView.setAnimations(enabled); |
|
46 | onAnimationsEnabled: scopeView.setAnimations(enabled); | |
46 | onSeriesTypeChanged: scopeView.changeSeriesType(type); |
|
47 | onSeriesTypeChanged: scopeView.changeSeriesType(type); | |
47 | onRefreshRateChanged: scopeView.changeRefreshRate(rate); |
|
48 | onRefreshRateChanged: scopeView.changeRefreshRate(rate); | |
48 | onAntialiasingEnabled: dataSource.setAntialiasing(enabled); |
|
49 | onAntialiasingEnabled: dataSource.setAntialiasing(enabled); | |
49 | } |
|
50 | } | |
50 |
|
51 | |||
51 | //![2] |
|
52 | //![2] | |
52 | ScopeView { |
|
53 | ScopeView { | |
53 | id: scopeView |
|
54 | id: scopeView | |
54 | anchors.top: parent.top |
|
55 | anchors.top: parent.top | |
55 | anchors.bottom: parent.bottom |
|
56 | anchors.bottom: parent.bottom | |
56 | anchors.right: parent.right |
|
57 | anchors.right: parent.right | |
57 | anchors.left: controlPanel.right |
|
58 | anchors.left: controlPanel.right | |
58 | height: main.height |
|
59 | height: main.height | |
59 | } |
|
60 | } | |
60 | //![2] |
|
61 | //![2] | |
61 | } |
|
62 | } |
General Comments 0
You need to be logged in to leave comments.
Login now