[xiph-commits] r12284 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Mon Jan 1 20:10:58 PST 2007


Author: xiphmont
Date: 2007-01-01 20:10:55 -0800 (Mon, 01 Jan 2007)
New Revision: 12284

Modified:
   trunk/sushivision/main.c
   trunk/sushivision/mapping.c
   trunk/sushivision/panel-1d.c
   trunk/sushivision/panel-1d.h
   trunk/sushivision/plot.c
   trunk/sushivision/scale.c
   trunk/sushivision/slider.c
   trunk/sushivision/slider.h
Log:
Numerous bug fixes

Flesh out 1d panel objective configuration a bit; still not entirely linked in.



Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c	2007-01-02 01:14:05 UTC (rev 12283)
+++ trunk/sushivision/main.c	2007-01-02 04:10:55 UTC (rev 12284)
@@ -38,8 +38,9 @@
 static pthread_cond_t mc = PTHREAD_COND_INITIALIZER;
 sig_atomic_t _sushiv_exiting=0;
 static int wake_pending = 0;
+static int num_threads;
 
-static int instances;
+static int instances=0;
 static sushiv_instance_t **instance_list;
 
 void _sushiv_clean_exit(int sig){
@@ -78,7 +79,7 @@
 void _sushiv_wake_workers(){
   if(instances){
     pthread_mutex_lock(&m);
-    wake_pending = instances;
+    wake_pending = num_threads;
     pthread_cond_broadcast(&mc);
     pthread_mutex_unlock(&m);
   }
@@ -169,6 +170,7 @@
 
 int main (int argc, char *argv[]){
   int ret;
+  num_threads = num_proccies();
 
   gtk_init (&argc, &argv);
   g_thread_init (NULL);
@@ -185,7 +187,7 @@
   
   {
     pthread_t dummy;
-    int threads = num_proccies();
+    int threads = num_threads;
     while(threads--)
       pthread_create(&dummy, NULL, &worker_thread,NULL);
   }

Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c	2007-01-02 01:14:05 UTC (rev 12283)
+++ trunk/sushivision/mapping.c	2007-01-02 04:10:55 UTC (rev 12284)
@@ -325,28 +325,84 @@
 }
 
 static u_int32_t swhite(double val, u_int32_t mix){
-  return 0xffffffU;
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int r = ((mix>>16) & 0xff) *(1.-val) + (val*0xff);
+    int g = ((mix>>8) & 0xff) *(1.-val) + (val*0xff);
+    int b = ((mix) & 0xff) *(1.-val) + (val*0xff);
+    return  (r<<16)+(g<<8)+b;
+  }
 }
 static u_int32_t sred(double val, u_int32_t mix){
-  return 0xff6060U;
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int r = ((mix>>16) & 0xff) *(1.-val) + (val*0xff);
+    int g = ((mix>>8) & 0xff) *(1.-val) + (val*0x60);
+    int b = ((mix) & 0xff) *(1.-val) + (val*0x60);
+    return  (r<<16)+(g<<8)+b;
+  }
 }
 static u_int32_t sgreen(double val, u_int32_t mix){
-  return 0x60ff60U;
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int r = ((mix>>16) & 0xff) *(1.-val) + (val*0x60);
+    int g = ((mix>>8) & 0xff) *(1.-val) + (val*0xff);
+    int b = ((mix) & 0xff) *(1.-val) + (val*0x60);
+    return  (r<<16)+(g<<8)+b;
+  }
 }
 static u_int32_t sblue(double val, u_int32_t mix){
-  return 0x8080ffU;
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int r = ((mix>>16) & 0xff) *(1.-val) + (val*0x80);
+    int g = ((mix>>8) & 0xff) *(1.-val) + (val*0x80);
+    int b = ((mix) & 0xff) *(1.-val) + (val*0xff);
+    return  (r<<16)+(g<<8)+b;
+  }
 }
 static u_int32_t syellow(double val, u_int32_t mix){
-  return 0xffff00U;
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int r = ((mix>>16) & 0xff) *(1.-val) + (val*0xff);
+    int g = ((mix>>8) & 0xff) *(1.-val) + (val*0xff);
+    int b = ((mix) & 0xff) *(1.-val);
+    return  (r<<16)+(g<<8)+b;
+  }
 }
 static u_int32_t scyan(double val, u_int32_t mix){
-  return 0x60ffffU;
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int r = ((mix>>16) & 0xff) *(1.-val) + (val*0x60);
+    int g = ((mix>>8) & 0xff) *(1.-val) + (val*0xff);
+    int b = ((mix) & 0xff) *(1.-val) + (val*0xff);
+    return  (r<<16)+(g<<8)+b;
+  }
 }
 static u_int32_t spurple(double val, u_int32_t mix){
-  return 0xff60ffU;
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int r = ((mix>>16) & 0xff) *(1.-val) + (val*0xff);
+    int g = ((mix>>8) & 0xff) *(1.-val) + (val*0x60);
+    int b = ((mix) & 0xff) *(1.-val) + (val*0xff);
+    return  (r<<16)+(g<<8)+b;
+  }
 }
 static u_int32_t sgray(double val, u_int32_t mix){
-  return 0xa0a0a0U;
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int r = ((mix>>16) & 0xff) *(1.-val) + (val*0xa0);
+    int g = ((mix>>8) & 0xff) *(1.-val) + (val*0xa0);
+    int b = ((mix) & 0xff) *(1.-val) + (val*0xa0);
+    return  (r<<16)+(g<<8)+b;
+  }
 }
 
 static u_int32_t (*solidfunc[])(double,u_int32_t)={

Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c	2007-01-02 01:14:05 UTC (rev 12283)
+++ trunk/sushivision/panel-1d.c	2007-01-02 04:10:55 UTC (rev 12284)
@@ -33,18 +33,26 @@
 #include <gdk/gdkkeysyms.h>
 #include "internal.h"
 
-#define LINETYPES 10
+#define LINETYPES 5
 static char *line_name[LINETYPES+1] = {
   "line",
+  "fill above",
+  "fill below",
+  "fill to zero",
+  "no line",
+  NULL
+};
+
+#define POINTTYPES 8
+static char *point_name[POINTTYPES+1] = {
   "dot",
-  "circle",
-  "square",
   "cross",
-  "triangle",
-  "line and circle",
-  "line and square",
-  "line and cross",
-  "line and triangle",
+  "open circle",
+  "open square",
+  "open triangle",
+  "solid circle",
+  "solid square",
+  "solid triangle",
   NULL
 };
 
@@ -88,15 +96,17 @@
       /* by objective */
       for(i=0;i<p->objectives;i++){
 	double *data_vec = p1->data_vec[i];
+	double alpha = slider_get_value(p1->alpha_scale[i],0);
 	if(data_vec){
 	  double yprev=NAN,xprev=NAN;
 	  
-	  u_int32_t color = mapping_calc(p1->mappings+i,0,0);
+	  u_int32_t color = mapping_calc(p1->mappings+i,1.,0);
 	  
-	  cairo_set_source_rgb(c,
-			       ((color>>16)&0xff)/255.,
-			       ((color>>8)&0xff)/255.,
-			       ((color)&0xff)/255.);
+	  cairo_set_source_rgba(c,
+				((color>>16)&0xff)/255.,
+				((color>>8)&0xff)/255.,
+				((color)&0xff)/255.,
+				alpha);
 	  
 	  /* by x */
 	  for(xi=0;xi<dw;xi++){
@@ -185,8 +195,9 @@
     {
       double val = (p1->flip?plot->sely:plot->selx);
       int bin = scalespace_pixel(&p1->vs, val);
-      u_int32_t color = mapping_calc(p1->mappings+i,0,0);
-	  
+      u_int32_t color = mapping_calc(p1->mappings+i,1.,0);
+      double alpha = slider_get_value(p1->alpha_scale[i],0);
+
       for(i=0;i<p->objectives;i++){
 
 	snprintf(buffer,320,"%s",
@@ -203,7 +214,7 @@
 	  }
 	}
 	
-	plot_legend_add_with_color(plot,buffer,color);
+	plot_legend_add_with_color(plot,buffer,color | ((unsigned)(alpha*255.)<<24));
 
       }
     }
@@ -246,12 +257,31 @@
   // oh, the wasteful
   solid_set_func(&p1->mappings[onum],
 		 gtk_combo_box_get_active(GTK_COMBO_BOX(w)));
-
+  slider_set_gradient(p1->alpha_scale[onum], &p1->mappings[onum]);
+  
   _sushiv_panel_dirty_map(p);
   _sushiv_panel_dirty_legend(p);
   _sushiv_panel_undo_resume(p);
 }
 
+static void alpha_callback_1d(void * in, int buttonstate){
+  sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
+  sushiv_panel_t *p = optr->p;
+  //  sushiv_panel1d_t *p1 = p->subtype->p1;
+  //  int onum = optr - p->objective_list;
+
+  if(buttonstate == 0){
+    _sushiv_panel_undo_push(p);
+    _sushiv_panel_undo_suspend(p);
+  }
+
+  _sushiv_panel_dirty_map(p);
+  _sushiv_panel_dirty_legend(p);
+
+  if(buttonstate == 2)
+    _sushiv_panel_undo_resume(p);
+}
+
 static void linetype_callback_1d(GtkWidget *w,gpointer in){
   sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
   sushiv_panel_t *p = optr->p;
@@ -268,6 +298,22 @@
   _sushiv_panel_undo_resume(p);
 }
 
+static void pointtype_callback_1d(GtkWidget *w,gpointer in){
+  sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
+  sushiv_panel_t *p = optr->p;
+  sushiv_panel1d_t *p1 = p->subtype->p1;
+  int onum = optr - p->objective_list;
+  
+  _sushiv_panel_undo_push(p);
+  _sushiv_panel_undo_suspend(p);
+
+  // update colormap
+  p1->pointtype[onum]=gtk_combo_box_get_active(GTK_COMBO_BOX(w));
+
+  _sushiv_panel_dirty_map(p);
+  _sushiv_panel_undo_resume(p);
+}
+
 static void map_callback_1d(void *in,int buttonstate){
   sushiv_panel_t *p = (sushiv_panel_t *)in;
   sushiv_panel1d_t *p1 = p->subtype->p1;
@@ -1070,7 +1116,7 @@
   gtk_container_add (GTK_CONTAINER (p->private->toplevel), p1->top_table);
   gtk_container_set_border_width (GTK_CONTAINER (p->private->toplevel), 5);
   
-  p1->obj_table = gtk_table_new(p->objectives,3,0);
+  p1->obj_table = gtk_table_new(p->objectives,5,0);
   gtk_table_attach(GTK_TABLE(p1->top_table),p1->obj_table,0,4,2,3,
 		   GTK_EXPAND|GTK_FILL,0,0,5);
 
@@ -1128,10 +1174,13 @@
   }
 
   /* objective pulldowns */
+  p1->pointtype = calloc(p->objectives,sizeof(*p1->pointtype));
   p1->linetype = calloc(p->objectives,sizeof(*p1->linetype));
   p1->mappings = calloc(p->objectives,sizeof(*p1->mappings));
   p1->map_pulldowns = calloc(p->objectives,sizeof(*p1->map_pulldowns));
   p1->line_pulldowns = calloc(p->objectives,sizeof(*p1->line_pulldowns));
+  p1->point_pulldowns = calloc(p->objectives,sizeof(*p1->point_pulldowns));
+  p1->alpha_scale = calloc(p->objectives,sizeof(*p1->alpha_scale));
 
   for(i=0;i<p->objectives;i++){
     sushiv_objective_t *o = p->objective_list[i].o;
@@ -1169,6 +1218,38 @@
 		       GTK_SHRINK,GTK_SHRINK,5,0);
       p1->line_pulldowns[i] = menu;
     }
+
+    /* point pulldown */
+    {
+      GtkWidget *menu=gtk_combo_box_new_text();
+      int j;
+      for(j=0;j<POINTTYPES;j++)
+	gtk_combo_box_append_text (GTK_COMBO_BOX (menu), point_name[j]);
+      gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
+      g_signal_connect (G_OBJECT (menu), "changed",
+			G_CALLBACK (pointtype_callback_1d), p->objective_list+i);
+      gtk_table_attach(GTK_TABLE(p1->obj_table),menu,3,4,i,i+1,
+		       GTK_SHRINK,GTK_SHRINK,5,0);
+      p1->point_pulldowns[i] = menu;
+    }
+
+    /* alpha slider */
+    {
+      GtkWidget **sl = calloc(1, sizeof(*sl));
+      sl[0] = slice_new(alpha_callback_1d,p->objective_list+i);
+      
+      gtk_table_attach(GTK_TABLE(p1->obj_table),sl[0],4,5,i,i+1,
+		       GTK_EXPAND|GTK_FILL,0,0,0);
+
+      p1->alpha_scale[i] = slider_new((Slice **)sl,1,
+				      (char *[]){"transparent","solid"},
+				      (double []){0.,1.},
+				      2,0);
+
+      slider_set_gradient(p1->alpha_scale[i], &p1->mappings[i]);
+      slice_thumb_set((Slice *)sl[0],1.);
+
+    }
   }
 
   if(p->dimensions){

Modified: trunk/sushivision/panel-1d.h
===================================================================
--- trunk/sushivision/panel-1d.h	2007-01-02 01:14:05 UTC (rev 12283)
+++ trunk/sushivision/panel-1d.h	2007-01-02 04:10:55 UTC (rev 12284)
@@ -51,8 +51,11 @@
   
   mapping *mappings;
   int *linetype;
+  int *pointtype;
   GtkWidget **map_pulldowns;
   GtkWidget **line_pulldowns;
+  GtkWidget **point_pulldowns;
+  Slider **alpha_scale;
 
   GtkWidget **dim_xb;
 

Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c	2007-01-02 01:14:05 UTC (rev 12283)
+++ trunk/sushivision/plot.c	2007-01-02 04:10:55 UTC (rev 12284)
@@ -233,7 +233,7 @@
 			    ((colors[i]>>16)&0xff)/255.,
 			    ((colors[i]>>8)&0xff)/255.,
 			    ((colors[i])&0xff)/255.,
-			    1.);
+			    ((colors[i]>>24)&0xff)/255.);
       cairo_move_to(c,x, y);
       cairo_show_text (c, buffer[i]);
 
@@ -1057,7 +1057,7 @@
 }
 
 void plot_legend_add(Plot *p, char *entry){
-  plot_legend_add_with_color(p,entry,0xffffffUL);
+  plot_legend_add_with_color(p,entry,0xffffffffUL);
 }
 
 void plot_legend_add_with_color(Plot *p, char *entry, u_int32_t color){

Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c	2007-01-02 01:14:05 UTC (rev 12283)
+++ trunk/sushivision/scale.c	2007-01-02 04:10:55 UTC (rev 12284)
@@ -248,10 +248,10 @@
   ret.pixels=pixels;
   ret.legend=name;
 
-  if(orange < DBL_MIN*pixels){
+  if(orange < 1e-30*pixels){
     // insufficient to safeguard the int64 first var below all by
     // itself, but it will keep things on track until later checks
-    orange = DBL_MIN * pixels;
+    orange = 1e-30 * pixels;
     highpoint = lowpoint + orange;
   }
 

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2007-01-02 01:14:05 UTC (rev 12283)
+++ trunk/sushivision/slider.c	2007-01-02 04:10:55 UTC (rev 12284)
@@ -125,7 +125,7 @@
   cairo_surface_flush(s->background);
 
   // Create trough innards
- if(s->gradient){
+  if(s->gradient){
     // background map gradient 
     u_int32_t *pixel=s->backdata+ty*s->w;
     
@@ -238,6 +238,7 @@
     slider_draw(s);
 
   }
+  s->realized = 1;
 }
 
 static double val_to_pixel(Slider *s,double v){
@@ -504,14 +505,15 @@
 }
 
 static double quant(Slider *s, double val){
-  val *= s->quant_denom;
-  val /= s->quant_num;
-  
-  val = rint(val);
+  if(s->quant_denom!=0.){
+    val *= s->quant_denom;
+    val /= s->quant_num;
     
-  val *= s->quant_num;
-  val /= s->quant_denom;
- 
+    val = rint(val);
+    
+    val *= s->quant_num;
+    val /= s->quant_denom;
+  }
   return val;
 }
 
@@ -676,7 +678,7 @@
 }
 
 static void update_gradient(Slider *s){
-  if(s->gradient){
+  if(s->gradient && s->num_slices>1){
     Slice *sl = SLICE(s->slices[0]);
     Slice *sh = SLICE(s->slices[s->num_slices-1]);
     double ldel = slider_val_to_del(s,sl->thumb_val);
@@ -798,8 +800,8 @@
 
   ret->slices = (GtkWidget **)slices;
   ret->num_slices = num_slices;
-  ret->quant_num=1.;
-  ret->quant_denom=1.;
+  ret->quant_num=0.;
+  ret->quant_denom=0.;
 
   ret->label = calloc(num_labels,sizeof(*ret->label));
   for(i=0;i<num_labels;i++)
@@ -828,6 +830,11 @@
 
 void slider_set_gradient(Slider *s, mapping *m){
   s->gradient = m;
+  if(s->realized){
+    slider_draw_background(s);
+    slider_draw(s);
+    slider_expose(s);
+  }
 }
 
 void slider_set_thumb_active(Slider *s, int thumbnum, int activep){

Modified: trunk/sushivision/slider.h
===================================================================
--- trunk/sushivision/slider.h	2007-01-02 01:14:05 UTC (rev 12283)
+++ trunk/sushivision/slider.h	2007-01-02 04:10:55 UTC (rev 12284)
@@ -24,7 +24,8 @@
 struct _Slider {
   GtkWidget **slices;
   int num_slices;
-  
+  int realized;
+
   u_int32_t *backdata;
   cairo_surface_t *background;
   cairo_surface_t *foreground;



More information about the commits mailing list