Chris@58
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- 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 Model;
|
Chris@0
|
18
|
Chris@0
|
19 class LayerFactory
|
Chris@0
|
20 {
|
Chris@0
|
21 public:
|
Chris@0
|
22 enum LayerType {
|
Chris@0
|
23
|
Chris@0
|
24 // Standard layers
|
Chris@0
|
25 Waveform,
|
Chris@0
|
26 Spectrogram,
|
Chris@0
|
27 TimeRuler,
|
Chris@0
|
28 TimeInstants,
|
Chris@0
|
29 TimeValues,
|
Chris@30
|
30 Notes,
|
Chris@35
|
31 Text,
|
Chris@0
|
32 Colour3DPlot,
|
Chris@0
|
33
|
Chris@0
|
34 // Layers with different initial parameters
|
Chris@0
|
35 MelodicRangeSpectrogram,
|
Chris@37
|
36 PeakFrequencySpectrogram,
|
Chris@0
|
37
|
Chris@0
|
38 // Not-a-layer-type
|
Chris@0
|
39 UnknownLayer = 255
|
Chris@0
|
40 };
|
Chris@0
|
41
|
Chris@0
|
42 static LayerFactory *instance();
|
Chris@0
|
43
|
Chris@0
|
44 virtual ~LayerFactory();
|
Chris@0
|
45
|
Chris@0
|
46 typedef std::set<LayerType> LayerTypeSet;
|
Chris@0
|
47 LayerTypeSet getValidLayerTypes(Model *model);
|
Chris@17
|
48 LayerTypeSet getValidEmptyLayerTypes();
|
Chris@0
|
49
|
Chris@6
|
50 LayerType getLayerType(const Layer *);
|
Chris@0
|
51
|
Chris@53
|
52 Layer *createLayer(LayerType type);
|
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@53
|
59 int getChannel(Layer *layer);
|
Chris@53
|
60 void setChannel(Layer *layer, int channel);
|
Chris@53
|
61
|
Chris@17
|
62 QString getLayerIconName(LayerType);
|
Chris@6
|
63 QString getLayerTypeName(LayerType);
|
Chris@6
|
64 LayerType getLayerTypeForName(QString);
|
Chris@6
|
65
|
Chris@0
|
66 protected:
|
Chris@0
|
67 template <typename LayerClass, typename ModelClass>
|
Chris@0
|
68 bool trySetModel(Layer *layerBase, Model *modelBase) {
|
Chris@0
|
69 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase);
|
Chris@0
|
70 if (!layer) return false;
|
Chris@0
|
71 ModelClass *model = dynamic_cast<ModelClass *>(modelBase);
|
Chris@17
|
72 if (!model) return false;
|
Chris@0
|
73 layer->setModel(model);
|
Chris@0
|
74 return true;
|
Chris@0
|
75 }
|
Chris@0
|
76
|
Chris@0
|
77 static LayerFactory *m_instance;
|
Chris@0
|
78 };
|
Chris@0
|
79
|
Chris@0
|
80 #endif
|
Chris@0
|
81
|