+ painter->setPen(getColor(graphNum));
+
+ //Draw y-axis
+ int xo = 5+(graphNum*40);
+ painter->drawLine(xo, plotRect.top(),xo, plotRect.bottom());
+
+ int vMarkers = (absVMax - (absVMax % 10)) / 5;
+ int minYDist = 40; //Minimum pixel-distance between markers
+
+ char yLbl[20];
+
+ int n = 0;
+ int lasty0 = 65535;
+
+ for(int v = vMarkers; yCoordOf(v,plotRect,absVMax) > plotRect.top() && n < 20; v+= vMarkers ,n++)
+ {
+ int y0 = yCoordOf(v,plotRect,absVMax);
+ int y1 = yCoordOf(-v,plotRect,absVMax);
+
+ if(lasty0 - y0 < minYDist) continue;
+
+ painter->drawLine(xo-5,y0, xo+5, y0);
+
+ sprintf(yLbl, "%d", v);
+ painter->drawText(xo+5,y0-2,yLbl);
+
+ painter->drawLine(xo-5, y1, xo+5, y1);
+ sprintf(yLbl, "%d",-v);
+ painter->drawText(xo+5, y1-2 , yLbl);
+ lasty0 = y0;
+ }
+
+
+ //Graph annotations
+ painter->drawPath(penPath);
+ char str[200];
+ sprintf(str, "max=%5d min=%5d mean=%5d n=%5d/%5d CursorA=[%5d] CursorB=[%5d]",
+ vMax, vMin, vMean, sample_index, len, buffer[CursorAPos], buffer[CursorBPos]);
+ painter->drawText(20, annotationRect.bottom() - 25 - 15 * graphNum, str);
+
+ clock_t end = clock();
+ double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
+ printf("Plot time %f\n", elapsed_secs);
+}
+void Plot::plotGridLines(QPainter* painter,QRect r)
+{
+ int zeroHeight = r.top() + (r.bottom() - r.top()) / 2;
+
+ int i;
+ int grid_delta_x = (int) (PlotGridX * GraphPixelsPerPoint);
+ int grid_delta_y = (int) (PlotGridY * GraphPixelsPerPoint);
+
+ if (PlotGridX > 0 && grid_delta_x > 1) {
+ for(i = 40 + (GridOffset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x)
+ painter->drawLine(r.left()+i, r.top(), r.left()+i, r.bottom());
+ }
+ if (PlotGridY > 0 && grid_delta_y > 1){
+ for(i = 0; i < ((r.top() + r.bottom())>>1); i += grid_delta_y) {
+ painter->drawLine(r.left() + 40,zeroHeight + i,r.right(),zeroHeight + i);
+ painter->drawLine(r.left() + 40,zeroHeight - i,r.right(),zeroHeight - i);