/[MITgcm]/MITgcm_contrib/darwinview/src/darwin.c
ViewVC logotype

Diff of /MITgcm_contrib/darwinview/src/darwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

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

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.22