/[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

--- MITgcm_contrib/darwinview/src/darwin.c	2007/08/01 18:04:15	1.7
+++ MITgcm_contrib/darwinview/src/darwin.c	2007/08/03 14:37:15	1.8
@@ -51,8 +51,8 @@
 }
 
 void display(){                 // called on glutPostRedisplay
- int i, j, h, ioff, q; 
- float r, g, b, k, y;
+ int i, h, ioff, q; 
+ float r, g, b, k, y, j, tmp;
  double num, logmx, logmn;
  char str[MAX]; 
 
@@ -91,9 +91,11 @@
    }
   }
  
-  if( scaledepth && xz || scaledepth && yz )  ymax=totaldepth;
-  ioff=0; h=0;                        // ioff will count both i&j b/c data is 1D
-  for( j=0; j<ymax; j++ ){            // cycles through y values
+  if( scaledepth && xz || scaledepth && yz ) ymax=NY;
+  tmp=(float)ymax/totaldepth;
+  j=0; ioff=0; h=0;                        // ioff will count both i&j b/c data is 1D
+
+  while ( j<ymax ){            // cycles through y values
    for( i=0; i<xmax; i++ ){           // cycles through x values
     r=g=b=0;                          // set color values to black
     if( data[q][ioff]==0 );           // if data=0, values stay black
@@ -123,15 +125,16 @@
 
     glColor3f( r, g, b );           // put r, g, b into effect
     if( scaledepth && xz || scaledepth && yz )
-     glRectf( i, j, i+1, j+depths[h] );
+     glRectf( i, j, i+1, j+(depths[h]*tmp) );
     else
      glRectf( i, j, i+1, j+1 );      // draws a square for data value 
     ioff++;                    
    } 
    if( scaledepth && xz || scaledepth && yz ){
-    j+=depths[h]-1;
+    j+=(depths[h]*tmp);
     h++;
    }
+   else j++;
   } 
 
   glColor3f( 1, 1, 1 );             // set color to white
@@ -216,12 +219,14 @@
 
 void key( unsigned char key, int x, int y ){   // called on key press
  int i, tmp;
+ char fn[MAX];
  
  switch(key){
   case 'q':   exit(0);              // quits on 'q'
               break;
   case 'r':   count=0;              // resets back to first time    
               ilev=1;               // and first level
+              xz=yz=0;
               break;
   case 'a':   anim=(anim+1)%2;      // turns anim on/off
               break;
@@ -234,8 +239,11 @@
   case 'z':   if( xz || yz ){
                scaledepth=( scaledepth+1 )%2;
                scalecount++;
-               if( scalecount==1 ) 
-                readdepths( ".darwinview/depths" );
+               if( scalecount==1 ){ 
+                printf( "Please enter filename containing depth data: " );
+                scanf( "%s", fn );
+                readdepths( fn );
+               }
               }
               break; 
  } 
@@ -421,7 +429,7 @@
  FILE* fp;
  int i, j; 
   
- fp=fopen( ".darwinview/jet.h", "r" );  // opens file containing values
+ fp=fopen( "jet.dat", "r" );  // opens file containing values
  for( i=0; i<64; i++ )        // reads in 64 sets of r, g, b values
   for( j=0; j<3; j++ )
    fscanf( fp, "%f", &jet[i][j] );
@@ -536,7 +544,7 @@
  fclose( fp );
 
  xmax=NX; ymax=NY;
- 
+
  readjet();                               // stores color values
  readnames( filename );                   // gets list of filenames to read from
  global();                                // calculates max and min for all data

 

  ViewVC Help
Powered by ViewVC 1.1.22