diff layer/Colour3DPlotLayer.cpp @ 28:202d1dca67d2

* Rationalise the local feature identification API in Layer subclasses * Add segmentation mode to TimeInstantLayer
author Chris Cannam
date Mon, 06 Feb 2006 17:24:52 +0000
parents 94381052a6c9
children ad214997dddb
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Fri Feb 03 17:30:47 2006 +0000
+++ b/layer/Colour3DPlotLayer.cpp	Mon Feb 06 17:24:52 2006 +0000
@@ -374,21 +374,30 @@
 */
 }
 
-int
-Colour3DPlotLayer::getNearestFeatureFrame(int frame,
-					  size_t &resolution,
-					  bool snapRight) const
+bool
+Colour3DPlotLayer::snapToFeatureFrame(int &frame,
+				      size_t &resolution,
+				      SnapType snap) const
 {
     if (!m_model) {
-	return Layer::getNearestFeatureFrame(frame, resolution, snapRight);
+	return Layer::snapToFeatureFrame(frame, resolution, snap);
     }
 
     resolution = m_model->getWindowSize();
+    int left = (frame / resolution) * resolution;
+    int right = left + resolution;
+
+    switch (snap) {
+    case SnapLeft:  frame = left;  break;
+    case SnapRight: frame = right; break;
+    case SnapNearest:
+    case SnapNeighbouring:
+	if (frame - left > right - frame) frame = right;
+	else frame = left;
+	break;
+    }
     
-    int returnFrame = (frame / resolution) * resolution;
-    if (snapRight) returnFrame += resolution;
-    
-    return returnFrame;
+    return true;
 }
 
 #ifdef INCLUDE_MOCFILES