#include #include #include #include #include "partxyplot.h" int Ncall = 0; int Winid; long dev; short val; int PartColors[] = {RED, YELLOW, BLUE, CYAN, GREEN}; void wait_for_escape(void) { while( 1 ) { if( qtest() ) { dev = qread(&val); if( (dev == ESCKEY) && val ) return; } } } void partxyplot_(double *x,double *y,int *pnpart) { partxyplot(x,y,*pnpart); } /* Call this routine with npart > 0 for normal operation, npart < 0 for tumble mode until escape key is depressed in graphics window ... */ void partxyplot(double *x,double *y,int npart) { if( Ncall == 0 ) { /* Open window, set graphics attributes and clear to black ... */ foreground(); prefposition(125,525,50,450); Winid = winopen("sphplot"); cmode(); doublebuffer(); gconfig(); color(BLACK); clear(); /* Set up coordinate system ... */ ortho2(-2.0, 2.0, -2.0, 2.0); /* Queue escape-key ... */ qdevice(ESCKEY); } if( npart > 0 ) { int ipart; /* Regular draw ... */ color(BLACK); clear(); for( ipart = 0; ipart < npart; ipart++ ) { color(PartColors[ipart]); circf((Coord) x[ipart],(Coord) y[ipart], (Coord) 0.10); } swapbuffers(); if( Ncall == 0 ) wait_for_escape(); } else { wait_for_escape(); } Ncall++; }