[xiph-commits] r12396 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Mon Jan 29 20:49:15 PST 2007
Author: xiphmont
Date: 2007-01-29 20:49:12 -0800 (Mon, 29 Jan 2007)
New Revision: 12396
Modified:
trunk/sushivision/Makefile
trunk/sushivision/dimension.c
trunk/sushivision/main.c
trunk/sushivision/panel-1d.c
trunk/sushivision/panel-2d.c
trunk/sushivision/plot.c
Log:
Substantially correct the bugs in discrete dimension mode. Reverse plot
y scale convention as it turns out to be much more convenient the other
way,
crosshair cleanup is left as yet, as well as discrete scale label
tweaking as well as render area (beginning end is often *just* invisible
off edege).
Modified: trunk/sushivision/Makefile
===================================================================
--- trunk/sushivision/Makefile 2007-01-30 03:13:48 UTC (rev 12395)
+++ trunk/sushivision/Makefile 2007-01-30 04:49:12 UTC (rev 12396)
@@ -26,11 +26,11 @@
SRC = main.c scale.c plot.c slider.c slice.c panel.c panel-1d.c panel-2d.c \
mapping.c dimension.c function.c objective.c undo.c gtksucks.c \
- example_fractal.c
+ example_fractal.c example_discrete.c
INC = sushivision.h
MAN =
-EXAMPLES = sushivision_fractal # sushivision_chirpfit
-EX_OBJ = example_fractal.o # example_chirpfit.o
+EXAMPLES = sushivision_fractal sushivision_discrete
+EX_OBJ = example_fractal.o example_discrete.o
OBJ = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o \
mapping.o dimension.o function.o objective.o undo.o gtksucks.o
LIBS = -lpthread -ldl
@@ -99,6 +99,7 @@
examples: $(OBJ) $(EX_OBJ)
$(LD) $(OBJ) example_fractal.o $(CFLAGS) -o sushivision_fractal $(LIBS) $(LDF)
+ $(LD) $(OBJ) example_discrete.o $(CFLAGS) -o sushivision_discrete $(LIBS) $(LDF)
# $(LD) $(OBJ) example_chirpfit.o $(CFLAGS) -o sushivision_chirpfit $(LIBS) $(LDF)
install: target
Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c 2007-01-30 03:13:48 UTC (rev 12395)
+++ trunk/sushivision/dimension.c 2007-01-30 04:49:12 UTC (rev 12396)
@@ -63,17 +63,17 @@
/* return a scale that when iterated will only hit values
quantized to the discrete base */
/* what is the absolute base? */
- /* the ceiling in a discrete dimension is an inclusive upper bound, not one-past */
int floor_i = rint(d->scale->val_list[0] * d->private->discrete_denominator /
d->private->discrete_numerator);
int ceil_i = rint(d->scale->val_list[d->scale->vals-1] * d->private->discrete_denominator /
- d->private->discrete_numerator) +1;
+ d->private->discrete_numerator);
int lo_i = floor(lo * d->private->discrete_denominator /
d->private->discrete_numerator);
int hi_i = floor(hi * d->private->discrete_denominator /
- d->private->discrete_numerator)+1;
-
+ d->private->discrete_numerator);
+ int extend = 0;
+
if(floor_i < ceil_i){
if(lo_i < floor_i)lo_i = floor_i;
if(hi_i > ceil_i)hi_i = ceil_i;
@@ -82,26 +82,39 @@
if(hi_i < ceil_i)hi_i = ceil_i;
}
- double lo = (double)lo_i * d->private->discrete_numerator /
- d->private->discrete_denominator;
- double hi = (double)hi_i * d->private->discrete_numerator /
- d->private->discrete_denominator;
+ // although the rest of the code assumes 'hi' is a one-past, the
+ // discrete dim code assumes hi is an inclusive bound, so we
+ // just extend.
+ if(lo_i<hi_i){
+ extend = 1;
+ }else{
+ extend = -1;
+ }
- data_w = hi_i-lo_i;
+ data_w = abs(hi_i-lo_i)+1;
if(!(d->flags & SUSHIV_DIM_ZEROINDEX))
floor_i = 0;
- *panel = scalespace_linear(lo, hi, panel_w, spacing, legend);
- *data = scalespace_linear(lo, hi, data_w, 1, legend);
+ *panel = scalespace_linear((double)lo_i * d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ (double)hi_i * d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ panel_w, spacing, legend);
+ *data = scalespace_linear((double)lo_i * d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ (double)(hi_i+extend) * d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ data_w, spacing, legend);
+
if(d->flags & SUSHIV_DIM_MONOTONIC)
- *iter = scalespace_linear(lo_i - floor_i, hi_i - floor_i,
+ *iter = scalespace_linear(lo_i - floor_i, hi_i - floor_i + extend,
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) *
+ (double)(hi_i - floor_i + extend) *
d->private->discrete_numerator /
d->private->discrete_denominator,
data_w, 1, legend);
Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c 2007-01-30 03:13:48 UTC (rev 12395)
+++ trunk/sushivision/main.c 2007-01-30 04:49:12 UTC (rev 12396)
@@ -200,8 +200,7 @@
int main (int argc, char *argv[]){
int ret;
- num_threads = 1;
- //num_threads = num_proccies();
+ num_threads = num_proccies();
gtk_init (&argc, &argv);
g_thread_init (NULL);
Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c 2007-01-30 03:13:48 UTC (rev 12395)
+++ trunk/sushivision/panel-1d.c 2007-01-30 04:49:12 UTC (rev 12396)
@@ -127,9 +127,9 @@
if(linetype>1 && linetype < 5){
double yA=-1;
if(linetype == 2) /* fill above */
- yA= r;
+ yA= (p1->flip?r:-1);
if(linetype == 3) /* fill below */
- yA = -1;
+ yA = (p1->flip?-1:r);
if(linetype == 4) /* fill to zero */
yA = scalespace_pixel(&p1->y,0.)+.5;
@@ -141,11 +141,11 @@
if(!isnan(yv[0])){
if(p1->flip){
- cairo_move_to(c,yA,h-xv[0]+.5);
- cairo_line_to(c,yv[0],h-xv[0]+.5);
+ cairo_move_to(c,yA,xv[0]+.5);
+ cairo_line_to(c,yv[0],xv[0]+.5);
}else{
- cairo_move_to(c,xv[0]-.5,h-yA);
- cairo_line_to(c,xv[0]-.5,h-yv[0]);
+ cairo_move_to(c,xv[0]-.5,yA);
+ cairo_line_to(c,xv[0]-.5,yv[0]);
}
}
@@ -155,28 +155,28 @@
if(!isnan(yv[i-1])){
/* close off the area */
if(p1->flip){
- cairo_line_to(c,yv[i-1],h-xv[i-1]-.5);
- cairo_line_to(c,yA,h-xv[i-1]-.5);
+ cairo_line_to(c,yv[i-1],xv[i-1]-.5);
+ cairo_line_to(c,yA,xv[i-1]-.5);
}else{
- cairo_line_to(c,xv[i-1]+.5,h-yv[i-1]);
- cairo_line_to(c,xv[i-1]+.5,h-yA);
+ cairo_line_to(c,xv[i-1]+.5,yv[i-1]);
+ cairo_line_to(c,xv[i-1]+.5,yA);
}
cairo_close_path(c);
}
}else{
if(isnan(yv[i-1])){
if(p1->flip){
- cairo_move_to(c,yA,h-xv[i]+.5);
- cairo_line_to(c,yv[i],h-xv[i]+.5);
+ cairo_move_to(c,yA,xv[i]+.5);
+ cairo_line_to(c,yv[i],xv[i]+.5);
}else{
- cairo_move_to(c,xv[i]-.5,h-yA);
- cairo_line_to(c,xv[i]-.5,h-yv[i]);
+ cairo_move_to(c,xv[i]-.5,yA);
+ cairo_line_to(c,xv[i]-.5,yv[i]);
}
}else{
if(p1->flip){
- cairo_line_to(c,yv[i],h-xv[i]);
+ cairo_line_to(c,yv[i],xv[i]);
}else{
- cairo_line_to(c,xv[i],h-yv[i]);
+ cairo_line_to(c,xv[i],yv[i]);
}
}
}
@@ -185,11 +185,11 @@
if(!isnan(yv[i-1])){
/* close off the area */
if(p1->flip){
- cairo_line_to(c,yv[i-1],h-xv[i-1]-.5);
- cairo_line_to(c,yA,h-xv[i-1]-.5);
+ cairo_line_to(c,yv[i-1],xv[i-1]-.5);
+ cairo_line_to(c,yA,xv[i-1]-.5);
}else{
- cairo_line_to(c,xv[i-1]+.5,h-yv[i-1]);
- cairo_line_to(c,xv[i-1]+.5,h-yA);
+ cairo_line_to(c,xv[i-1]+.5,yv[i-1]);
+ cairo_line_to(c,xv[i-1]+.5,yA);
}
cairo_close_path(c);
}
@@ -214,11 +214,11 @@
if(!isnan(yv[i-1]) && !isnan(yv[i])){
if(p1->flip){
- cairo_move_to(c,yv[i-1],h-xv[i-1]);
- cairo_line_to(c,yv[i],h-xv[i]);
+ cairo_move_to(c,yv[i-1],xv[i-1]);
+ cairo_line_to(c,yv[i],xv[i]);
}else{
- cairo_move_to(c,xv[i-1],h-yv[i-1]);
- cairo_line_to(c,xv[i],h-yv[i]);
+ cairo_move_to(c,xv[i-1],yv[i-1]);
+ cairo_line_to(c,xv[i],yv[i]);
}
cairo_stroke(c);
}
@@ -234,10 +234,10 @@
double xx,yy;
if(p1->flip){
xx = yv[i];
- yy = h - xv[i];
+ yy = xv[i];
}else{
xx = xv[i];
- yy = h- yv[i];
+ yy = yv[i];
}
cairo_set_source_rgba(c,
@@ -485,11 +485,20 @@
p1->range_bracket[0] = slider_get_value(p1->range_slider,0);
p1->range_bracket[1] = slider_get_value(p1->range_slider,1);
- p1->y = scalespace_linear(p1->range_bracket[0],
- p1->range_bracket[1],
- (p1->flip?w:h),
- PLOT(p->private->graph)->scalespacing,
- p1->range_scale->legend);
+ if(p1->flip)
+ p1->y = scalespace_linear(p1->range_bracket[0],
+ p1->range_bracket[1],
+ w,
+ plot->scalespacing,
+ p1->range_scale->legend);
+
+ else
+ p1->y = scalespace_linear(p1->range_bracket[1],
+ p1->range_bracket[0],
+ h,
+ plot->scalespacing,
+ p1->range_scale->legend);
+
}
//redraw the plot
@@ -610,21 +619,40 @@
}
if(plot && GTK_WIDGET_REALIZED(GTK_WIDGET(plot))){
- dw = _sushiv_dimension_scales(p1->x_d,
- p1->x_d->bracket[0],
- p1->x_d->bracket[1],
- (p1->flip?h:w),dw,
- plot->scalespacing,
- p1->x_d->name,
- &p1->x,
- &p1->x_v,
- &p1->x_i);
+ if(p1->flip){
+ dw = _sushiv_dimension_scales(p1->x_d,
+ p1->x_d->bracket[1],
+ p1->x_d->bracket[0],
+ h,dw,
+ plot->scalespacing,
+ p1->x_d->name,
+ &p1->x,
+ &p1->x_v,
+ &p1->x_i);
+
+ p1->y = scalespace_linear(p1->range_bracket[0],
+ p1->range_bracket[1],
+ w,
+ plot->scalespacing,
+ p1->range_scale->legend);
+
+ }else{
+ dw = _sushiv_dimension_scales(p1->x_d,
+ p1->x_d->bracket[0],
+ p1->x_d->bracket[1],
+ w,dw,
+ plot->scalespacing,
+ p1->x_d->name,
+ &p1->x,
+ &p1->x_v,
+ &p1->x_i);
- p1->y = scalespace_linear(p1->range_bracket[0],
- p1->range_bracket[1],
- (p1->flip?w:h),
- plot->scalespacing,
- p1->range_scale->legend);
+ p1->y = scalespace_linear(p1->range_bracket[1],
+ p1->range_bracket[0],
+ h,
+ plot->scalespacing,
+ p1->range_scale->legend);
+ }
if(p1->data_size != dw){
if(p1->data_vec){
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2007-01-30 03:13:48 UTC (rev 12395)
+++ trunk/sushivision/panel-2d.c 2007-01-30 04:49:12 UTC (rev 12396)
@@ -338,7 +338,7 @@
/* this is a resampling population */
float scaledel = scalespace_scaledel(&datay,&panely);
- float outdel = ph-scalespace_pixel(&panely,scalespace_value(&datay,dh-(y+.5)))+.5;
+ float outdel = scalespace_pixel(&panely,scalespace_value(&datay,y-.5))+.5;
int outbin = floor(outdel);
float outdel2 = (outdel-outbin) + scaledel;
outdel -= outbin;
@@ -873,10 +873,10 @@
double old_h = old.pixels;
double new_h = new.pixels;
- double old_lo = scalespace_value(&old,old_h);
- double old_hi = scalespace_value(&old,0);
- double new_lo = scalespace_value(&new,new_h);
- double new_hi = scalespace_value(&new,0);
+ double old_lo = scalespace_value(&old,0);
+ double old_hi = scalespace_value(&old,old_h);
+ double new_lo = scalespace_value(&new,0);
+ double new_hi = scalespace_value(&new,new_h);
double newscale = (new_hi-new_lo)/new_h;
double oldscale = old_h/(old_hi-old_lo);
@@ -1031,8 +1031,8 @@
&p2->x_v,
&p2->x_i);
_sushiv_dimension_scales(p2->y_d,
- p2->y_d->bracket[0],
p2->y_d->bracket[1],
+ p2->y_d->bracket[0],
h,h,// over/undersample will go here
plot->scalespacing,
p2->y_d->name,
@@ -1279,15 +1279,7 @@
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;
d = p->dimensions;
@@ -1299,31 +1291,38 @@
x_max = scalespace_value(&p2->x_i,dw);
x_d = p2->x_d->number;
- y_min = scalespace_value(&p2->y_i,dh);
- y_max = scalespace_value(&p2->y_i,0);
+ y_min = scalespace_value(&p2->y_i,0);
+ y_max = scalespace_value(&p2->y_i,dh);
y_d = p2->y_d->number;
- // if the scale bound has changed, fast scale our background data to fill
- // the pane while new, more precise data renders.
- if(memcmp(&sx,&plot->x,sizeof(sx))){
- for(i=0;i<p2->y_obj_num;i++){
- fast_scale_x(p2->y_num[i],pw,ph,
- sx,plot->x);
- fast_scale_x(p2->y_den[i],pw,ph,
- sx,plot->x);
+ // preparation and init before first line render attempt
+ _maintain_cache_2d(p,&c->p2,pw);
+ if(p2->last_line==0){
+ render_scale_flag = 1;
+ compute_prepare_render(p);
+
+ // if the scale bound has changed, fast scale our background data to fill
+ // the pane while new, more precise data renders.
+ if(memcmp(&sx,&plot->x,sizeof(sx))){
+ for(i=0;i<p2->y_obj_num;i++){
+ fast_scale_x(p2->y_num[i],pw,ph,
+ sx,plot->x);
+ fast_scale_x(p2->y_den[i],pw,ph,
+ sx,plot->x);
+ }
+ plot->x = sx;
+ _sushiv_panel2d_remap(p);
}
- plot->x = sx;
- _sushiv_panel2d_remap(p);
- }
- if(memcmp(&sy,&plot->y,sizeof(sy))){
- for(i=0;i<p2->y_obj_num;i++){
- fast_scale_y(p2->y_num[i],pw,ph,
- sy,plot->y);
- fast_scale_y(p2->y_den[i],pw,ph,
- sy,plot->y);
+ if(memcmp(&sy,&plot->y,sizeof(sy))){
+ for(i=0;i<p2->y_obj_num;i++){
+ fast_scale_y(p2->y_num[i],pw,ph,
+ sy,plot->y);
+ fast_scale_y(p2->y_den[i],pw,ph,
+ sy,plot->y);
+ }
+ plot->y = sy;
+ _sushiv_panel2d_remap(p);
}
- plot->y = sy;
- _sushiv_panel2d_remap(p);
}
// Initialize local dimension value array
@@ -1354,9 +1353,9 @@
compute_one_line_2d(p, serialno, sx, sx_v, sy, sy_v, y, x_d, x_min, x_max, dim_vals, &c->p2);
gdk_threads_enter ();
- p2->completed_lines++;
if(p2->serialno == serialno){
+ p2->completed_lines++;
if(p2->completed_lines==dh){
compute_complete_render(p, 1);
_sushiv_panel_dirty_map(p);
Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c 2007-01-30 03:13:48 UTC (rev 12395)
+++ trunk/sushivision/plot.c 2007-01-30 04:49:12 UTC (rev 12396)
@@ -67,8 +67,8 @@
i=0;
y=scalespace_mark(&ys,i++);
while(y < h){
- cairo_move_to(c,0,h-y+.5);
- cairo_line_to(c,w,h-y+.5);
+ cairo_move_to(c,0,y+.5);
+ cairo_line_to(c,w,y+.5);
y=scalespace_mark(&ys,i++);
}
cairo_stroke(c);
@@ -93,7 +93,7 @@
if(y - extents.height > 0){
- double yy = h-y+.5-(extents.height/2 + extents.y_bearing);
+ double yy = y+.5-(extents.height/2 + extents.y_bearing);
cairo_move_to(c,2, yy);
cairo_set_source_rgba(c,0,0,0,.5);
@@ -306,10 +306,8 @@
GtkWidget *widget = GTK_WIDGET(p);
double x1 = scalespace_pixel(&p->x,p->box_x1);
double x2 = scalespace_pixel(&p->x,p->box_x2);
- double y1 = widget->allocation.height-
- scalespace_pixel(&p->y,p->box_y1);
- double y2 = widget->allocation.height-
- scalespace_pixel(&p->y,p->box_y2);
+ double y1 = scalespace_pixel(&p->y,p->box_y1);
+ double y2 = scalespace_pixel(&p->y,p->box_y2);
vals[0] = (x1<x2 ? x1 : x2);
vals[1] = (y1<y2 ? y1 : y2);
@@ -548,7 +546,7 @@
int x = event->x;
int y = event->y;
int bx = scalespace_pixel(&p->x,p->box_x1);
- int by = widget->allocation.height-scalespace_pixel(&p->y,p->box_y1);
+ int by = scalespace_pixel(&p->y,p->box_y1);
if(p->button_down){
if(abs(bx - x)>5 ||
@@ -566,7 +564,7 @@
}
p->box_x2 = scalespace_value(&p->x,x);
- p->box_y2 = scalespace_value(&p->y,widget->allocation.height-y);
+ p->box_y2 = scalespace_value(&p->y,y);
}
box_check(p,x,y);
@@ -585,7 +583,7 @@
if(p->box_active && inside_box(p,event->x,event->y) && !p->button_down){
p->selx = scalespace_value(&p->x,event->x);
- p->sely = scalespace_value(&p->y,widget->allocation.height-event->y);
+ p->sely = scalespace_value(&p->y,event->y);
p->cross_active=1;
if(p->box_callback)
@@ -596,7 +594,7 @@
}else{
p->box_x2=p->box_x1 = scalespace_value(&p->x,event->x);
- p->box_y2=p->box_y1 = scalespace_value(&p->y,widget->allocation.height-event->y);
+ p->box_y2=p->box_y1 = scalespace_value(&p->y,event->y);
p->box_active = 0;
p->button_down=1;
}
@@ -614,7 +612,7 @@
if(!p->box_active && p->button_down){
p->selx = scalespace_value(&p->x,event->x);
- p->sely = scalespace_value(&p->y,widget->allocation.height-event->y);
+ p->sely = scalespace_value(&p->y,event->y);
p->cross_active=1;
if(p->crosshairs_callback)
@@ -648,8 +646,7 @@
if(p->button_down){
GdkEventButton event;
event.x = scalespace_pixel(&p->x,p->selx);
- event.y = GTK_WIDGET(p)->allocation.height-
- scalespace_pixel(&p->y,p->sely);
+ event.y = scalespace_pixel(&p->y,p->sely);
mouse_release(GTK_WIDGET(p),&event);
}else{
@@ -728,11 +725,11 @@
return TRUE;
case GDK_Up:
{
- double y = widget->allocation.height - scalespace_pixel(&p->y,p->sely)-1;
+ double y = scalespace_pixel(&p->y,p->sely)-1;
p->cross_active=1;
if(shift)
y-=9;
- p->sely = scalespace_value(&p->y,widget->allocation.height - y);
+ p->sely = scalespace_value(&p->y,y);
if(p->crosshairs_callback)
p->crosshairs_callback(p->cross_data);
@@ -747,11 +744,11 @@
return TRUE;
case GDK_Down:
{
- double y = widget->allocation.height - scalespace_pixel(&p->y,p->sely)+1;
+ double y = scalespace_pixel(&p->y,p->sely)+1;
p->cross_active=1;
if(shift)
y+=9;
- p->sely = scalespace_value(&p->y,widget->allocation.height - y);
+ p->sely = scalespace_value(&p->y,y);
if(p->crosshairs_callback)
p->crosshairs_callback(p->cross_data);
@@ -973,7 +970,7 @@
v = p->sely;
gdk_threads_leave();
- return (int)rint(widget->allocation.height-scalespace_pixel(&y,v));
+ return (int)rint(scalespace_pixel(&y,v));
}
void plot_unset_box(Plot *p){
@@ -990,8 +987,8 @@
ret[1] = (p->box_x1*n>p->box_x2*n?p->box_x1:p->box_x2);
n = p->y.neg;
- ret[2] = (p->box_y1*n<p->box_y2*n?p->box_y1:p->box_y2);
- ret[3] = (p->box_y1*n>p->box_y2*n?p->box_y1:p->box_y2);
+ ret[2] = (p->box_y1*n>p->box_y2*n?p->box_y1:p->box_y2);
+ ret[3] = (p->box_y1*n<p->box_y2*n?p->box_y1:p->box_y2);
gdk_threads_leave();
}
More information about the commits
mailing list