From fee3a49de14956c024a3249fb2bb51450b207677 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Tue, 24 May 2011 03:32:41 +0000 Subject: [PATCH] Increase volume size and fix colormap bugs --- src/plugins/level2.c | 25 +++++++++++-------------- src/plugins/radar-info.h | 6 ++++++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/plugins/level2.c b/src/plugins/level2.c index 271dfbe..14f9e34 100644 --- a/src/plugins/level2.c +++ b/src/plugins/level2.c @@ -58,15 +58,12 @@ static void _bscan_sweep(Sweep *sweep, AWeatherColormap *colormap, continue; } - /* Convert data value to index */ - gint idx = value * colormap->scale + colormap->shift; - idx = CLAMP(idx, 0, colormap->len); - /* Copy color to buffer */ - buf[buf_i+0] = colormap->data[idx][0]; - buf[buf_i+1] = colormap->data[idx][1]; - buf[buf_i+2] = colormap->data[idx][2]; - buf[buf_i+3] = colormap->data[idx][3]*0.75; // TESTING + guint8 *data = colormap_get(colormap, value); + buf[buf_i+0] = data[0]; + buf[buf_i+1] = data[1]; + buf[buf_i+2] = data[2]; + buf[buf_i+3] = data[3]*0.75; // TESTING } } @@ -161,7 +158,7 @@ static VolGrid *_load_grid(Volume *vol) gint nsweeps = vol->h.nsweeps; gint nrays = sweep->h.nrays/(1/sweep->h.beam_width)+1; gint nbins = ray->h.nbins /(1000/ray->h.gate_size); - nbins = MIN(nbins, 100); + nbins = MIN(nbins, 150); VolGrid *grid = vol_grid_new(nrays, nbins, nsweeps); @@ -324,11 +321,11 @@ void aweather_level2_set_iso(AWeatherLevel2 *level2, gfloat level) level2->volume = vol; } if (ISO_MIN < level && level < ISO_MAX) { - AWeatherColormap *cm = &level2->colormap[0]; - level2->volume->color[0] = cm->data[(gint)level][0]; - level2->volume->color[1] = cm->data[(gint)level][1]; - level2->volume->color[2] = cm->data[(gint)level][2]; - level2->volume->color[3] = cm->data[(gint)level][3]; + guint8 *data = colormap_get(&level2->colormap[0], level); + level2->volume->color[0] = data[0]; + level2->volume->color[1] = data[1]; + level2->volume->color[2] = data[2]; + level2->volume->color[3] = data[3]; grits_volume_set_level(level2->volume, level); GRITS_OBJECT(level2->volume)->hidden = FALSE; } else { diff --git a/src/plugins/radar-info.h b/src/plugins/radar-info.h index 664eeb1..db0e127 100644 --- a/src/plugins/radar-info.h +++ b/src/plugins/radar-info.h @@ -33,4 +33,10 @@ typedef struct { extern AWeatherColormap colormaps[]; +static inline guint8 *colormap_get(AWeatherColormap *colormap, int value) +{ + int idx = value * colormap->scale + colormap->shift; + return colormap->data[CLAMP(idx, 0, colormap->len)]; +} + #endif -- 2.43.2