Help: #drawOn: method monopolizes processor

Andres Valloud sqrmax at cvtci.com.ar
Wed Jun 16 02:31:14 UTC 1999


Hi.

>     I have a morphic component (MandelMorph) that draws a Mandelbrot
> Set fractal in a morphic world.

Hey! This is very nice!

> It seems that in order to use the method: #line:to:color: which is 
> crucial to drawing in morphic, I have to use a #drawOn method. The 
> problem is that #drawOn: is constantly sent to MandelMorph any time 
> that repainting is required - which is anytime I want to do something 
> with my MandelMorph - eg. trying to observe its properties (alt+enter) 
> thus preventing any other processing until the Mandelbrot has been 
> re-drawn ! It takes about 30 seconds on my machine (233 Mhz) to draw 
> the thing . If anyone is willing to fileIn the attatched *.st and then 
> eval : MandelMorph new, it will look like nothing is happening for 
> ~ 30 seconds and then the Mandelbrot Set will appear fully rendered. 
> If there was a way to make it so that the object is drawn only once
> that would solve the problem. I think this would involve caching,
> drawing the object off-screen, and/or drawing the object in a
> seperate thread or process. How would I go about doing this ? Thanks
> in advance to anyone who can help !

I had this very same problem with another kind of plotter, a function
plotter. What I did was to create the model without a Morphic
interface. I have FunctionPlotter subclasses, that when provided with
functions and other data, answer aForm with the plot. The Morph for
FunctionPlotters displays menues and does things like catching where
the mouse is clicked so they can attach a point to the hand that it's
the point "under" the hand and some other things. But the plotter
logic is not in the morph. All work is done and then later presented
by this drawOn: method:

drawOn: aCanvas

| toDraw |
(toDraw _ object answer) isNil ifTrue: [super drawOn: aCanvas]
	ifFalse:
		[
		self extent = toDraw extent ifFalse: 
			[self extent: toDraw extent. ^object updateMorph].
				aCanvas image: toDraw at: self position					]

The object is the plotter object, known by its morph. Its answer is
the form. The plotter object caches that form until a new plot is
requested.

Andres.





More information about the Squeak-dev mailing list