//Marcus Daniels Dec. 1 1999 #import #import #import #import #define XSIZE 100 #define YSIZE 150 @interface MyClass: SwarmObject { id colormap; id scamDisplay; id panel; } - drawEllipse; @end @implementation MyClass - exit { exit (0); } - (void)dropScamDisplay { [scamDisplay drop]; } - drawEllipse { int yradius = [uniformIntRand getIntegerWithMin: 0 withMax: 50]; int xradius = [uniformIntRand getIntegerWithMin: 0 withMax: 50]; int x0 = 50 - xradius; int y0 = 50 - yradius; int x1 = 50 + xradius; int y1 = 50 + yradius; [scamDisplay erase]; [scamDisplay ellipseX0: x0 Y0: y0 X1: x1 Y1: y1 Width: 1 Color: [uniformUnsRand getUnsignedWithMin: 0 withMax: 15]]; [scamDisplay drawSelf]; return self; } - zoomIn { [scamDisplay increaseZoom]; [self drawEllipse]; return self; } - zoomOut { [scamDisplay decreaseZoom]; [self drawEllipse]; return self; } - createEnd { id aZone = [self getZone]; int i; colormap = [Colormap create: aZone]; for (i = 0; i < 16; i++) [colormap setColor: i ToRed: (double)i / 15.0 Green: 0 Blue: 0]; [colormap setColor: 16 ToRed: 0 Green: 1 Blue: 0]; [colormap setColor: 17 ToRed: 0 Green: 0 Blue: 1]; [colormap setColor: 18 ToGrey: 10]; scamDisplay = [ZoomRaster create: aZone]; [scamDisplay setColormap: colormap]; [scamDisplay setWidth: XSIZE Height: YSIZE]; [scamDisplay setWindowTitle: "ScamDisplay"]; [scamDisplay setZoomFactor: 1]; [scamDisplay pack]; panel = [ButtonPanel createBegin: aZone]; [panel setButtonTarget: self]; panel = [panel createEnd]; [panel setWindowTitle: "ControlPanel"]; [panel addButtonName: "ZoomIn" method: @selector (zoomIn)]; [panel addButtonName: "ZoomOut" method: @selector (zoomOut)]; [panel addButtonName: "Redraw" method: @selector (drawEllipse)]; [panel addButtonName: "Drop" method: @selector (dropScamDisplay)]; [panel addButtonName: "Exit" method: @selector (exit)]; return self; } @end int main (int argc, const char **argv) { id mainObj; initSwarm (argc, argv); mainObj = [MyClass create: globalZone]; [mainObj drawEllipse]; while (1) { while (GUI_EVENT_ASYNC ()) {} } } /* Local Variables: compile-command: "gcc -DDLL -o zr2 -g -Wno-import -I$SWARMHOME/include -L$SWARMHOME/lib zr2.m -lswarmdll -lobjcdll" End: */