annotate layer/LayerFactory.h @ 33:651e4e868bcc
* Implement play mute, level and pan controls and a layer visibility control
* Handle swapping the buffers in AudioCallbackPlaySource more gracefully, so
that in many cases it can be done inaudibly. Still gets it wrong when
playing in a noncontiguous selection.
* Fix to SV file save for non-2d sparse models
* Fixes to LED button drawing and AudioDial mouse functionality
* Add progress bar for Ogg file import
* Reshuffle PropertyContainer and its subclasses so it can be a QObject
* Add layer dormancy (invisible layer permitted to free its cache space)
* Optimisations to SpectrogramLayer, removing locks when reading/writing
individual pixels in the cache (should be unnecessary there) -- there's
still an issue here as we need a lock when reading from the model in
case the model is replaced, and we don't currently have one
* Several munlock() calls to make it harder to exhaust real memory if
running in an RT mode with mlockall() active
author |
Chris Cannam |
date |
Fri, 17 Feb 2006 18:04:26 +0000 |
parents |
ea6fe8cfcdd5 |
children |
10ba9276a315 |
rev |
line source |
Chris@0
|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 A waveform viewer and audio annotation editor.
|
Chris@5
|
5 Chris Cannam, Queen Mary University of London, 2005-2006
|
Chris@0
|
6
|
Chris@0
|
7 This is experimental software. Not for distribution.
|
Chris@0
|
8 */
|
Chris@0
|
9
|
Chris@0
|
10 #ifndef _LAYER_FACTORY_H_
|
Chris@0
|
11 #define _LAYER_FACTORY_H_
|
Chris@0
|
12
|
Chris@0
|
13 #include <QString>
|
Chris@0
|
14 #include <set>
|
Chris@0
|
15
|
Chris@0
|
16 class Layer;
|
Chris@0
|
17 class View;
|
Chris@0
|
18 class Model;
|
Chris@0
|
19
|
Chris@0
|
20 class LayerFactory
|
Chris@0
|
21 {
|
Chris@0
|
22 public:
|
Chris@0
|
23 enum LayerType {
|
Chris@0
|
24
|
Chris@0
|
25 // Standard layers
|
Chris@0
|
26 Waveform,
|
Chris@0
|
27 Spectrogram,
|
Chris@0
|
28 TimeRuler,
|
Chris@0
|
29 TimeInstants,
|
Chris@0
|
30 TimeValues,
|
Chris@30
|
31 Notes,
|
Chris@0
|
32 Colour3DPlot,
|
Chris@0
|
33
|
Chris@0
|
34 // Layers with different initial parameters
|
Chris@0
|
35 MelodicRangeSpectrogram,
|
Chris@0
|
36
|
Chris@0
|
37 // Not-a-layer-type
|
Chris@0
|
38 UnknownLayer = 255
|
Chris@0
|
39 };
|
Chris@0
|
40
|
Chris@0
|
41 static LayerFactory *instance();
|
Chris@0
|
42
|
Chris@0
|
43 virtual ~LayerFactory();
|
Chris@0
|
44
|
Chris@0
|
45 typedef std::set<LayerType> LayerTypeSet;
|
Chris@0
|
46 LayerTypeSet getValidLayerTypes(Model *model);
|
Chris@17
|
47 LayerTypeSet getValidEmptyLayerTypes();
|
Chris@0
|
48
|
Chris@6
|
49 LayerType getLayerType(const Layer *);
|
Chris@0
|
50
|
Chris@0
|
51 Layer *createLayer(LayerType type, View *view,
|
Chris@0
|
52 Model *model = 0, int channel = -1);
|
Chris@0
|
53
|
Chris@0
|
54 QString getLayerPresentationName(LayerType type);
|
Chris@0
|
55
|
Chris@0
|
56 void setModel(Layer *layer, Model *model);
|
Chris@17
|
57 Model *createEmptyModel(LayerType type, Model *baseModel);
|
Chris@0
|
58
|
Chris@17
|
59 QString getLayerIconName(LayerType);
|
Chris@6
|
60 QString getLayerTypeName(LayerType);
|
Chris@6
|
61 LayerType getLayerTypeForName(QString);
|
Chris@6
|
62
|
Chris@0
|
63 protected:
|
Chris@0
|
64 template <typename LayerClass, typename ModelClass>
|
Chris@0
|
65 bool trySetModel(Layer *layerBase, Model *modelBase) {
|
Chris@0
|
66 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase);
|
Chris@0
|
67 if (!layer) return false;
|
Chris@0
|
68 ModelClass *model = dynamic_cast<ModelClass *>(modelBase);
|
Chris@17
|
69 if (!model) return false;
|
Chris@0
|
70 layer->setModel(model);
|
Chris@0
|
71 return true;
|
Chris@0
|
72 }
|
Chris@0
|
73
|
Chris@0
|
74 static LayerFactory *m_instance;
|
Chris@0
|
75 };
|
Chris@0
|
76
|
Chris@0
|
77 #endif
|
Chris@0
|
78
|