[xiph-commits] r12209 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Dec 14 23:10:05 PST 2006


Author: xiphmont
Date: 2006-12-14 23:10:00 -0800 (Thu, 14 Dec 2006)
New Revision: 12209

Modified:
   trunk/sushivision/example_fractal.c
   trunk/sushivision/example_submain.c
   trunk/sushivision/internal.h
   trunk/sushivision/objective.c
   trunk/sushivision/panel-2d.c
   trunk/sushivision/panel.c
   trunk/sushivision/sushivision.h
Log:
Move objective scale settings to the actual objectives; the original
idea had been all objectives would share one scale, but the lack of
flexibility that imposes doesn't really make sense.  In 1-d (line)
graphs, we'll simply need to display multiple Y scales when multiple
different Y scales are in use.



Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c	2006-12-13 12:53:44 UTC (rev 12208)
+++ trunk/sushivision/example_fractal.c	2006-12-15 07:10:00 UTC (rev 12209)
@@ -65,10 +65,11 @@
 		       NULL,
 		       SUSHIV_X_RANGE|SUSHIV_Y_RANGE);
   
-  sushiv_new_objective(s,0,"fractal",fractal_objective,0);
+  sushiv_new_objective(s,0,"fractal",
+		       4,(double []){0, .01, .1, 1.0},
+		       fractal_objective,0);
 
-  sushiv_new_panel_2d(s,0,"Mandel/Julia Fractal",4,
-		      (double []){0, .01, .1, 1.0},
+  sushiv_new_panel_2d(s,0,"Mandel/Julia Fractal",
 		      (int []){0,-1},
 		      (int []){0,1,2,3,-1},
 		      0);

Modified: trunk/sushivision/example_submain.c
===================================================================
--- trunk/sushivision/example_submain.c	2006-12-13 12:53:44 UTC (rev 12208)
+++ trunk/sushivision/example_submain.c	2006-12-15 07:10:00 UTC (rev 12209)
@@ -115,12 +115,13 @@
 		       NULL,
 		       SUSHIV_X_RANGE|SUSHIV_Y_RANGE);
   
-  sushiv_new_objective(s,0,"fourier",fourier_objective,0);
+  sushiv_new_objective(s,0,"fourier",
+		       8,(double []){-96,-48,-36,-24,-12,-6,0,6},
+		       fourier_objective,0);
   //sushiv_new_objective(s,1,"fit",fit_objective,0);
   //sushiv_new_objective(s,2,"waveform",fourier_objective,0);
 
-  sushiv_new_panel_2d(s,0,"fourier objective",8,
-		      (double []){-96,-48,-36,-24,-12,-6,0,6},
+  sushiv_new_panel_2d(s,0,"fourier objective",
 		      (int []){0,-1},
 		      (int []){2,3,4,5,6,-1},
 		      0);

Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h	2006-12-13 12:53:44 UTC (rev 12208)
+++ trunk/sushivision/internal.h	2006-12-15 07:10:00 UTC (rev 12209)
@@ -25,8 +25,6 @@
 extern int _sushiv_new_panel(sushiv_instance_t *s,
 			     int number,
 			     const char *name, 
-			     unsigned scalevals,
-			     double *scaleval_list,
 			     int *objectives,
 			     int *dimensions,
 			     unsigned flags);

Modified: trunk/sushivision/objective.c
===================================================================
--- trunk/sushivision/objective.c	2006-12-13 12:53:44 UTC (rev 12208)
+++ trunk/sushivision/objective.c	2006-12-15 07:10:00 UTC (rev 12209)
@@ -25,10 +25,52 @@
 #include <errno.h>
 #include "sushivision.h"
 #include "internal.h"
+#include "scale.h"
 
+int sushiv_objective_set_scale(sushiv_objective_t *d, unsigned scalevals, 
+			       double *scaleval_list){
+  int i;
+  
+  if(scalevals<2){
+    fprintf(stderr,"Scale requires at least two scale values.");
+    return -EINVAL;
+  }
+  
+  if(d->scale_val_list)free(d->scale_val_list);
+  if(d->scale_label_list){
+    for(i=0;i<d->scale_vals;i++)
+      free(d->scale_label_list[i]);
+    free(d->scale_label_list);
+  }
+
+  // copy values
+  d->scale_vals = scalevals;
+  d->scale_val_list = calloc(scalevals,sizeof(*d->scale_val_list));
+  for(i=0;i<(int)scalevals;i++)
+    d->scale_val_list[i] = scaleval_list[i];
+  
+  // generate labels
+  d->scale_label_list = scale_generate_labels(scalevals,scaleval_list);
+  
+  return 0;
+}
+
+int sushiv_objective_set_scalelabels(sushiv_objective_t *d, 
+				     char **scalelabel_list){
+  int i;
+  for(i=0;i<d->scale_vals;i++){
+    if(d->scale_label_list[i])
+      free(d->scale_label_list[i]);
+    d->scale_label_list[i] = strdup(scalelabel_list[i]);
+  }
+  return 0;
+}
+
 int sushiv_new_objective(sushiv_instance_t *s,
 			 int number,
 			 const char *name,
+			 unsigned scalevals,
+			 double *scaleval_list,
 			 double(*callback)(double *),
 			 unsigned flags){
   sushiv_objective_t *o;
@@ -60,5 +102,8 @@
   o->sushi = s;
   o->panel = NULL;
   o->callback = callback;
+
+  sushiv_objective_set_scale(o, scalevals, scaleval_list);
+
   return 0;
 }

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-12-13 12:53:44 UTC (rev 12208)
+++ trunk/sushivision/panel-2d.c	2006-12-15 07:10:00 UTC (rev 12209)
@@ -1134,7 +1134,6 @@
   int h = p2->data_h;
   int n = w*h;
   int count = 0;
-  int best_j = 0;
   
   // finds in order each peak (in the event there's more than one) of
   // each active objective
@@ -1337,8 +1336,6 @@
 void _sushiv_realize_panel2d(sushiv_panel_t *p){
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
   int i;
-  int lo = p->scale_val_list[0];
-  int hi = p->scale_val_list[p->scale_vals-1];
 
   panel2d_undo_suspend(p);
 
@@ -1369,6 +1366,8 @@
   for(i=0;i<p->objectives;i++){
     GtkWidget **sl = calloc(3,sizeof(*sl));
     sushiv_objective_t *o = p->objective_list[i];
+    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);
@@ -1400,8 +1399,8 @@
 		     GTK_EXPAND|GTK_FILL,0,0,0);
     gtk_table_attach(GTK_TABLE(p2->top_table),sl[2],3,4,i+1,i+2,
 		     GTK_EXPAND|GTK_FILL,0,0,0);
-    p2->range_scales[i] = slider_new((Slice **)sl,3,p->scale_label_list,p->scale_val_list,
-				    p->scale_vals,SLIDER_FLAG_INDEPENDENT_MIDDLE);
+    p2->range_scales[i] = slider_new((Slice **)sl,3,o->scale_label_list,o->scale_val_list,
+				    o->scale_vals,SLIDER_FLAG_INDEPENDENT_MIDDLE);
 
     slice_thumb_set((Slice *)sl[0],lo);
     slice_thumb_set((Slice *)sl[1],lo);
@@ -1512,14 +1511,11 @@
 int sushiv_new_panel_2d(sushiv_instance_t *s,
 			int number,
 			const char *name, 
-			unsigned scalevals,
-			double *scaleval_list,
-			       int *objectives,
+			int *objectives,
 			int *dimensions,
 			unsigned flags){
   
-  int ret = _sushiv_new_panel(s,number,name,scalevals,scaleval_list,
-			      objectives,dimensions,flags);
+  int ret = _sushiv_new_panel(s,number,name,objectives,dimensions,flags);
   sushiv_panel_t *p;
   sushiv_panel2d_t *p2;
 

Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c	2006-12-13 12:53:44 UTC (rev 12208)
+++ trunk/sushivision/panel.c	2006-12-15 07:10:00 UTC (rev 12209)
@@ -52,44 +52,6 @@
   }
 }
 
-int sushiv_panel_set_scale(sushiv_panel_t *d, unsigned scalevals, 
-			   double *scaleval_list){
-  int i;
-
-  if(scalevals<2){
-    fprintf(stderr,"Scale requires at least two scale values.");
-    return -EINVAL;
-  }
-
-  if(d->scale_val_list)free(d->scale_val_list);
-  if(d->scale_label_list){
-    for(i=0;i<d->scale_vals;i++)
-      free(d->scale_label_list[i]);
-    free(d->scale_label_list);
-  }
-
-  // copy values
-  d->scale_vals = scalevals;
-  d->scale_val_list = calloc(scalevals,sizeof(*d->scale_val_list));
-  for(i=0;i<(int)scalevals;i++)
-    d->scale_val_list[i] = scaleval_list[i];
-
-  // generate labels
-  d->scale_label_list = scale_generate_labels(scalevals,scaleval_list);
-
-  return 0;
-}
-
-int sushiv_panel_set_scalelabels(sushiv_panel_t *d, char **scalelabel_list){
-  int i;
-  for(i=0;i<d->scale_vals;i++){
-    if(d->scale_label_list[i])
-      free(d->scale_label_list[i]);
-    d->scale_label_list[i] = strdup(scalelabel_list[i]);
-  }
-  return 0;
-}
-
 static void _sushiv_panel_map_redraw(sushiv_panel_t *p){
   if(p->maps_dirty){
     p->maps_dirty = 0;
@@ -162,8 +124,6 @@
 int _sushiv_new_panel(sushiv_instance_t *s,
 		      int number,
 		      const char *name, 
-		      unsigned scalevals,
-		      double *scaleval_list,
 		      int *objectives,
 		      int *dimensions,
 		      unsigned flags){
@@ -227,8 +187,6 @@
     p->dimension_list[i] = d;
   }
 
-  sushiv_panel_set_scale(p, scalevals, scaleval_list);
-
   return number;
 }
 

Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h	2006-12-13 12:53:44 UTC (rev 12208)
+++ trunk/sushivision/sushivision.h	2006-12-15 07:10:00 UTC (rev 12209)
@@ -63,11 +63,15 @@
   int number;
   char *name;
 
+  int scale_vals;
+  double *scale_val_list;
+  char **scale_label_list; 
+  unsigned flags;
+
   double (*callback)(double[]);
   sushiv_panel_t *panel;
   sushiv_instance_t *sushi;
   void *internal;
-  unsigned flags;
 };
 
 enum sushiv_panel_type { SUSHIV_PANEL_1D, SUSHIV_PANEL_2D };
@@ -85,10 +89,6 @@
   int objectives;
   sushiv_objective_t **objective_list;
 
-  int scale_vals;
-  double *scale_val_list;
-  char **scale_label_list; 
-
   sushiv_instance_t *sushi;
   void *internal;
   unsigned flags;
@@ -112,14 +112,19 @@
 extern int sushiv_new_objective(sushiv_instance_t *s,
 				int number,
 				const char *name,
+				unsigned scalevals,
+				double *scaleval_list,
 				double (*callback)(double *),
 				unsigned flags);
+extern int sushiv_objective_set_scale(sushiv_objective_t *o, 
+				      unsigned scalevals, 
+				      double *scaleval_list);
+extern int sushiv_objective_set_scalelabels(sushiv_objective_t *o, 
+					    char **scalelabel_list);
 
 extern int sushiv_new_panel_2d(sushiv_instance_t *s,
 			       int number,
 			       const char *name, 
-			       unsigned scalevals,
-			       double *scaleval_list,
 			       int *objectives,
 			       int *dimensions,
 			       unsigned flags);
@@ -127,8 +132,6 @@
 extern int sushiv_new_panel_1d(sushiv_instance_t *s,
 			       int number,
 			       const char *name,
-			       unsigned scalevals,
-			       double *scaleval_list,
 			       int *objectives,
 			       int *dimensions,
 			       unsigned flags);



More information about the commits mailing list