#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;
static char red[256], green[256], blue[256];
static guint sweep_tex = 0;
+static AWeatherGui *gui = NULL;
+static Radar *radar = NULL;
+
static guint8 get_alpha(guint8 db)
{
if (db == BADVAL) return 0;
else return 255;
}
-//#ifdef USE_TWO_BYTE_PRECISION
-//#define F_FACTOR 100.0
-//#define F_DR_FACTOR 1000.0
-//#define F_DZ_RANGE_OFFSET 50
-//#else
-//#define F_FACTOR 2.0
-//#define F_DR_FACTOR 10.0
-//#define F_DZ_RANGE_OFFSET 32
-//#endif
-//#define F_OFFSET 4
-//static float dz_f(Range x)
-//{
-// if (x >= F_OFFSET)
-// return (((float)x-F_OFFSET)/F_FACTOR - F_DZ_RANGE_OFFSET);
-// if (x == 0) return BADVAL;
-// if (x == 1) return RFVAL;
-// if (x == 2) return APFLAG;
-// if (x == 3) return NOECHO;
-// return BADVAL;
-//}
-
/* Convert a sweep to an 2d array of data points */
static void bscan_sweep(Sweep *sweep, guint8 **data, int *width, int *height)
{
}
/* Load the default sweep */
-static gboolean configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
+static gboolean map(GtkWidget *da, GdkEvent *event, gpointer user_data)
{
- Sweep *first = (Sweep*)user_data;
+ g_message("radar:map");
+ 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;
}
//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();
return FALSE;
}
-gboolean radar_init(GtkDrawingArea *_drawing, GtkNotebook *config)
+//static void set_site(AWeatherView *view, char *site, gpointer user_data)
+//{
+// g_message("location changed to %s", site);
+//}
+
+gboolean radar_init(AWeatherGui *_gui)
{
- drawing = GTK_WIDGET(_drawing);
+ gui = _gui;
+ 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);
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, "map-event", G_CALLBACK(map), NULL);
+ g_signal_connect(drawing, "expose-event", G_CALLBACK(expose), NULL);
return TRUE;
}