site and time selection for both ridge and radar
authorAndy Spencer <andy753421@gmail.com>
Sun, 10 May 2009 10:55:26 +0000 (10:55 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 10 May 2009 10:55:26 +0000 (10:55 +0000)
src/Makefile.am
src/aweather-gui.c
src/aweather-gui.h
src/aweather-view.c
src/aweather-view.h
src/data.h
src/main.c
src/plugin-example.c
src/plugin-radar.c
src/plugin-ridge.c
src/wsr88ddec.c [moved from opt/dec.c with 98% similarity]

index 0617f6a..4632471 100644 (file)
@@ -1,7 +1,7 @@
 AM_CPPFLAGS  = -DDATADIR="\"$(datadir)\"" $(RSL_CFLAGS) $(GTK_CFLAGS) $(CURL_CFLAGS) 
-AM_CFLAGS    = -O3 -Wall -Werror --std=gnu99 
+AM_CFLAGS    = -O3 -Wall -Werror -Wno-unused --std=gnu99 
 AM_LDFLAGS   = -Wl,--export-dynamic
-bin_PROGRAMS = aweather
+bin_PROGRAMS = aweather wsr88ddec
 
 aweather_SOURCES  = main.c \
        aweather-gui.c   aweather-gui.h   \
@@ -13,6 +13,9 @@ aweather_SOURCES  = main.c \
        plugin-example.c plugin-example.h
 aweather_LDADD    = $(RSL_LIBS) $(GTK_LIBS) $(CURL_LIBS)
 
+wsr88ddec         = wsr88ddec.c
+wsr88ddec_LDADD   = -lbz2
+
 
 test: all
        LD_LIBRARY_PATH=/usr/local/trmm/GVBOX/lib/ \
index 16e7dec..83d9a3f 100644 (file)
@@ -20,24 +20,27 @@ gboolean on_window_key_press_event(GtkWidget *widget, GdkEventKey *event, gpoint
        return TRUE;
 }
 
-void on_site_changed(GtkComboBox *combo, AWeatherGui *gui) {
+void on_site_changed(GtkComboBox *combo, AWeatherGui *gui)
+{
        gchar *site;
        GtkTreeIter iter;
-       AWeatherView *view  = aweather_gui_get_view(gui);
        GtkTreeModel *model = gtk_combo_box_get_model(combo);
        gtk_combo_box_get_active_iter(combo, &iter);
        gtk_tree_model_get(model, &iter, 1, &site, -1);
+       AWeatherView *view = aweather_gui_get_view(gui);
        aweather_view_set_location(view, site);
 }
 
-void on_time_changed() {
-       //gchar *site;
-       //GtkTreeIter iter;
-       //AWeatherView *view  = aweather_gui_get_view(gui);
-       //GtkTreeModel *model = gtk_combo_box_get_model(combo);
-       //gtk_combo_box_get_active_iter(combo, &iter);
-       //gtk_tree_model_get(model, &iter, 1, &site, 0);
-       //aweather_view_set_time(view, site);
+void on_time_changed(GtkTreeView *view, GtkTreePath *path,
+               GtkTreeViewColumn *column, AWeatherGui *gui)
+{
+       gchar *time;
+       GtkTreeIter iter;
+       GtkTreeModel *model = gtk_tree_view_get_model(view);
+       gtk_tree_model_get_iter(model, &iter, path);
+       gtk_tree_model_get(model, &iter, 0, &time, -1);
+       AWeatherView *aview = aweather_gui_get_view(gui);
+       aweather_view_set_time(aview, time);
 }
 
 static gboolean map(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
@@ -132,8 +135,7 @@ static void site_setup(AWeatherGui *gui)
                }
        }
 
-       GtkBuilder      *builder  = aweather_gui_get_builder(gui);
-       GtkWidget       *combo    = GTK_WIDGET(gtk_builder_get_object(builder, "site"));
+       GtkWidget       *combo    = aweather_gui_get_widget(gui, "site");
        GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
        gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", 0, NULL);
@@ -146,22 +148,21 @@ static void site_setup(AWeatherGui *gui)
 
 static void time_setup(AWeatherGui *gui)
 {
-       GtkBuilder        *builder  = aweather_gui_get_builder(gui);
-       GtkWidget         *time     = GTK_WIDGET(gtk_builder_get_object(builder, "time"));
-       GtkCellRenderer   *rend     = gtk_cell_renderer_text_new();
-       GtkTreeViewColumn *col      = gtk_tree_view_column_new_with_attributes(
-                                       "Time", rend, 0, "text", NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(time), col);
+       GtkTreeView  *tview  = GTK_TREE_VIEW(aweather_gui_get_widget(gui, "time"));
+       GtkTreeModel *store  = GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_STRING));
+       gtk_tree_view_set_model(tview, store);
 
-       GtkTreeStore *store = gtk_tree_store_new(1, G_TYPE_STRING);
-       gtk_tree_view_set_model(GTK_TREE_VIEW(time), GTK_TREE_MODEL(store));
+       GtkCellRenderer   *rend = gtk_cell_renderer_text_new();
+       GtkTreeViewColumn *col  = gtk_tree_view_column_new_with_attributes(
+                                       "Time", rend, "text", 0, NULL);
+       gtk_tree_view_append_column(tview, col);
 
-       g_signal_connect(time, "row-activated", G_CALLBACK(on_time_changed), gui);
+       g_signal_connect(tview, "row-activated", G_CALLBACK(on_time_changed), gui);
 }
 
 gboolean opengl_setup(AWeatherGui *gui)
 {
-       GtkDrawingArea *drawing = aweather_gui_get_drawing(gui);
+       GtkDrawingArea *drawing = GTK_DRAWING_AREA(aweather_gui_get_widget(gui, "drawing"));
 
        GdkGLConfig *glconfig = gdk_gl_config_new_by_mode(
                        GDK_GL_MODE_RGBA   | GDK_GL_MODE_DEPTH |
@@ -259,26 +260,18 @@ GtkBuilder *aweather_gui_get_builder(AWeatherGui *gui)
        g_assert(AWEATHER_IS_GUI(gui));
        return gui->builder;
 }
-GtkWindow *aweather_gui_get_window(AWeatherGui *gui)
-{
-       g_assert(AWEATHER_IS_GUI(gui));
-       return gui->window;
-}
-GtkNotebook *aweather_gui_get_tabs(AWeatherGui *gui)
-{
-       g_assert(AWEATHER_IS_GUI(gui));
-       return gui->tabs;
-}
-GtkDrawingArea *aweather_gui_get_drawing(AWeatherGui *gui)
+GtkWidget *aweather_gui_get_widget(AWeatherGui *gui, const gchar *name)
 {
        g_assert(AWEATHER_IS_GUI(gui));
-       return gui->drawing;
+       GObject *widget = gtk_builder_get_object(gui->builder, name);
+       g_assert(GTK_IS_WIDGET(widget));
+       return GTK_WIDGET(widget);
 }
 void aweather_gui_gl_begin(AWeatherGui *gui)
 {
        g_assert(AWEATHER_IS_GUI(gui));
 
-       GtkDrawingArea *drawing    = aweather_gui_get_drawing(gui);
+       GtkDrawingArea *drawing    = GTK_DRAWING_AREA(aweather_gui_get_widget(gui, "drawing"));
        GdkGLContext   *glcontext  = gtk_widget_get_gl_context(GTK_WIDGET(drawing));
        GdkGLDrawable  *gldrawable = gtk_widget_get_gl_drawable(GTK_WIDGET(drawing));
 
index 921426c..efb1679 100644 (file)
@@ -38,10 +38,7 @@ GType aweather_gui_get_type(void);
 /* Methods */
 AWeatherGui    *aweather_gui_new();
 AWeatherView   *aweather_gui_get_view(AWeatherGui *gui);
-GtkBuilder     *aweather_gui_get_builder(AWeatherGui *gui);
-GtkWindow      *aweather_gui_get_window(AWeatherGui *gui);
-GtkNotebook    *aweather_gui_get_tabs(AWeatherGui *gui);
-GtkDrawingArea *aweather_gui_get_drawing(AWeatherGui *gui);
+GtkWidget      *aweather_gui_get_widget(AWeatherGui *gui, const gchar *name);
 void            aweather_gui_gl_begin(AWeatherGui *gui);
 void            aweather_gui_gl_end(AWeatherGui *gui);
 void            aweather_gui_gl_flush(AWeatherGui *gui);
index 7f5fc1f..8857bc5 100644 (file)
@@ -23,8 +23,8 @@ static void aweather_view_init(AWeatherView *self)
 {
        //g_message("aweather_view_init");
        /* Default values */
-       self->time     = 0;
-       self->location = g_strdup("IND");
+       self->time     = g_strdup(""); //g_strdup("LATEST");
+       self->location = g_strdup(""); //g_strdup("IND");
 }
 
 static GObject *aweather_view_constructor(GType gtype, guint n_properties,
@@ -56,7 +56,7 @@ static void aweather_view_set_property(GObject *object, guint property_id,
        //g_message("aweather_view_set_property");
        AWeatherView *self = AWEATHER_VIEW(object);
        switch (property_id) {
-       case PROP_TIME:     aweather_view_set_time    (self, g_value_get_int   (value)); break;
+       case PROP_TIME:     aweather_view_set_time    (self, g_value_get_string(value)); break;
        case PROP_LOCATION: aweather_view_set_location(self, g_value_get_string(value)); break;
        default:            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
        }
@@ -68,7 +68,7 @@ static void aweather_view_get_property(GObject *object, guint property_id,
        //g_message("aweather_view_get_property");
        AWeatherView *self = AWEATHER_VIEW(object);
        switch (property_id) {
-       case PROP_TIME:     g_value_set_int   (value, aweather_view_get_time    (self)); break;
+       case PROP_TIME:     g_value_set_string(value, aweather_view_get_time    (self)); break;
        case PROP_LOCATION: g_value_set_string(value, aweather_view_get_location(self)); break;
        default:            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
        }
@@ -84,11 +84,10 @@ static void aweather_view_class_init(AWeatherViewClass *klass)
        gobject_class->get_property = aweather_view_get_property;
        gobject_class->set_property = aweather_view_set_property;
        g_object_class_install_property(gobject_class, PROP_TIME,
-               g_param_spec_int(
+               g_param_spec_pointer(
                        "time",
                        "time of the current frame",
                        "(format unknown)", 
-                       G_MININT32, G_MAXINT32, 0,
                        G_PARAM_READWRITE));
        g_object_class_install_property(gobject_class, PROP_LOCATION,
                g_param_spec_pointer(
@@ -106,7 +105,7 @@ static void aweather_view_class_init(AWeatherViewClass *klass)
                        g_cclosure_marshal_VOID__INT,
                        G_TYPE_NONE,
                        1,
-                       G_TYPE_INT);
+                       G_TYPE_STRING);
        signals[SIG_LOCATION_CHANGED] = g_signal_new(
                        "location-changed",
                        G_TYPE_FROM_CLASS(gobject_class),
@@ -128,15 +127,15 @@ AWeatherView *aweather_view_new()
        return g_object_new(AWEATHER_TYPE_VIEW, NULL);
 }
 
-void aweather_view_set_time(AWeatherView *view, int time)
+void aweather_view_set_time(AWeatherView *view, const char *time)
 {
        g_assert(AWEATHER_IS_VIEW(view));
-       //g_message("aweather_view_set_time");
-       view->time = time;
+       //g_message("aweather_view:set_time: setting time to %s", time);
+       view->time = g_strdup(time);
        g_signal_emit(view, signals[SIG_TIME_CHANGED], 0, time);
 }
 
-int aweather_view_get_time(AWeatherView *view)
+gchar *aweather_view_get_time(AWeatherView *view)
 {
        g_assert(AWEATHER_IS_VIEW(view));
        //g_message("aweather_view_get_time");
index 0dc58fd..2278eae 100644 (file)
@@ -18,7 +18,7 @@ struct _AWeatherView {
        GObject parent_instance;
 
        /* instance members */
-       gint   time;
+       gchar *time;
        gchar *location;
 };
 
@@ -32,8 +32,8 @@ GType aweather_view_get_type(void);
 
 /* Methods */
 AWeatherView *aweather_view_new();
-void aweather_view_set_time(AWeatherView *view, gint time);
-gint aweather_view_get_time(AWeatherView *view);
+void aweather_view_set_time(AWeatherView *view, const gchar *time);
+gchar *aweather_view_get_time(AWeatherView *view);
 
 void aweather_view_set_location(AWeatherView *view, const gchar *location);
 gchar *aweather_view_get_location(AWeatherView *view);
index fd97829..9885fd0 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __DATA_H__
 #define __DATA_H__
 
-typedef void (*AWeatherCacheDoneCallback)(const gchar *file, gpointer user_data);
+typedef void (*AWeatherCacheDoneCallback)(gchar *file, gpointer user_data);
 
 void cache_file(char *base, char *path, AWeatherCacheDoneCallback callback, gpointer user_data);
 
index f88cdbe..f65d5b8 100644 (file)
@@ -20,11 +20,11 @@ int main(int argc, char *argv[])
        //AWeatherView *view = aweather_gui_get_view(gui);
 
        /* Load plugins */
-       radar_init  (gui);
-        ridge_init  (gui);
        //example_init(gui);
+        ridge_init  (gui);
+       radar_init  (gui);
 
-       gtk_widget_show_all(GTK_WIDGET(aweather_gui_get_window(gui)));
+       gtk_widget_show_all(aweather_gui_get_widget(gui, "window"));
        gtk_main();
 
        return 0;
index 16dbdd3..a2fb366 100644 (file)
@@ -60,8 +60,8 @@ static gboolean rotate(gpointer user_data)
 
 gboolean example_init(AWeatherGui *gui)
 {
-       GtkDrawingArea *drawing = aweather_gui_get_drawing(gui);
-       GtkNotebook    *config  = aweather_gui_get_tabs(gui);
+       GtkWidget *drawing = aweather_gui_get_widget(gui, "drawing");
+       GtkWidget *config  = aweather_gui_get_widget(gui, "tabs");
 
        /* Add configuration tab */
        GtkWidget *label = gtk_label_new("example");
index f4b68d7..3ac3682 100644 (file)
@@ -8,8 +8,10 @@
 
 #include "aweather-gui.h"
 #include "plugin-radar.h"
+#include "data.h"
 
 GtkWidget *drawing;
+GtkWidget *config_body;
 static Sweep *cur_sweep = NULL;  // make this not global
 static int nred, ngreen, nblue;
 static char red[256], green[256], blue[256];
@@ -18,6 +20,10 @@ static guint sweep_tex = 0;
 static AWeatherGui *gui = NULL;
 static Radar *radar = NULL;
 
+/**************************
+ * Data loading functions *
+ **************************/
+/* return a GL alpha value for a radar pixle */
 static guint8 get_alpha(guint8 db)
 {
        if (db == BADVAL) return 0;
@@ -67,6 +73,7 @@ static void bscan_sweep(Sweep *sweep, guint8 **data, int *width, int *height)
 /* Load a sweep as the active texture */
 static void load_sweep(Sweep *sweep)
 {
+       aweather_gui_gl_begin(gui);
        cur_sweep = sweep;
        int height, width;
        guint8 *data;
@@ -81,24 +88,121 @@ static void load_sweep(Sweep *sweep)
        g_free(data);
        gdk_window_invalidate_rect(drawing->window, &drawing->allocation, FALSE);
        gdk_window_process_updates(drawing->window, FALSE);
+       aweather_gui_gl_end(gui);
 }
 
-/* Load the default sweep */
-static gboolean map(GtkWidget *da, GdkEvent *event, gpointer user_data)
+/* Add selectors to the config area for the sweeps */
+static void load_radar_gui(Radar *radar)
 {
-       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);
+       /* Clear existing items */
+       GtkWidget *child = gtk_bin_get_child(GTK_BIN(config_body));
+       if (child)
+               gtk_widget_destroy(child);
 
-       return FALSE;
+       GtkWidget *hbox = gtk_hbox_new(TRUE, 0);
+       GtkWidget *button = NULL;
+       int vi = 0, si = 0;
+       for (vi = 0; vi < radar->h.nvolumes; vi++) {
+               Volume *vol = radar->v[vi];
+               if (vol == NULL) continue;
+               g_message("    adding volume: %d", vi);
+               GtkWidget *vbox = gtk_vbox_new(TRUE, 0);
+               for (si = vol->h.nsweeps-1; si >= 0; si--) {
+                       Sweep *sweep = vol->sweep[si];
+                       if (sweep == NULL) continue;
+                       char *label = g_strdup_printf("Tilt: %.2f (%s)", sweep->h.elev, vol->h.type_str);
+                       g_message("        adding sweep: %d - %s", si, label);
+                       button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), label);
+                       g_object_set(button, "draw-indicator", FALSE, NULL);
+                       g_signal_connect_swapped(button, "clicked", G_CALLBACK(load_sweep), sweep);
+                       gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, TRUE, 0);
+                       g_free(label);
+               }
+               g_message("adding vbox to hbox");
+               gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
+               gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+       }
+       g_message("adding hbox to scroll");
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(config_body), hbox);
+       gtk_widget_show_all(hbox);
 }
 
+/* Load a radar from a file */
+static void load_radar_rsl(GPid pid, gint status, gpointer _path)
+{
+       gchar *path = _path;
+       if (status != 0) {
+               g_warning("wsr88ddec exited with status %d", status);
+               return;
+       }
+       char *site = g_path_get_basename(g_path_get_dirname(path));
+       if (radar) RSL_free_radar(radar);
+       RSL_read_these_sweeps("all", NULL);
+       radar = RSL_wsr88d_to_radar(path, site);
+       if (radar == NULL) {
+               g_warning("fail to load radar: path=%s, site=%s", path, site);
+               return;
+       }
+
+       /* TODO: replace this with a better color table */
+       g_message("loading color table");
+       RSL_load_refl_color_table();
+       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);
+
+       /* Load the first sweep by default */
+       if (radar->h.nvolumes < 1 || radar->v[0]->h.nsweeps < 1) {
+               g_warning("No sweeps found\n");
+       } else {
+               /* load first available sweep */
+               for (int vi = 0; vi < radar->h.nvolumes; vi++) {
+                       if (radar->v[vi]== NULL) continue;
+                       for (int si = 0; si < radar->v[vi]->h.nsweeps; si++) {
+                               if (radar->v[vi]->sweep[si]== NULL) continue;
+                               load_sweep(radar->v[vi]->sweep[si]);
+                               break;
+                       }
+                       break;
+               }
+       }
+
+       load_radar_gui(radar);
+}
+
+/* decompress a radar file, then chain to the actuall loading function */
+static void load_radar(char *path, gpointer user_data)
+{
+       char *raw  = g_strconcat(path, ".raw", NULL);
+       if (g_file_test(raw, G_FILE_TEST_EXISTS)) {
+               load_radar_rsl(0, 0, raw);
+       } else {
+               char *argv[] = {"./wsr88ddec", path, raw, NULL};
+               GPid pid;
+               GError *error = NULL;
+               g_spawn_async(
+                       NULL,    // const gchar *working_directory,
+                       argv,    // gchar **argv,
+                       NULL,    // gchar **envp,
+                       G_SPAWN_DO_NOT_REAP_CHILD, // GSpawnFlags flags,
+                       NULL,    // GSpawnChildSetupFunc child_setup,
+                       NULL,    // gpointer user_data,
+                       &pid,    // GPid *child_pid,
+                       &error); // GError **error
+               if (error)
+                       g_warning("failed to decompress WSR88D data: %s", error->message);
+               g_child_watch_add(pid, load_radar_rsl, raw);
+       }
+}
+
+/*************
+ * Callbacks *
+ *************/
 static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
 {
        g_message("radar:expose");
+       if (cur_sweep == NULL)
+               return FALSE;
        Sweep *sweep = cur_sweep;
 
        /* Draw the rays */
@@ -163,56 +267,65 @@ static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
        return FALSE;
 }
 
-//static void set_site(AWeatherView *view, char *site, gpointer user_data)
-//{
-//     g_message("location changed to %s", site);
-//}
+static void set_time(AWeatherView *view, char *time, gpointer user_data)
+{
+       g_message("radar:setting time");
+       // format: http://mesonet.agron.iastate.edu/data/nexrd2/raw/KABR/KABR_20090510_0323
+       char *site = aweather_view_get_location(view);
+       char *base = "http://mesonet.agron.iastate.edu/data/";
+       char *path = g_strdup_printf("nexrd2/raw/K%s/K%s_%s", site, site, time);
+       //g_message("caching %s/%s", base, path);
+       cache_file(base, path, load_radar, NULL);
+}
+
+static void set_site(AWeatherView *view, char *site, gpointer user_data)
+{
+       g_message("Loading wsr88d list for %s", site);
+       gchar *data;
+       gsize length;
+       GError *error = NULL;
+       char *list_uri = g_strdup_printf("http://mesonet.agron.iastate.edu/data/nexrd2/raw/K%s/dir.list", site);
+       GFile *list    = g_file_new_for_uri(list_uri);
+       g_file_load_contents(list, NULL, &data, &length, NULL, &error);
+       if (error) {
+               g_warning("Error loading list for %s: %s", site, error->message);
+               return;
+       }
+       gchar **lines = g_strsplit(data, "\n", -1);
+       GtkTreeView  *tview  = GTK_TREE_VIEW(aweather_gui_get_widget(gui, "time"));
+       GtkListStore *lstore = GTK_LIST_STORE(gtk_tree_view_get_model(tview));
+       gtk_list_store_clear(lstore);
+       radar = NULL;
+       for (int i = 0; lines[i] && lines[i][0]; i++) {
+               // format: `841907 KABR_20090510_0159'
+               //g_message("\tadding %p [%s]", lines[i], lines[i]);
+               char **parts = g_strsplit(lines[i], " ", 2);
+               GtkTreeIter iter;
+               gtk_list_store_append(lstore, &iter);
+               gtk_list_store_set(lstore, &iter, 0, parts[1]+5, -1);
+               if (i == 0)
+                       set_time(view, parts[1]+5, NULL);
+       }
+}
 
+/* Init */
 gboolean radar_init(AWeatherGui *_gui)
 {
        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 = 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);
-       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");
+       drawing = aweather_gui_get_widget(gui, "drawing");
+       GtkNotebook    *config  = GTK_NOTEBOOK(aweather_gui_get_widget(gui, "tabs"));
+       AWeatherView   *view    = aweather_gui_get_view(gui);
 
        /* Add configuration tab */
-       GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
-       GtkWidget *hbox = gtk_hbox_new(TRUE, 0);
-       GtkWidget *button = NULL;
-       int vi = 0, si = 0;
-       for (vi = 0; vi < radar->h.nvolumes; vi++) {
-               Volume *vol = radar->v[vi];
-               if (vol == NULL) continue;
-               GtkWidget *vbox = gtk_vbox_new(TRUE, 0);
-               gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
-               for (si = 0; si < vol->h.nsweeps; si++) {
-                       Sweep *sweep = vol->sweep[si];
-                       if (sweep == NULL) continue;
-                       char *label = g_strdup_printf("Tilt: %.2f (%s)", sweep->h.elev, vol->h.type_str);
-                       button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), label);
-                       g_signal_connect_swapped(button, "clicked", G_CALLBACK(load_sweep), sweep);
-                       gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
-                       g_free(label);
-               }
-       }
-       GtkWidget *label = gtk_label_new("Radar");
-       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), hbox);
-       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-       gtk_notebook_append_page(GTK_NOTEBOOK(config), scroll, label);
+       config_body = gtk_scrolled_window_new(NULL, NULL);
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(config_body), gtk_label_new("No radar loaded"));
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(config_body), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+       gtk_notebook_append_page(GTK_NOTEBOOK(config), config_body, gtk_label_new("Radar"));
 
        /* Set up OpenGL Stuff */
-       g_signal_connect(drawing, "map-event",    G_CALLBACK(map),    NULL);
-       g_signal_connect(drawing, "expose-event", G_CALLBACK(expose), NULL);
+       g_signal_connect(drawing, "expose-event",     G_CALLBACK(expose),   NULL);
+       g_signal_connect(view,    "location-changed", G_CALLBACK(set_site), NULL);
+       g_signal_connect(view,    "time-changed",     G_CALLBACK(set_time), NULL);
 
        return TRUE;
 }
index 2b25bbf..525dc9b 100644 (file)
@@ -38,7 +38,7 @@ static AWeatherGui *gui = NULL;
  * \param  filename  Path to the image file
  * \return The OpenGL identifier for the texture
  */
-void load_texture(const gchar *filename, gpointer _layer)
+void load_texture(gchar *filename, gpointer _layer)
 {
        layer_t *layer = _layer;
        aweather_gui_gl_begin(gui);
@@ -69,7 +69,7 @@ void load_texture(const gchar *filename, gpointer _layer)
        aweather_gui_gl_end(gui);
 
        /* Redraw */
-       gtk_widget_queue_draw(GTK_WIDGET(aweather_gui_get_drawing(gui)));
+       gtk_widget_queue_draw(aweather_gui_get_widget(gui, "drawing"));
 }
 
 static void set_site(AWeatherView *view, gchar *site, gpointer user_data)
@@ -94,10 +94,10 @@ static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
                glBindTexture(GL_TEXTURE_2D, layers[i].tex);
 
                glBegin(GL_POLYGON);
-               glTexCoord2f(0.0, 0.0); glVertex3f(500*1000*-1.0, 500*1000* 1.0, layers[i].z);
-               glTexCoord2f(0.0, 1.0); glVertex3f(500*1000*-1.0, 500*1000*-1.0, layers[i].z);
-               glTexCoord2f(1.0, 1.0); glVertex3f(500*1000* 1.0, 500*1000*-1.0, layers[i].z);
-               glTexCoord2f(1.0, 0.0); glVertex3f(500*1000* 1.0, 500*1000* 1.0, layers[i].z);
+               glTexCoord2f(0.0, 0.0); glVertex3f(250*1000*-1.0, 250*1000* 1.0, layers[i].z);
+               glTexCoord2f(0.0, 1.0); glVertex3f(250*1000*-1.0, 250*1000*-1.0, layers[i].z);
+               glTexCoord2f(1.0, 1.0); glVertex3f(250*1000* 1.0, 250*1000*-1.0, layers[i].z);
+               glTexCoord2f(1.0, 0.0); glVertex3f(250*1000* 1.0, 250*1000* 1.0, layers[i].z);
                glEnd();
        }
 
@@ -108,7 +108,7 @@ static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
 gboolean ridge_init(AWeatherGui *_gui)
 {
        gui = _gui;
-       GtkDrawingArea *drawing = aweather_gui_get_drawing(gui);
+       GtkDrawingArea *drawing = GTK_DRAWING_AREA(aweather_gui_get_widget(gui, "drawing"));
        AWeatherView   *view    = aweather_gui_get_view(gui);
 
        /* Set up OpenGL Stuff */
similarity index 98%
rename from opt/dec.c
rename to src/wsr88ddec.c
index 6126249..d253e12 100644 (file)
--- a/opt/dec.c
@@ -52,7 +52,7 @@ char *bunzip2(char *input, int input_len, int *output_len)
 int main(int argc, char **argv)
 {
        if (argc != 3) {
-               printf("usage: ./dec <input> <output>\n");
+               printf("usage: %s <input> <output>\n", argv[0]);
                return 0;
        }