[xiph-commits] r12391 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Mon Jan 29 14:19:13 PST 2007
Author: xiphmont
Date: 2007-01-29 14:19:10 -0800 (Mon, 29 Jan 2007)
New Revision: 12391
Modified:
trunk/sushivision/dimension.c
trunk/sushivision/example_fractal.c
trunk/sushivision/main.c
trunk/sushivision/panel-2d.c
trunk/sushivision/scale.c
trunk/sushivision/sushivision.h
Log:
Numerous small scaling / rendering fixes to new discrete functionality.
Still not generally useful, currently the fractal example is badly modified for testing it (about to make new example for discont testing)
Numerous fixes as yet required.
Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c 2007-01-29 18:12:58 UTC (rev 12390)
+++ trunk/sushivision/dimension.c 2007-01-29 22:19:10 UTC (rev 12391)
@@ -82,9 +82,9 @@
if(hi_i < ceil_i)hi_i = ceil_i;
}
- double lo = lo_i * d->private->discrete_numerator /
+ double lo = (double)lo_i * d->private->discrete_numerator /
d->private->discrete_denominator;
- double hi = hi_i * d->private->discrete_numerator /
+ double hi = (double)hi_i * d->private->discrete_numerator /
d->private->discrete_denominator;
data_w = hi_i-lo_i;
@@ -92,8 +92,19 @@
floor_i = 0;
*panel = scalespace_linear(lo, hi, panel_w, spacing, legend);
- *data = scalespace_linear(lo_i, hi_i, data_w, 1, legend);
- *iter = scalespace_linear(lo_i - floor_i, hi_i - floor_i, data_w, 1, legend);
+ *data = scalespace_linear(lo, hi, data_w, 1, legend);
+
+ if(d->flags & SUSHIV_DIM_MONOTONIC)
+ *iter = scalespace_linear(lo_i - floor_i, hi_i - floor_i,
+ data_w, 1, legend);
+ else
+ *iter = scalespace_linear((double)(lo_i - floor_i) *
+ d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ (double)(hi_i - floor_i) *
+ d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ data_w, 1, legend);
break;
}
break;
Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c 2007-01-29 18:12:58 UTC (rev 12390)
+++ trunk/sushivision/example_fractal.c 2007-01-29 22:19:10 UTC (rev 12391)
@@ -54,13 +54,20 @@
s=sushiv_new_instance();
- sushiv_new_dimension(s,0,"Re(c)",
- 5,(double []){-2.25,-0.75,0,0.25,0.75},
- NULL,0);
- sushiv_new_dimension(s,1,"Im(c)",
- 5,(double []){-2,-1,0,1,2},
- NULL,0);
+ sushiv_new_dimension_discrete(s,0,"Re(c)",
+ 5,(double []){-2.25,-0.75,0,0.25,0.75},
+ NULL,1,1000,0);
+ sushiv_new_dimension_discrete(s,1,"Im(c)",
+ 5,(double []){-2,-1,0,1,2},
+ NULL,1,1000,0);
+ //sushiv_new_dimension(s,0,"Re(c)",
+ // 5,(double []){-2.25,-0.75,0,0.25,0.75},
+ // NULL,0);
+ //sushiv_new_dimension(s,1,"Im(c)",
+ // 5,(double []){-2,-1,0,1,2},
+ // NULL,0);
+
sushiv_new_dimension(s,2,"Re(z0)",
5,(double []){-2.25,-1,0,1,2.25},
NULL,0);
Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c 2007-01-29 18:12:58 UTC (rev 12390)
+++ trunk/sushivision/main.c 2007-01-29 22:19:10 UTC (rev 12391)
@@ -200,7 +200,8 @@
int main (int argc, char *argv[]){
int ret;
- num_threads = num_proccies();
+ num_threads = 1;
+ //num_threads = num_proccies();
gtk_init (&argc, &argv);
g_thread_init (NULL);
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2007-01-29 18:12:58 UTC (rev 12390)
+++ trunk/sushivision/panel-2d.c 2007-01-29 22:19:10 UTC (rev 12391)
@@ -129,18 +129,22 @@
/* progressive rendering helpers are specific to resampled y;
if ph=dh, there's nothing to do */
- if(!p2->y_rend && h != datay->pixels){
- p2->y_rend = calloc(h,sizeof(*p2->y_rend));
+ if(h != datay->pixels){
+ if(!p2->y_rend){
- if(!p2->y_num_rend)
- p2->y_num_rend = calloc(p2->y_obj_num,sizeof(*p2->y_num_rend));
- if(!p2->y_den_rend)
- p2->y_den_rend = calloc(p2->y_obj_num,sizeof(*p2->y_den_rend));
-
- for(i=0;i<p2->y_obj_num;i++){
- p2->y_num_rend[i] = calloc(w*h,sizeof(**p2->y_num_rend));
- p2->y_den_rend[i] = calloc(w*h,sizeof(**p2->y_den_rend));
+ p2->y_rend = calloc(h,sizeof(*p2->y_rend));
+
+ if(!p2->y_num_rend)
+ p2->y_num_rend = calloc(p2->y_obj_num,sizeof(*p2->y_num_rend));
+ if(!p2->y_den_rend)
+ p2->y_den_rend = calloc(p2->y_obj_num,sizeof(*p2->y_den_rend));
+
+ for(i=0;i<p2->y_obj_num;i++){
+ p2->y_num_rend[i] = calloc(w*h,sizeof(**p2->y_num_rend));
+ p2->y_den_rend[i] = calloc(w*h,sizeof(**p2->y_den_rend));
+ }
}
+ p2->render_flag = 1;
}
}
@@ -188,7 +192,7 @@
if(pw != dw){
/* resampled computation */
- float scaledel = scalespace_scaledel(&panelx,&datax);
+ float scaledel = scalespace_scaledel(&datax,&panelx);
float outdel = scalespace_pixel(&panelx,scalespace_value(&datax,0));
int outbin = floor(outdel);
outdel -= outbin;
@@ -243,7 +247,7 @@
}
}
- outdel2 -= addel;
+ outdel2--;;
outbin++;
outdel = 0.f;
}
@@ -259,6 +263,7 @@
}
}
}
+ outdel += addel;
}
}
@@ -332,15 +337,15 @@
if(ph != dh){
/* this is a resampling population */
- float scaledel = scalespace_scaledel(&panely,&datay);
- float outdel = scalespace_pixel(&panely,scalespace_value(&datay,y));
+ float scaledel = scalespace_scaledel(&datay,&panely);
+ float outdel = ph-scalespace_pixel(&panely,scalespace_value(&datay,dh-y));
int outbin = floor(outdel);
float outdel2 = (outdel-outbin) + scaledel;
outdel -= outbin;
while(outdel2>1.f){
float addel = (1.f - outdel);
-
+
if(outbin >= 0 && outbin < ph){
gdk_threads_enter ();
@@ -365,7 +370,7 @@
}
}
- outdel2 -= addel;
+ outdel2--;
outbin++;
outdel = 0.f;
}
@@ -832,8 +837,8 @@
double newscale = (new_hi-new_lo)/new_w;
double oldscale = old_w/(old_hi-old_lo);
for(x=0;x<w;x++){
- double xval = x*newscale+new_lo;
- double map = ((xval-old_lo)*oldscale);
+ double xval = (x+.5)*newscale+new_lo;
+ double map = ((xval-old_lo)*oldscale)-.5;
mapbase[x]=(int)floor(map);
mapdel[x]=map-floor(map);
}
@@ -876,8 +881,8 @@
double oldscale = old_h/(old_hi-old_lo);
for(y=0;y<h;y++){
- double yval = y*newscale+new_lo;
- double map = ((yval-old_lo)*oldscale);
+ double yval = (y+.5)*newscale+new_lo;
+ double map = ((yval-old_lo)*oldscale)-.5;
mapbase[y]=(int)floor(map);
mapdel[y]=map-floor(map);
}
@@ -1274,6 +1279,13 @@
return 0;
}
+ // preparation and init before first line render attempt
+ if(p2->last_line==0){
+ render_scale_flag = 1;
+ _maintain_cache_2d(p,&c->p2,pw);
+ compute_prepare_render(p);
+ }
+
plot = PLOT(p->private->graph);
serialno = p2->serialno;
@@ -1320,14 +1332,6 @@
dim_vals[i]=dim->val;
}
- _maintain_cache_2d(p,&c->p2,pw);
- compute_prepare_render(p);
-
- // update scales if we're just starting
- if(p2->last_line==0){
- render_scale_flag = 1;
- }
-
/* iterate */
/* by line */
if(p2->last_line<dh &&
@@ -1780,19 +1784,6 @@
}
}
- // verify all dimensions that can accept axis selection are continuous
- for(i=0;i<p->dimensions;i++){
- if(p->dimension_list[i].d->type != SUSHIV_DIM_CONTINUOUS){
- if( (p->dimension_list[i].d->flags & (SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y)) !=
- (SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y)){
- fprintf(stderr,"Panel %d: x/y selectable dimensions in a 2d panel\n"
- "must be continuous; removing dimension %d from selectable lists.\n",
- number,p->dimension_list[i].d->number);
- p->dimension_list[i].d->flags|=(SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y);
- }
- }
- }
-
p->private->realize = _sushiv_realize_panel2d;
p->private->map_redraw = _sushiv_panel2d_map_redraw;
p->private->legend_redraw = _sushiv_panel2d_legend_redraw;
Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c 2007-01-29 18:12:58 UTC (rev 12390)
+++ trunk/sushivision/scale.c 2007-01-29 22:19:10 UTC (rev 12391)
@@ -215,7 +215,7 @@
}
double scalespace_scaledel(scalespace *from, scalespace *to){
- return from->step_val / from->step_pixel * from->m / to->m * to->step_pixel / to->step_val;
+ return (double)from->step_val / from->step_pixel * from->m / to->m * to->step_pixel / to->step_val;
}
int scalespace_mark(scalespace *s, int num){
@@ -265,22 +265,22 @@
place = 0;
step = 1;
- while(pixels / range < max_spacing){
+ while(rint(pixels / range) < max_spacing){
place++;
range *= .1;
}
- while(pixels / range > max_spacing){
+ while(rint(pixels / range) > max_spacing){
place--;
range *= 10;
}
ret.decimal_exponent = place;
- if (pixels / (range*.2) <= max_spacing){
+ if (rint(pixels / (range*.2)) <= max_spacing){
step *= 5;
range *= .2;
}
- if (pixels / (range*.5) <= max_spacing){
+ if (rint(pixels / (range*.5)) <= max_spacing){
step *= 2;
range *= .5;
}
Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h 2007-01-29 18:12:58 UTC (rev 12390)
+++ trunk/sushivision/sushivision.h 2007-01-29 22:19:10 UTC (rev 12391)
@@ -56,6 +56,7 @@
#define SUSHIV_DIM_NO_X 0x100
#define SUSHIV_DIM_NO_Y 0x200
#define SUSHIV_DIM_ZEROINDEX 0x1
+#define SUSHIV_DIM_MONOTONIC 0x2
typedef struct sushiv_dimension_internal sushiv_dimension_internal_t;
enum sushiv_dimension_type { SUSHIV_DIM_CONTINUOUS,
More information about the commits
mailing list