I have hundreds of thousands of time series data that I want to represent for the user. My current solution is to present data to a PNG with a third party library and then load that PNG into a NSImage
and display it in a scroll view. It works great, Also:
- More than 32 x pixels NSImages do not display properly
- I want to be able to zoom data quickly and easily
- Writing from disk is stupid
My current effort is straightforward NSBezierPath
s is to draw on the NSView
. This scene presents beautifully, but very slowly, even if I only attract a limited subset of points at a time. And whenever I scroll, I have to draw again which is also slow.
I am certain as a relative cocoa newbie, that I am getting some better steps to do this. What is the "right" way to do this?
My current effort is to attract NSBezierPaths directly to an NSView Presents from, but very slowly, even if I only attract a limited subset of points at a time. And whenever I scroll, I have to attract again which is slow too.
Before you do any rigorous solution, try these simple steps:
- Clip. Use , which takes the rectangle as the argument of the
drawRect:
, passes. This is a one-liner. - Take a simple rectangle test before filling the paths. For each path, get your limits and use
NSIntersectsRect
to check it inside the rectangle. - Take a small rectangle test before the path path path. Similar to the previous step, except that the rectangle (which you have received your logic), line width, because the stroke will fall out of half way. For each path, get linewidth and deny it (
delta = - [path linewidth]
- and yes, you should include that minus sign), then both of the result Logic for the pass asNSInsetRect
. Make sure you keep the original rectangle all around, because different paths can have different linewidths.
Setting the clipping path (using NSRectClip
) to draw, just, less, reduce the amount of reducing results from the drawing operation Will give You will save more expensive clipping for those paths, except by completely falling paths outside the Draw rectangle.
And, of course, to ensure that you need a profile in each stage that you have not done things and slowed down. You may want to set some type of frame-rate counter.
One more thing: Getting the boundary of each route can be expensive. (Again, profile.) If so, you want to cache the boundaries of each path, perhaps using parallel NSArray
using NSValue
s or by using paths and boundaries Wraped together in one's own purpose, then you only calculate the boundary once and only get it back on the drawing run of the future.
Comments
Post a Comment