diff 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
line wrap: on
line diff
--- a/layer/LayerFactory.cpp	Thu Jan 26 11:56:09 2006 +0000
+++ b/layer/LayerFactory.cpp	Thu Jan 26 16:15:40 2006 +0000
@@ -90,6 +90,16 @@
     return types;
 }
 
+LayerFactory::LayerTypeSet
+LayerFactory::getValidEmptyLayerTypes()
+{
+    LayerTypeSet types;
+    types.insert(TimeInstants);
+    types.insert(TimeValues);
+    //!!! and in principle Colour3DPlot -- now that's a challenge
+    return types;
+}
+
 LayerFactory::LayerType
 LayerFactory::getLayerType(const Layer *layer)
 {
@@ -103,6 +113,20 @@
 }
 
 QString
+LayerFactory::getLayerIconName(LayerType type)
+{
+    switch (type) {
+    case Waveform: return "waveform";
+    case Spectrogram: return "spectrogram";
+    case TimeRuler: return "timeruler";
+    case TimeInstants: return "instants";
+    case TimeValues: return "values";
+    case Colour3DPlot: return "colour3d";
+    default: return "unknown";
+    }
+}
+
+QString
 LayerFactory::getLayerTypeName(LayerType type)
 {
     switch (type) {
@@ -153,6 +177,19 @@
 	return;
 }
 
+Model *
+LayerFactory::createEmptyModel(LayerType layerType, Model *baseModel)
+{
+    if (layerType == TimeInstants) {
+	return new SparseOneDimensionalModel(baseModel->getSampleRate(), 1);
+    } else if (layerType == TimeValues) {
+	return new SparseTimeValueModel(baseModel->getSampleRate(), 1,
+					0.0, 0.0, true);
+    } else {
+	return 0;
+    }
+}
+
 Layer *
 LayerFactory::createLayer(LayerType type, View *view,
 			  Model *model, int channel)