| 18 |
|
|
| 19 |
float data[MAX][MAX*MAX], mxval, mnval, jet[MAX][MAX]; |
float data[MAX][MAX*MAX], mxval, mnval, jet[MAX][MAX]; |
| 20 |
float globalmx=0, globalmn=100; |
float globalmx=0, globalmn=100; |
| 21 |
int win[MAX], ilev=1, howmany, count=0, glo=0, usr=0, anim=0; |
int win[MAX], ilev=1, howmany, count=0, glo=0, usr=0, anim=0, logscale=0; |
| 22 |
char initfns[MAX][MAX], fns[MAX][MAX][MAX]; |
char initfns[MAX][MAX], fns[MAX][MAX][MAX]; |
| 23 |
|
|
| 24 |
void menu(int value){ |
void menu(int value){ // called when menu is opened on right click |
|
int i; |
|
| 25 |
|
|
| 26 |
switch( value ){ |
switch( value ){ |
| 27 |
case 1: usr=glo=0; // unset glo & usr, sets local max/min |
case 1: usr=glo=0; // unset glo & usr, sets local max/min |
| 28 |
glutPostRedisplay(); |
glutPostRedisplay(); // recall display func with new values |
| 29 |
break; |
break; |
| 30 |
case 2: glo=1; // enables global max/min |
case 2: glo=1; // enables global max/min |
| 31 |
usr=0; // unsets usr |
usr=0; // unsets usr |
| 32 |
mxval=globalmx; // sets max to globalmx |
mxval=globalmx; // sets max to globalmx |
| 33 |
mnval=globalmn; // sets min to globalmn |
mnval=globalmn; // sets min to globalmn |
| 34 |
glutPostRedisplay(); // display with new values |
glutPostRedisplay(); // recall display func with new values |
| 35 |
break; |
break; |
| 36 |
case 3: usr=1; // switch to user-set max/min |
case 3: usr=1; // switch to user-set max/min |
| 37 |
glo=0; // unset glo |
glo=0; // unset glo |
| 38 |
printf( "Max=" ); scanf( "%f", &mxval ); // prompt for new max/min |
printf( "Max=" ); scanf( "%f", &mxval ); // prompt user for new max |
| 39 |
printf( "Min=" ); scanf( "%f", &mnval ); |
printf( "Min=" ); scanf( "%f", &mnval ); // prompt user for new min |
| 40 |
glutPostRedisplay(); // display with new values |
glutPostRedisplay(); // recall display func with new values |
| 41 |
|
break; |
| 42 |
|
case 4: logscale=(logscale+1)%2; // switch log scale on/off |
| 43 |
|
glutPostRedisplay(); |
| 44 |
break; |
break; |
| 45 |
} |
} |
| 46 |
} |
} |
| 47 |
|
|
| 48 |
void display(void){ |
void display(void){ // called on glutPostRedisplay |
| 49 |
int i, j, ioff, q; |
int i, j, ioff, q; |
| 50 |
float r, g, b, num, k, y; |
float r, g, b, k, y; |
| 51 |
|
double num, logmx, logmn; |
| 52 |
char str[MAX]; |
char str[MAX]; |
| 53 |
|
|
| 54 |
for( q=0; q<setsx*setsy; q++ ){ //runs display func for each window |
for( q=0; q<setsx*setsy; q++ ){ // runs display func for each subwindow |
| 55 |
glutSetWindow( win[q] ); |
glutSetWindow( win[q] ); // sets which subwindow to display to |
| 56 |
glClear( GL_COLOR_BUFFER_BIT ); // background to black |
glClear( GL_COLOR_BUFFER_BIT ); // background to black |
| 57 |
if( glo || usr ) |
if( glo || usr ) // if global or user-set max/min |
| 58 |
readarray( data[q], fns[q][count], ilev ); |
readarray( data[q], fns[q][count], ilev ); // read new array w/o calculating local max/min |
| 59 |
else |
else // if local max/min is set |
| 60 |
local( q, count, ilev ); |
local( q, count, ilev ); // read new array and calculate local max/min |
| 61 |
|
|
| 62 |
ioff=0; // ioff will count thru both i&j b/c data is 1D |
if( logscale ){ |
| 63 |
for( j=0; j<NY; j++ ){ |
if( usr ){ |
| 64 |
for( i=0; i<NX; i++ ){ |
logmx=(double)mxval; |
| 65 |
r=g=b=0; // set color values to black |
logmn=(double)mnval; |
| 66 |
if( data[q][ioff]==0 ); // if data=0, values stay black |
} |
| 67 |
|
else{ |
| 68 |
|
logmx=log10( mxval ); |
| 69 |
|
logmn=log10( mnval ); |
| 70 |
|
} |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
ioff=0; // ioff will count both i&j b/c data is 1D |
| 74 |
|
for( j=0; j<NY; j++ ){ // cycles through y values |
| 75 |
|
for( i=0; i<NX; i++ ){ // cycles through x values |
| 76 |
|
r=g=b=0; // set color values to black |
| 77 |
|
if( data[q][ioff]==0 ); // if data=0, values stay black |
| 78 |
else{ |
else{ |
| 79 |
if( data[q][ioff]<mnval ) num=0; // if data is less than min, =min |
if( logscale ){ |
| 80 |
|
num=(double)data[q][ioff]; |
| 81 |
|
num=log10( num ); |
| 82 |
|
if( num<logmn ) num=0; |
| 83 |
|
if( num>logmx ) num=63; |
| 84 |
|
else |
| 85 |
|
num=63*( num-logmn )/( logmx-logmn ); |
| 86 |
|
} |
| 87 |
else{ |
else{ |
| 88 |
if( data[q][ioff]>mxval ) num=63; // if data is more than max, =max |
if( data[q][ioff]<mnval ) num=0; // if data is less than min, =min |
| 89 |
else |
else |
| 90 |
num=63*( data[q][ioff]-mnval )/( mxval-mnval ); //scale num from 0-63 |
if( data[q][ioff]>mxval ) num=63; // if data is more than max, =max |
| 91 |
|
else |
| 92 |
|
num=63*( data[q][ioff]-mnval )/( mxval-mnval ); // scale num from 0-63 (not defined for 64) |
| 93 |
} |
} |
| 94 |
r=jet[(int)num][0]; // set red val |
r=jet[(int)num][0]; // set red val |
| 95 |
g=jet[(int)num][1]; // set green val |
g=jet[(int)num][1]; // set green val |
| 96 |
b=jet[(int)num][2]; // set blue val |
b=jet[(int)num][2]; // set blue val |
| 97 |
} |
} |
| 98 |
|
|
| 99 |
glColor3f( r, g, b ); // put r, g, b into effect |
glColor3f( r, g, b ); // put r, g, b into effect |
| 100 |
glRectf( i, j, i+1, j+1 ); // draws a square for data value |
glRectf( i, j, i+1, j+1 ); // draws a square for data value |
| 101 |
ioff++; |
ioff++; |
| 102 |
} |
} |
| 103 |
} |
} |
| 104 |
glColor3f( 1, 1, 1 ); // set color to white |
glColor3f( 1, 1, 1 ); // set color to white |
| 105 |
glRectf( NX, 0, NX+1, NY+1 ); // draws a border |
glRectf( NX, 0, NX+1, NY+1 ); // draws a border |
| 106 |
glRectf( 0, NY, NX, NY+1 ); // draws a border |
glRectf( 0, NY, NX, NY+1 ); // draws a border |
| 107 |
for( i=0; i<64; i++ ){ //draws color bar |
for( i=0; i<64; i++ ){ // draws color bar |
| 108 |
glColor3f( jet[i][0], jet[i][1], jet[i][2]); //sets color |
glColor3f( jet[i][0], jet[i][1], jet[i][2]); // sets color |
| 109 |
k=(float)i; // turns i into a float |
k=(float)i; // turns i into a float |
| 110 |
y=(float)NY/64; // sets height of rectangles |
y=(float)NY/64; // sets height of rectangles |
| 111 |
glRectf( NX+10, y*k, NX+20, (k+1)*y ); // draws rectangle |
glRectf( NX+10, y*k, NX+20, (k+1)*y ); // draws rectangle |
| 112 |
} |
} |
| 113 |
glColor3f( 1, 1, 1 ); // color to white |
glColor3f( 1, 1, 1 ); // color to white |
| 114 |
|
|
| 115 |
sprintf( str, "%.2e", mxval ); // labels color bar with max val |
if( logscale ) |
| 116 |
|
sprintf( str, "%.2f", logmx ); |
| 117 |
|
else |
| 118 |
|
sprintf( str, "%.2e", mxval ); // labels color bar with max val |
| 119 |
bitmap( str, NX+2, NY-1 ); |
bitmap( str, NX+2, NY-1 ); |
| 120 |
|
|
| 121 |
sprintf( str, "%.2e", mnval ); // labels color bar with min val |
if( logscale ) |
| 122 |
|
sprintf( str, "%.2f", logmn ); |
| 123 |
|
else |
| 124 |
|
sprintf( str, "%.2e", mnval ); // labels color bar with min val |
| 125 |
bitmap( str, NX+2, 1 ); |
bitmap( str, NX+2, 1 ); |
| 126 |
|
|
| 127 |
sprintf( str, "Level %d", ilev ); // labels current level |
sprintf( str, "Level %d", ilev ); // labels current level |
| 128 |
bitmap( str, 1, NY+3); |
bitmap( str, 1, NY+3 ); |
| 129 |
|
|
| 130 |
if( glo ) // labels how max/min have been set |
sprintf( str, "Time %d", count+1 ); // labels current time |
| 131 |
sprintf( str, "Global" ); // if glo is set, display Global |
bitmap( str, 50, NY+3 ); |
| 132 |
|
|
| 133 |
|
if( glo ) // labels how max/min have been set |
| 134 |
|
sprintf( str, "Global" ); // if glo is set, display Global |
| 135 |
if( usr ) |
if( usr ) |
| 136 |
sprintf( str, "User-set" ); // if usr is set, display User-set |
sprintf( str, "User-set" ); // if usr is set, display User-set |
| 137 |
if( !usr && !glo ) |
if( !usr && !glo ) |
| 138 |
sprintf( str, "Local" ); // else display Local |
sprintf( str, "Local" ); // else display Local |
| 139 |
bitmap( str, NX+12, NY+3); |
bitmap( str, NX+12, NY+3 ); |
| 140 |
|
|
| 141 |
if( anim ){ // tell user if autoplay is on |
if( anim ){ // tell user if autoplay is on |
| 142 |
sprintf( str, "Autoplay" ); |
sprintf( str, "Autoplay" ); |
| 143 |
bitmap( str, NX-15, NY+3 ); |
bitmap( str, NX-25, NY+3 ); |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
if( logscale ){ |
| 147 |
|
sprintf( str, "Log Scale" ); // tell user if log scale is on |
| 148 |
|
bitmap( str, NX-25, NY+10 ); |
| 149 |
} |
} |
| 150 |
|
|
| 151 |
bitmap( fns[q][count], 1, NY+6 ); // labels current file |
bitmap( fns[q][count], 1, NY+10 ); // labels current file |
| 152 |
|
|
| 153 |
glutSwapBuffers(); |
glutSwapBuffers(); // double buffering set to animate smoothly |
| 154 |
glFlush(); |
glFlush(); |
| 155 |
} |
} |
| 156 |
} |
} |
| 157 |
|
|
| 158 |
void bitmap( char str[], int x, int y ){ |
void bitmap( char str[], int x, int y ){ // called to display text onscreen |
| 159 |
int i; |
int i; |
| 160 |
|
|
| 161 |
glRasterPos2f( x, y ); |
glRasterPos2f( x, y ); // set position of text |
| 162 |
for( i=0; i<strlen( str ); i++) |
for( i=0; i<strlen( str ); i++) // display each character of str |
| 163 |
glutBitmapCharacter( GLUT_BITMAP_HELVETICA_12, str[i] ); |
glutBitmapCharacter( GLUT_BITMAP_HELVETICA_12, str[i] ); |
| 164 |
} |
} |
| 165 |
|
|
| 166 |
void key( unsigned char key, int x, int y ){ //called on key press |
void key( unsigned char key, int x, int y ){ // called on key press |
| 167 |
int i; |
int i; |
| 168 |
|
|
| 169 |
switch(key){ |
switch(key){ |
| 170 |
case 'q': exit(0); //quits on 'q' |
case 'q': exit(0); // quits on 'q' |
| 171 |
break; |
break; |
| 172 |
case 'r': count=0; |
case 'r': count=0; // resets back to first time |
| 173 |
ilev=1; |
ilev=1; // and first level |
| 174 |
glutPostRedisplay(); |
glutPostRedisplay(); |
| 175 |
break; |
break; |
| 176 |
case 'a': anim++; // switches autoplay off/on |
case 'a': anim=(anim+1)%2; // turns anim on/off |
|
anim=anim%2; // when a is pressed repeatedly |
|
| 177 |
glutPostRedisplay(); |
glutPostRedisplay(); |
| 178 |
break; |
break; |
| 179 |
} |
} |
| 180 |
} |
} |
| 181 |
|
|
| 182 |
void TimerFunction( int value ){ |
void TimerFunction( int value ){ // called when anim is set and arrow key is pressed |
| 183 |
int i; |
int i; |
| 184 |
|
|
| 185 |
switch(value){ // increments in the correct direction |
switch(value){ // increments in the correct direction |
| 186 |
case DOWN : if( ilev<MAXNZ ) |
case DOWN : if( ilev<MAXNZ ) |
| 187 |
ilev++; // if down arrow pressed, moves down levels |
ilev++; // if down arrow pressed, move down a level |
| 188 |
break; |
break; |
| 189 |
case UP : if( ilev>1 ) |
case UP : if( ilev>1 ) |
| 190 |
ilev--; // if up arrow is pressed, moves up levels |
ilev--; // if up arrow is pressed, move up a level |
| 191 |
break; |
break; |
| 192 |
case LEFT : if( count>0 ) |
case LEFT : if( count>0 ) |
| 193 |
count--; // if left arrow is pressed, moves back in time |
count--; // if left arrow is pressed, move back one time step |
| 194 |
break; |
break; |
| 195 |
case RIGHT: if( count<howmany-1 ) |
case RIGHT: if( count<howmany-1 ) |
| 196 |
count++; // if right arrow is pressed, moves forward in time |
count++; // if right arrow is pressed, moves forward one time step |
| 197 |
break; |
break; |
| 198 |
} |
} |
| 199 |
|
|
| 201 |
|
|
| 202 |
if (anim ) |
if (anim ) |
| 203 |
switch( value ){ |
switch( value ){ |
| 204 |
case DOWN : if( ilev==MAXNZ ) ilev=1; // sets limit that you can go down |
case DOWN : if( ilev==MAXNZ ) ilev=1; // if end reached, restart |
| 205 |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
| 206 |
break; |
break; |
| 207 |
case UP : if( ilev==1 ) ilev=MAXNZ; // sets limit that you can go up |
case UP : if( ilev==1 ) ilev=MAXNZ; // if end reached, restart |
| 208 |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
| 209 |
break; |
break; |
| 210 |
case LEFT : if( count==0 ) count=howmany-1;// sets limit that you can go left |
case LEFT : if( count==0 ) count=howmany-1; // if end reached, restart |
| 211 |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
| 212 |
break; |
break; |
| 213 |
case RIGHT: if( count==howmany-1 ) count=0; //sets limit that you can go right |
case RIGHT: if( count==howmany-1 ) count=0; // if end reached, restart |
| 214 |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
| 215 |
break; |
break; |
| 216 |
} |
} |
| 219 |
void specialkey( int key, int x, int y ){ |
void specialkey( int key, int x, int y ){ |
| 220 |
int i; |
int i; |
| 221 |
|
|
| 222 |
if( anim ) // if animation is set, call the timer function |
if( anim ) // if animation is set, call the timer function |
| 223 |
glutTimerFunc( 100, TimerFunction, key); |
glutTimerFunc( 100, TimerFunction, key); // to scroll automatically |
| 224 |
|
|
| 225 |
switch(key){ |
switch(key){ |
| 226 |
case DOWN : if( ilev<MAXNZ ) // if you haven't reached the bottom |
case DOWN : if( ilev<MAXNZ ) // if you haven't reached the bottom |
| 227 |
ilev++; // keep going down |
ilev++; // keep going down |
| 228 |
break; |
break; |
| 229 |
case UP : if( ilev>1 ) // if you haven't reached the top |
case UP : if( ilev>1 ) // if you haven't reached the top |
| 230 |
ilev--; // keep going up |
ilev--; // keep going up |
| 231 |
break; |
break; |
| 232 |
case RIGHT : if( count<howmany-1 ) // if you haven't reached the last file |
case RIGHT : if( count<howmany-1 ) // if you haven't reached the last file |
| 233 |
count++; // keep going right |
count++; // keep going right |
| 239 |
glutPostRedisplay(); |
glutPostRedisplay(); |
| 240 |
} |
} |
| 241 |
|
|
| 242 |
void global(){ // calculates the max/min for the total data set |
void global(){ // calculates the max/min for the total data set |
| 243 |
FILE* fp; |
FILE* fp; |
| 244 |
int h, i, j; |
int h, i, j; |
| 245 |
for( h=0; h<setsx*setsy; h++) // cycles through each data set |
for( h=0; h<setsx*setsy; h++) // cycles through each window |
| 246 |
for( i=0; i<howmany; i++ ) // cycles through each time |
for( i=0; i<howmany; i++ ) // cycles through each time |
| 247 |
for( j=0; j<MAXNZ; j++ ){ // cycles through each level for each file |
for( j=0; j<MAXNZ; j++ ){ // cycles through each level for each file |
| 248 |
local( h, i, j ); // calculates local/max/min for specific data set |
local( h, i, j ); // calculates local max/min for specific data set |
| 249 |
if( mxval > globalmx ) globalmx = mxval; // sets highest value to globalmx |
if( mxval > globalmx ) globalmx = mxval; // sets highest value to globalmx |
| 250 |
if( mnval < globalmn ) globalmn = mnval; // sets lowest value to globalmn |
if( mnval < globalmn ) globalmn = mnval; // sets lowest value to globalmn |
| 251 |
} |
} |
| 252 |
} |
} |
| 253 |
|
|
| 254 |
void local( int i, int time, int lev ){ // calculates local max/min |
void local( int i, int time, int lev ){ // calculates local max/min |
| 255 |
int j; |
int j; |
| 256 |
|
|
| 257 |
mxval=0; |
mxval=0; |
| 258 |
mnval=100; |
mnval=100; |
| 259 |
readarray( data[i], fns[i][time], lev ); // read new array of data |
readarray( data[i], fns[i][time], lev ); // read new array of data |
| 260 |
for( j=0; j<NX*NY; j++ ){ |
for( j=0; j<NX*NY; j++ ){ |
| 261 |
if( data[i][j] > mxval ) mxval=data[i][j]; // set largest val to mxval |
if( data[i][j] > mxval ) |
| 262 |
if( data[i][j] < mnval ) mnval=data[i][j]; // set smallest val to mnval |
mxval=data[i][j]; // set largest val to mxval |
| 263 |
|
if( data[i][j] < mnval && data[i][j] > 0 ) |
| 264 |
|
mnval=data[i][j]; // set smallest positive val to mnval |
| 265 |
} |
} |
| 266 |
} |
} |
| 267 |
|
|
| 268 |
void readnames( char filename[] ){ // reads in list of filenames |
void readnames( char filename[] ){ // reads in list of filenames |
| 269 |
FILE* fp; |
FILE* fp; |
| 270 |
int i=0, j=0; |
int i=0, j=0; |
| 271 |
|
|
| 272 |
fp=fopen( filename, "r" ); // opens list |
fp=fopen( filename, "r" ); // opens list of filenames |
| 273 |
while( !feof(fp) ){ // reads until the end of the file |
while( !feof(fp) ){ // reads until the end of the file |
| 274 |
fscanf( fp, "%s", initfns[i] ); // places filename into an array of strings |
fscanf( fp, "%s", initfns[i] ); // places filename into an array of strings |
| 275 |
i++; // counts how many filenames there are |
i++; // counts how many filenames there are |
| 276 |
} |
} |
| 277 |
fclose( fp ); // close file |
fclose( fp ); // close file |
| 278 |
howmany=i-1; |
howmany=i-1; // saves number of initial filenames |
| 279 |
|
|
| 280 |
for(i=0; i<howmany; i++){ |
for(i=0; i<howmany; i++){ // goes through each read-in filename |
| 281 |
fp=fopen( initfns[i], "r" ); |
fp=fopen( initfns[i], "r" ); // opens each filename |
| 282 |
j=0; |
j=0; |
| 283 |
while( !feof(fp) ){ |
while( !feof(fp) ){ // reads in filenames from each filename |
| 284 |
fscanf( fp, "%s", fns[i][j]); |
fscanf( fp, "%s", fns[i][j]); |
| 285 |
j++; |
j++; |
| 286 |
} |
} |
| 287 |
fclose(fp); |
fclose(fp); // close file |
| 288 |
} |
} |
| 289 |
howmany=j-1; |
howmany=j-1; // saves number of data filenames |
| 290 |
} |
} |
| 291 |
|
|
| 292 |
void readjet(){ //reads in color scale values |
void readjet(){ //reads in color scale values |
| 293 |
|
|
| 294 |
FILE* fp; |
FILE* fp; |
| 295 |
int i, j; |
int i, j; |
| 296 |
|
|
| 297 |
fp=fopen( "jet.dat", "r" ); // opens file containing values |
fp=fopen( "jet.dat", "r" ); // opens file containing values |
| 298 |
for( i=0; i<64; i++ ) // reads in 64 sets of r, g, b values |
for( i=0; i<64; i++ ) // reads in 64 sets of r, g, b values |
| 299 |
for( j=0; j<3; j++ ) |
for( j=0; j<3; j++ ) |
| 300 |
fscanf( fp, "%f", &jet[i][j] ); |
fscanf( fp, "%f", &jet[i][j] ); |
| 301 |
fclose( fp ); // closes file |
fclose( fp ); // closes file |
| 302 |
} |
} |
| 303 |
|
|
| 304 |
|
|
| 306 |
FILE *fp; |
FILE *fp; |
| 307 |
int i; |
int i; |
| 308 |
|
|
| 309 |
fp=fopen( filename, "r" ); // opens the file containing data |
fp=fopen( filename, "r" ); // opens the file containing data |
| 310 |
fseek( fp, (il-1)*NX*NY*4, SEEK_SET ); // seeks to the correct level using ilev |
fseek( fp, (il-1)*NX*NY*4, SEEK_SET ); // seeks to the correct place using ilev |
| 311 |
fread( arr, sizeof( arr[0] ), NX*NY, fp ); // reads in data to fill one level |
fread( arr, sizeof( arr[0] ), NX*NY, fp ); // reads in data to fill one level |
| 312 |
fclose( fp ); // close file |
fclose( fp ); // close file |
| 313 |
//do_byteswap_f32( arr, NX*NY ); // swaps the binary data |
for( i=0; i<NX*NY; i++ ) |
| 314 |
|
if( arr[i] < 0 ) arr[i] = pow(10, -20); // sets negative values to 10^-20 |
| 315 |
|
|
| 316 |
|
//do_byteswap_f32( arr, NX*NY ); // switches endian |
| 317 |
} |
} |
| 318 |
|
|
| 319 |
void do_byteswap_f32( float arr[], int nel ) // switches endian |
void do_byteswap_f32( float arr[], int nel ) // switches endian |
| 331 |
} |
} |
| 332 |
} |
} |
| 333 |
|
|
|
void parentfunc(){ |
|
|
glClear( GL_COLOR_BUFFER_BIT ); // background to black |
|
|
glutSwapBuffers(); |
|
|
glFlush(); |
|
|
} |
|
|
|
|
| 334 |
int main( int argc, char *argv[] ){ |
int main( int argc, char *argv[] ){ |
| 335 |
int i, tmpx, tmpy, winx, winy, parent; |
int i, tmpx, tmpy, winx, winy, parent; |
| 336 |
char filename[MAX]; |
char filename[MAX]; |
| 337 |
|
|
| 338 |
sscanf(argv[1], "%dx%d", &winx, &winy); |
sscanf(argv[1], "%dx%d", &winx, &winy); // reads screen resolution from command line |
| 339 |
winy-=20; |
winy-=60; winx-=20; // adjusts resolution so edges won't get cut off |
| 340 |
|
|
| 341 |
printf( "Please enter x, y and z dimensions.\n" ); |
printf( "Please enter x, y and z dimensions.\n" ); |
| 342 |
scanf( "%d %d %d", &NX, &NY, &MAXNZ ); //user-set NX, NY, NZ |
scanf( "%d %d %d", &NX, &NY, &MAXNZ ); // prompts user for NX, NY, NZ |
| 343 |
printf( "Please enter filename.\n" ); |
printf( "Please enter filename.\n" ); |
| 344 |
scanf( "%s", filename ); //filename contains names of data files |
scanf( "%s", filename ); // prompts user for initial filenames |
| 345 |
printf( "Please enter dimensions of data sets.\n" ); |
printf( "Please enter dimensions of data sets.\n" ); |
| 346 |
scanf( "%dx%d", &setsx, &setsy); |
scanf( "%dx%d", &setsx, &setsy); // prompts user for dimensions of subwindows |
| 347 |
|
|
| 348 |
readjet(); // stores color values |
readjet(); // stores color values |
| 349 |
readnames( filename ); // gets list of filenames to read from |
readnames( filename ); // gets list of filenames to read from |
| 350 |
global(); // calculates max and min for all data |
global(); // calculates max and min for all data |
| 351 |
|
|
| 352 |
glutInit( &argc, argv ); |
glutInit( &argc, argv ); |
| 353 |
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); |
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); // sets rgb mode and double buffering |
| 354 |
glutInitWindowSize( winx, winy ); |
glutInitWindowSize( winx, winy ); // parent window will cover screen |
| 355 |
glutInitWindowPosition( 10, 10 ); |
glutInitWindowPosition( 10, 10 ); // location of parent window |
| 356 |
parent=glutCreateWindow( WINDOW ); |
parent=glutCreateWindow( WINDOW ); // creates parent window |
| 357 |
|
|
| 358 |
glClearColor( 0, 0, 0, 0 ); // sets clear color to black |
glClearColor( 0, 0, 0, 0 ); // sets clear color to black |
| 359 |
gluOrtho2D( 0, winx , winy, 0 ); // sets how data is mapped to window |
gluOrtho2D( 0, winx , winy, 0 ); // sets(0,0) as top left corner |
| 360 |
glutDisplayFunc( display ); |
glutDisplayFunc( display ); |
| 361 |
glutKeyboardFunc( key ); // called on key press |
glutKeyboardFunc( key ); // called on key press |
| 362 |
glutSpecialFunc( specialkey ); // called on special key press (arrow keys) |
glutSpecialFunc( specialkey ); // called on special key press (arrow keys) |
| 363 |
|
|
| 364 |
for( i=0; i<setsx*setsy; i++ ){ |
for( i=0; i<setsx*setsy; i++ ){ |
| 365 |
tmpx = (i%setsx)*(winx/setsx); |
tmpx = (i%setsx)*(winx/setsx); // x coordinate of top left corner of subwindow |
| 366 |
tmpy = (i/setsx)*(winy/setsy); |
tmpy = (i/setsx)*(winy/setsy); // y coordinate of top left corner of subwindow |
| 367 |
|
|
| 368 |
local( i, count, ilev ); // sets curr data array, finds local max/min |
local( i, count, ilev ); // reads curr data array, finds local max/min |
| 369 |
|
|
| 370 |
win[i]=glutCreateSubWindow( parent, tmpx, tmpy, winx/setsx, winy/setsy ); |
win[i]=glutCreateSubWindow( parent, tmpx, tmpy, winx/setsx, winy/setsy ); // creates subwindow |
| 371 |
gluOrtho2D( 0, NX+35, 0, NY+15 ); // sets how data is mapped to window |
gluOrtho2D( 0, NX+35, 0, NY+15 ); // sets how data is mapped to subwindow |
| 372 |
glutDisplayFunc( display ); |
glutDisplayFunc( display ); // sets display func for subwindow |
| 373 |
glutKeyboardFunc( key ); // called on key press |
glutKeyboardFunc( key ); // called on key press |
| 374 |
glutSpecialFunc( specialkey ); // called on special key press (arrow keys) |
glutSpecialFunc( specialkey ); // called on special key press (arrow keys) |
| 375 |
|
|
| 376 |
glutCreateMenu( menu ); // adds a menu |
glutCreateMenu( menu ); // adds a menu |
| 377 |
glutAddMenuEntry( "Local Color Scale", 1 ); // describes choices |
glutAddMenuEntry( "Local Color Scale", 1 ); // adds a menu entry |
| 378 |
glutAddMenuEntry( "Global Color Scale", 2 ); |
glutAddMenuEntry( "Global Color Scale", 2 ); // adds a menu entry |
| 379 |
glutAddMenuEntry( "User-Set Color Scale", 3 ); |
glutAddMenuEntry( "User-Set Color Scale", 3 ); // adds a menu entry |
| 380 |
glutAttachMenu( GLUT_RIGHT_BUTTON ); // menu called on right click |
glutAddMenuEntry( "Log Scale (on/off)", 4 ); // adds a menu entry |
| 381 |
|
glutAttachMenu( GLUT_RIGHT_BUTTON ); // menu called on right click |
| 382 |
} |
} |
| 383 |
|
|
| 384 |
glutMainLoop(); |
glutMainLoop(); // begin processing events |
| 385 |
return 0; |
return 0; |
| 386 |
} |
} |
| 387 |
|
|