[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FunctionGraph Questions
From: |
Marcus G. Daniels |
Subject: |
Re: FunctionGraph Questions |
Date: |
08 Mar 1999 19:32:20 -0800 |
>>>>> "NC" == Nick Collier <address@hidden> writes:
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 <objectbase/SwarmObject.h>
#import <analysis.h>
#include <math.h>
@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 <FunctionGraph> fg;
id <GraphElement> fe;
id <Graph> 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
main (int argc, const char **argv)
{
id controller;
initSwarm (argc, argv);
controller = [Controller create: globalZone];
[controller graph];
while (1)
{
while (GUI_EVENT_ASYNC ()) {}
}
}
/*
Local Variables:
compile-command: "/opt/egcs/bin/gcc -o funcgraph -g -Wno-import
-L/opt/SUNWtcl/8.0/sun4/lib -R/opt/SUNWtcl/8.0/sun4/lib -L/opt/SDGblt/2.4g/lib
-R/opt/SDGblt/2.4g/lib -L/opt/SDGlibffi/1.20/lib -R/opt/SDGlibffi/1.20/lib
-L/opt/SDGswarm/1.4.1/lib -L/opt/SDGzlib/1.1.3/lib -L/usr/local/X11/lib
-R/usr/local/X11/lib -L/usr/openwin/lib -R/usr/openwin/lib
-L/opt/SDGhdf5/1.0.1/lib -I/opt/SDGswarm/1.4.1/include funcgraph.m -lanalysis
-lsimtools -lsimtoolsgui -lactivity -ltkobjc -lrandom -lobjectbase -ldefobj
-lcollections -lmisc -ltclobjc -ltk8.0 -ltcl8.0 -lBLT -lsocket -ldl -lnsl
-L/usr/openwin/lib -lhdf5 -lpng -lz -lXpm -lX11 -lffi -lm -lobjc -lpthread
-lposix4"
End:
*/
==================================
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.