##// END OF EJS Templates
Remove opengl dependency from oscilloscope demos....
Miikka Heikkinen -
r2525:5407eb4cd85a
parent child
Show More
@@ -1,37 +1,32
1 1 CURRENTLY_BUILDING_COMPONENTS = "demos"
2 2 !include( ../config.pri ) {
3 3 error( "Couldn't find the config.pri file!" )
4 4 }
5 5
6 6 TEMPLATE = subdirs
7 7 SUBDIRS += piechartcustomization \
8 8 dynamicspline \
9 9 nesteddonuts \
10 10 qmlchart \
11 11 qmlweather \
12 12 qmlf1legends \
13 13 qmlcustomizations \
14 14 qmlcustommodel \
15 15 chartinteractions \
16 16 qmlaxes \
17 17 qmlcustomlegend \
18 18 callout \
19 qmlpolarchart
20
21 contains(QT_CONFIG, opengl) {
22 SUBDIRS += chartthemes \
23 qmloscilloscope
24 } else {
25 message("OpenGL not available. Some demos are disabled")
26 }
19 qmlpolarchart \
20 qmloscilloscope \
21 chartthemes
27 22
28 23 contains(QT_CONFIG, multimedia) {
29 24 SUBDIRS += audio
30 25 } else {
31 26 message("QtMultimedia library not available. Some demos are disabled")
32 27 }
33 28
34 29 contains(QT_VERSION, ^5\\..*\\..*$):qtHaveModule(quick) {
35 30 SUBDIRS += quick2chart \
36 31 quick2oscilloscope
37 32 }
@@ -1,94 +1,93
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2013 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 #include "datasource.h"
22 22 #include <QXYSeries>
23 23 #include <QAreaSeries>
24 24 #include <QDeclarativeView>
25 #include <QGLWidget>
26 25 #include <QDebug>
27 26 #include <cmath>
28 27
29 28 QTCOMMERCIALCHART_USE_NAMESPACE
30 29
31 30 Q_DECLARE_METATYPE(QAbstractSeries *)
32 31
33 32 DataSource::DataSource(QDeclarativeView *appViewer, QObject *parent) :
34 33 QObject(parent),
35 34 m_appViewer(appViewer),
36 35 m_index(-1)
37 36 {
38 37 qRegisterMetaType<QAbstractSeries*>();
39 38
40 39 generateData(0, 5, 1024);
41 40 }
42 41
43 42 void DataSource::update(QAbstractSeries *series)
44 43 {
45 44 QXYSeries *xySeries = qobject_cast<QXYSeries *>(series);
46 45 Q_ASSERT(xySeries);
47 46
48 47 m_index++;
49 48 if (m_index > m_data.count() - 1)
50 49 m_index = 0;
51 50
52 51 QList<QPointF> points = m_data.at(m_index);
53 52 // Use replace instead of clear + append, it's optimized for performance
54 53 xySeries->replace(points);
55 54 }
56 55
57 56 void DataSource::generateData(int type, int rowCount, int colCount)
58 57 {
59 58 // Remove previous data
60 59 foreach (QList<QPointF> row, m_data)
61 60 row.clear();
62 61 m_data.clear();
63 62
64 63 // Append the new data depending on the type
65 64 for (int i(0); i < rowCount; i++) {
66 65 QList<QPointF> points;
67 66 for (int j(0); j < colCount; j++) {
68 67 qreal x(0);
69 68 qreal y(0);
70 69 switch (type) {
71 70 case 0:
72 71 // data with sin + random component
73 72 y = sin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX;
74 73 x = j;
75 74 break;
76 75 case 1:
77 76 // linear data
78 77 x = j;
79 78 y = (qreal) i / 10;
80 79 break;
81 80 default:
82 81 // unknown, do nothing
83 82 break;
84 83 }
85 84 points.append(QPointF(x, y));
86 85 }
87 86 m_data.append(points);
88 87 }
89 88 }
90 89
91 90 void DataSource::setAntialiasing(bool enabled)
92 91 {
93 92 m_appViewer->setRenderHint(QPainter::Antialiasing, enabled);
94 93 }
@@ -1,14 +1,13
1 1 !include( ../demos.pri ) {
2 2 error( "Couldn't find the demos.pri file!" )
3 3 }
4 4
5 QT += opengl
6 5 RESOURCES += resources.qrc
7 6 SOURCES += main.cpp \
8 7 datasource.cpp
9 8 OTHER_FILES += qml/qmloscilloscope/*
10 9
11 10 include(qmlapplicationviewer/qmlapplicationviewer.pri)
12 11
13 12 HEADERS += \
14 13 datasource.h
@@ -1,90 +1,89
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2013 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 #include "datasource.h"
22 22 #include <QXYSeries>
23 23 #include <QAreaSeries>
24 24 #include <QtQuick/QQuickView>
25 25 #include <QtQuick/QQuickItem>
26 #include <QGLWidget>
27 26 #include <QDebug>
28 27 #include <cmath>
29 28
30 29 QTCOMMERCIALCHART_USE_NAMESPACE
31 30
32 31 Q_DECLARE_METATYPE(QAbstractSeries *)
33 32
34 33 DataSource::DataSource(QQuickView *appViewer, QObject *parent) :
35 34 QObject(parent),
36 35 m_appViewer(appViewer),
37 36 m_index(-1)
38 37 {
39 38 qRegisterMetaType<QAbstractSeries*>();
40 39
41 40 generateData(0, 5, 1024);
42 41 }
43 42
44 43 void DataSource::update(QAbstractSeries *series)
45 44 {
46 45 QXYSeries *xySeries = qobject_cast<QXYSeries *>(series);
47 46 Q_ASSERT(xySeries);
48 47
49 48 m_index++;
50 49 if (m_index > m_data.count() - 1)
51 50 m_index = 0;
52 51
53 52 QList<QPointF> points = m_data.at(m_index);
54 53 // Use replace instead of clear + append, it's optimized for performance
55 54 xySeries->replace(points);
56 55 }
57 56
58 57 void DataSource::generateData(int type, int rowCount, int colCount)
59 58 {
60 59 // Remove previous data
61 60 foreach (QList<QPointF> row, m_data)
62 61 row.clear();
63 62 m_data.clear();
64 63
65 64 // Append the new data depending on the type
66 65 for (int i(0); i < rowCount; i++) {
67 66 QList<QPointF> points;
68 67 for (int j(0); j < colCount; j++) {
69 68 qreal x(0);
70 69 qreal y(0);
71 70 switch (type) {
72 71 case 0:
73 72 // data with sin + random component
74 73 y = sin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX;
75 74 x = j;
76 75 break;
77 76 case 1:
78 77 // linear data
79 78 x = j;
80 79 y = (qreal) i / 10;
81 80 break;
82 81 default:
83 82 // unknown, do nothing
84 83 break;
85 84 }
86 85 points.append(QPointF(x, y));
87 86 }
88 87 m_data.append(points);
89 88 }
90 89 }
@@ -1,14 +1,13
1 1 !include( ../demos.pri ) {
2 2 error( "Couldn't find the demos.pri file!" )
3 3 }
4 4
5 QT += opengl
6 5 RESOURCES += resources.qrc
7 6 SOURCES += main.cpp \
8 7 datasource.cpp
9 8 OTHER_FILES += qml/quick2oscilloscope/*
10 9
11 10 include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
12 11
13 12 HEADERS += \
14 13 datasource.h
General Comments 0
You need to be logged in to leave comments. Login now