[xiph-commits] r12282 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Mon Jan 1 14:27:24 PST 2007
Author: xiphmont
Date: 2007-01-01 14:27:22 -0800 (Mon, 01 Jan 2007)
New Revision: 12282
Modified:
trunk/sushivision/dimension.c
trunk/sushivision/example_fractal.c
trunk/sushivision/main.c
trunk/sushivision/slider.c
trunk/sushivision/slider.h
Log:
Commit numerous small fixups to discrete dimensions such that they
function as intended; iteration (xy/1d panels) has not yet been
tested.
Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c 2007-01-01 21:55:45 UTC (rev 12281)
+++ trunk/sushivision/dimension.c 2007-01-01 22:27:22 UTC (rev 12282)
@@ -71,6 +71,19 @@
return datascale->pixels;
}
+static double discrete_quantize_val(sushiv_dimension_t *d, double val){
+ if(d->type == SUSHIV_DIM_DISCRETE){
+ val *= d->private->discrete_denominator;
+ val /= d->private->discrete_numerator;
+
+ val = rint(val);
+
+ val *= d->private->discrete_numerator;
+ val /= d->private->discrete_denominator;
+ }
+ return val;
+}
+
static void _sushiv_dimension_center_callback(void *data, int buttonstate){
gdk_threads_enter();
@@ -80,7 +93,8 @@
sushiv_dimension_t *d = dw->dl->d;
sushiv_panel_t *p = dw->dl->p;
double val = slider_get_value(dw->scale,1);
-
+
+ val = discrete_quantize_val(d,val);
dw->center_updating = 1;
if(buttonstate == 0){
@@ -126,6 +140,9 @@
double lo = slider_get_value(dw->scale,0);
double hi = slider_get_value(dw->scale,2);
+ hi = discrete_quantize_val(d,hi);
+ lo = discrete_quantize_val(d,lo);
+
dw->bracket_updating = 1;
if(buttonstate == 0){
@@ -212,7 +229,17 @@
switch(d->type){
case SUSHIV_DIM_CONTINUOUS:
+ slider_set_value(dw->scale,thumb,val);
+ break;
case SUSHIV_DIM_DISCRETE:
+ val *= d->private->discrete_denominator;
+ val /= d->private->discrete_numerator;
+
+ val = rint(val);
+
+ val *= d->private->discrete_numerator;
+ val /= d->private->discrete_denominator;
+
slider_set_value(dw->scale,thumb,val);
break;
case SUSHIV_DIM_PICKLIST:
@@ -258,13 +285,13 @@
if(!d->private->widgets){
switch(thumb){
case 0:
- d->bracket[0] = val;
+ d->bracket[0] = discrete_quantize_val(d,val);
break;
case 1:
- d->val = val;
+ d->val = discrete_quantize_val(d,val);
break;
default:
- d->bracket[1] = val;
+ d->bracket[1] = discrete_quantize_val(d,val);
break;
}
}else
@@ -313,6 +340,8 @@
dw->scale = slider_new((Slice **)sl,3,d->scale->label_list,d->scale->val_list,
d->scale->vals,0);
+ if(d->type == SUSHIV_DIM_DISCRETE)
+ slider_set_quant(dw->scale,d->private->discrete_numerator,d->private->discrete_denominator);
slice_thumb_set((Slice *)sl[0],v[0]);
slice_thumb_set((Slice *)sl[1],v[1]);
Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c 2007-01-01 21:55:45 UTC (rev 12281)
+++ trunk/sushivision/example_fractal.c 2007-01-01 22:27:22 UTC (rev 12282)
@@ -63,13 +63,19 @@
5,(double []){-2.25,-1,0,1,2.25},
NULL,0);
+ sushiv_new_dimension_discrete(s,4,"Iterations",
+ 5,(double []){1,10,100,1000,10000},
+ NULL,
+ 10,1,
+ 0);
+
sushiv_new_dimension_picklist(s,4,"Max Iterations",
- 4,
- (double []){100,1000,10000,100000},
- (char *[]){"one hundred",
- "one thousand",
- "ten thousand",
- "one hundred thousand"},
+ 4,
+ (double []){100,1000,10000,100000},
+ (char *[]){"one hundred",
+ "one thousand",
+ "ten thousand",
+ "one hundred thousand"},
NULL,0);
sushiv_new_objective(s,0,"fractal",
@@ -88,8 +94,6 @@
sushiv_new_panel_1d_linked(s,2,"Y Slice",s->objective_list[0]->scale,
(int []){0,-1},
0,SUSHIV_PANEL_LINK_Y | SUSHIV_PANEL_FLIP);
-
- sushiv_dimension_set_value(s,4,1,10000);
return 0;
}
Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c 2007-01-01 21:55:45 UTC (rev 12281)
+++ trunk/sushivision/main.c 2007-01-01 22:27:22 UTC (rev 12282)
@@ -124,7 +124,7 @@
p->private->legend_redraw(p);
gdk_threads_enter ();
- p->private->maps_rendering = 0;
+ p->private->legend_rendering = 0;
}
gdk_threads_leave ();
Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c 2007-01-01 21:55:45 UTC (rev 12281)
+++ trunk/sushivision/slider.c 2007-01-01 22:27:22 UTC (rev 12282)
@@ -503,14 +503,26 @@
return x+width;
}
+static double quant(Slider *s, double val){
+ val *= s->quant_denom;
+ val /= s->quant_num;
+
+ val = rint(val);
+
+ val *= s->quant_num;
+ val /= s->quant_denom;
+
+ return val;
+}
+
double slider_pixel_to_val(Slider *s,double x){
int tx=s->xpad;
int tw=s->w - tx*2;
double del = (double)(x-tx)/tw;
if(del<0)
- return s->label_vals[0];
+ return quant(s,s->label_vals[0]);
if(del>=1.)
- return (s->label_vals[s->labels-1]);
+ return quant(s,(s->label_vals[s->labels-1]));
return slider_del_to_val(s,del);
}
@@ -535,7 +547,7 @@
base = floor(del);
del -= base;
- return ( (1.-del)*s->label_vals[base] + del*s->label_vals[base+1] );
+ return quant(s,( (1.-del)*s->label_vals[base] + del*s->label_vals[base+1] ));
}
void slider_vals_bound(Slider *s,int slicenum){
@@ -786,6 +798,8 @@
ret->slices = (GtkWidget **)slices;
ret->num_slices = num_slices;
+ ret->quant_num=1.;
+ ret->quant_denom=1.;
ret->label = calloc(num_labels,sizeof(*ret->label));
for(i=0;i<num_labels;i++)
@@ -836,3 +850,8 @@
slice_thumb_set(SLICE(w),v);
update_gradient(s);
}
+
+void slider_set_quant(Slider *s,double num, double denom){
+ s->quant_num=num;
+ s->quant_denom=denom;
+}
Modified: trunk/sushivision/slider.h
===================================================================
--- trunk/sushivision/slider.h 2007-01-01 21:55:45 UTC (rev 12281)
+++ trunk/sushivision/slider.h 2007-01-01 22:27:22 UTC (rev 12282)
@@ -39,7 +39,9 @@
int labels;
int neg;
int flags;
-
+
+ double quant_num;
+ double quant_denom;
//double minstep;
//double step;
};
@@ -70,3 +72,4 @@
extern double slider_get_value(Slider *s, int thumbnum);
extern void slider_set_value(Slider *s, int thumbnum, double v);
extern double slider_del_to_val(Slider *s, double del);
+extern void slider_set_quant(Slider *s, double n, double d);
More information about the commits
mailing list