Changeset View
Changeset View
Standalone View
Standalone View
src/context/applets/analyzer/plugin/BlockWorker.h
- This file was added.
1 | /**************************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2017 Malte Veerman <malte.veerman@gmail.com> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or modify it under * | ||||
5 | * the terms of the GNU General Public License as published by the Free Software * | ||||
6 | * Foundation; either version 2 of the License, or (at your option) any later * | ||||
7 | * version. * | ||||
8 | * * | ||||
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * | ||||
10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * | ||||
11 | * PARTICULAR PURPOSE. See the GNU General Pulic License for more details. * | ||||
12 | * * | ||||
13 | * You should have received a copy of the GNU General Public License along with * | ||||
14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | ||||
15 | ****************************************************************************************/ | ||||
16 | | ||||
17 | #ifndef BLOCKWORKER_H | ||||
18 | #define BLOCKWORKER_H | ||||
19 | | ||||
20 | #include "AnalyzerWorker.h" | ||||
21 | | ||||
22 | #include <QMutex> | ||||
23 | #include <QTime> | ||||
24 | #include <QVector> | ||||
25 | | ||||
26 | | ||||
27 | class BlockWorker : public Analyzer::Worker | ||||
28 | { | ||||
29 | friend class BlockRenderer; | ||||
30 | | ||||
31 | Q_OBJECT | ||||
32 | | ||||
33 | public: | ||||
34 | BlockWorker( int rows, int columns, qreal step, bool showFadebars ); | ||||
35 | | ||||
36 | void setStep( qreal step ) { m_step = step; } | ||||
37 | void setRows( int rows ); | ||||
38 | void setColumns( int columns ); | ||||
39 | void setRefreshRate( qreal refreshRate ) { m_refreshTime = std::floor( 1000.0 / refreshRate ); } | ||||
40 | void setShowFadebars( bool showFadebars ) { m_showFadebars = showFadebars; } | ||||
41 | | ||||
42 | signals: | ||||
43 | void finished(); | ||||
44 | | ||||
45 | protected: | ||||
46 | void analyze() Q_DECL_OVERRIDE; | ||||
47 | | ||||
48 | private: | ||||
49 | struct Fadebar | ||||
50 | { | ||||
51 | int y; | ||||
52 | qreal intensity; | ||||
53 | Fadebar() | ||||
54 | { | ||||
55 | y = 0; | ||||
56 | intensity = 0.0; | ||||
57 | } | ||||
58 | Fadebar( int y, qreal intensity ) | ||||
59 | { | ||||
60 | this->y = y; | ||||
61 | this->intensity = intensity; | ||||
62 | } | ||||
63 | }; | ||||
64 | mutable QMutex m_mutex; //used to lock m_store and m_fadebars | ||||
65 | QVector<double> m_store; //current bar heights | ||||
66 | QVector<double> m_yscale; | ||||
67 | QVector<QList<Fadebar> > m_fadebars; | ||||
68 | qreal m_step; | ||||
69 | int m_rows; | ||||
70 | int m_columns; | ||||
71 | int m_refreshTime; | ||||
72 | bool m_showFadebars; | ||||
73 | QTime m_lastUpdate; | ||||
74 | }; | ||||
75 | | ||||
76 | #endif //BLOCKWORKER_H |