diff layer/TimeValueLayer.cpp @ 699:1a1448f7beb2

Pull out colour scale drawing as well
author Chris Cannam
date Wed, 04 Dec 2013 13:11:23 +0000
parents ad7623c39396
children 7846175403f1
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp	Wed Dec 04 11:35:08 2013 +0000
+++ b/layer/TimeValueLayer.cpp	Wed Dec 04 13:11:23 2013 +0000
@@ -33,6 +33,8 @@
 #include "PianoScale.h"
 #include "LinearNumericalScale.h"
 #include "LogNumericalScale.h"
+#include "LinearColourScale.h"
+#include "LogColourScale.h"
 
 #include <QPainter>
 #include <QPainterPath>
@@ -1208,14 +1210,19 @@
 TimeValueLayer::getVerticalScaleWidth(View *v, bool, QPainter &paint) const
 {
     if (!m_model || shouldAutoAlign()) return 0;
-    int w = 0;
-    if (m_verticalScale == LogScale) {
-        w = LogNumericalScale().getWidth(v, paint);
+    if (m_plotStyle == PlotSegmentation) {
+        if (m_verticalScale == LogScale) {
+            return LogColourScale().getWidth(v, paint);
+        } else {
+            return LinearColourScale().getWidth(v, paint);
+        }
     } else {
-        w = LinearNumericalScale().getWidth(v, paint);
+        if (m_verticalScale == LogScale) {
+            return LogNumericalScale().getWidth(v, paint) + 10; // for piano
+        } else {
+            return LinearNumericalScale().getWidth(v, paint);
+        }
     }
-    if (m_plotStyle == PlotSegmentation) return w + 20;
-    else return w + 10;
 }
 
 void
@@ -1351,19 +1358,30 @@
 	val += inc;
     }
 */
+    QString unit;
     float min, max;
     bool logarithmic;
-    getScaleExtents(v, min, max, logarithmic);
 
     int w = getVerticalScaleWidth(v, false, paint);
     int h = v->height();
 
     if (m_plotStyle == PlotSegmentation) {
 
-        //!!! todo!
+        getValueExtents(min, max, logarithmic, unit);
+
+        if (logarithmic) {
+
+            LogRange::mapRange(min, max);
+            LogColourScale().paintVertical(v, this, paint, 0, min, max);
+
+        } else {
+            LinearColourScale().paintVertical(v, this, paint, 0, min, max);
+        }
 
     } else {
 
+        getScaleExtents(v, min, max, logarithmic);
+
         if (logarithmic) {
             LogNumericalScale().paintVertical(v, this, paint, 0, min, max);
         } else {