//http://www.santafe.edu/projects/swarm/archive/list-archive.9903/0066.html //NC> I'm trying to use FunctionGraph and am a little confused about the //NC> create syntax. Specifically, I'm wondering how best to create the //NC> necessary GraphElement. //Here's an example: #import //pj 2002-06-04 #import //pj 2002-06-04 #import #import #include @interface Agent: SwarmObject - compute: xPtr: yPtr; @end @implementation Agent - compute: xPtr: yPtr { double x = *(double *)xPtr; double y = sin (x); *(double *)yPtr = y; return (id)YES; } @end @interface Controller: SwarmObject { id fg; id fe; id graph; id agent; id panel; } - createEnd; - graph; - exit; @end @implementation Controller - createEnd { id fgd; agent = [Agent create: [self getZone]]; fgd = [Frame create: [self getZone]]; graph = [Graph createParent: fgd]; [graph setWindowTitle: "FunctionGraph"]; [graph pack]; fe = [graph createElement]; [fe setLabel: "myLabel"]; [fe setColor: "red"]; [fe setWidth: 1]; fg = [FunctionGraph createBegin: [self getZone]]; [fg setElement: fe]; [fg setDataFeed: agent]; [fg setFunctionSelector: M(compute::)]; [fg setXMin: 0.0 Max: 2.0 * M_PI Resolution: 100]; [fg setResetFrequency: 0]; fg = [fg createEnd]; panel = [ButtonPanel createBegin: [self getZone]]; [panel setButtonTarget: self]; panel = [panel createEnd]; [panel setWindowTitle: "ControlPanel"]; [panel addButtonName: "Exit" method: @selector (exit)]; return self; } - exit { exit (0); } - graph { [fg graph]; return self; } @end int main (int argc, const char **argv) { Controller * controller; initSwarm (argc, argv); controller = [Controller create: globalZone]; [controller graph]; while (1) { while (GUI_EVENT_ASYNC ()) {} } } /* Local Variables: compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -D_GNU_SOURCE -Wall -Werror -g -Wno-import -I$SWARMHOME/include -I$SWARMHOME/include/swarm -L$SWARMHOME/lib/swarm -o functionG FuncGraphElement2.m -lswarm -lobjc" End: */