]> Pileus Git - aweather/commitdiff
Whooo, radar displays! (but it's really slow ):
authorAndy Spencer <andy753421@gmail.com>
Sun, 22 Jun 2008 22:12:11 +0000 (22:12 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 22 Jun 2008 22:12:11 +0000 (22:12 +0000)
src/aweather.c
src/radar.c

index ebd8ce3429f1859a11298590c20dd1257cb902ae..56d9979107f4031c9a0bcfd587a24391b5edaae1 100644 (file)
@@ -69,8 +69,8 @@ int main(int argc, char *argv[])
 
        /* Load plugins */
        opengl_init(GTK_DRAWING_AREA(drawing), GTK_NOTEBOOK(tab_area));
-       cube_init  (GTK_DRAWING_AREA(drawing), GTK_NOTEBOOK(tab_area));
        radar_init (GTK_DRAWING_AREA(drawing), GTK_NOTEBOOK(tab_area));
+       cube_init  (GTK_DRAWING_AREA(drawing), GTK_NOTEBOOK(tab_area));
 
        gtk_widget_show_all(window);
        gtk_main();
index f3fcbdb0f5dd80b365e3ed58a5fb7033e71f664b..d31343a01ff5951fe8420dc345b6b909f71a2af6 100644 (file)
@@ -11,6 +11,9 @@
 
 static GtkWidget *rotate_button;
 static Radar *radar;
+static Sweep *sweep;
+static int nred, ngreen, nblue;
+static unsigned char red[256], green[256], blue[256];
 
 static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
 {
@@ -24,21 +27,59 @@ static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
 
        glShadeModel(GL_FLAT);
 
-       glBegin (GL_TRIANGLE_FAN);
-       glVertex3f(0., 0., 0.);
-       glVertex3f(0., .5, 0.);
-
-       int angle;
-       for (angle = 1; angle <= 360; angle++) {
-               double rad = (angle*M_PI)/180.0; 
-               double x = sin(rad);
-               double y = cos(rad);
-               //g_printf("tick.. %d - %5.3f: (%5.2f,%5.2f)\n", angle, rad, x, y);
-               glColor3f((float)angle/360.0, 0., 0.);
-               glVertex3f(x/2., y/2., 0.);
+       glBegin(GL_QUADS);
+
+       int rayi;
+       for (rayi = 0; rayi < sweep->h.nrays; rayi++) {
+               Ray *ray = sweep->ray[rayi];
+
+               /* right and left with respect to north */
+               double right = ((ray->h.azimuth + ray->h.beam_width)*M_PI)/180.0; 
+               double left  = ((ray->h.azimuth - ray->h.beam_width)*M_PI)/180.0; 
+
+               double rx = sin(right), ry = cos(right);
+               double lx = sin(left),  ly = cos(left);
+
+               int nbins = ray->h.nbins;
+               //int nbins = 20;
+               int max_dist = nbins * ray->h.gate_size + ray->h.range_bin1;
+               int bini, dist = ray->h.range_bin1;
+               for (bini = 0; bini < nbins; bini++, dist += ray->h.gate_size) {
+                       if (ray->range[bini] == BADVAL) continue;
+
+                       /* (find middle of bin) / scale for opengl */
+                       double nd = ((double)dist - ((double)ray->h.gate_size)/2.) / (double)max_dist;
+                       double fd = ((double)dist + ((double)ray->h.gate_size)/2.) / (double)max_dist;
+               
+                       glColor3ub(
+                                 red[(unsigned char)ray->h.f(ray->range[bini])],
+                               green[(unsigned char)ray->h.f(ray->range[bini])],
+                                blue[(unsigned char)ray->h.f(ray->range[bini])]
+                       );
+
+                       glVertex3f(lx*nd, ly*nd, 0.); // near left
+                       glVertex3f(lx*fd, ly*fd, 0.); // far  left
+                       glVertex3f(rx*fd, ry*fd, 0.); // far  right
+                       glVertex3f(rx*nd, ry*nd, 0.); // near right
+
+               }
+
+               g_print("\n");
        }
 
-       glEnd ();
+       glEnd();
+
+       /* Print the color table */
+       glBegin(GL_QUADS);
+       int i;
+       for (i = 0; i < nred; i++) {
+               glColor3ub(red[i], green[i], blue[i]);
+               glVertex3f(-1., (float)((i  ) - nred/2)/(nred/2), 0.); // bot left
+               glVertex3f(-1., (float)((i+1) - nred/2)/(nred/2), 0.); // top left
+               glVertex3f(-.9, (float)((i+1) - nred/2)/(nred/2), 0.); // top right
+               glVertex3f(-.9, (float)((i  ) - nred/2)/(nred/2), 0.); // bot right
+       }
+       glEnd();
        
        glPopMatrix ();
 
@@ -59,5 +100,11 @@ gboolean radar_init(GtkDrawingArea *drawing, GtkNotebook *config)
        RSL_read_these_sweeps("0", NULL);
        radar = RSL_wsr88d_to_radar("/scratch/aweather/src/KABR_20080609_0224", "KABR");
        RSL_load_refl_color_table();
-       RSL_volume_to_gif(radar->v[DZ_INDEX], "dz_sweep", 400, 400, 200.0);
+       RSL_get_color_table(RSL_RED_TABLE,   red,   &nred);
+       RSL_get_color_table(RSL_GREEN_TABLE, green, &ngreen);
+       RSL_get_color_table(RSL_BLUE_TABLE,  blue,  &nblue);
+       if (radar->h.nvolumes < 1 || radar->v[0]->h.nsweeps < 1)
+               g_print("No sweeps found\n");
+       sweep = radar->v[0]->sweep[0];
+       RSL_volume_to_gif(radar->v[DZ_INDEX], "dz_sweep", 1024, 1024, 200.0);
 }