FROM : Greg Titus
DATE : Tue Feb 12 23:39:14 2008
Hi Paul,
Here are a couple of suggestions:
1) Create an OrderStepCell class, which represents the visible display
of a single OrderStep. Have it have a pointer to the OrderStep and the
rect that it draws in (i.e. it caches your OSRect value).
2) Only update that drawing rect for the cell when the OrderStep is
moved. Or update them all when your scale changes (the
pixelsPerSecond) or when enough time passes (1.0 / pixelsPerSecond = #
of seconds before the display changes by a single pixel). Use an
NSTimer for the latter.
3) When a cell moves, scale changes, or time passes, call -
updateTrackingAreas. Implement -updateTrackingAreas to
removeAllTooltips, and then create a tooltip for each order step.
Cocoa will also call -updateTrackingAreas whenever the view's geometry
changes such that tracking areas / cursor rects / tooltips need to be
updated. See the NSView documentation.
4) As a result of these changes, you should be able to remove the
computation of off-line time and the tooltip creation from your
drawing loop. You also shouldn't need to constantly redisplay - only
do it when your timer goes off or when order steps are being moved.
In short, most of your slowness here isn't really the drawing, it is
that you are doing a lot of computation during drawing that ought to
be done much less often.
Hope this helps!
- Greg
DATE : Tue Feb 12 23:39:14 2008
Hi Paul,
Here are a couple of suggestions:
1) Create an OrderStepCell class, which represents the visible display
of a single OrderStep. Have it have a pointer to the OrderStep and the
rect that it draws in (i.e. it caches your OSRect value).
2) Only update that drawing rect for the cell when the OrderStep is
moved. Or update them all when your scale changes (the
pixelsPerSecond) or when enough time passes (1.0 / pixelsPerSecond = #
of seconds before the display changes by a single pixel). Use an
NSTimer for the latter.
3) When a cell moves, scale changes, or time passes, call -
updateTrackingAreas. Implement -updateTrackingAreas to
removeAllTooltips, and then create a tooltip for each order step.
Cocoa will also call -updateTrackingAreas whenever the view's geometry
changes such that tracking areas / cursor rects / tooltips need to be
updated. See the NSView documentation.
4) As a result of these changes, you should be able to remove the
computation of off-line time and the tooltip creation from your
drawing loop. You also shouldn't need to constantly redisplay - only
do it when your timer goes off or when order steps are being moved.
In short, most of your slowness here isn't really the drawing, it is
that you are doing a lot of computation during drawing that ought to
be done much less often.
Hope this helps!
- Greg
| Related mails | Author | Date |
|---|---|---|
| Paul Bruneau | Feb 12, 23:02 | |
| John Stiles | Feb 12, 23:17 | |
| Peter Ammon | Feb 12, 23:31 | |
| Greg Titus | Feb 12, 23:39 | |
| Graham | Feb 12, 23:49 | |
| Erik Buck | Feb 13, 00:51 | |
| Paul Bruneau | Feb 13, 14:22 | |
| Paul Bruneau | Feb 13, 14:22 | |
| John Stiles | Feb 13, 18:41 | |
| Paul Bruneau | Feb 14, 14:47 | |
| Paul Bruneau | Feb 14, 15:13 | |
| Paul Bruneau | Feb 14, 15:26 | |
| Kyle Sluder | Feb 14, 16:43 |






Cocoa mail archive

