]> Pileus Git - grits/blobdiff - src/plugin-radar.c
some site-switching code
[grits] / src / plugin-radar.c
index 6adcfa9983a54e4f86ffa45c30f0ebe138e13160..e227cf59a19a4978f8aa10760d659472f166778a 100644 (file)
@@ -1,10 +1,12 @@
 #include <config.h>
 #include <gtk/gtk.h>
+#include <gtk/gtkgl.h>
 #include <GL/gl.h>
 #include <math.h>
 
 #include "rsl.h"
 
+#include "aweather-gui.h"
 #include "plugin-radar.h"
 
 GtkWidget *drawing;
@@ -13,6 +15,8 @@ static int nred, ngreen, nblue;
 static char red[256], green[256], blue[256];
 static guint sweep_tex = 0;
 
+Radar *radar = NULL;
+
 static guint8 get_alpha(guint8 db)
 {
        if (db == BADVAL) return 0;
@@ -100,17 +104,22 @@ static void load_sweep(Sweep *sweep)
 }
 
 /* Load the default sweep */
-static gboolean configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
+static gboolean configure(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 {
-       Sweep *first = (Sweep*)user_data;
+       //g_message("radar:configure");
+       aweather_gui_gl_begin(gui);
+       Sweep *first = radar->v[0]->sweep[0];
        if (cur_sweep == NULL)
                load_sweep(first);
+       aweather_gui_gl_end(gui);
+
        return FALSE;
 }
 
-static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
+static gboolean expose(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
 {
-       g_message("radar:expose");
+       //g_message("radar:expose");
+       aweather_gui_gl_begin(gui);
        Sweep *sweep = cur_sweep;
 
        /* Draw the rays */
@@ -157,33 +166,35 @@ static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
        //glEnd();
 
        /* Print the color table */
-       //glDisable(GL_TEXTURE_2D);
-       //glMatrixMode(GL_MODELVIEW ); glPushMatrix(); glLoadIdentity();
-       //glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
-       //glBegin(GL_QUADS);
-       //int i;
-       //for (i = 0; i < nred; i++) {
-       //      glColor4ub(red[i], green[i], blue[i], get_alpha(i));
-       //      glVertex3f(-1.0, (float)((i  ) - nred/2)/(nred/2), 0.0); // bot left
-       //      glVertex3f(-1.0, (float)((i+1) - nred/2)/(nred/2), 0.0); // top left
-       //      glVertex3f(-0.9, (float)((i+1) - nred/2)/(nred/2), 0.0); // top right
-       //      glVertex3f(-0.9, (float)((i  ) - nred/2)/(nred/2), 0.0); // bot right
-       //}
-       //glEnd();
-        //glMatrixMode(GL_PROJECTION); glPopMatrix(); 
-       //glMatrixMode(GL_MODELVIEW ); glPopMatrix();
+       glDisable(GL_TEXTURE_2D);
+       glMatrixMode(GL_MODELVIEW ); glPushMatrix(); glLoadIdentity();
+       glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
+       glBegin(GL_QUADS);
+       int i;
+       for (i = 0; i < nred; i++) {
+               glColor4ub(red[i], green[i], blue[i], get_alpha(i));
+               glVertex3f(-1.0, (float)((i  ) - nred/2)/(nred/2), 0.0); // bot left
+               glVertex3f(-1.0, (float)((i+1) - nred/2)/(nred/2), 0.0); // top left
+               glVertex3f(-0.9, (float)((i+1) - nred/2)/(nred/2), 0.0); // top right
+               glVertex3f(-0.9, (float)((i  ) - nred/2)/(nred/2), 0.0); // bot right
+       }
+       glEnd();
+        glMatrixMode(GL_PROJECTION); glPopMatrix(); 
+       glMatrixMode(GL_MODELVIEW ); glPopMatrix();
 
+       aweather_gui_gl_end(gui);
        return FALSE;
 }
 
-gboolean radar_init(GtkDrawingArea *_drawing, GtkNotebook *config)
+gboolean radar_init(AWeatherGui *gui)
 {
-       drawing = GTK_WIDGET(_drawing);
+       drawing = GTK_WIDGET(aweather_gui_get_drawing(gui));
+       GtkNotebook    *config  = aweather_gui_get_tabs(gui);
 
        /* Parse hard coded file.. */
        RSL_read_these_sweeps("all", NULL);
        //RSL_read_these_sweeps("all", NULL);
-       Radar *radar = RSL_wsr88d_to_radar("/scratch/aweather/data/level2/KNQA_20090501_1925.raw", "KNQA");
+       radar = RSL_wsr88d_to_radar("/scratch/aweather/data/level2/KNQA_20090501_1925.raw", "KNQA");
        RSL_load_refl_color_table();
        RSL_get_color_table(RSL_RED_TABLE,   red,   &nred);
        RSL_get_color_table(RSL_GREEN_TABLE, green, &ngreen);
@@ -217,8 +228,8 @@ gboolean radar_init(GtkDrawingArea *_drawing, GtkNotebook *config)
        gtk_notebook_append_page(GTK_NOTEBOOK(config), scroll, label);
 
        /* Set up OpenGL Stuff */
-       g_signal_connect(drawing, "expose-event",    G_CALLBACK(expose),    NULL);
-       g_signal_connect(drawing, "configure-event", G_CALLBACK(configure), radar->v[0]->sweep[0]);
+       g_signal_connect(drawing, "expose-event",    G_CALLBACK(expose),    gui);
+       g_signal_connect(drawing, "configure-event", G_CALLBACK(configure), gui);
 
        return TRUE;
 }