annotate layer/LayerFactory.h @ 134:13949a6970ab

* Use peaks instead of means for calculating display values in pixels that cover more than one bin
author Chris Cannam
date Wed, 16 Aug 2006 14:57:47 +0000
parents 9e6b3e239b9d
children 57c2350a8c40
rev   line source
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@59 4 Sonic Visualiser
Chris@59 5 An audio file viewer and annotation editor.
Chris@59 6 Centre for Digital Music, Queen Mary, University of London.
Chris@59 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@59 9 This program is free software; you can redistribute it and/or
Chris@59 10 modify it under the terms of the GNU General Public License as
Chris@59 11 published by the Free Software Foundation; either version 2 of the
Chris@59 12 License, or (at your option) any later version. See the file
Chris@59 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _LAYER_FACTORY_H_
Chris@0 17 #define _LAYER_FACTORY_H_
Chris@0 18
Chris@0 19 #include <QString>
Chris@0 20 #include <set>
Chris@0 21
Chris@0 22 class Layer;
Chris@0 23 class Model;
Chris@0 24
Chris@0 25 class LayerFactory
Chris@0 26 {
Chris@0 27 public:
Chris@0 28 enum LayerType {
Chris@0 29
Chris@0 30 // Standard layers
Chris@0 31 Waveform,
Chris@0 32 Spectrogram,
Chris@0 33 TimeRuler,
Chris@0 34 TimeInstants,
Chris@0 35 TimeValues,
Chris@30 36 Notes,
Chris@35 37 Text,
Chris@0 38 Colour3DPlot,
Chris@133 39 Spectrum,
Chris@0 40
Chris@0 41 // Layers with different initial parameters
Chris@0 42 MelodicRangeSpectrogram,
Chris@37 43 PeakFrequencySpectrogram,
Chris@0 44
Chris@0 45 // Not-a-layer-type
Chris@0 46 UnknownLayer = 255
Chris@0 47 };
Chris@0 48
Chris@125 49 static LayerFactory *getInstance();
Chris@0 50
Chris@0 51 virtual ~LayerFactory();
Chris@0 52
Chris@0 53 typedef std::set<LayerType> LayerTypeSet;
Chris@0 54 LayerTypeSet getValidLayerTypes(Model *model);
Chris@17 55 LayerTypeSet getValidEmptyLayerTypes();
Chris@0 56
Chris@6 57 LayerType getLayerType(const Layer *);
Chris@0 58
Chris@53 59 Layer *createLayer(LayerType type);
Chris@0 60
Chris@0 61 QString getLayerPresentationName(LayerType type);
Chris@0 62
Chris@0 63 void setModel(Layer *layer, Model *model);
Chris@17 64 Model *createEmptyModel(LayerType type, Model *baseModel);
Chris@0 65
Chris@53 66 int getChannel(Layer *layer);
Chris@53 67 void setChannel(Layer *layer, int channel);
Chris@53 68
Chris@17 69 QString getLayerIconName(LayerType);
Chris@6 70 QString getLayerTypeName(LayerType);
Chris@6 71 LayerType getLayerTypeForName(QString);
Chris@6 72
Chris@0 73 protected:
Chris@0 74 template <typename LayerClass, typename ModelClass>
Chris@0 75 bool trySetModel(Layer *layerBase, Model *modelBase) {
Chris@0 76 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase);
Chris@0 77 if (!layer) return false;
Chris@0 78 ModelClass *model = dynamic_cast<ModelClass *>(modelBase);
Chris@17 79 if (!model) return false;
Chris@0 80 layer->setModel(model);
Chris@0 81 return true;
Chris@0 82 }
Chris@0 83
Chris@0 84 static LayerFactory *m_instance;
Chris@0 85 };
Chris@0 86
Chris@0 87 #endif
Chris@0 88