Re: displaying a calculated image
Re: displaying a calculated image
- Subject: Re: displaying a calculated image
- From: Cameron Hayne <email@hidden>
- Date: Sun, 26 May 2002 08:55:23 -0400
I had asked a while ago about how best to display an image which is the
result of an ongoing calculation in another thread. I have now
accomplished what I had hoped for by using NSTimer to tell the view to
redisplay at fixed intervals and by doing the drawing in a subclass of
NSView. One problem that I had to overcome was that NSSlider does not
seem to allow processing of timer events when the mouse is held down on
the slider. To fix this (which might be considered a bug in NSSlider ?),
I use a subclass of NSSlider which sends a stream of Periodic Events
when the mouse is down.
You can get my sample code at:
http://www.hayne.net/MacDev/ImageCalc/
This illustrates several aspects of Cocoa programming:
* calculation in a separate thread
* synchronizing use of shared variables via NSLock
* image drawn via NSBitmapImageRep in a subclass of NSView
* regular display updates via NSTimer
* subclass of NSSlider that allows timer events while mouse is down
* auxiliary information displayed in an NSDrawer
I would be very interested in hearing any comments on the above code:
- better (simpler/faster) ways to do it ?
- opinions on my use of MVC ?
... Cameron
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.