00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _LAYER_FACTORY_H_
00017 #define _LAYER_FACTORY_H_
00018
00019 #include <QString>
00020 #include <set>
00021
00022 class Layer;
00023 class Model;
00024 class Clipboard;
00025
00026 class LayerFactory
00027 {
00028 public:
00029 enum LayerType {
00030
00031
00032 Waveform,
00033 Spectrogram,
00034 TimeRuler,
00035 TimeInstants,
00036 TimeValues,
00037 Notes,
00038 Text,
00039 Image,
00040 Colour3DPlot,
00041 Spectrum,
00042 Slice,
00043
00044
00045 MelodicRangeSpectrogram,
00046 PeakFrequencySpectrogram,
00047
00048
00049 UnknownLayer = 255
00050 };
00051
00052 static LayerFactory *getInstance();
00053
00054 virtual ~LayerFactory();
00055
00056 typedef std::set<LayerType> LayerTypeSet;
00057 LayerTypeSet getValidLayerTypes(Model *model);
00058 LayerTypeSet getValidEmptyLayerTypes();
00059
00060 LayerType getLayerType(const Layer *);
00061
00062 Layer *createLayer(LayerType type);
00063
00064 void setLayerDefaultProperties(LayerType type, Layer *layer);
00065
00066 QString getLayerPresentationName(LayerType type);
00067
00068 bool isLayerSliceable(const Layer *);
00069
00070 void setModel(Layer *layer, Model *model);
00071 Model *createEmptyModel(LayerType type, Model *baseModel);
00072
00073 int getChannel(Layer *layer);
00074 void setChannel(Layer *layer, int channel);
00075
00076 QString getLayerIconName(LayerType);
00077 QString getLayerTypeName(LayerType);
00078 LayerType getLayerTypeForName(QString);
00079
00080 LayerType getLayerTypeForClipboardContents(const Clipboard &);
00081
00082 protected:
00083 template <typename LayerClass, typename ModelClass>
00084 bool trySetModel(Layer *layerBase, Model *modelBase) {
00085 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase);
00086 if (!layer) return false;
00087 ModelClass *model = dynamic_cast<ModelClass *>(modelBase);
00088 if (!model) return false;
00089 layer->setModel(model);
00090 return true;
00091 }
00092
00093 static LayerFactory *m_instance;
00094 };
00095
00096 #endif
00097