kwave  18.07.70
OverViewCache.h
Go to the documentation of this file.
1 /***************************************************************************
2  OverViewCache.h - fast cache for sample data overview
3  -------------------
4  begin : Mon May 20 2002
5  copyright : (C) 2000 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef OVER_VIEW_CACHE_H
19 #define OVER_VIEW_CACHE_H
20 
21 #include "config.h"
22 
23 #include <QtGlobal>
24 #include <QHash>
25 #include <QImage>
26 #include <QList>
27 #include <QMutex>
28 #include <QObject>
29 #include <QUuid>
30 #include <QVector>
31 
32 #include "libkwave/Sample.h"
33 
35 
36 class QColor;
37 
38 namespace Kwave
39 {
40 
41  class SignalManager;
42  class Track;
43 
50  class Q_DECL_EXPORT OverViewCache: public QObject
51  {
52  Q_OBJECT
53  public:
54 
55  typedef struct {
58  } MinMax;
59 
60  typedef QVector<MinMax> MinMaxArray;
61 
73  sample_index_t src_offset,
74  sample_index_t src_length,
75  const QList<unsigned int> *src_tracks);
76 
78  virtual ~OverViewCache();
79 
86  int getMinMax(int width, MinMaxArray &minmax);
87 
97  virtual QImage getOverView(int width, int height,
98  const QColor &fg, const QColor &bg,
99  double gain = 1.0);
100 
101  signals:
102 
104  void changed();
105 
106  protected slots:
107 
113  void slotTrackInserted(const QUuid &track_id);
114 
120  void slotTrackDeleted(const QUuid &track_id);
121 
127  void slotLengthChanged(sample_index_t new_length);
128 
135  void slotInvalidated(const QUuid *track_id,
136  sample_index_t first,
137  sample_index_t last);
138 
139  protected:
140 
142  typedef enum {
143  Invalid = 0,
146  Unused
147  } CacheState;
148 
149  private:
150 
154  void scaleUp();
155 
161  void scaleDown();
162 
169  void invalidateCache(const QUuid *uuid,
170  unsigned int first,
171  unsigned int last);
172 
173  private:
174 
177 
180 
182  QHash<QUuid, QVector <sample_t> > m_min;
183 
185  QHash<QUuid, QVector <sample_t> > m_max;
186 
188  QHash<QUuid, QVector <CacheState> > m_state;
189 
191  MinMaxArray m_minmax;
192 
194  quint64 m_scale;
195 
197  QMutex m_lock;
198 
199  };
200 }
201 
202 #endif // _OVER_VIEW_CACHE_H_
203 
204 //***************************************************************************
205 //***************************************************************************
Definition: App.h:33
QHash< QUuid, QVector< sample_t > > m_min
quint64 sample_index_t
Definition: Sample.h:28
Kwave::SelectionTracker m_selection
QVector< MinMax > MinMaxArray
Definition: OverViewCache.h:60
QHash< QUuid, QVector< sample_t > > m_max
QHash< QUuid, QVector< CacheState > > m_state
Kwave::SignalManager & m_signal
qint32 sample_t
Definition: Sample.h:37