##// 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 21 #include "wavechart.h"
2 22 #include <QApplication>
3 23 #include <QMainWindow>
4 24 #include <QGLWidget>
5 25
6 26 int main(int argc, char *argv[])
7 27 {
8 28 QApplication a(argc, argv);
9 29
10 30 QMainWindow window;
11 31 QChart *chart = new QChart();
12 32 WaveChart *waveChart = new WaveChart(chart,&window);
13 33
14 34 waveChart->setViewport( new QGLWidget() );
15 35 waveChart->setRenderHint(QPainter::Antialiasing);
16 36 chart->setAnimationOptions(QChart::AllAnimations);
17 37 chart->setTitle("This is wave generator.");
18 38
19 39 window.setCentralWidget(waveChart);
20 40 window.resize(400, 300);
21 41 window.show();
22 42
23 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 21 #include "wavechart.h"
2 22 #include <cmath>
3 23
4 24 QTCOMMERCIALCHART_USE_NAMESPACE
5 25
6 26 #define PI 3.14159265358979
7 27 static const int numPoints =100;
8 28
9 29 WaveChart::WaveChart(QChart* chart, QWidget* parent) :
10 30 QChartView(chart, parent),
11 31 m_series(new QLineSeries()),
12 32 m_wave(0),
13 33 m_step(2 * PI / numPoints)
14 34 {
15 35 QPen blue(Qt::blue);
16 36 blue.setWidth(3);
17 37 m_series->setPen(blue);
18 38
19 39 QTime now = QTime::currentTime();
20 40 qsrand((uint) now.msec());
21 41
22 42 int fluctuate = 100;
23 43
24 44 for (qreal x = 0; x <= 2 * PI; x += m_step) {
25 45 m_series->append(x, fabs(sin(x) * fluctuate));
26 46 }
27 47
28 48 chart->addSeries(m_series);
29 49
30 50 QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(update()));
31 51 m_timer.setInterval(5000);
32 52 m_timer.start();
33 53
34 54 }
35 55 ;
36 56
37 57 void WaveChart::update()
38 58 {
39 59
40 60 int fluctuate;
41 61
42 62 for (qreal i = 0, x = 0; x <= 2 * PI; x += m_step, i++) {
43 63 fluctuate = qrand() % 100;
44 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 21 #include <QTimer>
2 22 #include <QTime>
3 23 #include <QObject>
4 24 #include <QLineSeries>
5 25 #include <QChartView>
6 26
7 27 QTCOMMERCIALCHART_USE_NAMESPACE
8 28
9 29 class WaveChart: public QChartView
10 30 {
11 31 Q_OBJECT
12 32
13 33 public:
14 34 WaveChart(QChart* chart, QWidget* parent);
15 35
16 36 private slots:
17 37 void update();
18 38
19 39 private:
20 40 QLineSeries* m_series;
21 41 int m_wave;
22 42 qreal m_step;
23 43 QTimer m_timer;
24 44 };
General Comments 0
You need to be logged in to leave comments. Login now