[xiph-commits] r12229 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Dec 19 21:22:00 PST 2006


Author: xiphmont
Date: 2006-12-19 21:21:57 -0800 (Tue, 19 Dec 2006)
New Revision: 12229

Modified:
   trunk/sushivision/Makefile
   trunk/sushivision/dimension.c
   trunk/sushivision/mapping.c
   trunk/sushivision/mapping.h
   trunk/sushivision/objective.c
   trunk/sushivision/panel-2d.c
   trunk/sushivision/panel.c
   trunk/sushivision/sushivision.h
Log:
API tweak to allow association of objectives/dimensions with multiple 
panels (needed by 1-d linking) but still have direct objective/dimension 
callbacks with panel association

Also extend 'mappings' for solid colors in line plots.



Modified: trunk/sushivision/Makefile
===================================================================
--- trunk/sushivision/Makefile	2006-12-20 04:59:58 UTC (rev 12228)
+++ trunk/sushivision/Makefile	2006-12-20 05:21:57 UTC (rev 12229)
@@ -40,7 +40,7 @@
 	$(MAKE) examples CFLAGS='-pg -g -O2 $(GCF) $(ADD_DEF)' LIBS='-lgprof-helper'
 
 clean:
-	rm -f $(OBJ) *.d *.d.* gmon.out $(TARGET)
+	rm -f *.o *.d *.d.* gmon.out $(TARGET)
 
 distclean: clean
 	rm -f *~

Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c	2006-12-20 04:59:58 UTC (rev 12228)
+++ trunk/sushivision/dimension.c	2006-12-20 05:21:57 UTC (rev 12229)
@@ -98,6 +98,5 @@
   d->flags = flags;
   d->sushi = s;
   d->callback = callback;
-  d->panel = NULL;
   return sushiv_dim_set_scale(d, scalevals, scaleval_list);
 }

Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c	2006-12-20 04:59:58 UTC (rev 12228)
+++ trunk/sushivision/mapping.c	2006-12-20 05:21:57 UTC (rev 12229)
@@ -299,6 +299,14 @@
   m->mapfunc = mapfunc[funcnum];
 }
 
+double mapping_val(mapping *m, double in){
+  if(m->i_range==0){
+    return NAN;
+  }else{
+    return (in - m->low) * m->i_range;
+  }
+}
+
 u_int32_t mapping_calc(mapping *m, double in, u_int32_t mix){
   if(m->i_range==0){
     if(in<=m->low)
@@ -315,3 +323,70 @@
   if(m->mapfunc == inactive)return 1;
   return 0;
 }
+
+static u_int32_t swhite(double val, u_int32_t mix){
+  return 0xffffffU;
+}
+static u_int32_t sred(double val, u_int32_t mix){
+  return 0xff0000U;
+}
+static u_int32_t sgreen(double val, u_int32_t mix){
+  return 0x00ff00U;
+}
+static u_int32_t sblue(double val, u_int32_t mix){
+  return 0x0000ffU;
+}
+static u_int32_t syellow(double val, u_int32_t mix){
+  return 0xffff00U;
+}
+static u_int32_t scyan(double val, u_int32_t mix){
+  return 0x00ffffU;
+}
+static u_int32_t spurple(double val, u_int32_t mix){
+  return 0xff00ffU;
+}
+static u_int32_t sgray(double val, u_int32_t mix){
+  return 0xa0a0a0aU;
+}
+
+static u_int32_t (*solidfunc[])(double,u_int32_t)={
+  swhite,
+  sred,
+  sgreen,
+  sblue,
+  syellow,
+  scyan,
+  spurple,
+  sgray,
+  inactive
+};
+
+static char *solidnames[]={
+  "white",
+  "red",
+  "green",
+  "blue",
+  "yellow",
+  "cyan",
+  "purple",
+  "gray",
+  "inactive",
+  0
+};
+
+int num_solids(){
+  int i=0;
+  while(solidnames[i])i++;
+  return i;
+}
+
+char *solid_name(int i){
+  return solidnames[i];
+}
+
+void solid_setup(mapping *m, double lo, double hi, int funcnum){
+  m->low = lo;
+  m->high = hi;
+  m->i_range = 1./(hi-lo);
+  m->mapfunc = solidfunc[funcnum];
+}

Modified: trunk/sushivision/mapping.h
===================================================================
--- trunk/sushivision/mapping.h	2006-12-20 04:59:58 UTC (rev 12228)
+++ trunk/sushivision/mapping.h	2006-12-20 05:21:57 UTC (rev 12229)
@@ -26,7 +26,6 @@
   double high;
   double i_range;
   u_int32_t (*mapfunc)(double val,u_int32_t mix);
-
 } mapping;
 
 extern int num_mappings();
@@ -35,5 +34,6 @@
 extern void mapping_set_lo(mapping *m, double lo);
 extern void mapping_set_hi(mapping *m, double hi);
 extern void mapping_set_func(mapping *m, int funcnum);
+extern double mapping_val(mapping *m, double in);
 extern u_int32_t mapping_calc(mapping *m, double in, u_int32_t mix);
 extern int mapping_inactive_p(mapping *m);

Modified: trunk/sushivision/objective.c
===================================================================
--- trunk/sushivision/objective.c	2006-12-20 04:59:58 UTC (rev 12228)
+++ trunk/sushivision/objective.c	2006-12-20 05:21:57 UTC (rev 12229)
@@ -100,7 +100,6 @@
   o->name = strdup(name);
   o->flags = flags;
   o->sushi = s;
-  o->panel = NULL;
   o->callback = callback;
 
   sushiv_objective_set_scale(o, scalevals, scaleval_list);

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-12-20 04:59:58 UTC (rev 12228)
+++ trunk/sushivision/panel-2d.c	2006-12-20 05:21:57 UTC (rev 12229)
@@ -148,12 +148,12 @@
     // 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;
+      int depth = del_depth(p->dimension_list[i].d->bracket[0],
+			    p->dimension_list[i].d->bracket[1]) + offset;
       snprintf(buffer,320,"%s = %.*f",
-	       p->dimension_list[i]->name,
+	       p->dimension_list[i].d->name,
 	       depth,
-	       p->dimension_list[i]->val);
+	       p->dimension_list[i].d->val);
       plot_legend_add(plot,buffer);
     }
 
@@ -176,7 +176,7 @@
 	
 	if(!isnan(val) && !mapping_inactive_p(p2->mappings+i)){
 	  snprintf(buffer,320,"%s = %f",
-		   p->objective_list[i]->name,
+		   p->objective_list[i].o->name,
 		   val);
 	  plot_legend_add(plot,buffer);
 	}
@@ -190,9 +190,9 @@
 }
 
 static void mapchange_callback_2d(GtkWidget *w,gpointer in){
-  sushiv_objective_t **optr = (sushiv_objective_t **)in;
-  sushiv_objective_t *o = *optr;
-  sushiv_panel_t *p = o->panel;
+  sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
+  //sushiv_objective_t *o = optr->o;
+  sushiv_panel_t *p = optr->p;
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
   int onum = optr - p->objective_list;
 
@@ -214,9 +214,9 @@
 }
 
 static void map_callback_2d(void *in,int buttonstate){
-  sushiv_objective_t **optr = (sushiv_objective_t **)in;
-  sushiv_objective_t *o = *optr;
-  sushiv_panel_t *p = o->panel;
+  sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
+  //sushiv_objective_t *o = optr->o;
+  sushiv_panel_t *p = optr->p;
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
   int onum = optr - p->objective_list;
 
@@ -250,7 +250,7 @@
 	gtk_widget_set_sensitive_fixup(p2->dim_yb[i],FALSE);
 
       // set the x dim flag
-      p2->x_d = p->dimension_list[i];
+      p2->x_d = p->dimension_list[i].d;
       p2->x_scale = p2->dim_scales[i];
       p2->x_dnum = i;
       // set panel x scale to this dim
@@ -271,7 +271,7 @@
 	gtk_widget_set_sensitive_fixup(p2->dim_xb[i],FALSE);
 
       // set the y dim
-      p2->y_d = p->dimension_list[i];
+      p2->y_d = p->dimension_list[i].d;
       p2->y_scale = p2->dim_scales[i];
       p2->y_dnum = i;
       // set panel y scale to this dim
@@ -319,7 +319,7 @@
   
   /* by objective */
   for(i=0;i<p->objectives;i++){
-    sushiv_objective_t *o = p->objective_list[i];
+    sushiv_objective_t *o = p->objective_list[i].o;
     double alpha = p2->alphadel[i];
     
     gdk_threads_leave (); // misuse me as a global mutex
@@ -599,7 +599,7 @@
 	  p2->data_rect[i][j]=NAN;
       _sushiv_panel2d_map_redraw(p);
     }
-    
+
     _sushiv_wake_workers();
   }
 }
@@ -616,7 +616,7 @@
   int i;
   
   for(i=0;i<p->dimensions;i++){
-    sushiv_dimension_t *d = p->dimension_list[i];
+    sushiv_dimension_t *d = p->dimension_list[i].d;
     sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
     if(d == p2->x_d)
       x = slider_get_value(p2->dim_scales[i],1);
@@ -630,7 +630,7 @@
   // 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_dimension_t *d = p->dimension_list[i].d;
     sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
     if(d == p2->x_d)
       d->val = scalespace_value(&plot->x,plot_get_crosshair_xpixel(plot));
@@ -641,9 +641,9 @@
 }
 
 static void dim_callback_2d(void *in, int buttonstate){
-  sushiv_dimension_t **dptr = (sushiv_dimension_t **)in;
-  sushiv_dimension_t *d = *dptr;
-  sushiv_panel_t *p = d->panel;
+  sushiv_dimension_list_t *dptr = (sushiv_dimension_list_t *)in;
+  sushiv_dimension_t *d = dptr->d;
+  sushiv_panel_t *p = dptr->p;
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
   //Plot *plot = PLOT(p2->graph);
   int dnum = dptr - p->dimension_list;
@@ -669,9 +669,9 @@
 }
 
 static void bracket_callback_2d(void *in, int buttonstate){
-  sushiv_dimension_t **dptr = (sushiv_dimension_t **)in;
-  sushiv_dimension_t *d = *dptr;
-  sushiv_panel_t *p = d->panel;
+  sushiv_dimension_list_t *dptr = (sushiv_dimension_list_t *)in;
+  sushiv_dimension_t *d = dptr->d;
+  sushiv_panel_t *p = dptr->p;
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
   int dnum = dptr - p->dimension_list;
   double lo = slider_get_value(p2->dim_scales[dnum],0);
@@ -737,7 +737,7 @@
   panel2d_undo_suspend(p);
 
   for(i=0;i<p->dimensions;i++){
-    sushiv_dimension_t *d = p->dimension_list[i];
+    sushiv_dimension_t *d = p->dimension_list[i].d;
     sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
     if(d == p2->x_d){
       slider_set_value(p2->dim_scales[i],1,x);
@@ -824,6 +824,7 @@
     gdk_threads_leave ();
     plot_expose_request(plot);
     update_legend(p); 
+    //_sushiv_panel1d_mark_recompute_linked(p);    
     return 0;
   }
   
@@ -843,7 +844,7 @@
 
   /* which dim is our x?  Our y? */
   for(i=0;i<d;i++){
-    sushiv_dimension_t *dim = p->dimension_list[i];
+    sushiv_dimension_t *dim = p->dimension_list[i].d;
     if(dim == p2->x_d){
       x_min = scalespace_value(&sx,0);
       x_max = scalespace_value(&sx,w);
@@ -853,7 +854,7 @@
   }
 
   for(i=0;i<d;i++){
-    sushiv_dimension_t *dim = p->dimension_list[i];
+    sushiv_dimension_t *dim = p->dimension_list[i].d;
     if(dim == p2->y_d){
       y_min = scalespace_value(&sy,h);
       y_max = scalespace_value(&sy,0);
@@ -1365,9 +1366,11 @@
   p2->mappings = calloc(p->objectives,sizeof(*p2->mappings));
   for(i=0;i<p->objectives;i++){
     GtkWidget **sl = calloc(3,sizeof(*sl));
-    sushiv_objective_t *o = p->objective_list[i];
+    sushiv_objective_t *o = p->objective_list[i].o;
     int lo = o->scale_val_list[0];
     int hi = o->scale_val_list[o->scale_vals-1];
+    int lo = o->scale_val_list[0];
+    int hi = o->scale_val_list[o->scale_vals-1];
 
     /* label */
     GtkWidget *label = gtk_label_new(o->name);
@@ -1418,7 +1421,7 @@
 
   for(i=0;i<p->dimensions;i++){
     GtkWidget **sl = calloc(3,sizeof(*sl));
-    sushiv_dimension_t *d = p->dimension_list[i];
+    sushiv_dimension_t *d = p->dimension_list[i].d;
 
     /* label */
     GtkWidget *label = gtk_label_new(d->name);

Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c	2006-12-20 04:59:58 UTC (rev 12228)
+++ trunk/sushivision/panel.c	2006-12-20 05:21:57 UTC (rev 12229)
@@ -164,13 +164,8 @@
   p->objective_list = malloc(i*sizeof(*p->objective_list));
   for(i=0;i<p->objectives;i++){
     sushiv_objective_t *o = s->objective_list[objectives[i]];
-    if(o->panel){
-      fprintf(stderr,"Objective %d already in use with another panel\n",o->number);
-      return -EINVAL;
-    }
-    o->panel = p;
-    p->objective_list[i] = o;
-    
+    p->objective_list[i].o = o;
+    p->objective_list[i].p = p;
   }
 
   i=0;
@@ -179,12 +174,8 @@
   p->dimension_list = malloc(i*sizeof(*p->dimension_list));
   for(i=0;i<p->dimensions;i++){
     sushiv_dimension_t *d = s->dimension_list[dimensions[i]];
-    if(d->panel){
-      fprintf(stderr,"Dimension %d already in use with another panel\n",d->number);
-      return -EINVAL;
-    }
-    d->panel = p;
-    p->dimension_list[i] = d;
+    p->dimension_list[i].d = d;
+    p->dimension_list[i].p = p;
   }
 
   return number;

Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h	2006-12-20 04:59:58 UTC (rev 12228)
+++ trunk/sushivision/sushivision.h	2006-12-20 05:21:57 UTC (rev 12229)
@@ -54,7 +54,6 @@
   unsigned flags;
   
   int (*callback)(sushiv_dimension_t *);
-  sushiv_panel_t *panel;
   sushiv_instance_t *sushi;
   void *internal;
 };
@@ -69,12 +68,21 @@
   unsigned flags;
 
   double (*callback)(double[]);
-  sushiv_panel_t *panel;
   sushiv_instance_t *sushi;
   void *internal;
 };
 
 enum sushiv_panel_type { SUSHIV_PANEL_1D, SUSHIV_PANEL_2D };
+
+typedef struct {
+  sushiv_dimension_t *d;
+  sushiv_panel_t *p;
+} sushiv_dimension_list_t;
+
+typedef struct {
+  sushiv_objective_t *o;
+  sushiv_panel_t *p;
+} sushiv_objective_list_t;
  
 struct sushiv_panel {
   int number;
@@ -85,9 +93,9 @@
   int legend_dirty;
 
   int dimensions;
-  sushiv_dimension_t **dimension_list;
+  sushiv_dimension_list_t *dimension_list;
   int objectives;
-  sushiv_objective_t **objective_list;
+  sushiv_objective_list_t *objective_list;
 
   sushiv_instance_t *sushi;
   void *internal;



More information about the commits mailing list