FIX: 'data plot + keypress g on empty plot' correct fix.

This commit is contained in:
iceman1001 2018-03-01 14:35:47 +01:00
commit 04d4ecddbf

View file

@ -241,7 +241,8 @@ int Plot::xCoordOf(int i, QRect r ) {
int Plot::yCoordOf(int v, QRect r, int maxVal) { int Plot::yCoordOf(int v, QRect r, int maxVal) {
int z = (r.bottom() - r.top()) / 2; int z = (r.bottom() - r.top()) / 2;
return -(z * v) / (maxVal + z); if ( maxVal == 0 ) ++maxVal;
return -(z * v) / maxVal + z;
} }
int Plot::valueOf_yCoord(int y, QRect r, int maxVal) { int Plot::valueOf_yCoord(int y, QRect r, int maxVal) {
@ -388,8 +389,7 @@ void Plot::PlotGraph(int *buffer, int len, QRect plotRect, QRect annotationRect,
int n = 0; int n = 0;
int lasty0 = 65535; int lasty0 = 65535;
for(v = vMarkers; yCoordOf(v,plotRect,g_absVMax) > plotRect.top() && n < 20; v+= vMarkers ,n++) for (v = vMarkers; yCoordOf(v, plotRect, g_absVMax) > plotRect.top() && n < 20; v+= vMarkers ,n++) {
{
int y0 = yCoordOf(v, plotRect, g_absVMax); int y0 = yCoordOf(v, plotRect, g_absVMax);
int y1 = yCoordOf(-v, plotRect, g_absVMax); int y1 = yCoordOf(-v, plotRect, g_absVMax);