diff view/Pane.cpp @ 268:70537b0434c4

* Use a command for adding layer measurements
author Chris Cannam
date Tue, 26 Jun 2007 11:08:21 +0000
parents 4ed1446ad604
children 61a704654497
line wrap: on
line diff
--- a/view/Pane.cpp	Thu Jun 21 16:12:00 2007 +0000
+++ b/view/Pane.cpp	Tue Jun 26 11:08:21 2007 +0000
@@ -396,11 +396,11 @@
         }
     }
 
-    Layer *topLayer = 0;
+    Layer *topLayer = getTopLayer();
+
     const Model *waveformModel = 0; // just for reporting purposes
     for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
         --vi;
-        if (!topLayer) topLayer = *vi;
         if (dynamic_cast<WaveformLayer *>(*vi)) {
             waveformModel = (*vi)->getModel();
             break;
@@ -968,8 +968,7 @@
                                 float &dmin, float &dmax,
                                 QString *unit) 
 {
-    Layer *layer = 0;
-    if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
+    Layer *layer = getTopLayer();
     if (!layer) return false;
     bool vlog;
     QString vunit;
@@ -982,8 +981,7 @@
 bool
 Pane::setTopLayerDisplayExtents(float dmin, float dmax)
 {
-    Layer *layer = 0;
-    if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
+    Layer *layer = getTopLayer();
     if (!layer) return false;
     return layer->setDisplayExtents(dmin, dmax);
 }
@@ -1089,7 +1087,7 @@
 
     } else if (mode == ViewManager::MeasureMode) {
 
-        Layer *layer = getSelectedLayer();
+        Layer *layer = getTopLayer();
         if (layer) layer->measureStart(this, e);
         update();
     }
@@ -1175,7 +1173,7 @@
 
     } else if (mode == ViewManager::MeasureMode) {
 
-        Layer *layer = getSelectedLayer();
+        Layer *layer = getTopLayer();
         if (layer) layer->measureEnd(this, e);
         if (m_measureCursor1) setCursor(*m_measureCursor1);
         update();
@@ -1268,7 +1266,7 @@
 
         if (m_measureCursor2) setCursor(*m_measureCursor2);
 
-        Layer *layer = getSelectedLayer();
+        Layer *layer = getTopLayer();
         if (layer) layer->measureDrag(this, e);
 
         if (hasTopLayerTimeXAxis()) {