##// END OF EJS Templates
minor. add missing license files
Michal Klocek -
r875:329bfbd049c1
parent child
Show More
@@ -1,24 +1,44
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 #include "wavechart.h"
21 #include "wavechart.h"
2 #include <QApplication>
22 #include <QApplication>
3 #include <QMainWindow>
23 #include <QMainWindow>
4 #include <QGLWidget>
24 #include <QGLWidget>
5
25
6 int main(int argc, char *argv[])
26 int main(int argc, char *argv[])
7 {
27 {
8 QApplication a(argc, argv);
28 QApplication a(argc, argv);
9
29
10 QMainWindow window;
30 QMainWindow window;
11 QChart *chart = new QChart();
31 QChart *chart = new QChart();
12 WaveChart *waveChart = new WaveChart(chart,&window);
32 WaveChart *waveChart = new WaveChart(chart,&window);
13
33
14 waveChart->setViewport( new QGLWidget() );
34 waveChart->setViewport( new QGLWidget() );
15 waveChart->setRenderHint(QPainter::Antialiasing);
35 waveChart->setRenderHint(QPainter::Antialiasing);
16 chart->setAnimationOptions(QChart::AllAnimations);
36 chart->setAnimationOptions(QChart::AllAnimations);
17 chart->setTitle("This is wave generator.");
37 chart->setTitle("This is wave generator.");
18
38
19 window.setCentralWidget(waveChart);
39 window.setCentralWidget(waveChart);
20 window.resize(400, 300);
40 window.resize(400, 300);
21 window.show();
41 window.show();
22
42
23 return a.exec();
43 return a.exec();
24 }
44 }
@@ -1,48 +1,68
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 #include "wavechart.h"
21 #include "wavechart.h"
2 #include <cmath>
22 #include <cmath>
3
23
4 QTCOMMERCIALCHART_USE_NAMESPACE
24 QTCOMMERCIALCHART_USE_NAMESPACE
5
25
6 #define PI 3.14159265358979
26 #define PI 3.14159265358979
7 static const int numPoints =100;
27 static const int numPoints =100;
8
28
9 WaveChart::WaveChart(QChart* chart, QWidget* parent) :
29 WaveChart::WaveChart(QChart* chart, QWidget* parent) :
10 QChartView(chart, parent),
30 QChartView(chart, parent),
11 m_series(new QLineSeries()),
31 m_series(new QLineSeries()),
12 m_wave(0),
32 m_wave(0),
13 m_step(2 * PI / numPoints)
33 m_step(2 * PI / numPoints)
14 {
34 {
15 QPen blue(Qt::blue);
35 QPen blue(Qt::blue);
16 blue.setWidth(3);
36 blue.setWidth(3);
17 m_series->setPen(blue);
37 m_series->setPen(blue);
18
38
19 QTime now = QTime::currentTime();
39 QTime now = QTime::currentTime();
20 qsrand((uint) now.msec());
40 qsrand((uint) now.msec());
21
41
22 int fluctuate = 100;
42 int fluctuate = 100;
23
43
24 for (qreal x = 0; x <= 2 * PI; x += m_step) {
44 for (qreal x = 0; x <= 2 * PI; x += m_step) {
25 m_series->append(x, fabs(sin(x) * fluctuate));
45 m_series->append(x, fabs(sin(x) * fluctuate));
26 }
46 }
27
47
28 chart->addSeries(m_series);
48 chart->addSeries(m_series);
29
49
30 QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(update()));
50 QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(update()));
31 m_timer.setInterval(5000);
51 m_timer.setInterval(5000);
32 m_timer.start();
52 m_timer.start();
33
53
34 }
54 }
35 ;
55 ;
36
56
37 void WaveChart::update()
57 void WaveChart::update()
38 {
58 {
39
59
40 int fluctuate;
60 int fluctuate;
41
61
42 for (qreal i = 0, x = 0; x <= 2 * PI; x += m_step, i++) {
62 for (qreal i = 0, x = 0; x <= 2 * PI; x += m_step, i++) {
43 fluctuate = qrand() % 100;
63 fluctuate = qrand() % 100;
44 m_series->replace(x, fabs(sin(x) * fluctuate));
64 m_series->replace(x, fabs(sin(x) * fluctuate));
45
65
46 }
66 }
47
67
48 }
68 }
@@ -1,24 +1,44
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 #include <QTimer>
21 #include <QTimer>
2 #include <QTime>
22 #include <QTime>
3 #include <QObject>
23 #include <QObject>
4 #include <QLineSeries>
24 #include <QLineSeries>
5 #include <QChartView>
25 #include <QChartView>
6
26
7 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
8
28
9 class WaveChart: public QChartView
29 class WaveChart: public QChartView
10 {
30 {
11 Q_OBJECT
31 Q_OBJECT
12
32
13 public:
33 public:
14 WaveChart(QChart* chart, QWidget* parent);
34 WaveChart(QChart* chart, QWidget* parent);
15
35
16 private slots:
36 private slots:
17 void update();
37 void update();
18
38
19 private:
39 private:
20 QLineSeries* m_series;
40 QLineSeries* m_series;
21 int m_wave;
41 int m_wave;
22 qreal m_step;
42 qreal m_step;
23 QTimer m_timer;
43 QTimer m_timer;
24 };
44 };
General Comments 0
You need to be logged in to leave comments. Login now