[xiph-commits] r12233 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Sat Dec 23 08:26:17 PST 2006
Author: xiphmont
Date: 2006-12-23 08:26:15 -0800 (Sat, 23 Dec 2006)
New Revision: 12233
Modified:
trunk/sushivision/dimension.c
trunk/sushivision/mapping.c
trunk/sushivision/mapping.h
trunk/sushivision/objective.c
trunk/sushivision/panel-2d.c
trunk/sushivision/scale.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
Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c 2006-12-21 17:18:26 UTC (rev 12232)
+++ trunk/sushivision/dimension.c 2006-12-23 16:26:15 UTC (rev 12233)
@@ -27,47 +27,11 @@
#include "internal.h"
#include "scale.h"
-int sushiv_dim_set_scale(sushiv_dimension_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_dim_set_scalelabels(sushiv_dimension_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_dimension(sushiv_instance_t *s,
int number,
const char *name,
- unsigned scalevals, double *scaleval_list,
+ unsigned scalevals,
+ double *scaleval_list,
int (*callback)(sushiv_dimension_t *),
unsigned flags){
sushiv_dimension_t *d;
@@ -98,5 +62,6 @@
d->flags = flags;
d->sushi = s;
d->callback = callback;
- return sushiv_dim_set_scale(d, scalevals, scaleval_list);
+ d->scale = scale_new(scalevals, scaleval_list);
+ return 0;
}
Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c 2006-12-21 17:18:26 UTC (rev 12232)
+++ trunk/sushivision/mapping.c 2006-12-23 16:26:15 UTC (rev 12233)
@@ -390,3 +390,8 @@
m->i_range = 1./(hi-lo);
m->mapfunc = solidfunc[funcnum];
}
+
+void solid_set_func(mapping *m, int funcnum){
+ m->mapnum = funcnum;
+ m->mapfunc = solidfunc[funcnum];
+}
Modified: trunk/sushivision/mapping.h
===================================================================
--- trunk/sushivision/mapping.h 2006-12-21 17:18:26 UTC (rev 12232)
+++ trunk/sushivision/mapping.h 2006-12-23 16:26:15 UTC (rev 12233)
@@ -37,3 +37,8 @@
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);
+
+extern int num_solids();
+extern char *solid_name(int i);
+extern void solid_setup(mapping *m, double lo, double hi, int funcnum);
+extern void solid_set_func(mapping *m, int funcnum);
Modified: trunk/sushivision/objective.c
===================================================================
--- trunk/sushivision/objective.c 2006-12-21 17:18:26 UTC (rev 12232)
+++ trunk/sushivision/objective.c 2006-12-23 16:26:15 UTC (rev 12233)
@@ -27,45 +27,6 @@
#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,
@@ -102,7 +63,8 @@
o->sushi = s;
o->callback = callback;
- sushiv_objective_set_scale(o, scalevals, scaleval_list);
+ if(scalevals>0 && scaleval_list)
+ o->scale=scale_new(scalevals, scaleval_list);
return 0;
}
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2006-12-21 17:18:26 UTC (rev 12232)
+++ trunk/sushivision/panel-2d.c 2006-12-23 16:26:15 UTC (rev 12233)
@@ -548,6 +548,8 @@
int w = plot->w.allocation.width;
int h = plot->w.allocation.height;
+ //_sushiv_panel1d_mark_recompute_linked(p); XXXX
+
if(plot && GTK_WIDGET_REALIZED(GTK_WIDGET(plot))){
if(p2->data_w != plot->w.allocation.width ||
p2->data_h != plot->w.allocation.height){
@@ -637,6 +639,9 @@
if(d == p2->y_d)
d->val = scalespace_value(&plot->y,p2->data_h - plot_get_crosshair_ypixel(plot));
}
+
+ // _sushiv_panel1d_update_linked_crosshairs(p); XXXX
+
update_legend(p);
}
@@ -726,7 +731,7 @@
}
}
-static void crosshairs_callback(void *in){
+void _sushiv_panel2d_crosshairs_callback(void *in){
sushiv_panel_t *p = (sushiv_panel_t *)in;
sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
double x=PLOT(p2->graph)->selx;
@@ -775,7 +780,7 @@
panel2d_undo_push(p);
panel2d_undo_suspend(p);
- crosshairs_callback(p);
+ _sushiv_panel2d_crosshairs_callback(p);
slider_set_value(p2->x_scale,0,p2->oldbox[0]);
slider_set_value(p2->x_scale,2,p2->oldbox[1]);
@@ -1171,7 +1176,7 @@
double yv = scalespace_value(&p2->y,h-y);
plot_set_crosshairs(plot,xv,yv);
- crosshairs_callback(p);
+ _sushiv_panel2d_crosshairs_callback(p);
p2->peak_count++;
@@ -1354,7 +1359,7 @@
/* graph */
p2->graph = GTK_WIDGET(plot_new(recompute_callback_2d,p,
- crosshairs_callback,p,
+ _sushiv_panel2d_crosshairs_callback,p,
box_callback,p));
gtk_table_attach(GTK_TABLE(p2->top_table),p2->graph,0,5,0,1,
GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,0,5);
@@ -1367,8 +1372,8 @@
for(i=0;i<p->objectives;i++){
GtkWidget **sl = calloc(3,sizeof(*sl));
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);
@@ -1400,8 +1405,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,o->scale_label_list,o->scale_val_list,
- o->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);
@@ -1463,12 +1468,12 @@
gtk_table_attach(GTK_TABLE(p2->dim_table),sl[2],5,6,i,i+1,
GTK_EXPAND|GTK_FILL,0,0,0);
- p2->dim_scales[i] = slider_new((Slice **)sl,3,d->scale_label_list,d->scale_val_list,
- d->scale_vals,0);
+ p2->dim_scales[i] = slider_new((Slice **)sl,3,d->scale->label_list,d->scale->val_list,
+ d->scale->vals,0);
- slice_thumb_set((Slice *)sl[0],d->scale_val_list[0]);
+ slice_thumb_set((Slice *)sl[0],d->scale->val_list[0]);
slice_thumb_set((Slice *)sl[1],0);
- slice_thumb_set((Slice *)sl[2],d->scale_val_list[d->scale_vals-1]);
+ slice_thumb_set((Slice *)sl[2],d->scale->val_list[d->scale->vals-1]);
}
for(i=0;i<p->dimensions;i++){
@@ -1516,6 +1521,7 @@
int *dimensions,
unsigned flags){
+ int i;
int ret = _sushiv_new_panel(s,number,name,objectives,dimensions,flags);
sushiv_panel_t *p;
sushiv_panel2d_t *p2;
@@ -1526,6 +1532,14 @@
p->internal = p2;
p->type = SUSHIV_PANEL_2D;
+ // verify all the objectives have scales
+ for(i=0;i<p->objectives;i++){
+ if(!p->objective_list[i].o->scale){
+ fprintf(stderr,"All objectives in a 2d panel must have a scale\n");
+ return -EINVAL;
+ }
+ }
+
return 0;
}
Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c 2006-12-21 17:18:26 UTC (rev 12232)
+++ trunk/sushivision/scale.c 2006-12-23 16:26:15 UTC (rev 12233)
@@ -26,6 +26,7 @@
#include <fontconfig/fontconfig.h>
#include <stdio.h>
#include <limits.h>
+#include "sushivision.h"
#include "scale.h"
/* slider scales */
@@ -144,7 +145,54 @@
return ret;
}
+void scale_free(sushiv_scale_t *s){
+ int i;
+
+ if(s){
+ if(s->val_list)free(s->val_list);
+ if(s->label_list){
+ for(i=0;i<s->vals;i++)
+ free(s->label_list[i]);
+ free(s->label_list);
+ }
+ free(s);
+ }
+}
+sushiv_scale_t *scale_new(unsigned scalevals, double *scaleval_list){
+ int i;
+
+ sushiv_scale_t *s = NULL;
+
+ if(scalevals<2){
+ fprintf(stderr,"Scale requires at least two scale values.");
+ return NULL;
+ }
+
+ s = calloc(1, sizeof(*s));
+
+ // copy values
+ s->vals = scalevals;
+ s->val_list = calloc(scalevals,sizeof(*s->val_list));
+ for(i=0;i<(int)scalevals;i++)
+ s->val_list[i] = scaleval_list[i];
+
+ // generate labels
+ s->label_list = scale_generate_labels(scalevals,scaleval_list);
+
+ return s;
+}
+
+int scale_set_scalelabels(sushiv_scale_t *s, char **scalelabel_list){
+ int i;
+ for(i=0;i<s->vals;i++){
+ if(s->label_list[i])
+ free(s->label_list[i]);
+ s->label_list[i] = strdup(scalelabel_list[i]);
+ }
+ return 0;
+}
+
/* plot and graph scales */
double scalespace_value(scalespace *s, double pixel){
Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h 2006-12-21 17:18:26 UTC (rev 12232)
+++ trunk/sushivision/sushivision.h 2006-12-23 16:26:15 UTC (rev 12233)
@@ -22,6 +22,7 @@
#ifndef _SUSHIVISION_
#define _SUSHIVISION_
+typedef struct sushiv_scale sushiv_scale_t;
typedef struct sushiv_panel sushiv_panel_t;
typedef struct sushiv_dimension sushiv_dimension_t;
typedef struct sushiv_objective sushiv_objective_t;
@@ -42,15 +43,19 @@
#define SUSHIV_NO_X 0x100
#define SUSHIV_NO_Y 0x200
+struct sushiv_scale{
+ int vals;
+ double *val_list;
+ char **label_list;
+};
+
struct sushiv_dimension{
int number;
char *name;
double bracket[2];
double val;
- int scale_vals;
- double *scale_val_list;
- char **scale_label_list;
+ sushiv_scale_t *scale;
unsigned flags;
int (*callback)(sushiv_dimension_t *);
@@ -62,9 +67,7 @@
int number;
char *name;
- int scale_vals;
- double *scale_val_list;
- char **scale_label_list;
+ sushiv_scale_t *scale;
unsigned flags;
double (*callback)(double[]);
@@ -104,6 +107,10 @@
extern sushiv_instance_t *sushiv_new_instance(void);
+extern void scale_free(sushiv_scale_t *s);
+extern sushiv_scale_t *scale_new(unsigned scalevals, double *scaleval_list);
+extern int scale_set_scalelabels(sushiv_scale_t *s, char **scalelabel_list);
+
extern int sushiv_new_dimension(sushiv_instance_t *s,
int number,
const char *name,
@@ -111,24 +118,14 @@
double *scaleval_list,
int (*callback)(sushiv_dimension_t *),
unsigned flags);
-extern int sushiv_dim_set_scale(sushiv_dimension_t *d,
- unsigned scalevals,
- double *scaleval_list);
-extern int sushiv_dim_set_scalelabels(sushiv_dimension_t *d,
- char **scalelabel_list);
extern int sushiv_new_objective(sushiv_instance_t *s,
int number,
const char *name,
- unsigned scalevals,
+ 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,
@@ -140,10 +137,29 @@
extern int sushiv_new_panel_1d(sushiv_instance_t *s,
int number,
const char *name,
+ sushiv_scale_t *scale,
int *objectives,
- int *dimensions,
+ int *dimensions,
unsigned flags);
+extern int sushiv_new_panel_1d_linked(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ sushiv_scale_t *scale,
+ int *objectives,
+ sushiv_panel_t *s2d,
+ unsigned flags);
+
+extern int sushiv_new_panel_xy(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ sushiv_scale_t *xscale,
+ sushiv_scale_t *yscale,
+ int *objectives,
+ int *dimensions,
+ unsigned flags);
+
+
extern int sushiv_submain(int argc, char *argv[]);
#endif
More information about the commits
mailing list