##// END OF EJS Templates
Documented QML oscilloscope
Tero Ahola -
r1825:3f96a0e4b951
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,27
1 /*!
2 \example demos/qmloscilloscope
3 \title Oscilloscope
4
5 \image demos_qmloscilloscope.png
6
7 Oscilloscope application demonstrates how to use QtCommercial Charts QML api to implement an
8 application with strict performance requirements. The application uses generated data with
9 configurable characteristics to mimic a simple oscilloscope user interface. To find out the
10 actual screen refresh performance of the application, you can set QML_SHOW_FRAMERATE = 1 to
11 your run environment settings to get the framerate shown in the application output console.
12 I.e. go to Projects - Run - Run environment in Qt Creator and select Add. Then you can
13 experiment with the different configurable options of the demo application to find the
14 configuration that gives you the best performance in your environment.
15
16 The application window is shared by control and scope views:
17 \snippet ../demos/qmloscilloscope/qml/qmloscilloscope/main.qml 1
18 \snippet ../demos/qmloscilloscope/qml/qmloscilloscope/main.qml 2
19
20 ControlView implements the buttons used for configuring. ScopeView uses a ChartView to show
21 a chart with two line series:
22 \snippet ../demos/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml 1
23
24 The data of the line series is updated with a QML timer. In a real life application the
25 updating could triggered with a signal from Qt C++ code.
26 \snippet ../demos/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml 2
27 */
@@ -1,92 +1,103
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.0
22 import QtCommercial.Chart 1.0
23
23
24 //![1]
24 ChartView {
25 ChartView {
25 id: chartView
26 id: chartView
26 animationOptions: ChartView.NoAnimation
27 animationOptions: ChartView.NoAnimation
27
28
28 ValueAxis {
29 ValueAxis {
29 id: axisY
30 id: axisY1
30 min: -1
31 min: -1
31 max: 3
32 max: 4
33 }
34
35 ValueAxis {
36 id: axisY2
37 min: -10
38 max: 5
32 }
39 }
33
40
34 ValueAxis {
41 ValueAxis {
35 id: axisX
42 id: axisX
36 min: 0
43 min: 0
37 max: 1000
44 max: 1000
38 }
45 }
39
46
40 LineSeries {
47 LineSeries {
41 id: lineSeries1
48 id: lineSeries1
42 name: "signal 1"
49 name: "signal 1"
43 axisX: axisX
50 axisX: axisX
44 axisY: axisY
51 axisY: axisY1
45 }
52 }
46 LineSeries {
53 LineSeries {
47 id: lineSeries2
54 id: lineSeries2
48 name: "signal 2"
55 name: "signal 2"
49 axisX: axisX
56 axisX: axisX
50 axisY: axisY
57 axisY: axisY2
51 }
58 }
59 // ...
60 //![1]
52
61
62 //![2]
53 Timer {
63 Timer {
54 id: refreshTimer
64 id: refreshTimer
55 interval: 1 / 60 * 1000 // 60 Hz
65 interval: 1 / 60 * 1000 // 60 Hz
56 running: true
66 running: true
57 repeat: true
67 repeat: true
58 onTriggered: {
68 onTriggered: {
59 dataSource.update(chartView.series(0));
69 dataSource.update(chartView.series(0));
60 dataSource.update(chartView.series(1));
70 dataSource.update(chartView.series(1));
61 }
71 }
62 }
72 }
73 //![2]
63
74
64 function changeSeriesType(type) {
75 function changeSeriesType(type) {
65 chartView.series(1).destroy();
76 chartView.series(1).destroy();
66 chartView.series(0).destroy();
77 chartView.series(0).destroy();
67 var seriesCount = 2;
78 var seriesCount = 2;
68 for (var i = 0; i < seriesCount; i++) {
79 for (var i = 0; i < seriesCount; i++) {
69 var series;
80 var series;
70 if (type == "line") {
81 if (type == "line") {
71 series = scopeView.createSeries(ChartView.SeriesTypeLine, "signal " + (i + 1));
82 series = scopeView.createSeries(ChartView.SeriesTypeLine, "signal " + (i + 1));
72 } else if (type == "spline") {
83 } else if (type == "spline") {
73 series = chartView.createSeries(ChartView.SeriesTypeSpline, "signal " + (i + 1));
84 series = chartView.createSeries(ChartView.SeriesTypeSpline, "signal " + (i + 1));
74 } else {
85 } else {
75 series = chartView.createSeries(ChartView.SeriesTypeScatter, "signal " + (i + 1));
86 series = chartView.createSeries(ChartView.SeriesTypeScatter, "signal " + (i + 1));
76 series.markerSize = 3;
87 series.markerSize = 3;
77 series.borderColor = "transparent";
88 series.borderColor = "transparent";
78 }
89 }
79 }
90 }
80 }
91 }
81
92
82 function setAnimations(enabled) {
93 function setAnimations(enabled) {
83 if (enabled)
94 if (enabled)
84 scopeView.animationOptions = ChartView.SeriesAnimations;
95 scopeView.animationOptions = ChartView.SeriesAnimations;
85 else
96 else
86 scopeView.animationOptions = ChartView.NoAnimation;
97 scopeView.animationOptions = ChartView.NoAnimation;
87 }
98 }
88
99
89 function changeRefreshRate(rate) {
100 function changeRefreshRate(rate) {
90 refreshTimer.interval = 1 / Number(rate) * 1000;
101 refreshTimer.interval = 1 / Number(rate) * 1000;
91 }
102 }
92 }
103 }
@@ -1,56 +1,61
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 Rectangle {
24 Rectangle {
24 id: main
25 id: main
25 width: 400
26 width: 400
26 height: 300
27 height: 300
27
28
28 ControlPanel {
29 ControlPanel {
29 id: controlPanel
30 id: controlPanel
30 anchors.top: parent.top
31 anchors.top: parent.top
31 anchors.topMargin: 10
32 anchors.topMargin: 10
32 anchors.bottom: parent.bottom
33 anchors.bottom: parent.bottom
33 anchors.left: parent.left
34 anchors.left: parent.left
34 anchors.leftMargin: 10
35 anchors.leftMargin: 10
36 // ...
37 //![1]
35
38
36 onSignalSourceChanged: {
39 onSignalSourceChanged: {
37 if (source == "sin")
40 if (source == "sin")
38 dataSource.generateData(0, signalCount, sampleCount);
41 dataSource.generateData(0, signalCount, sampleCount);
39 else
42 else
40 dataSource.generateData(1, signalCount, sampleCount);
43 dataSource.generateData(1, signalCount, sampleCount);
41 }
44 }
42 onOpenGLEnabled: dataSource.setOpenGL(enabled);
45 onOpenGLEnabled: dataSource.setOpenGL(enabled);
43 onAnimationsEnabled: scopeView.setAnimations(enabled);
46 onAnimationsEnabled: scopeView.setAnimations(enabled);
44 onSeriesTypeChanged: scopeView.changeSeriesType(type);
47 onSeriesTypeChanged: scopeView.changeSeriesType(type);
45 onRefreshRateChanged: scopeView.changeRefreshRate(rate);
48 onRefreshRateChanged: scopeView.changeRefreshRate(rate);
46 }
49 }
47
50
51 //![2]
48 ScopeView {
52 ScopeView {
49 id: scopeView
53 id: scopeView
50 anchors.top: parent.top
54 anchors.top: parent.top
51 anchors.bottom: parent.bottom
55 anchors.bottom: parent.bottom
52 anchors.right: parent.right
56 anchors.right: parent.right
53 anchors.left: controlPanel.right
57 anchors.left: controlPanel.right
54 height: main.height
58 height: main.height
55 }
59 }
60 //![2]
56 }
61 }
@@ -1,29 +1,30
1 /*!
1 /*!
2 \page demos.html
2 \page demos.html
3 \title Demos
3 \title Demos
4 \keyword Demos
4 \keyword Demos
5
5
6 \raw HTML
6 \raw HTML
7 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
7 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
8 <tr>
8 <tr>
9 <th class="titleheader" width="33%">
9 <th class="titleheader" width="33%">
10 List of demos
10 List of demos
11 </th>
11 </th>
12 </tr>
12 </tr>
13 <tr>
13 <tr>
14 <td valign="top">
14 <td valign="top">
15 <ul>
15 <ul>
16 <li><a href="demos-chartthemes.html">Chart themes</a></li>
16 <li><a href="demos-chartthemes.html">Chart themes</a></li>
17 <li><a href="demos-piechartcustomization.html">Pie chart customization</a></li>
17 <li><a href="demos-piechartcustomization.html">Pie chart customization</a></li>
18 <li><a href="demos-dynamicspline.html">Dynamic spline chart</a></li>
18 <li><a href="demos-dynamicspline.html">Dynamic spline chart</a></li>
19 <li><a href="demos-qmlchart.html">Qml Basic Charts</a></li>
19 <li><a href="demos-qmlchart.html">Qml Basic Charts</a></li>
20 <li><a href="demos-qmlcustomizations.html">Qml Customizations</a></li>
20 <li><a href="demos-qmlcustomizations.html">Qml Customizations</a></li>
21 <li><a href="demos-qmlweather.html">Qml Weather</a></li>
21 <li><a href="demos-qmlweather.html">Qml Weather</a></li>
22 <li><a href="demos-qmlf1legends.html">Qml F1 Legends</a></li>
22 <li><a href="demos-qmlf1legends.html">Qml F1 Legends</a></li>
23 <li><a href="demos-qmlcustommodel.html">Qml Custom Model</a></li>
23 <li><a href="demos-qmlcustommodel.html">Qml Custom Model</a></li>
24 <li><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></li>
24 </ul>
25 </ul>
25 </td>
26 </td>
26 </tr>
27 </tr>
27 </table>
28 </table>
28 \endraw
29 \endraw
29 */
30 */
General Comments 0
You need to be logged in to leave comments. Login now