##// END OF EJS Templates
Documented QML oscilloscope
Tero Ahola -
r1825:3f96a0e4b951
parent child
Show More
1 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 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 //![1]
24 25 ChartView {
25 26 id: chartView
26 27 animationOptions: ChartView.NoAnimation
27 28
28 29 ValueAxis {
29 id: axisY
30 id: axisY1
30 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 41 ValueAxis {
35 42 id: axisX
36 43 min: 0
37 44 max: 1000
38 45 }
39 46
40 47 LineSeries {
41 48 id: lineSeries1
42 49 name: "signal 1"
43 50 axisX: axisX
44 axisY: axisY
51 axisY: axisY1
45 52 }
46 53 LineSeries {
47 54 id: lineSeries2
48 55 name: "signal 2"
49 56 axisX: axisX
50 axisY: axisY
57 axisY: axisY2
51 58 }
59 // ...
60 //![1]
52 61
62 //![2]
53 63 Timer {
54 64 id: refreshTimer
55 65 interval: 1 / 60 * 1000 // 60 Hz
56 66 running: true
57 67 repeat: true
58 68 onTriggered: {
59 69 dataSource.update(chartView.series(0));
60 70 dataSource.update(chartView.series(1));
61 71 }
62 72 }
73 //![2]
63 74
64 75 function changeSeriesType(type) {
65 76 chartView.series(1).destroy();
66 77 chartView.series(0).destroy();
67 78 var seriesCount = 2;
68 79 for (var i = 0; i < seriesCount; i++) {
69 80 var series;
70 81 if (type == "line") {
71 82 series = scopeView.createSeries(ChartView.SeriesTypeLine, "signal " + (i + 1));
72 83 } else if (type == "spline") {
73 84 series = chartView.createSeries(ChartView.SeriesTypeSpline, "signal " + (i + 1));
74 85 } else {
75 86 series = chartView.createSeries(ChartView.SeriesTypeScatter, "signal " + (i + 1));
76 87 series.markerSize = 3;
77 88 series.borderColor = "transparent";
78 89 }
79 90 }
80 91 }
81 92
82 93 function setAnimations(enabled) {
83 94 if (enabled)
84 95 scopeView.animationOptions = ChartView.SeriesAnimations;
85 96 else
86 97 scopeView.animationOptions = ChartView.NoAnimation;
87 98 }
88 99
89 100 function changeRefreshRate(rate) {
90 101 refreshTimer.interval = 1 / Number(rate) * 1000;
91 102 }
92 103 }
@@ -1,56 +1,61
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22
23 //![1]
23 24 Rectangle {
24 25 id: main
25 26 width: 400
26 27 height: 300
27 28
28 29 ControlPanel {
29 30 id: controlPanel
30 31 anchors.top: parent.top
31 32 anchors.topMargin: 10
32 33 anchors.bottom: parent.bottom
33 34 anchors.left: parent.left
34 35 anchors.leftMargin: 10
36 // ...
37 //![1]
35 38
36 39 onSignalSourceChanged: {
37 40 if (source == "sin")
38 41 dataSource.generateData(0, signalCount, sampleCount);
39 42 else
40 43 dataSource.generateData(1, signalCount, sampleCount);
41 44 }
42 45 onOpenGLEnabled: dataSource.setOpenGL(enabled);
43 46 onAnimationsEnabled: scopeView.setAnimations(enabled);
44 47 onSeriesTypeChanged: scopeView.changeSeriesType(type);
45 48 onRefreshRateChanged: scopeView.changeRefreshRate(rate);
46 49 }
47 50
51 //![2]
48 52 ScopeView {
49 53 id: scopeView
50 54 anchors.top: parent.top
51 55 anchors.bottom: parent.bottom
52 56 anchors.right: parent.right
53 57 anchors.left: controlPanel.right
54 58 height: main.height
55 59 }
60 //![2]
56 61 }
@@ -1,29 +1,30
1 1 /*!
2 2 \page demos.html
3 3 \title Demos
4 4 \keyword Demos
5 5
6 6 \raw HTML
7 7 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
8 8 <tr>
9 9 <th class="titleheader" width="33%">
10 10 List of demos
11 11 </th>
12 12 </tr>
13 13 <tr>
14 14 <td valign="top">
15 15 <ul>
16 16 <li><a href="demos-chartthemes.html">Chart themes</a></li>
17 17 <li><a href="demos-piechartcustomization.html">Pie chart customization</a></li>
18 18 <li><a href="demos-dynamicspline.html">Dynamic spline chart</a></li>
19 19 <li><a href="demos-qmlchart.html">Qml Basic Charts</a></li>
20 20 <li><a href="demos-qmlcustomizations.html">Qml Customizations</a></li>
21 21 <li><a href="demos-qmlweather.html">Qml Weather</a></li>
22 22 <li><a href="demos-qmlf1legends.html">Qml F1 Legends</a></li>
23 23 <li><a href="demos-qmlcustommodel.html">Qml Custom Model</a></li>
24 <li><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></li>
24 25 </ul>
25 26 </td>
26 27 </tr>
27 28 </table>
28 29 \endraw
29 30 */
General Comments 0
You need to be logged in to leave comments. Login now