diff layer/NoteLayer.cpp @ 197:6b023411087b

* Work on harmonising colour and scale ranges between types of layer * Add normalize options to colour 3d plot layer
author Chris Cannam
date Thu, 01 Feb 2007 14:31:28 +0000
parents 33929e0c3c6b
children c2ed5014d4ff
line wrap: on
line diff
--- a/layer/NoteLayer.cpp	Wed Jan 31 12:13:47 2007 +0000
+++ b/layer/NoteLayer.cpp	Thu Feb 01 14:31:28 2007 +0000
@@ -19,6 +19,7 @@
 #include "base/RealTime.h"
 #include "base/Profiler.h"
 #include "base/Pitch.h"
+#include "base/LogRange.h"
 #include "view/View.h"
 
 #include "data/model/NoteModel.h"
@@ -485,8 +486,7 @@
 
         } else if (log) {
 
-            min = (min < 0.0) ? -log10(-min) : (min == 0.0) ? 0.0 : log10(min);
-            max = (max < 0.0) ? -log10(-max) : (max == 0.0) ? 0.0 : log10(max);
+            LogRange::mapRange(min, max);
 
             std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl;
 
@@ -506,8 +506,7 @@
         }
 
         if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) {
-            min = (min < 0.0) ? -log10(-min) : (min == 0.0) ? 0.0 : log10(min);
-            max = (max < 0.0) ? -log10(-max) : (max == 0.0) ? 0.0 : log10(max);
+            LogRange::mapRange(min, max);
             log = true;
         }
     }
@@ -533,7 +532,7 @@
     }
 
     if (logarithmic) {
-        val = (val < 0.0) ? -log10(-val) : (val == 0.0) ? 0.0 : log10(val);
+        val = LogRange::map(val);
 //        std::cerr << "logarithmic true, val now = " << val << std::endl;
     }
 
@@ -554,7 +553,7 @@
     float val = min + (float(h - y) * float(max - min)) / h;
 
     if (logarithmic) {
-        val = pow(10, val);
+        val = powf(10.f, val);
     }
 
     if (shouldConvertMIDIToHz()) {