diff layer/TimeValueLayer.cpp @ 100:0db5e7492ce8

* Add units repository, and unit property on time-value and note layers.
author Chris Cannam
date Thu, 11 May 2006 15:02:14 +0000
parents 453f7da3534e
children 0f36cdf407a6
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp	Thu May 11 11:35:46 2006 +0000
+++ b/layer/TimeValueLayer.cpp	Thu May 11 15:02:14 2006 +0000
@@ -72,6 +72,7 @@
     list.push_back("Colour");
     list.push_back("Plot Type");
     list.push_back("Vertical Scale");
+    list.push_back("Scale Units");
     return list;
 }
 
@@ -81,13 +82,15 @@
     if (name == "Colour") return tr("Colour");
     if (name == "Plot Type") return tr("Plot Type");
     if (name == "Vertical Scale") return tr("Vertical Scale");
+    if (name == "Scale Units") return tr("Scale Units");
     return "";
 }
 
 Layer::PropertyType
 TimeValueLayer::getPropertyType(const PropertyName &name) const
 {
-    return ValueProperty;
+    if (name == "Scale Units") return UnitsProperty;
+    else return ValueProperty;
 }
 
 int
@@ -124,6 +127,13 @@
 	
 	deft = int(m_verticalScale);
 
+    } else if (name == "Scale Units") {
+
+        if (m_model) {
+            deft = UnitDatabase::getInstance()->getUnitId
+                (m_model->getScaleUnits());
+        }
+
     } else {
 	
 	deft = Layer::getPropertyRangeAndValue(name, min, max);
@@ -185,6 +195,12 @@
 	setPlotStyle(PlotStyle(value));
     } else if (name == "Vertical Scale") {
 	setVerticalScale(VerticalScale(value));
+    } else if (name == "Scale Units") {
+        if (m_model) {
+            m_model->setScaleUnits
+                (UnitDatabase::getInstance()->getUnitById(value));
+            emit modelChanged();
+        }
     }
 }