comparison layer/LayerFactory.cpp @ 17:0183ebb725ca

* Add ability to create empty layers for editing * Add first basic editing capability (adding points to a time instant layer) * Add various keyboard and mouse shortcuts for navigation &c * Add ability to resize a selection by dragging its edges * Add maximum zoom level
author Chris Cannam
date Thu, 26 Jan 2006 16:15:40 +0000
parents 2d5005f2b3d9
children ea6fe8cfcdd5
comparison
equal deleted inserted replaced
16:02a718909b2d 17:0183ebb725ca
85 } 85 }
86 86
87 // We don't count TimeRuler here as it doesn't actually display 87 // We don't count TimeRuler here as it doesn't actually display
88 // the data, although it can be backed by any model 88 // the data, although it can be backed by any model
89 89
90 return types;
91 }
92
93 LayerFactory::LayerTypeSet
94 LayerFactory::getValidEmptyLayerTypes()
95 {
96 LayerTypeSet types;
97 types.insert(TimeInstants);
98 types.insert(TimeValues);
99 //!!! and in principle Colour3DPlot -- now that's a challenge
90 return types; 100 return types;
91 } 101 }
92 102
93 LayerFactory::LayerType 103 LayerFactory::LayerType
94 LayerFactory::getLayerType(const Layer *layer) 104 LayerFactory::getLayerType(const Layer *layer)
101 if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot; 111 if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot;
102 return UnknownLayer; 112 return UnknownLayer;
103 } 113 }
104 114
105 QString 115 QString
116 LayerFactory::getLayerIconName(LayerType type)
117 {
118 switch (type) {
119 case Waveform: return "waveform";
120 case Spectrogram: return "spectrogram";
121 case TimeRuler: return "timeruler";
122 case TimeInstants: return "instants";
123 case TimeValues: return "values";
124 case Colour3DPlot: return "colour3d";
125 default: return "unknown";
126 }
127 }
128
129 QString
106 LayerFactory::getLayerTypeName(LayerType type) 130 LayerFactory::getLayerTypeName(LayerType type)
107 { 131 {
108 switch (type) { 132 switch (type) {
109 case Waveform: return "waveform"; 133 case Waveform: return "waveform";
110 case Spectrogram: return "spectrogram"; 134 case Spectrogram: return "spectrogram";
149 if (trySetModel<Colour3DPlotLayer, DenseThreeDimensionalModel>(layer, model)) 173 if (trySetModel<Colour3DPlotLayer, DenseThreeDimensionalModel>(layer, model))
150 return; 174 return;
151 175
152 if (trySetModel<SpectrogramLayer, DenseTimeValueModel>(layer, model)) 176 if (trySetModel<SpectrogramLayer, DenseTimeValueModel>(layer, model))
153 return; 177 return;
178 }
179
180 Model *
181 LayerFactory::createEmptyModel(LayerType layerType, Model *baseModel)
182 {
183 if (layerType == TimeInstants) {
184 return new SparseOneDimensionalModel(baseModel->getSampleRate(), 1);
185 } else if (layerType == TimeValues) {
186 return new SparseTimeValueModel(baseModel->getSampleRate(), 1,
187 0.0, 0.0, true);
188 } else {
189 return 0;
190 }
154 } 191 }
155 192
156 Layer * 193 Layer *
157 LayerFactory::createLayer(LayerType type, View *view, 194 LayerFactory::createLayer(LayerType type, View *view,
158 Model *model, int channel) 195 Model *model, int channel)