changeset 23:6ace4286ba06

* 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 a1a6acb7cd37
children bb9291d84810
files base/Layer.h
diffstat 1 files changed, 29 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/base/Layer.h	Fri Feb 03 17:30:47 2006 +0000
+++ b/base/Layer.h	Mon Feb 06 17:24:52 2006 +0000
@@ -72,21 +72,37 @@
     //all applicable layers can actually do this from
     //paintVerticalScale as well?
 
-    // Select mode:
-    //
-    //!!! Next, a method that gets the frame of the nearest feature in
-    //a particular snap direction.  This would be used for selection
-    //mode, where we're selecting from the waveform based on feature
-    //location.  Do we need multi-select on features as well?  This is
-    //an issue; if you select a feature are you selecting that feature
-    //(in which case what do you do with it?) or a section of the
-    //underlying waveform?
+    enum SnapType {
+	SnapLeft,
+	SnapRight,
+	SnapNearest,
+	SnapNeighbouring
+    };
 
-    virtual int getNearestFeatureFrame(int frame,
-				       size_t &resolution,
-				       bool snapRight = true) const {
+    /**
+     * Adjust the given frame to snap to the nearest feature, if
+     * possible.
+     *
+     * If snap is SnapLeft or SnapRight, adjust the frame to match
+     * that of the nearest feature in the given direction regardless
+     * of how far away it is.  If snap is SnapNearest, adjust the
+     * frame to that of the nearest feature in either direction.  If
+     * snap is SnapNeighbouring, adjust the frame to that of the
+     * nearest feature if it is close, and leave it alone (returning
+     * false) otherwise.  SnapNeighbouring should always choose the
+     * same feature that would be used in an editing operation through
+     * calls to editStart etc.
+     *
+     * Return true if a suitable feature was found and frame adjusted
+     * accordingly.  Return false if no suitable feature was
+     * available.  Also return the resolution of the model in this
+     * layer in sample frames.
+     */
+    virtual bool snapToFeatureFrame(int &frame,
+				    size_t &resolution,
+				    SnapType snap) const {
 	resolution = 1;
-	return frame;
+	return false;
     }
 
     // Draw and edit modes: