home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD2.img
/
d4xx
/
d433
/
gwin
/
exsrc.lzh
/
spiceplot.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-12
|
3KB
|
157 lines
#include "gwin.user.h"
float sdata[10][1000];
float mindata = 1e15;
float maxdata = -1e15;
char s[8][20];
float wind[4],xdx,height,width;
int n,npoints;
int reset(),cancel_redraw;
int quit();
int event;
main()
{
char string[256];
char string1[100];
int i,j;
float x,y,xanchor,yanchor,xold,yold;
char key;
while(1 == 1){
if(!gets(string))exit(1); /* read one line */
if(!strncmp(" TIME",string,(int)9)){ /* look for data */
printf("FOUND DATA\n");
break;
}
}
n = sscanf(string,"%s %s %s %s %s %s %s %s %s %s",
s[0],s[1],s[2],s[3],s[4],s[5],s[6]
,s[7],s[8],s[9]); /* store field names */
/* print field names */
printf("%s %s %s %s %s\n",s[0],s[1],s[2],s[3],s[4],s[5]);
if(!gets(string))exit(1); /* skip blank line */
j = 0;
while(1 == 1){
for(i=0;i<n;i++){
if(scanf("%e",&sdata[i][j]) < 1)goto plot;
if(sdata[i][j]>maxdata) maxdata = sdata[i][j];
if(sdata[i][j]<mindata) mindata = sdata[i][j];
}
j++;
}
plot:
npoints = j;
ustart("high2",(float)0.,(float)640.0,(float)0.,(float)400.0);
uamenu(1,0,0,"COMMANDS",' ',0,MIDRAWN|MENUENABLED,7);
uamenu(1,1,0,"RESET",'R',0,MIDRAWN|ITEMTEXT|HIGHCOMP
|COMMSEQ|ITEMENABLED,reset);
uamenu(1,2,0,"QUIT",'Q',0,MIDRAWN|ITEMTEXT|HIGHCOMP
|COMMSEQ|ITEMENABLED,quit);
reset();
while(1 == 1){
while(key != 'a') {
ugrinl(&x,&y,&event,&key);
sprintf(string1,"x = %15.8e",x);
uprint( wind[0] + .1*width, wind[3] -.05*height, string1);
sprintf(string1,"y = %15.8e",y);
uprint( wind[0] + .5*width, wind[3] -.05*height, string1);
}
uset("comp");
xanchor = x; /* anchor point */
yanchor = y;
xold = x;
yold = y;
while (key != 'A'){
ugrinl(&x,&y,&event,&key);
urect(xanchor,yanchor,xold,yold);
urect(xanchor,yanchor,x,y);
xold = x;
yold = y;
}
if((xanchor != x) && (yanchor != y)){
wind[0] = (xanchor < x) ? xanchor : x;
wind[1] = (xanchor > x) ? xanchor : x;
wind[2] = (yanchor < y) ? yanchor : y;
wind[3] = (yanchor > y) ? yanchor : y;
}
width = wind[1] - wind[0];
height = wind[3] - wind[2];
uwindo(wind[0],wind[1],wind[2],wind[3]);
uset("ncom");
uerase();
uoutln();
uset("clip");
redraw();
}
}
reset()
{
wind[0] = sdata[0][0];
wind[1] = sdata[0][npoints-1];
wind[2] = mindata - .1*(maxdata-mindata);
wind[3] = maxdata + .1*(maxdata-mindata);
width = wind[1] - wind[0];
height = wind[3] - wind[2];
uwindo(wind[0],wind[1],wind[2],wind[3]);
uset("ncli");
upset("ccol",(float)0.0);
uerase();
uoutln();
redraw();
cancel_redraw = 1;
}
redraw()
{
int i,j;
float x,y;
char key;
cancel_redraw = 0;
for(i=1;i<n;i++){
upset("colo",(float)(i+2));
uprint( wind[0]+.8*width, wind[3]-(.04 + .03*(i-1))*height,s[i]);
umove(sdata[0][0],sdata[i][0]);
for(j=1;j<npoints;j++){
ugrina(&x,&y,&event,&key);
if(cancel_redraw){
upset("colo",7.0);
return(0);
}
udraw(sdata[0][j],sdata[i][j]);
}
}
upset("colo",7.0);
}
quit()
{
uend();
exit(0);
}