Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!sdd.hp.com!samsung!munnari.oz.au!metro!ipso!runxtsa!timm From: timm@runx.oz.au (Tim Menzies) Newsgroups: comp.lang.smalltalk Subject: optimising redraws of graphic panes in ST/V 286 Message-ID: <1991Feb8.102528.10392@runx.oz.au> Date: 8 Feb 91 10:25:28 GMT Sender: timm@runx.oz.au (Tim Menzies) Organization: RUNX Un*x Timeshare. Sydney, Australia. Lines: 130 Dear netland, I've got a graphics application written in Smalltalk V/286. One problem with it is that the screen redraws are a slow. I've got a display of a X-Y plot with lots of lines/ text labels on it. I've tried various ways to speed up the redraws. The manuals isn't exactly helpful and so I include below a sample listing and ask the following questions... - would you expect that writing to a virtual form, then copying this to the display, would speed up the redraw? If yes, then how is this done? I've tried every variant I can think of on setting drawLine's pen's dest/sourceForm to Display/form etc., etc. - any other ideas on how to speed up the redraws on the following sample system? There must be a way. The standard Smalltalk window redraws are FASTTTT. What am I doing wrong? Tanks in advance, -- _--_|\ Tim Menzies (timm@runxtsa.oz) "A degree proves that you can do / \ HiSoft Expert Systems Group, something you don't enjoy for 3 \_.--._/ 2-6 Orion Rd, Lane Cove, NSW, 2066 years. And if you get good marks, v 61 2 9297729(voice),61 2 4280200(fax) it shows you can do it well." --- cut here ---- Object subclass: #UNSDrawTest instanceVariableNames: 'view form ' classVariableNames: '' poolDictionaries: '' ! !UNSDrawTest class methods ! demo "Give it a whirl and see what happens." self new open! ! !UNSDrawTest methods ! comment " This class is a test of various methods of speeding up a graphic redraw."! drawLines "Draw a line from position to position." |pen| pen := Pen new defaultNib: 1; frame: view frame. self positions pairsDo: [:last :next| pen place: last. pen goto: next]! graph: rect "Return a new graph-form for the display." form := Display compatibleForm width: rect width height: rect height. form displayAt: rect origin. self drawLines. ^form! open "open the display." |topPane| topPane := TopPane new label: 'redraw test'; minimumSize: (200 @ 100); yourself. topPane addSubpane: (view := GraphPane new model: self; name: #graph:; framingBlock: [ :box | box]). topPane reframe: (10 @ 10 extent: 350 @ 200). topPane dispatcher open scheduleWindow! positions "Return a long list of points that are the corners of a complicated line that will take some time to draw on the screen." |topLeft topRight bottomLeft bottomRight x0 y0 x1 y1 n deltax deltay positions| positions := OrderedCollection new. n := 20. topLeft := view frame origin. topRight := view frame origin + (view frame width @ 0). bottomLeft := view frame origin + (0 @ view frame height). bottomRight := view frame corner. y0 := topLeft y. y1 := bottomLeft y. x0 := topLeft x. x1 := bottomRight x. deltax := x1 - x0 / n. deltay := y1 - y0 / n. x0 to: x1 by: deltax do: [:x| y1 to: y0 by: deltay negated do: [:y| positions add: x rounded @ y rounded]]. x0 to: x1 by: deltax do: [:x| y0 to: y1 by: deltay do: [:y| positions add: x rounded @ y rounded]]. ^positions ! ! ! Collection methods ! pairsDo: aBlock "Message the block with all adjacent items in the receiver, working left to right." |last| self indexDo: [:next :index| index > 1 ifTrue: [aBlock value: last value: next]. last := next] ! ! ! GraphDispatcher methods ! processControlKey: aCharacter "Private - Cr = update." aCharacter == Cr ifTrue: [^pane update]. super processControlKey: aCharacter ! !