SinceĀ Tiger, my NSScrollView is messing up my view during redrawing or scrolling. I think I traced the problem to the drawRect method of my view getting the wrong rectangle. Here are results during running of the code:
1. The view is created, the bounds are set, data to plot are loaded, and setNeedsDisplay is set to YES to trigger drawing the plot. In this first pass, the rect passed to drawRect matches theĀ bounds of the view.
setBounds {{-0.00375384, -0.0162667}, {0.0395077, 0.0285333}} Plot data set 1 in view bounds {{-0.00375384, -0.0162667}, {0.0395077, 0.0285333}} drawRect gets {{-0.00375384, -0.0162667}, {0.0395077, 0.0285333}}
2. To draw a new plot, the data are changed and for this problem the bounds are unchanged. The first line is printed when the new data are loading showing the view still has the same bounds. But, after setNeedsDisplay triggers an update, drawRect is now getting something different than the bounds and thus only part of the new plot is drawn and the update is wrong.
Plot data set 2 in view bounds {{-0.00375384, -0.0162667}, {0.0395077, 0.0285333}} drawRect gets {{2.62138e-05, -0.0162667}, {0.0357276, 0.0285333}} Plot data set 3 in view bounds {{-0.00375384, -0.0162667}, {0.0395077, 0.0285333}} drawRect gets {{2.62138e-05, -0.0162667}, {0.0357276, 0.0285333}}
Thus, even though nothing has changed in my view, all subsequent needs to redraw are getting a different rectangle than the first time it draws. Even explicitly setting needs display in my view's bounds does not change the wrong rectangle getting to drawRect. It might be a coincidence, but the left edge of my bounds is negative and the bad rectangle passed on subsequent calls has left edge close to zero. The section of the plot with negative x coordinates is the part that does not draw correctly.
|