diff layer/Layer.h @ 267:4ed1446ad604

* more on measurement tool -- pull out some logic from pane to layer &c still more to do
author Chris Cannam
date Thu, 21 Jun 2007 16:12:00 +0000
parents 6d113226bb4c
children 70537b0434c4
line wrap: on
line diff
--- a/layer/Layer.h	Thu Jun 21 14:05:23 2007 +0000
+++ b/layer/Layer.h	Thu Jun 21 16:12:00 2007 +0000
@@ -105,6 +105,8 @@
     }
     virtual void paintCrosshairs(View *, QPainter &, QPoint) const { }
 
+    virtual void paintMeasurementRects(View *, QPainter &) const;
+
     virtual QString getFeatureDescription(View *, QPoint &) const {
 	return "";
     }
@@ -156,6 +158,14 @@
     virtual void editDrag(View *, QMouseEvent *) { }
     virtual void editEnd(View *, QMouseEvent *) { }
 
+    // Measurement rectangle (or equivalent).  Unlike draw and edit,
+    // the base Layer class can provide working implementations of
+    // these for most situations.
+    //
+    virtual void measureStart(View *, QMouseEvent *);
+    virtual void measureDrag(View *, QMouseEvent *);
+    virtual void measureEnd(View *, QMouseEvent *);
+
     /**
      * Open an editor on the item under the mouse (e.g. on
      * double-click).  If there is no item or editing is not
@@ -323,14 +333,14 @@
      * measurement tool.  The default implementation works correctly
      * if the layer hasTimeXAxis().
      */
-    virtual bool getXScaleValue(View *v, int x,
+    virtual bool getXScaleValue(const View *v, int x,
                                 float &value, QString &unit) const;
 
     /** 
      * Return the value and unit at the given y coordinate in the
      * given view.
      */
-    virtual bool getYScaleValue(View *, int /* y */,
+    virtual bool getYScaleValue(const View *, int /* y */,
                                 float &/* value */, QString &/* unit */) const {
         return false;
     }
@@ -390,6 +400,18 @@
 
     void verticalZoomChanged();
 
+protected:
+    struct MeasureRect {
+        mutable QRect pixrect;
+        long startFrame; // only valid for a layer that hasTimeXAxis
+        long endFrame;   // ditto
+    };
+
+    typedef std::vector<MeasureRect> MeasureRectList; // should be x-ordered
+    MeasureRectList m_measureRectList;
+    MeasureRect m_draggingRect;
+    bool m_haveDraggingRect;
+
 private:
     mutable QMutex m_dormancyMutex;
     mutable std::map<const void *, bool> m_dormancy;