[xiph-commits] r12076 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Nov 10 15:07:58 PST 2006


Author: xiphmont
Date: 2006-11-10 15:07:53 -0800 (Fri, 10 Nov 2006)
New Revision: 12076

Modified:
   trunk/sushivision/Makefile
   trunk/sushivision/internal.h
   trunk/sushivision/mapping.c
   trunk/sushivision/mapping.h
   trunk/sushivision/panel-2d.c
   trunk/sushivision/panel-2d.h
   trunk/sushivision/panel.c
   trunk/sushivision/plot.c
   trunk/sushivision/plot.h
   trunk/sushivision/scale.c
   trunk/sushivision/scale.h
   trunk/sushivision/slider.c
   trunk/sushivision/slider.h
   trunk/sushivision/sushivision.h
Log:
Correct some minor slider bugs
Add a legend to graph panel



Modified: trunk/sushivision/Makefile
===================================================================
--- trunk/sushivision/Makefile	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/Makefile	2006-11-10 23:07:53 UTC (rev 12076)
@@ -22,7 +22,7 @@
 LIBS = -lpthread -ldl
 CAIROVER =  >= 1.0.0
 GTKVER   =  >= 2.8.0
-GCF  = -std=c99 `pkg-config --static --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) freetype2 gthread-2.0"`
+GCF  = `pkg-config --static --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) freetype2 gthread-2.0"`
 LDF  = -pthread -L/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lm -lfontconfig -lpng12 -lXrender -lX11 -lpthread -lfreetype -lz -lgthread-2.0 -lglib-2.0 -lcairo
 
 all:    

Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/internal.h	2006-11-10 23:07:53 UTC (rev 12076)
@@ -32,6 +32,7 @@
 			     unsigned flags);
 
 extern void _sushiv_panel_dirty_map(sushiv_panel_t *p);
+extern void _sushiv_panel_dirty_legend(sushiv_panel_t *p);
 extern void _sushiv_wake_workers(void);
 
 extern int _sushiv_panel_cooperative_compute(sushiv_panel_t *p);

Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/mapping.c	2006-11-10 23:07:53 UTC (rev 12076)
@@ -310,3 +310,8 @@
     return m->mapfunc(val,mix);
   }
 }
+
+int mapping_inactive_p(mapping *m){
+  if(m->mapfunc == inactive)return 1;
+  return 0;
+}

Modified: trunk/sushivision/mapping.h
===================================================================
--- trunk/sushivision/mapping.h	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/mapping.h	2006-11-10 23:07:53 UTC (rev 12076)
@@ -36,3 +36,4 @@
 extern void mapping_set_hi(mapping *m, double hi);
 extern void mapping_set_func(mapping *m, int funcnum);
 extern u_int32_t mapping_calc(mapping *m, double in, u_int32_t mix);
+extern int mapping_inactive_p(mapping *m);

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/panel-2d.c	2006-11-10 23:07:53 UTC (rev 12076)
@@ -109,6 +109,82 @@
   gdk_threads_leave (); // misuse me as a global mutex
 }
 
+void _sushiv_panel2d_legend_redraw(sushiv_panel_t *p){
+  sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
+  Plot *plot = PLOT(p2->graph);
+
+  if(plot)
+    plot_draw_scales(plot);
+}
+
+static int ilog10(int x){
+  int count=0;
+  if(x<0)x=-x;
+  while(x){
+    count++;
+    x/=10;
+  }
+  return count;
+}
+
+static void update_legend(sushiv_panel_t *p){  
+  sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;  
+  Plot *plot = PLOT(p2->graph);
+
+  gdk_threads_enter ();
+  int w = p2->data_w;
+  int h = p2->data_h;
+  int x = plot_get_crosshair_xpixel(plot);
+  int y = plot_get_crosshair_ypixel(plot);
+  int offset = ilog10(w>h?w:h);
+
+  if(plot){
+    int i;
+    char buffer[320];
+    plot_legend_clear(plot);
+
+    // add each dimension to the legend
+    for(i=0;i<p->dimensions;i++){
+      // display decimal precision relative to bracket
+      int depth = del_depth(p->dimension_list[i]->bracket[0],
+			    p->dimension_list[i]->bracket[1]) + offset;
+      snprintf(buffer,320,"%s = %.*f",
+	       p->dimension_list[i]->name,
+	       depth,
+	       p->dimension_list[i]->val);
+      plot_legend_add(plot,buffer);
+    }
+
+    // one space 
+    plot_legend_add(plot,NULL);
+
+    // add each active objective to the legend
+    // choose the value under the crosshairs 
+    for(i=0;i<p->objectives;i++){
+      float val=NAN;
+
+      if(p2->data_rect && p2->data_rect[i])
+	val = p2->data_rect[i][y*w+x];
+
+      if(!isnan(val) && val >= p2->alphadel[i]){
+	
+	val = slider_del_to_val(p2->range_scales[i],val);
+	
+	if(!isnan(val) && !mapping_inactive_p(p2->mappings+i)){
+	  snprintf(buffer,320,"%s = %f",
+		   p->objective_list[i]->name,
+		   val);
+	  plot_legend_add(plot,buffer);
+	}
+      }
+    }
+    gdk_threads_leave ();
+
+    _sushiv_panel_dirty_legend(p);
+
+  }
+}
+
 static void mapchange_callback_2d(GtkWidget *w,gpointer in){
   sushiv_objective_t **optr = (sushiv_objective_t **)in;
   sushiv_objective_t *o = *optr;
@@ -126,6 +202,8 @@
   slider_draw(p2->range_scales[onum]);
   slider_expose(p2->range_scales[onum]);
     
+  update_legend(p);
+
   //redraw the plot
   _sushiv_panel_dirty_map(p);
   panel2d_undo_resume(p);
@@ -522,6 +600,7 @@
 
 static void update_crosshairs(sushiv_panel_t *p){
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
+  Plot *plot = PLOT(p2->graph);
   double x=0,y=0;
   int i;
   
@@ -536,6 +615,18 @@
   }
   
   plot_set_crosshairs(PLOT(p2->graph),x,y);
+
+  // crosshairs snap to a pixel position; the cached dimension value
+  // should be accurate with respect to the crosshairs
+  for(i=0;i<p->dimensions;i++){
+    sushiv_dimension_t *d = p->dimension_list[i];
+    sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
+    if(d == p2->x_d)
+      d->val = scalespace_value(&p2->x,plot_get_crosshair_xpixel(plot));
+    if(d == p2->y_d)
+      d->val = scalespace_value(&p2->y,plot_get_crosshair_ypixel(plot));
+  }
+  update_legend(p);
 }
 
 static void dim_callback_2d(void *in, int buttonstate){
@@ -543,6 +634,7 @@
   sushiv_dimension_t *d = *dptr;
   sushiv_panel_t *p = d->panel;
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
+  Plot *plot = PLOT(p2->graph);
   int dnum = dptr - p->dimension_list;
   int axisp = (d == p2->x_d || d == p2->y_d);
 
@@ -574,27 +666,30 @@
   double lo = slider_get_value(p2->dim_scales[dnum],0);
   double hi = slider_get_value(p2->dim_scales[dnum],2);
   
-
-  double xy_p = d == p2->x_d;
-  scalespace s = scalespace_linear(lo,hi,(xy_p?p2->data_w:p2->data_h),
-				   PLOT(p2->graph)->scalespacing);
   if(buttonstate == 0){
     panel2d_undo_push(p);
     panel2d_undo_suspend(p);
   }
 
-  if(s.m == 0){
-    if(xy_p)
-      fprintf(stderr,"X scale underflow; cannot zoom further.\n");
-    else
-      fprintf(stderr,"Y scale underflow; cannot zoom further.\n");
-  }else{
-    xy_p?(p2->x=s):(p2->y=s);
+  if(d->bracket[0] != lo || d->bracket[1] != hi){
+    double xy_p = d == p2->x_d;
+    scalespace s = scalespace_linear(lo,hi,(xy_p?p2->data_w:p2->data_h),
+				     PLOT(p2->graph)->scalespacing);
+    
+    if(s.m == 0){
+      if(xy_p)
+	fprintf(stderr,"X scale underflow; cannot zoom further.\n");
+      else
+	fprintf(stderr,"Y scale underflow; cannot zoom further.\n");
+    }else{
+      xy_p?(p2->x=s):(p2->y=s);
+      
+      d->bracket[0] = lo;
+      d->bracket[1] = hi;
+      update_crosshairs(p);
 
-    d->bracket[0] = lo;
-    d->bracket[1] = hi;
-    
-    _mark_recompute_2d(p);
+      _mark_recompute_2d(p);
+    }
   }
  
   if(buttonstate == 2)
@@ -632,10 +727,22 @@
   for(i=0;i<p->dimensions;i++){
     sushiv_dimension_t *d = p->dimension_list[i];
     sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
-    if(d == p2->x_d)
+    if(d == p2->x_d){
       slider_set_value(p2->dim_scales[i],1,x);
-    if(d == p2->y_d)
+
+      // key bindings could move crosshairs out of the window; we
+      // stretch in that case, which requires a recompute.
+      bracket_callback_2d(p->dimension_list+i,1);
+    }
+
+    if(d == p2->y_d){
       slider_set_value(p2->dim_scales[i],1,y);
+
+      // key bindings could move crosshairs out of the window; we
+      // stretch in that case, which requires a recompute.
+      bracket_callback_2d(p->dimension_list+i,1);
+    }
+
     p2->oldbox_active = 0;
   }
   panel2d_undo_resume(p);
@@ -646,7 +753,6 @@
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
   Plot *plot = PLOT(p2->graph);
   
-
   switch(state){
   case 0: // box set
     panel2d_undo_push(p);
@@ -656,6 +762,7 @@
   case 1: // box activate
     panel2d_undo_push(p);
     panel2d_undo_suspend(p);
+
     slider_set_value(p2->x_scale,0,p2->oldbox[0]);
     slider_set_value(p2->x_scale,2,p2->oldbox[1]);
     slider_set_value(p2->y_scale,0,p2->oldbox[2]);
@@ -690,11 +797,13 @@
   sx = p2->x;
   sy = p2->y;
 
-  if(p2->last_line>=h){
-      gdk_threads_leave ();
-      return 0;
+  if(p2->last_line==h){
+    p2->last_line++;
+    gdk_threads_leave ();
+    update_legend(p);
+    return 0;
   }
-
+  
   plot = PLOT(p2->graph);
   serialno = p2->serialno;
   invh = 1./h;
@@ -1201,4 +1310,3 @@
   return 0;
 }
 
-

Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/panel-2d.h	2006-11-10 23:07:53 UTC (rev 12076)
@@ -78,3 +78,4 @@
 extern void _sushiv_realize_panel2d(sushiv_panel_t *p);
 extern int _sushiv_panel_cooperative_compute_2d(sushiv_panel_t *p);
 extern void _sushiv_panel2d_map_redraw(sushiv_panel_t *p);
+extern void _sushiv_panel2d_legend_redraw(sushiv_panel_t *p);

Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/panel.c	2006-11-10 23:07:53 UTC (rev 12076)
@@ -104,6 +104,20 @@
   }
 }
 
+static void _sushiv_panel_legend_redraw(sushiv_panel_t *p){
+  if(p->legend_dirty){
+    p->legend_dirty = 0;
+    switch(p->type){
+    case SUSHIV_PANEL_1D:
+      //_sushiv_panel1d_legend_redraw(p);
+      break;
+    case SUSHIV_PANEL_2D:
+      _sushiv_panel2d_legend_redraw(p);
+      break;
+    }
+  }
+}
+
 int _sushiv_panel_cooperative_compute(sushiv_panel_t *p){
   if(p->realized){
     if(p->type == SUSHIV_PANEL_2D)
@@ -124,12 +138,27 @@
   return FALSE;
 }
 
+static gboolean _legend_idle_work(gpointer ptr){
+  sushiv_instance_t *s = (sushiv_instance_t *)ptr;
+  int i;
+  
+  for(i=0;i<s->panels;i++)
+    _sushiv_panel_legend_redraw(s->panel_list[i]);
+  
+  return FALSE;
+}
 
+
 void _sushiv_panel_dirty_map(sushiv_panel_t *p){
   p->maps_dirty = 1;
   g_idle_add(_map_idle_work,p->sushi);
 }
 
+void _sushiv_panel_dirty_legend(sushiv_panel_t *p){
+  p->legend_dirty = 1;
+  g_idle_add(_legend_idle_work,p->sushi);
+}
+
 int _sushiv_new_panel(sushiv_instance_t *s,
 		      int number,
 		      const char *name, 

Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/plot.c	2006-11-10 23:07:53 UTC (rev 12076)
@@ -140,6 +140,61 @@
   cairo_destroy(c);
 }
 
+static void draw_legend_work(Plot *p, cairo_surface_t *s){
+  if(p->legend_entries && p->legend_list){
+    int w = cairo_image_surface_get_width(s);
+    //int h = cairo_image_surface_get_height(s);
+    cairo_t *c = cairo_create(s);
+    int i;
+    int textw=0, texth=0;
+    int totalh=0;
+    int x,y;
+    cairo_text_extents_t extents;
+    
+    cairo_select_font_face (c, "Sans",
+			    CAIRO_FONT_SLANT_NORMAL,
+			    CAIRO_FONT_WEIGHT_NORMAL);
+    cairo_set_font_size (c, 10);
+    cairo_set_line_width(c,1);
+    
+    /* determine complete x/y extents of text */
+    
+    for(i=0;i<p->legend_entries;i++){
+      cairo_text_extents (c, p->legend_list[i], &extents);
+      if(texth < extents.height)
+	texth = extents.height;
+      if(textw < extents.width)
+	textw = extents.width;
+    }
+    
+    y = 10+texth;
+    texth = ceil(texth * 1.2+3);
+    totalh = texth*p->legend_entries;
+    
+    x = w - textw - 10;
+    
+    for(i=0;i<p->legend_entries;i++){
+      cairo_text_extents (c, p->legend_list[i], &extents);
+      x = w - extents.width - 10;
+      
+      cairo_move_to(c,x, y);
+      cairo_text_path (c, p->legend_list[i]); 
+
+      cairo_set_source_rgba(c,0,0,0,.5);
+      cairo_set_line_width(c,3);
+      cairo_stroke(c);
+
+      cairo_set_source_rgba(c,1.,1.,1.,1.);
+      cairo_move_to(c,x, y);
+      cairo_show_text (c, p->legend_list[i]);
+
+      y+=texth;
+    }
+    
+    cairo_destroy(c);
+  }
+}
+
 void plot_draw_scales(Plot *p){
   // render into a temporary surface; do it [potentially] outside the global Gtk lock.
   gdk_threads_enter();
@@ -151,6 +206,7 @@
   gdk_threads_leave();
   
   draw_scales_work(s,x,y);
+  draw_legend_work(p,s);
   
   gdk_threads_enter();
   // swap fore/temp
@@ -237,8 +293,8 @@
     
     // transient foreground
     {
-      double sx = scalespace_pixel(&p->x,p->selx);
-      double sy = widget->allocation.height-scalespace_pixel(&p->y,p->sely);
+      double sx = plot_get_crosshair_xpixel(p);
+      double sy = plot_get_crosshair_ypixel(p);
       cairo_set_source_rgba(c,1.,1.,1.,.8);
       cairo_set_line_width(c,1.);
       cairo_move_to(c,0,sy+.5);
@@ -455,6 +511,11 @@
  
   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);
+
+    if(p->crosshairs_callback)
+      p->crosshairs_callback(p->cross_data);
     if(p->box_callback)
       p->box_callback(p->cross_data,1);
 
@@ -710,12 +771,14 @@
   GtkWidget *widget = GTK_WIDGET(p);
   GdkRectangle r;
   
-  r.x=0;
-  r.y=0;
-  r.width=widget->allocation.width;
-  r.height=widget->allocation.height;
-  
-  gdk_window_invalidate_rect (widget->window, &r, FALSE);
+  if (GTK_WIDGET_REALIZED (widget)){
+    r.x=0;
+    r.y=0;
+    r.width=widget->allocation.width;
+    r.height=widget->allocation.height;
+    
+    gdk_window_invalidate_rect (widget->window, &r, FALSE);
+  }
   gdk_threads_leave();
 }
 
@@ -756,7 +819,7 @@
 }
 
 void plot_set_y_scale(Plot *p, scalespace y){
-  GtkWidget *widget = GTK_WIDGET(p);
+  //GtkWidget *widget = GTK_WIDGET(p);
   scalespace temp = p->y;
   p->y = y;
   if(memcmp(&temp,&p->y,sizeof(temp)))
@@ -794,6 +857,31 @@
   gdk_threads_leave();
 }
 
+int plot_get_crosshair_xpixel(Plot *p){
+  scalespace x;
+  double v;
+
+  gdk_threads_enter();
+  x = p->x;
+  v = p->selx;
+  gdk_threads_leave();
+
+  return (int)rint(scalespace_pixel(&x,v));
+}
+
+int plot_get_crosshair_ypixel(Plot *p){
+  GtkWidget *widget = GTK_WIDGET(p);
+  scalespace y;
+  double v;
+
+  gdk_threads_enter();
+  y = p->y;
+  v = p->sely;
+  gdk_threads_leave();
+
+  return (int)rint(widget->allocation.height-scalespace_pixel(&y,v));
+}
+
 void plot_unset_box(Plot *p){
   gdk_threads_enter();
   p->box_active = 0;
@@ -822,3 +910,30 @@
   plot_expose_request(p);
   gdk_threads_leave();
 }
+
+void plot_legend_clear(Plot *p){
+  int i;
+  if(p->legend_list){
+    for(i=0;i<p->legend_entries;i++)
+      if(p->legend_list[i])
+	free(p->legend_list[i]);
+    free(p->legend_list);
+    p->legend_list=NULL;
+  }
+  p->legend_entries=0;
+}
+
+void plot_legend_add(Plot *p, char *entry){
+  if(!p->legend_list){
+    p->legend_list = calloc(1, sizeof(*p->legend_list));
+    p->legend_entries=1;
+  }else{
+    p->legend_entries++;
+    p->legend_list = realloc(p->legend_list, p->legend_entries*sizeof(*p->legend_list));
+  }
+
+  if(entry)
+    p->legend_list[p->legend_entries-1] = strdup(entry);
+  else
+    p->legend_list[p->legend_entries-1] = strdup("");
+}

Modified: trunk/sushivision/plot.h
===================================================================
--- trunk/sushivision/plot.h	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/plot.h	2006-11-10 23:07:53 UTC (rev 12076)
@@ -69,7 +69,9 @@
   void (*recompute_callback)(void *);
   void *cross_data;
   void (*crosshairs_callback)(void *);
-  
+
+  int legend_entries;
+  char **legend_list;
 };
 
 struct _PlotClass{
@@ -99,3 +101,7 @@
 void plot_unset_box(Plot *p);
 void plot_box_vals(Plot *p, double ret[4]);
 void plot_box_set(Plot *p, double vals[4]);
+void plot_legend_add(Plot *p, char *entry);
+void plot_legend_clear(Plot *p);
+int plot_get_crosshair_xpixel(Plot *p);
+int plot_get_crosshair_ypixel(Plot *p);

Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/scale.c	2006-11-10 23:07:53 UTC (rev 12076)
@@ -40,8 +40,8 @@
   return count;
 }
 
-/* depth, at a minimum, must capture the difference between consective scale values */
-static int del_depth(double A, double B){
+/* depth, at a minimum, must capture the difference between consecutive scale values */
+int del_depth(double A, double B){
   int depth = 0;
 
   double del = B-A;

Modified: trunk/sushivision/scale.h
===================================================================
--- trunk/sushivision/scale.h	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/scale.h	2006-11-10 23:07:53 UTC (rev 12076)
@@ -36,6 +36,7 @@
   int pixels;
 } scalespace;
 
+int del_depth(double A, double B);
 extern char **scale_generate_labels(unsigned scalevals, double *scaleval_list);
 
 extern double scalespace_value(scalespace *s, double pixel);

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/slider.c	2006-11-10 23:07:53 UTC (rev 12076)
@@ -130,7 +130,7 @@
     u_int32_t *pixel=s->backdata+ty*s->w;
     
     for(i=tx;i<tx+tw;i++)
-      pixel[i]=mapping_calc(s->gradient,slider_pixel_to_del(s,0,i), pixel[i]);
+      pixel[i]=mapping_calc(s->gradient,slider_pixel_to_del(s,i), pixel[i]);
     
     for(i=ty+1;i<ty+th;i++){
       memcpy(pixel+w,pixel,w*4);
@@ -503,35 +503,22 @@
   return x+width;
 }
 
-double slider_pixel_to_val(Slider *s,int slicenum,double x){
-  int j;
+double slider_pixel_to_val(Slider *s,double x){
   int tx=s->xpad;
   int tw=s->w - tx*2;
-  double pixlo;
-  x=slice_adjust_pixel(s,slicenum,x);
-
-  pixlo = tx;
-  for(j=0;j<s->labels-1;j++){
-    double pixhi=rint((double)(j+1)/(s->labels-1)*tw)+tx;
-
-    if(x>=pixlo && x<=pixhi){
-      double del=(double)(x-pixlo)/(pixhi-pixlo);
-      return ( (1.-del)*s->label_vals[j] + del*s->label_vals[j+1] );
-    }
-    pixlo=pixhi;
-  }
-  if(x<tx)
+  double del = (double)(x-tx)/tw;
+  if(del<0)
     return s->label_vals[0];
-  else
+  if(del>=1.)
     return (s->label_vals[s->labels-1]);
+  return slider_del_to_val(s,del);
 }
 
-double slider_pixel_to_del(Slider *s,int slicenum,double x){
+double slider_pixel_to_del(Slider *s,double x){
   int tx=s->xpad;
   int tw=s->w - tx*2;
+  x-=tx;
 
-  x=slice_adjust_pixel(s,slicenum,x-tx);
-
   if(x<=0){
     return 0.;
   }else if (x>tw){
@@ -540,6 +527,17 @@
     return x/tw;
 }
 
+double slider_del_to_val(Slider *s, double del){
+  int base;
+  if(isnan(del))return del;
+
+  del *= (s->labels-1);
+  base = floor(del);
+  del -= base;
+  
+  return ( (1.-del)*s->label_vals[base] + del*s->label_vals[base+1] );
+}
+
 void slider_vals_bound(Slider *s,int slicenum){
   int i,flag=0;
   Slice *center = SLICE(s->slices[slicenum]);
@@ -687,7 +685,8 @@
   for(i=0;i<s->num_slices;i++){
     Slice *sl = SLICE(s->slices[i]);
     if(sl->thumb_grab){      
-      sl->thumb_val=slider_pixel_to_val(s,slicenum,x);
+      sl->thumb_val=
+	slider_pixel_to_val(s,slice_adjust_pixel(s,slicenum,x));
       slider_vals_bound(s,i);
       altered=i+1;
     }
@@ -724,7 +723,7 @@
       double x = val_to_pixel(s,sl->thumb_val)-1;
       if(shift)
 	x-=9;
-      sl->thumb_val=slider_pixel_to_val(s,0,x);
+      sl->thumb_val=slider_pixel_to_val(s,x);
       slider_vals_bound(s,slicenum);
       // did a gradient get altered?
       update_gradient(s);
@@ -744,7 +743,7 @@
       double x = val_to_pixel(s,sl->thumb_val)+1;
       if(shift)
 	x+=9;
-      sl->thumb_val=slider_pixel_to_val(s,0,x);
+      sl->thumb_val=slider_pixel_to_val(s,x);
       slider_vals_bound(s,slicenum);
       // did a gradient get altered?
       update_gradient(s);

Modified: trunk/sushivision/slider.h
===================================================================
--- trunk/sushivision/slider.h	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/slider.h	2006-11-10 23:07:53 UTC (rev 12076)
@@ -51,8 +51,8 @@
 extern void slider_expose_slice(Slider *s, int slicenum);
 extern void slider_expose(Slider *s);
 extern void slider_size_request_slice(Slider *s,GtkRequisition *requisition);
-extern double slider_pixel_to_val(Slider *slider,int slicenum,double x);
-extern double slider_pixel_to_del(Slider *slider,int slicenum,double x);
+extern double slider_pixel_to_val(Slider *slider,double x);
+extern double slider_pixel_to_del(Slider *slider,double x);
 extern double slider_val_to_del(Slider *slider,double v);
 extern void slider_vals_bound(Slider *slider,int slicenum);
 extern int slider_lightme(Slider *slider,int slicenum,int x,int y);
@@ -68,3 +68,4 @@
 extern void slider_set_gradient(Slider *s, mapping *m);
 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);

Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h	2006-11-10 13:11:08 UTC (rev 12075)
+++ trunk/sushivision/sushivision.h	2006-11-10 23:07:53 UTC (rev 12076)
@@ -78,6 +78,7 @@
   enum sushiv_panel_type type;
   int realized;
   int maps_dirty;
+  int legend_dirty;
 
   int dimensions;
   sushiv_dimension_t **dimension_list;



More information about the commits mailing list