[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lists of Raster objects
From: |
Ken Cline |
Subject: |
Re: Lists of Raster objects |
Date: |
Fri, 3 Apr 1998 15:16:15 -0500 (EST) |
Matt,
Where did you add the "lifeDisplay" to the "displayList" ?
I didn't see a line like: "[ displayList addLast: lifeDisplay ]"
anywhere within the loop.
BTW, you could move the "worldRaster" and "lifeDisplay"
pointer declarations out of the while-loop since you can
just keep reusing the one set of pointers. Perhaps the
compiler optimization routines do this automatically.
Ken.
On Fri, 3 Apr 1998, Matt M. Burke wrote:
> Help! I'm sure I'm overlooking something simple....
>
> First, I should mention I'm using the Win95 version since my access
> to our Sun network is temporarily down.
>
> I've been trying to whip up a "simple" little test and have hit a snag.
>
> Problem Summary: I create a list of ZoomRasters and a list of
> Value2dDisplays and hook them up to a list of ConwayLife2ds. The model
> compiles and runs, but all the raster windows are empty.
>
> Details: (Code is attached at the end of this message.)
>
> In ConwayModelSwarm I create a list of ConwayLife2ds. The Swarm
> implements a method "getWorldList" which returns this list of CAs.
>
> In ConwayObserverSwarm I fetch the list of CAs from the model swarm
> and iterate over this list creating a ZoomRaster and a Value2dDisplay
> for each.
>
> Now I build an ActionGroup and the first things I stick in there are
> a createActionForEach targeting the Value2dDisplay list and sending the
> message 'update' and then a createActionForEach targeting the raster list
> and sending a drawSelf message.
>
> Now, here's the kicker: I create two global variables myRaster and
> myDisplay and use them to temporarily hold each of the rasters/v2ds as
> I'm iterating over my list of CAs. So when I finish the loop the two
> variables still point to the last raster/v2d that I created. If I then
> stick the appropriate createAction messages so that myDisplay is given
> an update and myRaster is given a drawSelf then when I run the model I
> get (n-1) blank rasters and 1 raster that displays properly.
>
> Ok, what am I overlooking? Here's the relevent code from
> ConwaryObserverSwarm:
>
>
> In buildObjects:
>
>
> index = [ [conwayModelSwarm getWorldList] begin: [self getZone]];
> while ( (world = [index next]) ) {
> id <ZoomRaster> worldRaster;
> Value2dDisplay* lifeDisplay;
>
> worldRaster = [ZoomRaster createBegin: [self getZone]];
> SET_WINDOW_GEOMETRY_RECORD_NAME (worldRaster);
> worldRaster = [worldRaster createEnd];
> [worldRaster enableDestroyNotification: self
> notificationMethod: @selector (_worldRasterDeath_:)];
> [worldRaster setColormap: colormap];
> [worldRaster setZoomFactor: 4];
> [worldRaster setWidth: [conwayModelSwarm getWorldXSize]
> Height: [conwayModelSwarm getWorldYSize]];
> [worldRaster setWindowTitle: "Conway's Life World"];
> [worldRaster pack];
> [rasterList addLast: worldRaster];
>
> myRas = worldRaster;
>
> lifeDisplay = [Value2dDisplay createBegin: [self getZone]];
> [lifeDisplay setDisplayWidget: worldRaster colormap: colormap];
> [lifeDisplay setDiscrete2dToDisplay: world];
> lifeDisplay = [lifeDisplay createEnd];
>
> myDis = lifeDisplay;
>
> }
>
>
>
> and in buildActions:
>
> displayActions = [ActionGroup create: [self getZone]];
>
> [displayActions createActionForEach: displayList message: M(display)];
> [displayActions createActionForEach: rasterList message: M(drawSelf)];
> [displayActions createActionTo: myDis message: M(display)];
> [displayActions createActionTo: myRas message: M(drawSelf)];
> [displayActions createActionTo: probeDisplayManager message: M(update)];
> [displayActions createActionTo: actionCache message: M(doTkEvents)];
>
> displaySchedule = [Schedule createBegin: [self getZone]];
> [displaySchedule setRepeatInterval: displayFrequency];
> displaySchedule = [displaySchedule createEnd];
> [displaySchedule at: 0 createAction: displayActions];
>
>
>
> ==================================
> Swarm-Support is for discussion of the technical details of the day
> to day usage of Swarm. For list administration needs (esp.
> [un]subscribing), please send a message to <address@hidden>
> with "help" in the body of the message.
> ==================================
>
_________________________________________________________
Ken Cline address@hidden
SAIC VOICE (410) 571-0413
Annapolis, MD FAX (301) 261-8427
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================