+
+ 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 = g_fopen(filename, "r");
+ if (!file)
+ g_error("GritsPluginRadar: open failed");
+ guint8 color[4];
+ GArray *array = g_array_sized_new(FALSE, TRUE, sizeof(color), 256);
+ fgets(cm->name, sizeof(cm->name), file);
+ fscanf(file, "%f\n", &cm->scale);
+ fscanf(file, "%f\n", &cm->shift);
+ while (fscanf(file, "%hhd %hhd %hhd %hhd\n",
+ &color[0], &color[1], &color[2], &color[3]) == 4)
+ g_array_append_val(array, color);
+ cm->len = (gint )array->len;
+ cm->data = (void*)array->data;
+ g_array_free(array, FALSE);
+}
+
+static void _update_hidden(GtkNotebook *notebook,
+ GtkNotebookPage *page, 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(conus->tile[0])->hidden = is_hidden;
+ GRITS_OBJECT(conus->tile[1])->hidden = is_hidden;
+ } else if (site) {
+ site->hidden = is_hidden;
+ if (site->level2)
+ GRITS_OBJECT(site->level2)->hidden = is_hidden;
+ } else {
+ g_warning("GritsPluginRadar: _update_hidden - no site or counus found");
+ }