+
+ GHashTableIter iter;
+ gpointer name, _site;
+ GritsPluginRadar *self = GRITS_PLUGIN_RADAR(_self);
+ g_hash_table_iter_init(&iter, self->sites);
+ while (g_hash_table_iter_next(&iter, &name, &_site)) {
+ /* Pick correct colormaps */
+ RadarSite *site = _site;
+ if (site->hidden || !site->level2)
+ continue;
+ AWeatherColormap *colormap = site->level2->sweep_colors;
+
+ /* Print the color table */
+ glBegin(GL_QUADS);
+ int len = colormap->len;
+ for (int i = 0; i < len; i++) {
+ glColor4ubv(colormap->data[i]);
+ glVertex3f(-1.0, (float)((i ) - len/2)/(len/2), 0.0); // bot left
+ glVertex3f(-1.0, (float)((i+1) - len/2)/(len/2), 0.0); // top left
+ glVertex3f(-0.9, (float)((i+1) - len/2)/(len/2), 0.0); // top right
+ glVertex3f(-0.9, (float)((i ) - len/2)/(len/2), 0.0); // bot right
+ }
+ glEnd();
+ }
+}
+
+static void _load_colormap(gchar *filename, AWeatherColormap *cm)
+{
+ g_debug("GritsPluginRadar: _load_colormap - %s", filename);
+ FILE *file = fopen(filename, "r");
+ if (!file)
+ g_error("GritsPluginRadar: open failed");
+ guint8 color[4];
+ GArray *array = g_array_sized_new(FALSE, TRUE, sizeof(color), 256);
+ if (!fgets(cm->name, sizeof(cm->name), file)) goto out;
+ if (!fscanf(file, "%f\n", &cm->scale)) goto out;
+ if (!fscanf(file, "%f\n", &cm->shift)) goto out;
+ int r, g, b, a;
+ while (fscanf(file, "%d %d %d %d\n", &r, &g, &b, &a) == 4) {
+ color[0] = r;
+ color[1] = g;
+ color[2] = b;
+ color[3] = a;
+ g_array_append_val(array, color);
+ }
+ cm->len = (gint )array->len;
+ cm->data = (void*)array->data;
+out:
+ g_array_free(array, FALSE);
+ fclose(file);
+}
+
+static void _update_hidden(GtkNotebook *notebook,
+ gpointer _, guint page_num, gpointer viewer)
+{
+ g_debug("GritsPluginRadar: _update_hidden - 0..%d = %d",
+ gtk_notebook_get_n_pages(notebook), page_num);
+
+ for (gint i = 0; i < gtk_notebook_get_n_pages(notebook); i++) {
+ gboolean is_hidden = (i != page_num);
+ GtkWidget *config = gtk_notebook_get_nth_page(notebook, i);
+ RadarConus *conus = g_object_get_data(G_OBJECT(config), "conus");
+ RadarSite *site = g_object_get_data(G_OBJECT(config), "site");
+
+ /* Conus */
+ if (conus) {
+ grits_object_hide(GRITS_OBJECT(conus->tile[0]), is_hidden);
+ grits_object_hide(GRITS_OBJECT(conus->tile[1]), is_hidden);
+ } else if (site) {
+ site->hidden = is_hidden;
+ if (site->level2)
+ grits_object_hide(GRITS_OBJECT(site->level2), is_hidden);
+ } else {
+ g_warning("GritsPluginRadar: _update_hidden - no site or counus found");
+ }