diff layer/Colour3DPlotLayer.cpp @ 1047:86a8145a1897

Fix incorrect handling of model start frame
author Chris Cannam
date Fri, 04 Mar 2016 12:23:07 +0000
parents 19bb1744518e
children e8102ff5573b
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Fri Mar 04 12:22:42 2016 +0000
+++ b/layer/Colour3DPlotLayer.cpp	Fri Mar 04 12:23:07 2016 +0000
@@ -1309,6 +1309,7 @@
     double srRatio =
         v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate();
 
+    // the s-prefix values are source, i.e. model, column and bin numbers
     int sx0 = int((double(v->getFrameForX(x0)) / srRatio - double(modelStart))
                   / modelResolution);
     int sx1 = int((double(v->getFrameForX(x1)) / srRatio - double(modelStart))
@@ -1353,12 +1354,12 @@
 
     for (int sx = sx0; sx <= sx1; ++sx) {
 
-	sv_frame_t fx = sx * modelResolution;
+	sv_frame_t fx = sx * modelResolution + modelStart;
 
 	if (fx + modelResolution <= modelStart || fx > modelEnd) continue;
 
-        int rx0 = v->getXForFrame(int(double(fx + modelStart) * srRatio));
-	int rx1 = v->getXForFrame(int(double(fx + modelStart + modelResolution + 1) * srRatio));
+        int rx0 = v->getXForFrame(int(double(fx) * srRatio));
+	int rx1 = v->getXForFrame(int(double(fx + modelResolution + 1) * srRatio));
 
 	int rw = rx1 - rx0;
 	if (rw < 1) rw = 1;