[xiph-commits] r12786 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Wed Mar 21 10:33:46 PDT 2007
Author: xiphmont
Date: 2007-03-21 10:33:32 -0700 (Wed, 21 Mar 2007)
New Revision: 12786
Modified:
trunk/sushivision/Makefile
trunk/sushivision/dimension.c
trunk/sushivision/dimension.h
trunk/sushivision/example_chirp.c
trunk/sushivision/example_discrete.c
trunk/sushivision/example_fractal.c
trunk/sushivision/example_spirograph.c
trunk/sushivision/function.c
trunk/sushivision/gtksucks.c
trunk/sushivision/gtksucks.h
trunk/sushivision/internal.h
trunk/sushivision/main.c
trunk/sushivision/mapping.c
trunk/sushivision/mapping.h
trunk/sushivision/objective.c
trunk/sushivision/objective.h
trunk/sushivision/panel-1d.c
trunk/sushivision/panel-1d.h
trunk/sushivision/panel-2d.c
trunk/sushivision/panel-2d.h
trunk/sushivision/panel-xy.c
trunk/sushivision/panel-xy.h
trunk/sushivision/panel.c
trunk/sushivision/plot.c
trunk/sushivision/plot.h
trunk/sushivision/scale.c
trunk/sushivision/scale.h
trunk/sushivision/slice.c
trunk/sushivision/slice.h
trunk/sushivision/slider.c
trunk/sushivision/slider.h
trunk/sushivision/spinner.c
trunk/sushivision/spinner.h
trunk/sushivision/sushivision.h
trunk/sushivision/undo.c
trunk/sushivision/xml.c
trunk/sushivision/xml.h
Log:
The beginning of a moderate retooling of the library namespace as well
as the programmatic API toward something alittle closer to common
convention.
Modified: trunk/sushivision/Makefile
===================================================================
--- trunk/sushivision/Makefile 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/Makefile 2007-03-21 17:33:32 UTC (rev 12786)
@@ -58,7 +58,7 @@
rm -f *.o *.d *.d.* *.pc gmon.out $(TARGET) sushivision_* sushi-gtkrc.h
distclean: clean
- rm -f *~
+ rm -f core core.* *~
%.d: %.c
$(CC) -M $(CFLAGS) $< > $@.$$$$; sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; rm -f $@.$$$$
Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/dimension.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -39,16 +39,17 @@
such that discrete dimensions will count from 0 in iteration. */
/* data_w ignored except in the continuous case, where it may be used
to generate linked or over/undersampled data scales. */
-int _sushiv_dimension_scales(sushiv_dimension_t *d,
- double lo,
- double hi,
- int panel_w, int data_w,
- int spacing,
- char *legend,
- scalespace *panel,
- scalespace *data,
- scalespace *iter){
+int _sv_dim_scales(sv_dim_t *d,
+ double lo,
+ double hi,
+ int panel_w, int data_w,
+ int spacing,
+ char *legend,
+ _sv_scalespace_t *panel,
+ _sv_scalespace_t *data,
+ _sv_scalespace_t *iter){
+
/* the panel scales may be reversed (the easiest way to do y)
and/or the dimension may have an inverted scale. */
int pneg, dimneg;
@@ -66,27 +67,27 @@
}
switch(d->type){
- case SUSHIV_DIM_CONTINUOUS:
+ case SV_DIM_CONTINUOUS:
{
//double ceil = d->scale->val_list[d->scale->vals-1] * dimneg;
- double fl = ((d->flags & SUSHIV_DIM_ZEROINDEX) ? d->scale->val_list[0] : 0.);
- *panel = scalespace_linear(lo, hi, panel_w, spacing, legend);
+ double fl = ((d->flags & SV_DIM_ZEROINDEX) ? d->scale->val_list[0] : 0.);
+ *panel = _sv_scalespace_linear(lo, hi, panel_w, spacing, legend);
if(panel_w == data_w){
*iter = *data = *panel;
}else{
- *data = scalespace_linear(lo, hi, data_w, 1, legend);
- *iter = scalespace_linear(lo-fl, hi-fl, data_w, 1, legend);
+ *data = _sv_scalespace_linear(lo, hi, data_w, 1, legend);
+ *iter = _sv_scalespace_linear(lo-fl, hi-fl, data_w, 1, legend);
/* if possible, the data/iterator scales should cover the entire pane exposed
by the panel scale so long as there's room left to extend them without
overflowing the lo/hi fenceposts */
while(1){
- double panel2 = scalespace_value(panel,panel_w-1)*pneg;
- double data2 = scalespace_value(data,data_w-1)*pneg;
+ double panel2 = _sv_scalespace_value(panel,panel_w-1)*pneg;
+ double data2 = _sv_scalespace_value(data,data_w-1)*pneg;
if(data2>=panel2)break;
data_w++;
@@ -97,7 +98,7 @@
}
}
break;
- case SUSHIV_DIM_DISCRETE:
+ case SV_DIM_DISCRETE:
{
/* return a scale that when iterated will only hit values
quantized to the discrete base */
@@ -110,7 +111,7 @@
int lo_i = floor(lo * d->private->discrete_denominator /
d->private->discrete_numerator);
int hi_i = floor(hi * d->private->discrete_denominator /
- d->private->discrete_numerator);
+ d->private->discrete_numerator);
if(floor_i < ceil_i){
if(lo_i < floor_i)lo_i = floor_i;
@@ -120,28 +121,28 @@
if(hi_i < ceil_i)hi_i = ceil_i;
}
- *panel = scalespace_linear((double)(lo_i-pneg*.4) * d->private->discrete_numerator /
- d->private->discrete_denominator,
- (double)(hi_i+pneg*.4) * d->private->discrete_numerator /
- d->private->discrete_denominator,
- panel_w, spacing, legend);
+ *panel = _sv_scalespace_linear((double)(lo_i-pneg*.4) * d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ (double)(hi_i+pneg*.4) * d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ panel_w, spacing, legend);
/* if possible, the data/iterator scales should cover the entire pane exposed
by the panel scale so long as there's room left to extend them without
overflowing the lo/hi fenceposts */
- double panel1 = scalespace_value(panel,0)*pneg;
- double panel2 = scalespace_value(panel,panel->pixels)*pneg;
+ double panel1 = _sv_scalespace_value(panel,0)*pneg;
+ double panel2 = _sv_scalespace_value(panel,panel->pixels)*pneg;
double data1 = (double)(lo_i-.49*pneg) * d->private->discrete_numerator /
d->private->discrete_denominator*pneg;
double data2 = (double)(hi_i-.51*pneg) * d->private->discrete_numerator /
d->private->discrete_denominator*pneg;
-
+
while(data1 > panel1 && lo_i*dimneg > floor_i*dimneg){
lo_i -= pneg;
data1 = (double)(lo_i-.49*pneg) * d->private->discrete_numerator /
d->private->discrete_denominator*pneg;
}
-
+
while(data2 < panel2 && hi_i*dimneg <= ceil_i*dimneg){ // inclusive upper
hi_i += pneg;
data2 = (double)(hi_i-.51*pneg) * d->private->discrete_numerator /
@@ -150,30 +151,30 @@
/* cosmetic adjustment complete, generate the scales */
data_w = abs(hi_i-lo_i);
- if(!(d->flags & SUSHIV_DIM_ZEROINDEX))
+ if(!(d->flags & SV_DIM_ZEROINDEX))
floor_i = 0;
-
- *data = scalespace_linear((double)lo_i * d->private->discrete_numerator /
- d->private->discrete_denominator,
- (double)hi_i * d->private->discrete_numerator /
- d->private->discrete_denominator,
- data_w, 1, legend);
- if(d->flags & SUSHIV_DIM_MONOTONIC)
- *iter = scalespace_linear(lo_i - floor_i, hi_i - floor_i,
- data_w, 1, legend);
+ *data = _sv_scalespace_linear((double)lo_i * d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ (double)hi_i * d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ data_w, 1, legend);
+
+ if(d->flags & SV_DIM_MONOTONIC)
+ *iter = _sv_scalespace_linear(lo_i - floor_i, hi_i - floor_i,
+ data_w, 1, legend);
else
- *iter = scalespace_linear((double)(lo_i - floor_i) *
- d->private->discrete_numerator /
- d->private->discrete_denominator,
- (double)(hi_i - floor_i) *
- d->private->discrete_numerator /
- d->private->discrete_denominator,
- data_w, 1, legend);
+ *iter = _sv_scalespace_linear((double)(lo_i - floor_i) *
+ d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ (double)(hi_i - floor_i) *
+ d->private->discrete_numerator /
+ d->private->discrete_denominator,
+ data_w, 1, legend);
break;
}
break;
- case SUSHIV_DIM_PICKLIST:
+ case SV_DIM_PICKLIST:
fprintf(stderr,"ERROR: Cannot iterate over picklist dimension!\n"
"\tA picklist dimension may not be a panel axis.\n");
data_w = 0;
@@ -183,31 +184,30 @@
data_w = 0;
break;
}
-
+
return data_w;
}
-int _sushiv_dimension_scales_from_panel(sushiv_dimension_t *d,
- scalespace panel,
- int data_w,
- scalespace *data,
- scalespace *iter){
-
- return _sushiv_dimension_scales(d,
- panel.lo,
- panel.hi,
- panel.pixels,
- data_w,
- panel.spacing,
- panel.legend,
- &panel, // dummy
- data,
- iter);
+int _sv_dim_scales_from_panel(sv_dim_t *d,
+ _sv_scalespace_t panel,
+ int data_w,
+ _sv_scalespace_t *data,
+ _sv_scalespace_t *iter){
+
+ return _sv_dim_scales(d,
+ panel.lo,
+ panel.hi,
+ panel.pixels,
+ data_w,
+ panel.spacing,
+ panel.legend,
+ &panel, // dummy
+ data,
+ iter);
}
-
-static double discrete_quantize_val(sushiv_dimension_t *d, double val){
- if(d->type == SUSHIV_DIM_DISCRETE){
+static double discrete_quantize_val(sv_dim_t *d, double val){
+ if(d->type == SV_DIM_DISCRETE){
val *= d->private->discrete_denominator;
val /= d->private->discrete_numerator;
@@ -219,21 +219,21 @@
return val;
}
-static void _sushiv_dimension_center_callback(void *data, int buttonstate){
+static void _sv_dim_center_callback(void *data, int buttonstate){
gdk_threads_enter();
- sushiv_dim_widget_t *dw = (sushiv_dim_widget_t *)data;
+ _sv_dim_widget_t *dw = (_sv_dim_widget_t *)data;
- sushiv_dimension_t *d = dw->dl->d;
- sushiv_panel_t *p = dw->dl->p;
- double val = slider_get_value(dw->scale,1);
+ sv_dim_t *d = dw->dl->d;
+ sv_panel_t *p = dw->dl->p;
+ double val = _sv_slider_get_value(dw->scale,1);
char buffer[80];
val = discrete_quantize_val(d,val);
if(buttonstate == 0){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
}
if(d->val != val){
@@ -243,20 +243,20 @@
/* dims can be shared amongst multiple widgets; all must be updated */
for(i=0;i<d->private->widgets;i++){
- sushiv_dim_widget_t *w = d->private->widget_list[i];
+ _sv_dim_widget_t *w = d->private->widget_list[i];
if(w->scale) // all shared widgets had better have scales, but bulletproof in case
- slider_set_value(w->scale,1,val);
+ _sv_slider_set_value(w->scale,1,val);
}
/* dims can be shared amongst multiple widgets; all must get callbacks */
for(i=0;i<d->private->widgets;i++){
- sushiv_dim_widget_t *w = d->private->widget_list[i];
+ _sv_dim_widget_t *w = d->private->widget_list[i];
w->center_callback(dw->dl);
}
}
if(buttonstate == 2)
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
snprintf(buffer,80,"%.10g",d->bracket[0]);
gtk_entry_set_text(GTK_ENTRY(dw->entry[0]),buffer);
@@ -268,23 +268,23 @@
gdk_threads_leave();
}
-static void _sushiv_dimension_bracket_callback(void *data, int buttonstate){
+static void _sv_dim_bracket_callback(void *data, int buttonstate){
gdk_threads_enter();
- sushiv_dim_widget_t *dw = (sushiv_dim_widget_t *)data;
+ _sv_dim_widget_t *dw = (_sv_dim_widget_t *)data;
- sushiv_dimension_t *d = dw->dl->d;
- sushiv_panel_t *p = dw->dl->p;
- double lo = slider_get_value(dw->scale,0);
- double hi = slider_get_value(dw->scale,2);
+ sv_dim_t *d = dw->dl->d;
+ sv_panel_t *p = dw->dl->p;
+ double lo = _sv_slider_get_value(dw->scale,0);
+ double hi = _sv_slider_get_value(dw->scale,2);
char buffer[80];
hi = discrete_quantize_val(d,hi);
lo = discrete_quantize_val(d,lo);
if(buttonstate == 0){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
}
if(d->bracket[0] != lo || d->bracket[1] != hi){
@@ -295,22 +295,22 @@
/* dims can be shared amongst multiple widgets; all must be updated */
for(i=0;i<d->private->widgets;i++){
- sushiv_dim_widget_t *w = d->private->widget_list[i];
+ _sv_dim_widget_t *w = d->private->widget_list[i];
if(w->scale){ // all shared widgets had better have scales, but bulletproof in case
- slider_set_value(w->scale,0,lo);
- slider_set_value(w->scale,2,hi);
+ _sv_slider_set_value(w->scale,0,lo);
+ _sv_slider_set_value(w->scale,2,hi);
}
}
/* dims can be shared amongst multiple widgets; all must get callbacks */
for(i=0;i<d->private->widgets;i++){
- sushiv_dim_widget_t *w = d->private->widget_list[i];
+ _sv_dim_widget_t *w = d->private->widget_list[i];
w->bracket_callback(dw->dl);
}
}
if(buttonstate == 2)
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
snprintf(buffer,80,"%.10g",d->bracket[0]);
gtk_entry_set_text(GTK_ENTRY(dw->entry[0]),buffer);
@@ -322,18 +322,18 @@
gdk_threads_leave();
}
-static void _sushiv_dimension_dropdown_callback(GtkWidget *dummy, void *data){
+static void _sv_dim_dropdown_callback(GtkWidget *dummy, void *data){
gdk_threads_enter();
- sushiv_dim_widget_t *dw = (sushiv_dim_widget_t *)data;
+ _sv_dim_widget_t *dw = (_sv_dim_widget_t *)data;
- sushiv_dimension_t *d = dw->dl->d;
- sushiv_panel_t *p = dw->dl->p;
+ sv_dim_t *d = dw->dl->d;
+ sv_panel_t *p = dw->dl->p;
int bin = gtk_combo_box_get_active(GTK_COMBO_BOX(dw->menu));
double val = d->scale->val_list[bin];
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
if(d->val != val){
int i;
@@ -344,31 +344,31 @@
/* dims can be shared amongst multiple widgets; all must be updated */
for(i=0;i<d->private->widgets;i++){
- sushiv_dim_widget_t *w = d->private->widget_list[i];
+ _sv_dim_widget_t *w = d->private->widget_list[i];
if(w->menu) // all shared widgets had better have scales, but bulletproof in case
gtk_combo_box_set_active(GTK_COMBO_BOX(w->menu),bin);
}
/* dims can be shared amongst multiple widgets; all must get callbacks */
for(i=0;i<d->private->widgets;i++){
- sushiv_dim_widget_t *w = d->private->widget_list[i];
+ _sv_dim_widget_t *w = d->private->widget_list[i];
w->center_callback(dw->dl);
}
}
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
gdk_threads_leave();
}
/* undo/redo have to frob widgets; this is indirected here too */
-void _sushiv_dimension_set_value(sushiv_dim_widget_t *dw, int thumb, double val){
- sushiv_dimension_t *d = dw->dl->d;
+int _sv_dim_set_value(_sv_dim_widget_t *dw, int thumb, double val){
+ sv_dim_t *d = dw->dl->d;
switch(d->type){
- case SUSHIV_DIM_CONTINUOUS:
- slider_set_value(dw->scale,thumb,val);
+ case SV_DIM_CONTINUOUS:
+ _sv_slider_set_value(dw->scale,thumb,val);
break;
- case SUSHIV_DIM_DISCRETE:
+ case SV_DIM_DISCRETE:
val *= d->private->discrete_denominator;
val /= d->private->discrete_numerator;
@@ -377,9 +377,9 @@
val *= d->private->discrete_numerator;
val /= d->private->discrete_denominator;
- slider_set_value(dw->scale,thumb,val);
+ _sv_slider_set_value(dw->scale,thumb,val);
break;
- case SUSHIV_DIM_PICKLIST:
+ case SV_DIM_PICKLIST:
/* find the picklist val closest to matching requested val */
if(thumb == 1){
int best=-1;
@@ -400,25 +400,16 @@
break;
default:
fprintf(stderr,"ERROR: Unsupporrted dimension type in dimension_set_value.\n");
- break;
+ errno = -EINVAL;
+ return -EINVAL;
}
+ return 0;
}
/* external version with externalish API */
-void sushiv_dimension_set_value(sushiv_instance_t *s, int dim_number, int thumb, double val){
- sushiv_dimension_t *d;
+int sv_dim_set_value(sv_dim_t *in, int thumb, double val){
+ sv_dim_t *d = (sv_dim_t *)in; // unwrap
- if(dim_number<0 || dim_number>=s->dimensions){
- fprintf(stderr,"Dimension number %d out of range.\n",dim_number);
- return;
- }
-
- d=s->dimension_list[dim_number];
- if(!d){
- fprintf(stderr,"Dimension %d does not exist.\n",dim_number);
- return;
- }
-
if(!d->private->widgets){
switch(thumb){
case 0:
@@ -427,36 +418,39 @@
case 1:
d->val = discrete_quantize_val(d,val);
break;
- default:
+ case 2:
d->bracket[1] = discrete_quantize_val(d,val);
break;
+ default:
+ errno = -EINVAL;
+ return -EINVAL;
}
}else
- _sushiv_dimension_set_value(d->private->widget_list[0],thumb,val);
-
+ return _sv_dim_set_value(d->private->widget_list[0],thumb,val);
+ return 0;
}
-void _sushiv_dim_widget_set_thumb_active(sushiv_dim_widget_t *dw, int thumb, int active){
+void _sv_dim_widget_set_thumb_active(_sv_dim_widget_t *dw, int thumb, int active){
if(dw->scale)
- slider_set_thumb_active(dw->scale,thumb,active);
+ _sv_slider_set_thumb_active(dw->scale,thumb,active);
}
static int expander_level = 0; // avoid races due to calling main_loop internally
static int expander_loop = 0;
-static void expander_callback (GtkExpander *expander, sushiv_dim_widget_t *dw){
+static void _sv_dim_expander_callback (GtkExpander *expander, _sv_dim_widget_t *dw){
expander_level++;
if(expander_level==1){
- // do not allow the Plot to resize
- plot_resizable(PLOT(dw->dl->p->private->graph),0);
+ // do not allow the plot to resize
+ _sv_plot_resizable(PLOT(dw->dl->p->private->graph),0);
do{
expander_loop = 0;
// Prevent the resizing algorithm from frobbing the plot's box
- gtk_box_freeze_child (GTK_BOX(dw->dl->p->private->topbox),
- dw->dl->p->private->plotbox);
+ _gtk_box_freeze_child (GTK_BOX(dw->dl->p->private->topbox),
+ dw->dl->p->private->plotbox);
// allow the toplevel to resize automatically
gtk_window_set_policy (GTK_WINDOW (dw->dl->p->private->toplevel), FALSE, FALSE, TRUE);
@@ -489,8 +483,8 @@
}
// revert plot box to autofilling if user alters window size
- gtk_box_unfreeze_child(GTK_BOX(dw->dl->p->private->topbox),
- dw->dl->p->private->plotbox);
+ _gtk_box_unfreeze_child(GTK_BOX(dw->dl->p->private->topbox),
+ dw->dl->p->private->plotbox);
while(gtk_events_pending()){
gtk_main_iteration();
gdk_flush();
@@ -499,7 +493,7 @@
} while(expander_loop);
// lastly, allow plot to resize again
- plot_resizable(PLOT(dw->dl->p->private->graph),1);
+ _sv_plot_resizable(PLOT(dw->dl->p->private->graph),1);
}else
expander_loop=1;
@@ -507,35 +501,35 @@
expander_level--;
}
-static void entry_callback (GtkEntry *entry, Slice *s){
- slice_thumb_set(s, atof(gtk_entry_get_text(entry)));
+static void _sv_dim_entry_callback (GtkEntry *entry, _sv_slice_t *s){
+ _sv_slice_thumb_set(s, atof(gtk_entry_get_text(entry)));
}
-static gboolean entry_refresh_callback (GtkEntry *entry, GdkEventFocus *event, double *v){
+static gboolean _sv_dim_entry_refresh_callback (GtkEntry *entry, GdkEventFocus *event, double *v){
char buffer[80];
snprintf(buffer,80,"%.10g",*v);
gtk_entry_set_text(entry,buffer);
return FALSE;
}
-static void entry_active_callback(void *e, int active){
+static void _sv_dim_entry_active_callback(void *e, int active){
gtk_widget_set_sensitive(GTK_WIDGET(e),active);
}
-sushiv_dim_widget_t *_sushiv_new_dimension_widget(sushiv_dimension_list_t *dl,
- void (*center_callback)(sushiv_dimension_list_t *),
- void (*bracket_callback)(sushiv_dimension_list_t *)){
+_sv_dim_widget_t *_sv_dim_widget_new(sv_dim_list_t *dl,
+ void (*center_callback)(sv_dim_list_t *),
+ void (*bracket_callback)(sv_dim_list_t *)){
- sushiv_dim_widget_t *dw = calloc(1, sizeof(*dw));
- sushiv_dimension_t *d = dl->d;
+ _sv_dim_widget_t *dw = calloc(1, sizeof(*dw));
+ sv_dim_t *d = dl->d;
dw->dl = dl;
dw->center_callback = center_callback;
dw->bracket_callback = bracket_callback;
switch(d->type){
- case SUSHIV_DIM_CONTINUOUS:
- case SUSHIV_DIM_DISCRETE:
+ case SV_DIM_CONTINUOUS:
+ case SV_DIM_DISCRETE:
/* Continuous and discrete dimensions get sliders */
{
double v[3];
@@ -547,9 +541,9 @@
v[1]=d->val;
v[2]=d->bracket[1];
- sl[0] = slice_new(_sushiv_dimension_bracket_callback,dw);
- sl[1] = slice_new(_sushiv_dimension_center_callback,dw);
- sl[2] = slice_new(_sushiv_dimension_bracket_callback,dw);
+ sl[0] = _sv_slice_new(_sv_dim_bracket_callback,dw);
+ sl[1] = _sv_slice_new(_sv_dim_center_callback,dw);
+ sl[2] = _sv_slice_new(_sv_dim_bracket_callback,dw);
dw->entry[0] = gtk_entry_new();
dw->entry[1] = gtk_entry_new();
dw->entry[2] = gtk_entry_new();
@@ -578,55 +572,55 @@
gtk_table_attach(st,dw->entry[2],3,4,1,2,
GTK_EXPAND|GTK_FILL,0,0,0);
- dw->scale = slider_new((Slice **)sl,3,d->scale->label_list,d->scale->val_list,
- d->scale->vals,0);
- if(d->type == SUSHIV_DIM_DISCRETE)
- slider_set_quant(dw->scale,d->private->discrete_numerator,d->private->discrete_denominator);
+ dw->scale = _sv_slider_new((_sv_slice_t **)sl,3,d->scale->label_list,d->scale->val_list,
+ d->scale->vals,0);
+ if(d->type == SV_DIM_DISCRETE)
+ _sv_slider_set_quant(dw->scale,d->private->discrete_numerator,d->private->discrete_denominator);
- slice_thumb_set((Slice *)sl[0],v[0]);
- slice_thumb_set((Slice *)sl[1],v[1]);
- slice_thumb_set((Slice *)sl[2],v[2]);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[0],v[0]);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[1],v[1]);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[2],v[2]);
g_signal_connect_after (G_OBJECT (exp), "activate",
- G_CALLBACK (expander_callback), dw);
+ G_CALLBACK (_sv_dim_expander_callback), dw);
g_signal_connect (G_OBJECT (dw->entry[0]), "activate",
- G_CALLBACK (entry_callback), sl[0]);
+ G_CALLBACK (_sv_dim_entry_callback), sl[0]);
g_signal_connect (G_OBJECT (dw->entry[1]), "activate",
- G_CALLBACK (entry_callback), sl[1]);
+ G_CALLBACK (_sv_dim_entry_callback), sl[1]);
g_signal_connect (G_OBJECT (dw->entry[2]), "activate",
- G_CALLBACK (entry_callback), sl[2]);
+ G_CALLBACK (_sv_dim_entry_callback), sl[2]);
g_signal_connect (G_OBJECT (dw->entry[0]), "focus-out-event",
- G_CALLBACK (entry_refresh_callback), &d->bracket[0]);
+ G_CALLBACK (_sv_dim_entry_refresh_callback), &d->bracket[0]);
g_signal_connect (G_OBJECT (dw->entry[1]), "focus-out-event",
- G_CALLBACK (entry_refresh_callback), &d->val);
+ G_CALLBACK (_sv_dim_entry_refresh_callback), &d->val);
g_signal_connect (G_OBJECT (dw->entry[2]), "focus-out-event",
- G_CALLBACK (entry_refresh_callback), &d->bracket[1]);
+ G_CALLBACK (_sv_dim_entry_refresh_callback), &d->bracket[1]);
- slice_set_active_callback((Slice *)sl[0], entry_active_callback, dw->entry[0]);
- slice_set_active_callback((Slice *)sl[1], entry_active_callback, dw->entry[1]);
- slice_set_active_callback((Slice *)sl[2], entry_active_callback, dw->entry[2]);
+ _sv_slice_set_active_callback((_sv_slice_t *)sl[0], _sv_dim_entry_active_callback, dw->entry[0]);
+ _sv_slice_set_active_callback((_sv_slice_t *)sl[1], _sv_dim_entry_active_callback, dw->entry[1]);
+ _sv_slice_set_active_callback((_sv_slice_t *)sl[2], _sv_dim_entry_active_callback, dw->entry[2]);
dw->t = GTK_WIDGET(st);
}
break;
- case SUSHIV_DIM_PICKLIST:
+ case SV_DIM_PICKLIST:
/* picklist dimensions get a wide dropdown */
dw->t = gtk_table_new(1,1,0);
{
int j;
- dw->menu=gtk_combo_box_new_markup();
+ dw->menu = _gtk_combo_box_new_markup();
for(j=0;j<d->scale->vals;j++)
gtk_combo_box_append_text (GTK_COMBO_BOX (dw->menu), d->scale->label_list[j]);
g_signal_connect (G_OBJECT (dw->menu), "changed",
- G_CALLBACK (_sushiv_dimension_dropdown_callback), dw);
+ G_CALLBACK (_sv_dim_dropdown_callback), dw);
gtk_table_attach(GTK_TABLE(dw->t),dw->menu,0,1,0,1,
GTK_EXPAND|GTK_FILL,GTK_SHRINK,0,2);
- _sushiv_dimension_set_value(dw,1,d->val);
+ _sv_dim_set_value(dw,1,d->val);
//gtk_combo_box_set_active(GTK_COMBO_BOX(dw->menu),0);
}
break;
@@ -648,24 +642,25 @@
return dw;
};
-int sushiv_new_dimension(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned scalevals,
- double *scaleval_list,
- int (*callback)(sushiv_dimension_t *),
- unsigned flags){
- sushiv_dimension_t *d;
+sv_dim_t *sv_dim_new(sv_instance_t *in,
+ int number,
+ char *name,
+ unsigned flags){
+
+ sv_instance_t *s = (sv_instance_t *)in;
+ sv_dim_t *d;
if(number<0){
fprintf(stderr,"Dimension number must be >= 0\n");
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
if(number<s->dimensions){
if(s->dimension_list[number]!=NULL){
fprintf(stderr,"Dimension number %d already exists\n",number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
}else{
if(s->dimensions == 0){
@@ -682,113 +677,118 @@
d->name = strdup(name);
d->flags = flags;
d->sushi = s;
- d->callback = callback;
- d->scale = scale_new(scalevals, scaleval_list, name);
- d->type = SUSHIV_DIM_CONTINUOUS;
+ d->type = SV_DIM_CONTINUOUS;
d->private = calloc(1, sizeof(*d->private));
- d->bracket[0]=d->scale->val_list[0];
- d->val = 0;
- d->bracket[1]=d->scale->val_list[d->scale->vals-1];
-
- return 0;
+ return d;
}
-int sushiv_new_dimension_discrete(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned scalevals,
- double *scaleval_list,
- int (*callback)(sushiv_dimension_t *),
- long num,
- long denom,
- unsigned flags){
+// XXXX need to recompute after
+// XXXX need to add scale cloning to compute to make this safe in callbacks
+int sv_dim_set_scale(sv_dim_t *in,
+ sv_scale_t *scale){
+ sv_dim_t *d = (sv_dim_t *)in; // unwrap
+
+ if(d->scale)
+ sv_scale_free(d->scale); // always a deep copy we own
- /* template is a normal continuous dim */
- sushiv_dimension_t *d;
- int ret=sushiv_new_dimension(s,number,name,scalevals,scaleval_list,callback,flags);
+ d->scale = (sv_scale_t *)sv_scale_copy(scale);
- if(ret)return ret;
+ d->bracket[0]=scale->val_list[0];
+ d->val = 0;
+ d->bracket[1]=scale->val_list[d->scale->vals-1];
- d = s->dimension_list[number];
+ // redraw the slider
- d->private->discrete_numerator = num;
- d->private->discrete_denominator = denom;
- d->type = SUSHIV_DIM_DISCRETE;
-
return 0;
}
-int sushiv_new_dimension_picklist(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned pickvals,
- double *pickval_list,
- char **pickval_labels,
- int (*callback)(sushiv_dimension_t *),
- unsigned flags){
+// XXXX need to recompute after
+// XXXX need to add scale cloning to compute to make this safe in callbacks
+int sv_dim_make_scale(sv_dim_t *in,
+ unsigned scalevals,
+ double *scaleval_list,
+ char **scalelabel_list,
+ unsigned flags){
+ sv_dim_t *d = (sv_dim_t *)in; //unwrap
- /* template is a normal continuous dim */
- sushiv_dimension_t *d;
- int ret=sushiv_new_dimension(s,number,name,pickvals,pickval_list,callback,flags);
+ sv_scale_t *scale = sv_scale_new(d->name,scalevals,scaleval_list,scalelabel_list,0);
+ if(!scale)return errno;
- if(ret)return ret;
+ int ret = sv_dim_set_scale(d,scale);
+ sv_scale_free(scale);
+ return ret;
+}
- d = s->dimension_list[number];
+// XXXX need to recompute after
+int sv_dim_set_discrete(sv_dim_t *in,
+ long quant_numerator,
+ long quant_denominator){
- scale_set_scalelabels(d->scale, pickval_labels);
- d->flags |= SUSHIV_DIM_NO_X;
- d->flags |= SUSHIV_DIM_NO_Y;
- d->type = SUSHIV_DIM_PICKLIST;
+ sv_dim_t *d = (sv_dim_t *)in; //unwrap
+ if(!d) return -EINVAL;
+ d->private->discrete_numerator = quant_numerator;
+ d->private->discrete_denominator = quant_denominator;
+ d->type = SV_DIM_DISCRETE;
+
return 0;
+}
+int sv_dim_set_picklist(sv_dim_t *in){
+
+ sv_dim_t *d = (sv_dim_t *)in; //unwrap
+ if(!d) return -EINVAL;
+
+ d->type = SV_DIM_PICKLIST;
+
+ return 0;
}
-static propmap *typemap[]={
- &(propmap){"continuous",SUSHIV_DIM_CONTINUOUS, NULL,NULL,NULL},
- &(propmap){"discrete",SUSHIV_DIM_DISCRETE, NULL,NULL,NULL},
- &(propmap){"picklist",SUSHIV_DIM_PICKLIST, NULL,NULL,NULL},
+static _sv_propmap_t *typemap[]={
+ &(_sv_propmap_t){"continuous",SV_DIM_CONTINUOUS, NULL,NULL,NULL},
+ &(_sv_propmap_t){"discrete",SV_DIM_DISCRETE, NULL,NULL,NULL},
+ &(_sv_propmap_t){"picklist",SV_DIM_PICKLIST, NULL,NULL,NULL},
NULL
};
-int _load_dimension(sushiv_dimension_t *d,
- sushiv_instance_undo_t *u,
- xmlNodePtr dn,
- int warn){
+int _sv_dim_load(sv_dim_t *d,
+ _sv_instance_undo_t *u,
+ xmlNodePtr dn,
+ int warn){
// check name
- xmlCheckPropS(dn,"name",d->name,"Dimension %d name mismatch in save file.",d->number,&warn);
+ _xmlCheckPropS(dn,"name",d->name,"Dimension %d name mismatch in save file.",d->number,&warn);
// check type
- xmlCheckMap(dn,"type",typemap, d->type, "Dimension %d type mismatch in save file.",d->number,&warn);
+ _xmlCheckMap(dn,"type",typemap, d->type, "Dimension %d type mismatch in save file.",d->number,&warn);
// load vals
- xmlGetPropF(dn,"low-bracket", &u->dim_vals[0][d->number]);
- xmlGetPropF(dn,"value", &u->dim_vals[1][d->number]);
- xmlGetPropF(dn,"high-bracket", &u->dim_vals[2][d->number]);
+ _xmlGetPropF(dn,"low-bracket", &u->dim_vals[0][d->number]);
+ _xmlGetPropF(dn,"value", &u->dim_vals[1][d->number]);
+ _xmlGetPropF(dn,"high-bracket", &u->dim_vals[2][d->number]);
return warn;
}
-int _save_dimension(sushiv_dimension_t *d, xmlNodePtr instance){
+int _sv_dim_save(sv_dim_t *d, xmlNodePtr instance){
if(!d) return 0;
int ret=0;
xmlNodePtr dn = xmlNewChild(instance, NULL, (xmlChar *) "dimension", NULL);
- xmlNewPropI(dn, "number", d->number);
- xmlNewPropS(dn, "name", d->name);
- xmlNewMapProp(dn, "type", typemap, d->type);
+ _xmlNewPropI(dn, "number", d->number);
+ _xmlNewPropS(dn, "name", d->name);
+ _xmlNewMapProp(dn, "type", typemap, d->type);
switch(d->type){
- case SUSHIV_DIM_CONTINUOUS:
- case SUSHIV_DIM_DISCRETE:
- xmlNewPropF(dn, "low-bracket", d->bracket[0]);
- xmlNewPropF(dn, "high-bracket", d->bracket[1]);
+ case SV_DIM_CONTINUOUS:
+ case SV_DIM_DISCRETE:
+ _xmlNewPropF(dn, "low-bracket", d->bracket[0]);
+ _xmlNewPropF(dn, "high-bracket", d->bracket[1]);
- case SUSHIV_DIM_PICKLIST:
- xmlNewPropF(dn, "value", d->val);
+ case SV_DIM_PICKLIST:
+ _xmlNewPropF(dn, "value", d->val);
break;
}
Modified: trunk/sushivision/dimension.h
===================================================================
--- trunk/sushivision/dimension.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/dimension.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -21,11 +21,11 @@
typedef struct {
- sushiv_dimension_list_t *dl;
+ sv_dim_list_t *dl;
GtkWidget *t;
/* one or the other */
- Slider *scale;
+ _sv_slider_t *scale;
GtkWidget *menu;
GtkWidget *entry[3];
@@ -35,37 +35,37 @@
2: end set
3: programmatic modification
*/
- void (*center_callback)(sushiv_dimension_list_t *);
- void (*bracket_callback)(sushiv_dimension_list_t *);
-} sushiv_dim_widget_t;
+ void (*center_callback)(sv_dim_list_t *);
+ void (*bracket_callback)(sv_dim_list_t *);
+} _sv_dim_widget_t;
-struct sushiv_dimension_internal {
+struct _sv_dim_internal {
long discrete_numerator;
long discrete_denominator;
-
+
int widgets;
- sushiv_dim_widget_t **widget_list;
+ _sv_dim_widget_t **widget_list;
};
-extern int _sushiv_dimension_scales(sushiv_dimension_t *d,
- double lo,
- double hi,
- int panel_w, int data_w,
- int spacing,
- char *legend,
- scalespace *panel,
- scalespace *data,
- scalespace *iter);
-extern int _sushiv_dimension_scales_from_panel(sushiv_dimension_t *d,
- scalespace panel,
- int data_w,
- scalespace *data,
- scalespace *iter);
+extern int _sv_dim_scales(sv_dim_t *d,
+ double lo,
+ double hi,
+ int panel_w, int data_w,
+ int spacing,
+ char *legend,
+ _sv_scalespace_t *panel,
+ _sv_scalespace_t *data,
+ _sv_scalespace_t *iter);
+extern int _sv_dim_scales_from_panel(sv_dim_t *d,
+ _sv_scalespace_t panel,
+ int data_w,
+ _sv_scalespace_t *data,
+ _sv_scalespace_t *iter);
-extern void _sushiv_dimension_set_value(sushiv_dim_widget_t *d, int thumb, double val);
-extern void _sushiv_dim_widget_set_thumb_active(sushiv_dim_widget_t *dw, int thumb, int active);
-extern sushiv_dim_widget_t *_sushiv_new_dimension_widget(sushiv_dimension_list_t *dl,
- void (*center_callback)(sushiv_dimension_list_t *),
- void (*bracket_callback)(sushiv_dimension_list_t *));
-extern int _save_dimension(sushiv_dimension_t *d, xmlNodePtr instance);
-extern int _load_dimension(sushiv_dimension_t *d, sushiv_instance_undo_t *u, xmlNodePtr dn, int warn);
+extern int _sv_dim_set_value(_sv_dim_widget_t *d, int thumb, double val);
+extern void _sv_dim_widget_set_thumb_active(_sv_dim_widget_t *dw, int thumb, int active);
+extern _sv_dim_widget_t *_sv_dim_widget_new(sv_dim_list_t *dl,
+ void (*center_callback)(sv_dim_list_t *),
+ void (*bracket_callback)(sv_dim_list_t *));
+extern int _sv_dim_save(sv_dim_t *d, xmlNodePtr instance);
+extern int _sv_dim_load(sv_dim_t *d, _sv_instance_undo_t *u, xmlNodePtr dn, int warn);
Modified: trunk/sushivision/example_chirp.c
===================================================================
--- trunk/sushivision/example_chirp.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/example_chirp.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -24,8 +24,6 @@
#include <math.h>
#include "sushivision.h"
-sushiv_instance_t *s;
-
static void chirp(double *d, double *ret){
double freq = d[0];
double ampl = d[1];
@@ -47,61 +45,55 @@
ret[0] = sin(phase_t) * (ampl + damp*t);
}
-int sushiv_submain(int argc, char *argv[]){
-
- s=sushiv_new_instance(0,"chirp");
-
- sushiv_new_dimension(s,0,"initial Hz",
- 4,(double []){1,10,100,1000},
- NULL,SUSHIV_DIM_NO_X);
- sushiv_new_dimension(s,1,"initial amplitude",
- 3,(double []){0,.1,1},
- NULL,SUSHIV_DIM_NO_X);
- sushiv_new_dimension(s,2,"initial phase",
- 3,(double []){-M_PI,0,M_PI},
- NULL,SUSHIV_DIM_NO_X);
- sushiv_new_dimension(s,3,"delta amplitude",
- 3,(double []){0,-.1,-1},
- NULL,SUSHIV_DIM_NO_X);
- sushiv_new_dimension(s,4,"delta frequency",
- 7,
- (double []){-100*M_PI,-10*M_PI,-M_PI,0,M_PI,10*M_PI,100*M_PI},
- NULL,
- SUSHIV_DIM_NO_X);
-
- scale_set_scalelabels(s->dimension_list[4]->scale,(char *[]){"-100pi","-10pi","-pi","0","pi","10pi","100pi"});
-
- sushiv_new_dimension(s,5,"seconds",
- 5,(double []){0,.001,.01,.1,1},
- NULL,0);
+int sv_submain(int argc, char *argv[]){
- sushiv_dimension_set_value(s,1,1,1.0);
+ sv_instance_t *s = sv_new(0,"chirp");
+
+ sv_dim_t *d0 = sv_dim_new(s,0,"initial Hz",SV_DIM_NO_X);
+ sv_dim_make_scale(d0,4,(double []){1,10,100,1000},NULL,0);
+
+ sv_dim_t *d1 = sv_dim_new(s,1,"initial amplitude",SV_DIM_NO_X);
+ sv_dim_make_scale(d1,3,(double []){0,.1,1},NULL,0);
+ sv_dim_set_value(d1,1,1.0);
+
+ sv_dim_t *d2 = sv_dim_new(s,2,"initial phase",SV_DIM_NO_X);
+ sv_dim_make_scale(d2,3,(double []){-M_PI,0,M_PI},NULL,0);
+
+ sv_dim_t *d3 = sv_dim_new(s,3,"delta amplitude",SV_DIM_NO_X);
+ sv_dim_make_scale(d3,3,(double []){0,-.1,-1},NULL,0);
+
+ sv_dim_t *d4 = sv_dim_new(s,4,"delta frequency",SV_DIM_NO_X);
+ sv_dim_make_scale(d4,7,(double []){-100*M_PI,-10*M_PI,-M_PI,0,M_PI,10*M_PI,100*M_PI},
+ (char *[]){"-100pi","-10pi","-pi","0","pi","10pi","100pi"}, 0);
+
+ sv_dim_t *d5 = sv_dim_new(s,5,"seconds",0);
+ sv_dim_make_scale(d5,5,(double []){0,.001,.01,.1,1},NULL,0);
+
+ sv_func_t *f = sv_func_new(s, 0, 3, chirp, 0);
+
+ sv_obj_t *o0 = sv_obj_new(s,0,"sin",
+ (sv_func_t *[]){f},
+ (int []){0},
+ "Y", 0);
+ sv_obj_make_scale(o0, 2,(double []){-1.5, 1.5}, NULL, 0);
+
+ sv_obj_t *o1 = sv_obj_new(s,1,"phase",
+ (sv_func_t *[]){f},
+ (int []){1},
+ "Y", 0);
+ sv_obj_make_scale(o1, 2,(double []){-1.0, 1.0}, NULL, 0);
+
+ sv_obj_t *o2 = sv_obj_new(s,2,"amplitude",
+ (sv_func_t *[]){f},
+ (int []){2},
+ "Y", 0);
+ sv_obj_make_scale(o2, 2,(double []){-1.0, 1.0}, NULL, 0);
+
+ sv_panel_new_1d(s,2,"chirp",
+ s->objective_list[0]->scale,
+ (sv_obj_t *[]){o0,o1,o2,NULL},
+ (sv_dim_t *[]){d0,d1,d2,d3,d4,d5,NULL},
+ 0);
- sushiv_new_function(s, 0, 3, chirp, 0);
-
- sushiv_new_objective(s,0,"sin",
- 2,(double []){-1.5, 1.5},
- (int []){0},
- (int []){0},
- "Y", 0);
-
- sushiv_new_objective(s,1,"phase",
- 2,(double []){-1.0, 1.0},
- (int []){0},
- (int []){1},
- "Y", 0);
-
- sushiv_new_objective(s,2,"amplitude",
- 2,(double []){-1.0, 1.0},
- (int []){0},
- (int []){2},
- "Y", 0);
-
- sushiv_new_panel_1d(s,2,"chirp",
- s->objective_list[0]->scale,
- (int []){0,1,2,-1},
- (int []){0,1,2,3,4,5,-1},
- 0);
-
return 0;
}
Modified: trunk/sushivision/example_discrete.c
===================================================================
--- trunk/sushivision/example_discrete.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/example_discrete.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -24,8 +24,6 @@
#include <math.h>
#include "sushivision.h"
-sushiv_instance_t *s;
-
static void discrete_objective(double *d, double *ret){
int X = rint(d[0]);
@@ -37,43 +35,45 @@
ret[0]=1.;
}
-int sushiv_submain(int argc, char *argv[]){
+int sv_submain(int argc, char *argv[]){
- s=sushiv_new_instance(0,NULL);
+ sv_instance_t *s = sv_new(0,NULL);
- sushiv_new_dimension_discrete(s,0,"A",
- 5,(double []){-500,-10,0,10,500},
- NULL,1,1,0);
- sushiv_new_dimension_discrete(s,1,"B",
- 5,(double []){-500,-10,0,10,500},
- NULL,1,1,0);
+ sv_dim_t *d0 = sv_dim_new(s,0,"A",0);
+ sv_dim_make_scale(d0, 5,(double []){-500,-10,0,10,500}, NULL, 0);
+ sv_dim_set_discrete(d0, 1, 1);
- sushiv_dimension_set_value(s,0,0,-2);
- sushiv_dimension_set_value(s,0,2,2);
- sushiv_dimension_set_value(s,1,0,-2);
- sushiv_dimension_set_value(s,1,2,2);
+ sv_dim_t *d1 = sv_dim_new(s,1,"B",0);
+ sv_dim_make_scale(d1, 5,(double []){-500,-10,0,10,500}, NULL, 0);
+ sv_dim_set_discrete(d1, 1, 1);
- sushiv_new_function(s, 0, 1, discrete_objective, 0);
+ sv_dim_set_value(d0,0,-2);
+ sv_dim_set_value(d0,2,2);
+ sv_dim_set_value(d1,0,-2);
+ sv_dim_set_value(d1,2,2);
- sushiv_new_objective(s,0,"test pattern",
- 2,(double []){0, 1.0},
- (int []){0},
- (int []){0},
- "Y", 0);
+ sv_func_t *f = sv_func_new(s, 0, 1, discrete_objective, 0);
- sushiv_new_panel_2d(s,0,"Discrete data example",
- (int []){0,-1},
- (int []){0,1,-1},
- 0);
-
- sushiv_new_panel_1d_linked(s,1,"X Slice",s->objective_list[0]->scale,
- (int []){0,-1},
- 0,0);
-
- sushiv_new_panel_1d_linked(s,2,"Y Slice",s->objective_list[0]->scale,
- (int []){0,-1},
- 0,SUSHIV_PANEL_LINK_Y | SUSHIV_PANEL_FLIP);
-
-
+ sv_obj_t *o0 = sv_obj_new(s,0,"test pattern",
+ (sv_func_t *[]){f},
+ (int []){0},
+ "Y",0);
+ sv_obj_make_scale(o0, 2, (double []){0, 1.0}, NULL, 0);
+
+ sv_panel_t *p2 = sv_panel_new_2d(s,0,"Discrete data example",
+ (sv_obj_t *[]){o0,NULL},
+ (sv_dim_t *[]){d0,d1,NULL},
+ 0);
+
+ sv_panel_t *px = sv_panel_new_1d(s,1,"X Slice", s->objective_list[0]->scale,
+ (sv_obj_t *[]){o0,NULL},
+ NULL,0);
+ sv_panel_link_1d(px, p2, SV_PANEL_LINK_X);
+
+ sv_panel_t *py = sv_panel_new_1d(s,2,"Y Slice", s->objective_list[0]->scale,
+ (sv_obj_t *[]){o0,NULL},
+ NULL,SV_PANEL_FLIP);
+ sv_panel_link_1d(py, p2, SV_PANEL_LINK_Y);
+
return 0;
}
Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/example_fractal.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -24,13 +24,13 @@
#include <math.h>
#include "sushivision.h"
-sushiv_instance_t *s;
+sv_instance_t *s;
static void fractal_objective(double *d, double *ret){
int max_iter = d[4];
int i;
double z, zi, zz;
- const double c=d[0],ci=d[1];
+ double c=d[0],ci=d[1];
ret[0]=NAN;
ret[1]=1.;
@@ -50,59 +50,55 @@
ret[1] = sqrt(z*z + zi*zi)/4.;
}
-int sushiv_submain(int argc, char *argv[]){
+int sv_submain(int argc, char *argv[]){
- s=sushiv_new_instance(0,"fractal");
+ sv_instance_t *s = sv_new(0,"fractal");
+
+ sv_dim_t *d0 = sv_dim_new(s, 0, "Re(c)", 0);
+ sv_dim_make_scale(d0, 5, (double []){-2.25,-0.75,0,0.25,0.75}, NULL, 0);
+
+ sv_dim_t *d1 = sv_dim_new(s, 1, "Im(c)", 0);
+ sv_dim_make_scale(d1, 5, (double []){-2,-1,0,1,2}, NULL, 0);
- sushiv_new_dimension(s,0,"Re(c)",
- 5,(double []){-2.25,-0.75,0,0.25,0.75},
- NULL,0);
- sushiv_new_dimension(s,1,"Im(c)",
- 5,(double []){-2,-1,0,1,2},
- NULL,0);
+ sv_dim_t *d2 = sv_dim_new(s, 2, "Re(z0)", 0);
+ sv_dim_make_scale(d2, 5, (double []){-2.25,-1,0,1,2.25}, NULL, 0);
- sushiv_new_dimension(s,2,"Re(z0)",
- 5,(double []){-2.25,-1,0,1,2.25},
- NULL,0);
- sushiv_new_dimension(s,3,"Im(z0)",
- 5,(double []){-2.25,-1,0,1,2.25},
- NULL,0);
+ sv_dim_t *d3 = sv_dim_new(s, 3, "Im(z0)", 0);
+ sv_dim_make_scale(d3, 5, (double []){-2.25,-1,0,1,2.25}, NULL, 0);
- sushiv_new_dimension_picklist(s,4,"Max Iterations",
- 4,
- (double []){100,1000,10000,100000},
- (char *[]){"one hundred",
- "one thousand",
- "ten thousand",
- "one hundred thousand"},
- NULL,0);
- sushiv_dimension_set_value(s,4,1,100);
+ sv_dim_t *d4 = sv_dim_new(s, 4, "Max Iterations", 0);
+ sv_dim_make_scale(d4, 4, (double []){100,1000,10000,100000},
+ (char *[]){"one hundred",
+ "one thousand",
+ "ten thousand",
+ "one hundred thousand"}, 0);
+ sv_dim_set_picklist(d4);
+ sv_dim_set_value(d4,1,100);
- sushiv_new_function(s, 0, 2, fractal_objective, 0);
-
- sushiv_new_objective(s,0,"outer",
- 5,(double []){0, .001, .01, .1, 1.0},
- (int []){0},
- (int []){0},
- "Y", 0);
-
- sushiv_new_objective(s,1,"inner",
- 5,(double []){0, .001, .01, .1, 1.0},
- (int []){0},
- (int []){1},
- "Y", 0);
+ sv_func_t *f = sv_func_new(s, 0, 2, fractal_objective, 0);
- sushiv_new_panel_2d(s,0,"Mandel/Julia Fractal",
- (int []){0,1,-1},
- (int []){0,1,2,3,4,-1},
- 0);
-
+ sv_obj_t *o0 = sv_obj_new(s,0,"outer",
+ (sv_func_t *[]){f},
+ (int []){0},
+ "Y", 0);
+ sv_obj_make_scale(o0, 5, (double []){0, .001, .01, .1, 1.0}, NULL, 0);
+
+ sv_obj_t *o1 = sv_obj_new(s,1,"inner",
+ (sv_func_t *[]){f},
+ (int []){1},
+ "Y", 0);
+ sv_obj_make_scale(o1, 5, (double []){0, .001, .01, .1, 1.0}, NULL, 0);
+
+ sv_panel_new_2d(s,0,"Mandel/Julia Fractal",
+ (sv_obj_t *[]){o0,o1,NULL},
+ (sv_dim_t *[]){d0,d1,d2,d3,d4,NULL},
+ 0);
+
return 0;
}
/* sushiv_atexit is entirely optional and may be ommitted */
-int sushiv_atexit(void){
+int sv_atexit(void){
fprintf(stderr,"Done!\n");
return 0;
-
}
Modified: trunk/sushivision/example_spirograph.c
===================================================================
--- trunk/sushivision/example_spirograph.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/example_spirograph.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -26,7 +26,6 @@
#define MAX_TEETH 100
-sushiv_instance_t *s;
int mult[MAX_TEETH+1][MAX_TEETH+1];
static void inner(double *d, double *ret){
@@ -63,55 +62,52 @@
return y;
}
-int sushiv_submain(int argc, char *argv[]){
+int sv_submain(int argc, char *argv[]){
int i,j;
for(i=0;i<=MAX_TEETH;i++)
for(j=0;j<=MAX_TEETH;j++)
mult[i][j] = factored_mult(i,j);
- s=sushiv_new_instance(0,"spirograph");
+ sv_instance_t *s = sv_new(0,"spirograph");
- sushiv_new_dimension_discrete(s,0,"ring teeth",
- 2,(double []){11,MAX_TEETH},
- NULL,1,1,0);
- sushiv_new_dimension_discrete(s,1,"wheel teeth",
- 2,(double []){7,MAX_TEETH},
- NULL,1,1,0);
- sushiv_new_dimension(s,2,"wheel pen",
- 2,(double []){0,MAX_TEETH},
- NULL,0);
- sushiv_new_dimension(s,3,"trace",
- 2,(double []){0,1},
- NULL,0);
+ sv_dim_t *d0 = sv_dim_new(s,0,"ring teeth",0);
+ sv_dim_make_scale(d0,2,(double []){11,MAX_TEETH},NULL,0);
+ sv_dim_set_discrete(d0,1,1);
- scale_set_scalelabels(s->dimension_list[3]->scale,(char *[]){"start","end"});
+ sv_dim_t *d1 = sv_dim_new(s,1,"wheel teeth",0);
+ sv_dim_make_scale(d1,2,(double []){7,MAX_TEETH},NULL,0);
+ sv_dim_set_discrete(d1,1,1);
+
+ sv_dim_t *d2 = sv_dim_new(s,2,"wheel pen",0);
+ sv_dim_make_scale(d2,2,(double []){0,MAX_TEETH},NULL,0);
- sushiv_new_function(s, 0, 2, inner, 0);
- sushiv_new_function(s, 1, 2, outer, 0);
+ sv_dim_t *d3 = sv_dim_new(s,3,"trace",0);
+ sv_dim_make_scale(d3,2,(double []){0,1},(char *[]){"start","end"},0);
- sushiv_new_objective(s,0,"inner",
- 0,NULL,
- (int []){0,0},
- (int []){0,1},
- "XY", 0);
+ sv_func_t *f0 = sv_func_new(s, 0, 2, inner, 0);
+ sv_func_t *f1 = sv_func_new(s, 1, 2, outer, 0);
+
+ sv_obj_t *o0 = sv_obj_new(s,0,"inner",
+ (sv_func_t *[]){f0,f0},
+ (int []){0,1},
+ "XY", 0);
+
+ sv_obj_t *o1 = sv_obj_new(s,1,"outer",
+ (sv_func_t *[]){f1,f1},
+ (int []){0,1},
+ "XY", 0);
+
+ sv_scale_t *axis = sv_scale_new(NULL,3,(double []){-MAX_TEETH*3,0,MAX_TEETH*3},NULL,0);
+
+ sv_panel_new_xy(s,0,"spirograph (TM)",
+ axis,axis,
+ (sv_obj_t *[]){o0,o1,NULL},
+ (sv_dim_t *[]){d3,d0,d1,d2,NULL},
+ 0);
- sushiv_new_objective(s,1,"outer",
- 0,NULL,
- (int []){1,1},
- (int []){0,1},
- "XY", 0);
+ sv_dim_set_value(d0,1,100);
+ sv_dim_set_value(d1,1,70);
+ sv_dim_set_value(d2,1,50);
- sushiv_scale_t *axis = scale_new(3,(double []){-MAX_TEETH*3,0,MAX_TEETH*3},NULL);
-
- sushiv_new_panel_xy(s,2,"spirograph (TM)",
- axis,axis,
- (int []){0,1,-1},
- (int []){3,0,1,2,-1},
- 0);
-
- sushiv_dimension_set_value(s,0,1,100);
- sushiv_dimension_set_value(s,1,1,70);
- sushiv_dimension_set_value(s,2,1,50);
-
return 0;
}
Modified: trunk/sushivision/function.c
===================================================================
--- trunk/sushivision/function.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/function.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -25,22 +25,25 @@
#include <errno.h>
#include "internal.h"
-int sushiv_new_function(sushiv_instance_t *s,
- int number,
- int out_vals,
- void(*callback)(double *,double *),
- unsigned flags){
- sushiv_function_t *f;
+sv_func_t *sv_func_new(sv_instance_t *in,
+ int number,
+ int out_vals,
+ void(*callback)(double *,double *),
+ unsigned flags){
+ sv_instance_t *s = (sv_instance_t *)in; // unwrap
+ sv_func_t *f;
if(number<0){
fprintf(stderr,"Function number must be >= 0\n");
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
if(number<s->functions){
if(s->function_list[number]!=NULL){
fprintf(stderr,"Function number %d already exists\n",number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
}else{
if(s->functions == 0){
@@ -58,7 +61,7 @@
f->sushi = s;
f->callback = callback;
f->outputs = out_vals;
- f->type = SUSHIV_FUNC_BASIC;
+ f->type = SV_FUNC_BASIC;
- return 0;
+ return f;
}
Modified: trunk/sushivision/gtksucks.c
===================================================================
--- trunk/sushivision/gtksucks.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/gtksucks.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -49,14 +49,14 @@
/* Note that this only works after the widget is realized, as
realization will clobber the event mask */
-void gtk_widget_set_sensitive_fixup(GtkWidget *w, gboolean state){
+void _gtk_widget_set_sensitive_fixup(GtkWidget *w, gboolean state){
gdk_threads_enter();
gtk_widget_set_sensitive(w,state);
if(state)
gtk_widget_add_events (w, GDK_ALL_EVENTS_MASK);
else
- gtk_widget_remove_events (w, GDK_ALL_EVENTS_MASK);
+ _gtk_widget_remove_events (w, GDK_ALL_EVENTS_MASK);
gdk_threads_leave();
}
@@ -85,7 +85,7 @@
/* gtk provides a 'gtk_widget_add_events' but not a converse to remove
events. 'gtk_widget_set_events' only works pre-realization, so it
can't be used instead. */
-void gtk_widget_remove_events (GtkWidget *widget,
+void _gtk_widget_remove_events (GtkWidget *widget,
gint events){
g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -138,7 +138,7 @@
initialized and made a copy of the Button's class structure and
handlers */
-static gboolean gtk_button_button_press_new (GtkWidget *widget,
+static gboolean _gtk_button_button_press_new (GtkWidget *widget,
GdkEventButton *event){
if (event->type == GDK_BUTTON_PRESS){
@@ -158,7 +158,7 @@
return FALSE;
}
-static gboolean gtk_button_button_release_new (GtkWidget *widget,
+static gboolean _gtk_button_button_release_new (GtkWidget *widget,
GdkEventButton *event){
if (event->button == 1) {
GtkButton *button = GTK_BUTTON (widget);
@@ -170,27 +170,27 @@
}
/* does not currently handle all button types, just the ones we use */
-void gtk_button3_fixup(){
+void _gtk_button3_fixup(){
GtkWidget *bb = gtk_button_new();
GtkWidgetClass *bc = GTK_WIDGET_GET_CLASS(bb);
- bc->button_press_event = gtk_button_button_press_new;
- bc->button_release_event = gtk_button_button_release_new;
+ bc->button_press_event = _gtk_button_button_press_new;
+ bc->button_release_event = _gtk_button_button_release_new;
bb = gtk_radio_button_new(NULL);
bc = GTK_WIDGET_GET_CLASS(bb);
- bc->button_press_event = gtk_button_button_press_new;
- bc->button_release_event = gtk_button_button_release_new;
+ bc->button_press_event = _gtk_button_button_press_new;
+ bc->button_release_event = _gtk_button_button_release_new;
bb = gtk_toggle_button_new();
bc = GTK_WIDGET_GET_CLASS(bb);
- bc->button_press_event = gtk_button_button_press_new;
- bc->button_release_event = gtk_button_button_release_new;
+ bc->button_press_event = _gtk_button_button_press_new;
+ bc->button_release_event = _gtk_button_button_release_new;
bb = gtk_check_button_new();
bc = GTK_WIDGET_GET_CLASS(bb);
- bc->button_press_event = gtk_button_button_press_new;
- bc->button_release_event = gtk_button_button_release_new;
+ bc->button_press_event = _gtk_button_button_press_new;
+ bc->button_release_event = _gtk_button_button_release_new;
// just leak 'em. they'll go away on exit.
@@ -225,14 +225,14 @@
pthread_mutex_unlock(&gdkm);
}
-void gtk_mutex_fixup(){
+void _gtk_mutex_fixup(){
pthread_mutexattr_init(&gdkma);
pthread_mutexattr_settype(&gdkma,PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&gdkm,&gdkma);
gdk_threads_set_lock_functions(recursive_gdk_lock,recursive_gdk_unlock);
}
-pthread_mutex_t *gtk_get_mutex(void){
+pthread_mutex_t *_gtk_get_mutex(void){
return &gdkm;
}
@@ -254,11 +254,11 @@
return FALSE;
}
-GtkWidget *gtk_menu_new_twocol(GtkWidget *bind,
- propmap **items,
- void *callback_data){
+GtkWidget *_gtk_menu_new_twocol(GtkWidget *bind,
+ _sv_propmap_t **items,
+ void *callback_data){
- propmap *ptr = *items++;
+ _sv_propmap_t *ptr = *items++;
GtkWidget *ret = gtk_menu_new();
/* create packable boxes for labels, put left labels in */
@@ -290,7 +290,7 @@
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (ptr->callback), callback_data);
if(ptr->submenu){
- GtkWidget *submenu = gtk_menu_new_twocol(ret,ptr->submenu,callback_data);
+ GtkWidget *submenu = _gtk_menu_new_twocol(ret,ptr->submenu,callback_data);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu);
}
}
@@ -308,7 +308,7 @@
return ret;
}
-GtkWidget *gtk_menu_get_item(GtkMenu *m, int pos){
+GtkWidget *_gtk_menu_get_item(GtkMenu *m, int pos){
int i=0;
GList *l=gtk_container_get_children (GTK_CONTAINER(m));
@@ -326,7 +326,7 @@
return NULL;
}
-int gtk_menu_item_position(GtkWidget *w){
+int _gtk_menu_item_position(GtkWidget *w){
//GtkMenuItem *mi = GTK_MENU_ITEM(w);
GtkWidget *box = gtk_widget_get_parent(w);
GList *l = gtk_container_get_children(GTK_CONTAINER(box));
@@ -344,11 +344,11 @@
return 0;
}
-void gtk_menu_alter_item_label(GtkMenu *m, int pos, char *text){
+void _gtk_menu_alter_item_label(GtkMenu *m, int pos, char *text){
GList *l;
GtkWidget *box=NULL;
GtkWidget *label=NULL;
- GtkWidget *item = gtk_menu_get_item(m, pos);
+ GtkWidget *item = _gtk_menu_get_item(m, pos);
if(!item)return;
l=gtk_container_get_children (GTK_CONTAINER(item));
@@ -366,11 +366,11 @@
gtk_label_set_markup(GTK_LABEL(label),text);
}
-void gtk_menu_alter_item_right(GtkMenu *m, int pos, char *text){
+void _gtk_menu_alter_item_right(GtkMenu *m, int pos, char *text){
GList *l;
GtkWidget *box=NULL;
GtkWidget *label=NULL;
- GtkWidget *item = gtk_menu_get_item(m, pos);
+ GtkWidget *item = _gtk_menu_get_item(m, pos);
if(!item)return;
l=gtk_container_get_children (GTK_CONTAINER(item));
@@ -392,7 +392,7 @@
/**********************************************************************/
/* unlock text combo boxes to support markup as well as straight text */
-GtkWidget * gtk_combo_box_new_markup (void){
+GtkWidget *_gtk_combo_box_new_markup (void){
GtkWidget *combo_box;
GtkCellRenderer *cell;
GtkListStore *store;
@@ -423,7 +423,7 @@
The below lets us freeze/unfreeze an auto-resizing box's
child at its current size without queueing resize events. */
-void gtk_box_freeze_child (GtkBox *box,
+void _gtk_box_freeze_child (GtkBox *box,
GtkWidget *child){
GList *list;
GtkBoxChild *child_info = NULL;
@@ -446,7 +446,7 @@
}
}
-void gtk_box_unfreeze_child (GtkBox *box,
+void _gtk_box_unfreeze_child (GtkBox *box,
GtkWidget *child){
GList *list;
GtkBoxChild *child_info = NULL;
Modified: trunk/sushivision/gtksucks.h
===================================================================
--- trunk/sushivision/gtksucks.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/gtksucks.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -22,22 +22,22 @@
#ifndef _GTK_SUCKS_H_
#define _GTK_SUCKS_H_
-extern void gtk_widget_set_sensitive_fixup(GtkWidget *w, gboolean state);
-extern void gtk_widget_remove_events (GtkWidget *widget, gint events);
-extern void gtk_button3_fixup();
-extern void gtk_mutex_fixup();
-extern pthread_mutex_t *gtk_get_mutex();
+extern void _gtk_widget_set_sensitive_fixup(GtkWidget *w, gboolean state);
+extern void _gtk_widget_remove_events (GtkWidget *widget, gint events);
+extern void _gtk_button3_fixup();
+extern void _gtk_mutex_fixup();
+extern pthread_mutex_t *_gtk_get_mutex();
-extern GtkWidget *gtk_menu_new_twocol(GtkWidget *bind,
- propmap **items,
- void *callback_data);
-extern GtkWidget *gtk_menu_get_item(GtkMenu *m, int pos);
-extern int gtk_menu_item_position(GtkWidget *w);
-extern void gtk_menu_alter_item_label(GtkMenu *m, int pos, char *text);
-extern void gtk_menu_alter_item_right(GtkMenu *m, int pos, char *text);
-extern GtkWidget * gtk_combo_box_new_markup (void);
+extern GtkWidget *_gtk_menu_new_twocol(GtkWidget *bind,
+ _sv_propmap_t **items,
+ void *callback_data);
+extern GtkWidget *_gtk_menu_get_item(GtkMenu *m, int pos);
+extern int _gtk_menu_item_position(GtkWidget *w);
+extern void _gtk_menu_alter_item_label(GtkMenu *m, int pos, char *text);
+extern void _gtk_menu_alter_item_right(GtkMenu *m, int pos, char *text);
+extern GtkWidget * _gtk_combo_box_new_markup (void);
-extern void gtk_box_freeze_child (GtkBox *box, GtkWidget *child);
-extern void gtk_box_unfreeze_child (GtkBox *box, GtkWidget *child);
+extern void _gtk_box_freeze_child (GtkBox *box, GtkWidget *child);
+extern void _gtk_box_unfreeze_child (GtkBox *box, GtkWidget *child);
#endif
Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/internal.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -19,7 +19,7 @@
*
*/
-typedef struct sushiv_instance_undo sushiv_instance_undo_t;
+typedef struct _sv_instance_undo _sv_instance_undo_t;
#include <time.h>
#include <signal.h>
@@ -29,14 +29,15 @@
#include "sushivision.h"
// used to glue numeric settings to semantic labels for menus/save files
-typedef struct propmap {
+typedef struct _sv_propmap _sv_propmap_t;
+struct _sv_propmap {
char *left;
int value;
-
+
char *right;
- struct propmap **submenu;
- void (*callback)(sushiv_panel_t *, GtkWidget *);
-} propmap;
+ _sv_propmap_t **submenu;
+ void (*callback)(sv_panel_t *, GtkWidget *);
+};
#include "mapping.h"
#include "slice.h"
@@ -52,16 +53,16 @@
#include "xml.h"
#include "gtksucks.h"
-union sushiv_panel_subtype {
- sushiv_panelxy_t *xy;
- sushiv_panel1d_t *p1;
- sushiv_panel2d_t *p2;
+union _sv_panel_subtype {
+ _sv_panelxy_t *xy;
+ _sv_panel1d_t *p1;
+ _sv_panel2d_t *p2;
};
// undo history; the panel types vary slightly, but only slightly, so
// for now we use a master undo type which leaves one or two fields
// unused for a given panel.
-typedef struct sushiv_panel_undo {
+typedef struct {
int *mappings;
double *scale_vals[3];
@@ -80,24 +81,24 @@
int oversample_n;
int oversample_d;
-} sushiv_panel_undo_t;
+} _sv_panel_undo_t;
typedef union {
- _sushiv_bythread_cache_1d p1;
- _sushiv_bythread_cache_xy xy;
- _sushiv_bythread_cache_2d p2;
-} _sushiv_bythread_cache;
+ _sv_bythread_cache_1d_t p1;
+ _sv_bythread_cache_xy_t xy;
+ _sv_bythread_cache_2d_t p2;
+} _sv_bythread_cache_t;
-struct sushiv_panel_internal {
+struct _sv_panel_internal {
GtkWidget *toplevel;
GtkWidget *topbox;
GtkWidget *plotbox;
GtkWidget *graph;
- Spinner *spinner;
+ _sv_spinner_t *spinner;
GtkWidget *popmenu;
- enum sushiv_background bg_type;
- sushiv_dim_widget_t **dim_scales;
+ enum sv_background bg_type;
+ _sv_dim_widget_t **dim_scales;
int oldbox_active;
int realized;
@@ -125,78 +126,76 @@
int def_oversample_n;
int def_oversample_d;
-
// function bundles
- void (*realize)(sushiv_panel_t *p);
- int (*map_action)(sushiv_panel_t *p, _sushiv_bythread_cache *c);
- int (*legend_action)(sushiv_panel_t *p);
- int (*compute_action)(sushiv_panel_t *p, _sushiv_bythread_cache *c);
- void (*request_compute)(sushiv_panel_t *p);
- void (*crosshair_action)(sushiv_panel_t *p);
- void (*print_action)(sushiv_panel_t *p, cairo_t *c, int w, int h);
- int (*save_action)(sushiv_panel_t *p, xmlNodePtr pn);
- int (*load_action)(sushiv_panel_t *p, sushiv_panel_undo_t *u, xmlNodePtr pn, int warn);
+ void (*realize)(sv_panel_t *p);
+ int (*map_action)(sv_panel_t *p, _sv_bythread_cache_t *c);
+ int (*legend_action)(sv_panel_t *p);
+ int (*compute_action)(sv_panel_t *p, _sv_bythread_cache_t *c);
+ void (*request_compute)(sv_panel_t *p);
+ void (*crosshair_action)(sv_panel_t *p);
+ void (*print_action)(sv_panel_t *p, cairo_t *c, int w, int h);
+ int (*save_action)(sv_panel_t *p, xmlNodePtr pn);
+ int (*load_action)(sv_panel_t *p, _sv_panel_undo_t *u, xmlNodePtr pn, int warn);
- void (*undo_log)(sushiv_panel_undo_t *u, sushiv_panel_t *p);
- void (*undo_restore)(sushiv_panel_undo_t *u, sushiv_panel_t *p);
+ void (*undo_log)(_sv_panel_undo_t *u, sv_panel_t *p);
+ void (*undo_restore)(_sv_panel_undo_t *u, sv_panel_t *p);
};
-struct sushiv_instance_undo {
- sushiv_panel_undo_t *panels;
+struct _sv_instance_undo {
+ _sv_panel_undo_t *panels;
double *dim_vals[3];
};
-struct sushiv_instance_internal {
+struct _sv_instance_internal {
int undo_level;
int undo_suspend;
- sushiv_instance_undo_t **undo_stack;
+ _sv_instance_undo_t **undo_stack;
};
-extern void _sushiv_realize_panel(sushiv_panel_t *p);
-extern void _sushiv_clean_exit(int sig);
-extern void _sushiv_wake_workers();
+extern void _sv_clean_exit(int sig);
+extern void _sv_wake_workers();
+extern int _sv_main_save();
+extern int _sv_main_load();
+extern void _sv_first_load_warning(int *);
-extern int _sushiv_new_panel(sushiv_instance_t *s,
- int number,
- const char *name,
- int *objectives,
- int *dimensions,
- unsigned flags);
-extern void set_map_throttle_time(sushiv_panel_t *p);
-extern void _sushiv_panel_dirty_map(sushiv_panel_t *p);
-extern void _sushiv_panel_dirty_map_throttled(sushiv_panel_t *p);
-extern void _sushiv_panel_dirty_legend(sushiv_panel_t *p);
-extern void _sushiv_panel_dirty_plot(sushiv_panel_t *p);
-extern void _sushiv_panel_recompute(sushiv_panel_t *p);
-extern void _sushiv_panel_clean_map(sushiv_panel_t *p);
-extern void _sushiv_panel_clean_legend(sushiv_panel_t *p);
-extern void _sushiv_panel_clean_plot(sushiv_panel_t *p);
+extern sv_panel_t *_sv_panel_new(sv_instance_t *s,
+ int number,
+ char *name,
+ sv_obj_t **objectives,
+ sv_dim_t **dimensions,
+ unsigned flags);
+extern void _sv_panel_realize(sv_panel_t *p);
+extern void _sv_panel_dirty_map(sv_panel_t *p);
+extern void _sv_panel_dirty_map_throttled(sv_panel_t *p);
+extern void _sv_panel_dirty_legend(sv_panel_t *p);
+extern void _sv_panel_dirty_plot(sv_panel_t *p);
+extern void _sv_panel_recompute(sv_panel_t *p);
+extern void _sv_panel_clean_map(sv_panel_t *p);
+extern void _sv_panel_clean_legend(sv_panel_t *p);
+extern void _sv_panel_clean_plot(sv_panel_t *p);
+extern void _sv_panel_undo_log(sv_panel_t *p, _sv_panel_undo_t *u);
+extern void _sv_panel_undo_restore(sv_panel_t *p, _sv_panel_undo_t *u);
+extern void _sv_panel_update_menus(sv_panel_t *p);
+extern int _sv_panel_save(sv_panel_t *p, xmlNodePtr instance);
+extern int _sv_panel_load(sv_panel_t *p, _sv_panel_undo_t *u, xmlNodePtr instance, int warn);
-extern void _sushiv_undo_log(sushiv_instance_t *s);
-extern void _sushiv_undo_push(sushiv_instance_t *s);
-extern void _sushiv_undo_pop(sushiv_instance_t *s);
-extern void _sushiv_undo_suspend(sushiv_instance_t *s);
-extern void _sushiv_undo_resume(sushiv_instance_t *s);
-extern void _sushiv_undo_restore(sushiv_instance_t *s);
-extern void _sushiv_undo_up(sushiv_instance_t *s);
-extern void _sushiv_undo_down(sushiv_instance_t *s);
+extern void _sv_panel1d_mark_recompute_linked(sv_panel_t *p);
+extern void _sv_panel1d_update_linked_crosshairs(sv_panel_t *p, int xflag, int yflag);
-extern void _sushiv_panel_undo_log(sushiv_panel_t *p, sushiv_panel_undo_t *u);
-extern void _sushiv_panel_undo_restore(sushiv_panel_t *p, sushiv_panel_undo_t *u);
+extern void _sv_map_set_throttle_time(sv_panel_t *p);
-extern void _sushiv_panel1d_mark_recompute_linked(sushiv_panel_t *p);
-extern void _sushiv_panel1d_update_linked_crosshairs(sushiv_panel_t *p, int xflag, int yflag);
-extern void _sushiv_panel_update_menus(sushiv_panel_t *p);
+extern void _sv_undo_log(sv_instance_t *s);
+extern void _sv_undo_push(sv_instance_t *s);
+extern void _sv_undo_pop(sv_instance_t *s);
+extern void _sv_undo_suspend(sv_instance_t *s);
+extern void _sv_undo_resume(sv_instance_t *s);
+extern void _sv_undo_restore(sv_instance_t *s);
+extern void _sv_undo_up(sv_instance_t *s);
+extern void _sv_undo_down(sv_instance_t *s);
-extern int save_main();
-extern int load_main();
-extern int _save_panel(sushiv_panel_t *p, xmlNodePtr instance);
-extern int _load_panel(sushiv_panel_t *p, sushiv_panel_undo_t *u, xmlNodePtr instance, int warn);
-extern void first_load_warning(int *);
-
-extern sig_atomic_t _sushiv_exiting;
-extern char *filebase;
-extern char *filename;
-extern char *dirname;
-extern char *cwdname;
+extern sig_atomic_t _sv_exiting;
+extern char *_sv_filebase;
+extern char *_sv_filename;
+extern char *_sv_dirname;
+extern char *_sv_cwdname;
Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/main.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -41,14 +41,14 @@
static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t mc = PTHREAD_COND_INITIALIZER;
-sig_atomic_t _sushiv_exiting=0;
+sig_atomic_t _sv_exiting=0;
static int wake_pending = 0;
static int num_threads;
static int instances=0;
-static sushiv_instance_t **instance_list;
+static sv_instance_t **instance_list;
-void _sushiv_wake_workers(){
+void _sv_wake_workers(){
if(instances){
pthread_mutex_lock(&m);
wake_pending = num_threads;
@@ -57,9 +57,9 @@
}
}
-void _sushiv_clean_exit(int sig){
- _sushiv_exiting = 1;
- _sushiv_wake_workers();
+void _sv_clean_exit(int sig){
+ _sv_exiting = 1;
+ _sv_wake_workers();
//signal(sig,SIG_IGN);
if(sig!=SIGINT)
@@ -92,29 +92,29 @@
static void *worker_thread(void *dummy){
/* set up temporary working space for function rendering; this saves
continuously recreating it in the loop below */
- _sushiv_bythread_cache **c; // [instance][panel]
+ _sv_bythread_cache_t **c; // [instance][panel]
int i,j;
c = calloc(instances,sizeof(*c));
for(j=0;j<instances;j++){
- sushiv_instance_t *s = instance_list[j];
+ sv_instance_t *s = instance_list[j];
c[j] = calloc(s->panels,sizeof(**c));
}
while(1){
- if(_sushiv_exiting)break;
+ if(_sv_exiting)break;
// look for work
{
int flag=0;
// by instance
for(j=0;j<instances;j++){
- sushiv_instance_t *s = instance_list[j];
+ sv_instance_t *s = instance_list[j];
for(i=0;i<s->panels;i++){
- sushiv_panel_t *p = s->panel_list[i];
+ sv_panel_t *p = s->panel_list[i];
- if(_sushiv_exiting)break;
+ if(_sv_exiting)break;
// pending remap work?
gdk_threads_enter();
@@ -122,30 +122,30 @@
// pending computation work?
if(p->private->plot_active){
- spinner_set_busy(p->private->spinner);
+ _sv_spinner_set_busy(p->private->spinner);
flag |= p->private->compute_action(p,&c[j][i]); // may drop lock internally
}
if(p->private->map_active){
int ret = 1;
while(ret){ // favor completing remaps over other ops
- spinner_set_busy(p->private->spinner);
+ _sv_spinner_set_busy(p->private->spinner);
flag |= ret = p->private->map_action(p,&c[j][i]); // may drop lock internally
if(!p->private->map_active)
- set_map_throttle_time(p);
+ _sv_map_set_throttle_time(p);
}
}
// pending legend work?
if(p->private->legend_active){
- spinner_set_busy(p->private->spinner);
+ _sv_spinner_set_busy(p->private->spinner);
flag |= p->private->legend_action(p); // may drop lock internally
}
if(!p->private->plot_active &&
!p->private->legend_active &&
!p->private->map_active)
- spinner_set_idle(p->private->spinner);
+ _sv_spinner_set_idle(p->private->spinner);
}
gdk_threads_leave ();
}
@@ -170,25 +170,25 @@
return _SUSHI_GTKRC_STRING;
}
-static void sushiv_realize_instance(sushiv_instance_t *s){
+static void _sv_instance_realize(sv_instance_t *s){
int i;
for(i=0;i<s->panels;i++)
- _sushiv_realize_panel(s->panel_list[i]);
+ _sv_panel_realize(s->panel_list[i]);
for(i=0;i<s->panels;i++)
if(s->panel_list[i])
s->panel_list[i]->private->request_compute(s->panel_list[i]);
}
-static void sushiv_realize_all(void){
+static void _sv_realize_all(void){
int i;
for(i=0;i<instances;i++)
- sushiv_realize_instance(instance_list[i]);
+ _sv_instance_realize(instance_list[i]);
}
/* externally visible interface */
-sushiv_instance_t *sushiv_new_instance(int number, char *name) {
- sushiv_instance_t *ret;
+sv_instance_t *sv_new(int number, char *name) {
+ sv_instance_t *ret;
if(number<0){
fprintf(stderr,"Instance number must be >= 0\n");
@@ -220,73 +220,73 @@
return ret;
}
-char *appname = NULL;
-char *filename = NULL;
-char *filebase = NULL;
-char *dirname = NULL;
-char *cwdname = NULL;
+char *_sv_appname = NULL;
+char *_sv_filename = NULL;
+char *_sv_filebase = NULL;
+char *_sv_dirname = NULL;
+char *_sv_cwdname = NULL;
int main (int argc, char *argv[]){
int ret;
num_threads = num_proccies();
- gtk_mutex_fixup();
+ _gtk_mutex_fixup();
g_thread_init (NULL);
gtk_init (&argc, &argv);
gdk_threads_init ();
gtk_rc_parse_string(gtkrc_string());
gtk_rc_add_default_file("sushi-gtkrc");
- ret = sushiv_submain(argc,argv);
+ ret = sv_submain(argc,argv);
if(ret)return ret;
gdk_threads_enter();
- sushiv_realize_all();
- gtk_button3_fixup();
+ _sv_realize_all();
+ _gtk_button3_fixup();
- appname = g_get_prgname ();
- cwdname = getcwd(NULL,0);
- dirname = strdup(cwdname);
+ _sv_appname = g_get_prgname ();
+ _sv_cwdname = getcwd(NULL,0);
+ _sv_dirname = strdup(_sv_cwdname);
if(argc>1){
// file to load specified on commandline
if(argv[argc-1][0] != '-'){
- filebase = strdup(argv[argc-1]);
- char *base = strrchr(filebase,'/');
+ _sv_filebase = strdup(argv[argc-1]);
+ char *base = strrchr(_sv_filebase,'/');
// filebase may include a path; pull it off and apply it toward dirname
if(base){
base[0] = '\0';
- char *dirbit = strdup(filebase);
- filebase = base+1;
+ char *dirbit = strdup(_sv_filebase);
+ _sv_filebase = base+1;
if(g_path_is_absolute(dirbit)){
// replace dirname
- free(dirname);
- dirname = dirbit;
+ free(_sv_dirname);
+ _sv_dirname = dirbit;
}else{
// append to dirname
char *buf;
- asprintf(&buf,"%s/%s",dirname,dirbit);
- free(dirname);
- dirname = buf;
+ asprintf(&buf,"%s/%s",_sv_dirname,dirbit);
+ free(_sv_dirname);
+ _sv_dirname = buf;
}
}
- asprintf(&filename,"%s/%s",dirname,filebase);
+ asprintf(&_sv_filename,"%s/%s",_sv_dirname,_sv_filebase);
}
}
- if(!filename || load_main()){
- if(appname){
- char *base = strrchr(appname,'/');
+ if(!_sv_filename || _sv_main_load()){
+ if(_sv_appname){
+ char *base = strrchr(_sv_appname,'/');
if(!base)
- base = appname;
+ base = _sv_appname;
else
base++;
- asprintf(&filebase, "%s.sushi",base);
+ asprintf(&_sv_filebase, "%s.sushi",base);
}else
- filebase = strdup("default.sushi");
- asprintf(&filename,"%s/%s",dirname,filebase);
+ _sv_filebase = strdup("default.sushi");
+ asprintf(&_sv_filename,"%s/%s",_sv_dirname,_sv_filebase);
}
{
@@ -296,15 +296,15 @@
pthread_create(&dummy, NULL, &worker_thread,NULL);
}
- signal(SIGINT,_sushiv_clean_exit);
- //signal(SIGSEGV,_sushiv_clean_exit);
+ signal(SIGINT,_sv_clean_exit);
+ //signal(SIGSEGV,_sv_clean_exit);
gtk_main ();
gdk_threads_leave();
{
- int (*optional_exit)(void) = dlsym(RTLD_DEFAULT, "sushiv_atexit");
+ int (*optional_exit)(void) = dlsym(RTLD_DEFAULT, "sv_atexit");
if(optional_exit)
return optional_exit();
}
@@ -312,38 +312,38 @@
return 0;
}
-static int save_instance(sushiv_instance_t *s, xmlNodePtr root){
+static int _sv_instance_save(sv_instance_t *s, xmlNodePtr root){
if(!s) return 0;
int i, ret=0;
xmlNodePtr instance = xmlNewChild(root, NULL, (xmlChar *) "instance", NULL);
- xmlNewPropI(instance, "number", s->number);
- xmlNewPropS(instance, "name", s->name);
+ _xmlNewPropI(instance, "number", s->number);
+ _xmlNewPropS(instance, "name", s->name);
// dimension values are independent of panel
for(i=0;i<s->dimensions;i++)
- ret|=_save_dimension(s->dimension_list[i], instance);
+ ret|=_sv_dim_save(s->dimension_list[i], instance);
// objectives have no independent settings
// panel settings (by panel)
for(i=0;i<s->panels;i++)
- ret|=_save_panel(s->panel_list[i], instance);
+ ret|=_sv_panel_save(s->panel_list[i], instance);
return ret;
}
-void first_load_warning(int *warn){
+void _sv_first_load_warning(int *warn){
if(!*warn)
fprintf(stderr,"\nWARNING: The data file to be opened is not a perfect match to\n"
"%s.\n\nThis may be because the file is for a different version of\n"
"the executable, or because it is is not a save file for \n%s at all.\n\n"
- "Specific warnings follow:\n\n",appname,appname);
+ "Specific warnings follow:\n\n",_sv_appname,_sv_appname);
*warn = 1;
}
-static int load_instance(sushiv_instance_t *s, xmlNodePtr in, int warn){
+static int _sv_instance_load(sv_instance_t *s, xmlNodePtr in, int warn){
int i;
// piggyback off undo (as it already goes through the trouble of
@@ -351,21 +351,21 @@
// if this instance has an undo stack, pop it all, then log current state into it
s->private->undo_level=0;
- _sushiv_undo_log(s);
+ _sv_undo_log(s);
- sushiv_instance_undo_t *u = s->private->undo_stack[s->private->undo_level];
+ _sv_instance_undo_t *u = s->private->undo_stack[s->private->undo_level];
// load dimensions
for(i=0;i<s->dimensions;i++){
- sushiv_dimension_t *d = s->dimension_list[i];
+ sv_dim_t *d = s->dimension_list[i];
if(d){
- xmlNodePtr dn = xmlGetChildI(in,"dimension","number",d->number);
+ xmlNodePtr dn = _xmlGetChildI(in,"dimension","number",d->number);
if(!dn){
- first_load_warning(&warn);
+ _sv_first_load_warning(&warn);
fprintf(stderr,"Could not find data for dimension \"%s\" in save file.\n",
d->name);
}else{
- warn |= _load_dimension(d,u,dn,warn);
+ warn |= _sv_dim_load(d,u,dn,warn);
xmlFreeNode(dn);
}
}
@@ -373,15 +373,15 @@
// load panels
for(i=0;i<s->panels;i++){
- sushiv_panel_t *p = s->panel_list[i];
+ sv_panel_t *p = s->panel_list[i];
if(p){
- xmlNodePtr pn = xmlGetChildI(in,"panel","number",p->number);
+ xmlNodePtr pn = _xmlGetChildI(in,"panel","number",p->number);
if(!pn){
- first_load_warning(&warn);
+ _sv_first_load_warning(&warn);
fprintf(stderr,"Could not find data for panel \"%s\" in save file.\n",
p->name);
}else{
- warn |= _load_panel(p,u->panels+i,pn,warn);
+ warn |= _sv_panel_load(p,u->panels+i,pn,warn);
xmlFreeNode(pn);
}
}
@@ -392,7 +392,7 @@
while(node){
if (node->type == XML_ELEMENT_NODE) {
xmlChar *name = xmlGetProp(node, (xmlChar *)"name");
- first_load_warning(&warn);
+ _sv_first_load_warning(&warn);
if(name){
fprintf(stderr,"Save file contains data for nonexistant object \"%s\".\n",
name);
@@ -404,14 +404,14 @@
}
// effect the loaded values
- _sushiv_undo_suspend(s);
- _sushiv_undo_restore(s);
- _sushiv_undo_resume(s);
+ _sv_undo_suspend(s);
+ _sv_undo_restore(s);
+ _sv_undo_resume(s);
return warn;
}
-int save_main(){
+int _sv_main_save(){
xmlDocPtr doc = NULL;
xmlNodePtr root_node = NULL;
int i, ret=0;
@@ -419,14 +419,14 @@
LIBXML_TEST_VERSION;
doc = xmlNewDoc((xmlChar *)"1.0");
- root_node = xmlNewNode(NULL, (xmlChar *)appname);
+ root_node = xmlNewNode(NULL, (xmlChar *)_sv_appname);
xmlDocSetRootElement(doc, root_node);
// save each instance
for(i=0;i<instances;i++)
- ret |= save_instance(instance_list[i],root_node);
+ ret |= _sv_instance_save(instance_list[i],root_node);
- xmlSaveFormatFileEnc(filename, doc, "UTF-8", 1);
+ xmlSaveFormatFileEnc(_sv_filename, doc, "UTF-8", 1);
xmlFreeDoc(doc);
xmlCleanupParser();
@@ -434,7 +434,7 @@
return ret;
}
-int load_main(){
+int _sv_main_load(){
xmlDoc *doc = NULL;
xmlNode *root = NULL;
int fd,warn=0;
@@ -442,13 +442,13 @@
LIBXML_TEST_VERSION;
- fd = open(filename, O_RDONLY);
+ fd = open(_sv_filename, O_RDONLY);
if(fd<0){
GtkWidget *dialog = gtk_message_dialog_new (NULL,0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Error opening file '%s': %s",
- filename, strerror (errno));
+ _sv_filename, strerror (errno));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return 1;
@@ -462,7 +462,7 @@
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Error parsing file '%s'",
- filename);
+ _sv_filename);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return 1;
@@ -472,16 +472,16 @@
// load each instance
for(i=0;i<instances;i++){
- sushiv_instance_t *s = instance_list[i];
+ sv_instance_t *s = instance_list[i];
if(s){
- xmlNodePtr in = xmlGetChildI(root,"instance","number",s->number);
+ xmlNodePtr in = _xmlGetChildI(root,"instance","number",s->number);
if(!in){
- first_load_warning(&warn);
+ _sv_first_load_warning(&warn);
fprintf(stderr,"Could not find data for instance \"%s\" in save file.\n",
s->name);
}
// load even if no node; need to set fallbacks
- warn |= load_instance(s,in,warn);
+ warn |= _sv_instance_load(s,in,warn);
if(in)xmlFreeNode(in);
}
}
@@ -492,8 +492,8 @@
while(node){
if (node->type == XML_ELEMENT_NODE) {
char *name = NULL;
- xmlGetPropS(node, "name", &name);
- first_load_warning(&warn);
+ _xmlGetPropS(node, "name", &name);
+ _sv_first_load_warning(&warn);
if(name){
fprintf(stderr,"Save file contains data for nonexistant object \"%s\".\n",
name);
Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/mapping.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -25,7 +25,7 @@
#include "internal.h"
// val is .16; lcolor has pigment added in the range [0,mul]
-static void scalloped_colorwheel(int val, int mul, lcolor *r){
+static void _sv_mapping_scalloped_colorwheel(int val, int mul, _sv_lcolor_t *r){
int category = val*12;
if(category<0)return;
@@ -63,7 +63,7 @@
}
}
-static void smooth_colorwheel(int val, int mul, lcolor *r){
+static void _sv_mapping_smooth_colorwheel(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
r->a += mul;
if(val < 37450){ // 4/7
@@ -120,7 +120,7 @@
}
}
-static void white(int val, int mul, lcolor *r){
+static void _sv_mapping_white(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += mul;
@@ -129,34 +129,34 @@
r->b += val;
}
-static void red(int val, int mul, lcolor *r){
+static void _sv_mapping_red(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += mul;
r->r += val;
}
-static void green(int val, int mul, lcolor *r){
+static void _sv_mapping_green(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += mul;
r->g += val;
}
-static void blue(int val, int mul, lcolor *r){
+static void _sv_mapping_blue(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += mul;
r->b += val;
}
-static void black_a(int val, int mul, lcolor *r){
+static void _sv_mapping_black_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
}
-static void white_a(int val, int mul, lcolor *r){
+static void _sv_mapping_white_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
@@ -165,21 +165,21 @@
r->b += val;
}
-static void red_a(int val, int mul, lcolor *r){
+static void _sv_mapping_red_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
r->r += val;
}
-static void green_a(int val, int mul, lcolor *r){
+static void _sv_mapping_green_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
r->g += val;
}
-static void blue_a(int val, int mul, lcolor *r){
+static void _sv_mapping_blue_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
@@ -188,7 +188,7 @@
r->b += val;
}
-static void yellow_a(int val, int mul, lcolor *r){
+static void _sv_mapping_yellow_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
@@ -196,7 +196,7 @@
r->g += val;
}
-static void cyan_a(int val, int mul, lcolor *r){
+static void _sv_mapping_cyan_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
@@ -204,7 +204,7 @@
r->b += val;
}
-static void purple_a(int val, int mul, lcolor *r){
+static void _sv_mapping_purple_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
@@ -212,7 +212,7 @@
r->b += val;
}
-static void gray_a(int val, int mul, lcolor *r){
+static void _sv_mapping_gray_a(int val, int mul, _sv_lcolor_t *r){
if(val<0)return;
val = (val*mul)>>16;
r->a += val;
@@ -221,12 +221,12 @@
r->b += val>>1;
}
-static void inactive(int val, int mul, lcolor *r){
+static void _sv_mapping_inactive(int val, int mul, _sv_lcolor_t *r){
return;
}
// premultiplied alpha
-static ucolor normal_mix(ucolor in, ucolor bg){
+static _sv_ucolor_t _sv_mapping_normal_mix(_sv_ucolor_t in, _sv_ucolor_t bg){
u_int32_t sa, s1, s2, d1, d2;
if(in.c.a==255) return in;
@@ -254,10 +254,10 @@
d2 |= 0x01000100 - ((d2 >> 8) & 0x00ff00ff);
d2 &= 0x00ff00ff;
- return (ucolor)(d1 | (d2 << 8));
+ return (_sv_ucolor_t)(d1 | (d2 << 8));
}
-static ucolor overlay_mix(ucolor in, ucolor bg){
+static _sv_ucolor_t _sv_mapping_overlay_mix(_sv_ucolor_t in, _sv_ucolor_t bg){
int r = bg.c.r + in.c.r;
int g = bg.c.g + in.c.g;
int b = bg.c.b + in.c.b;
@@ -276,68 +276,68 @@
if(g<0) g = 0;
if(b<0) b = 0;
- return (ucolor)(u_int32_t)((r<<16) + (g<<8) + b);
+ return (_sv_ucolor_t)(u_int32_t)((r<<16) + (g<<8) + b);
}
-static ucolor inactive_mix(ucolor in, ucolor bg){
+static _sv_ucolor_t _sv_mapping_inactive_mix(_sv_ucolor_t in, _sv_ucolor_t bg){
return bg;
}
-static void (*mapfunc[])(int, int, lcolor *)={
- smooth_colorwheel,
- scalloped_colorwheel,
- white,
- red,
- green,
- blue,
- red,
- green,
- blue,
- inactive
+static void (*mapfunc[])(int, int, _sv_lcolor_t *)={
+ _sv_mapping_smooth_colorwheel,
+ _sv_mapping_scalloped_colorwheel,
+ _sv_mapping_white,
+ _sv_mapping_red,
+ _sv_mapping_green,
+ _sv_mapping_blue,
+ _sv_mapping_red,
+ _sv_mapping_green,
+ _sv_mapping_blue,
+ _sv_mapping_inactive
};
-static ucolor (*mixfunc[])(ucolor, ucolor)={
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- overlay_mix,
- overlay_mix,
- overlay_mix,
- inactive_mix
+static _sv_ucolor_t (*mixfunc[])(_sv_ucolor_t, _sv_ucolor_t)={
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_overlay_mix,
+ _sv_mapping_overlay_mix,
+ _sv_mapping_overlay_mix,
+ _sv_mapping_inactive_mix
};
-static propmap *mapnames[]={
- &(propmap){"smooth colorwheel",0, NULL, NULL, NULL},
- &(propmap){"scalloped colorwheel",1, NULL, NULL, NULL},
- &(propmap){"grayscale",2, NULL, NULL, NULL},
- &(propmap){"red",3, NULL, NULL, NULL},
- &(propmap){"green",4, NULL, NULL, NULL},
- &(propmap){"blue",5, NULL, NULL, NULL},
- &(propmap){"red overlay",6, NULL, NULL, NULL},
- &(propmap){"green overlay",7, NULL, NULL, NULL},
- &(propmap){"blue overlay",8, NULL, NULL, NULL},
- &(propmap){"inactive",9, NULL, NULL, NULL},
+static _sv_propmap_t *mapnames[]={
+ &(_sv_propmap_t){"smooth colorwheel",0, NULL, NULL, NULL},
+ &(_sv_propmap_t){"scalloped colorwheel",1, NULL, NULL, NULL},
+ &(_sv_propmap_t){"grayscale",2, NULL, NULL, NULL},
+ &(_sv_propmap_t){"red",3, NULL, NULL, NULL},
+ &(_sv_propmap_t){"green",4, NULL, NULL, NULL},
+ &(_sv_propmap_t){"blue",5, NULL, NULL, NULL},
+ &(_sv_propmap_t){"red overlay",6, NULL, NULL, NULL},
+ &(_sv_propmap_t){"green overlay",7, NULL, NULL, NULL},
+ &(_sv_propmap_t){"blue overlay",8, NULL, NULL, NULL},
+ &(_sv_propmap_t){"inactive",9, NULL, NULL, NULL},
NULL
};
-int num_mappings(){
+int _sv_mapping_names(){
int i=0;
while(mapnames[i])i++;
return i;
}
-char *mapping_name(int i){
+char *_sv_mapping_name(int i){
return mapnames[i]->left;
}
-propmap **mapping_map(){
+_sv_propmap_t **_sv_mapping_map(){
return mapnames;
}
-void mapping_setup(mapping *m, float lo, float hi, int funcnum){
+void _sv_mapping_setup(_sv_mapping_t *m, float lo, float hi, int funcnum){
m->low = lo;
m->high = hi;
m->i_range = 1./(hi-lo);
@@ -345,7 +345,7 @@
m->mixfunc = mixfunc[funcnum];
}
-void mapping_set_lo(mapping *m, float lo){
+void _sv_mapping_set_lo(_sv_mapping_t *m, float lo){
m->low = lo;
if(m->high-m->low>0.)
m->i_range = 1./(m->high-m->low);
@@ -353,7 +353,7 @@
m->i_range=0;
}
-void mapping_set_hi(mapping *m, float hi){
+void _sv_mapping_set_hi(_sv_mapping_t *m, float hi){
m->high=hi;
if(m->high-m->low>0.)
m->i_range = 1./(m->high-m->low);
@@ -361,13 +361,13 @@
m->i_range=0;
}
-void mapping_set_func(mapping *m, int funcnum){
+void _sv_mapping_set_func(_sv_mapping_t *m, int funcnum){
m->mapnum = funcnum;
m->mapfunc = mapfunc[funcnum];
m->mixfunc = mixfunc[funcnum];
}
-float mapping_val(mapping *m, float in){
+float _sv_mapping_val(_sv_mapping_t *m, float in){
if(m->i_range==0){
return NAN;
}else{
@@ -375,8 +375,8 @@
}
}
-u_int32_t mapping_calc(mapping *m, float in, u_int32_t mix){
- lcolor outc = {0,0,0,0};
+u_int32_t _sv_mapping_calc(_sv_mapping_t *m, float in, u_int32_t mix){
+ _sv_lcolor_t outc = {0,0,0,0};
if(m->i_range==0){
if(in<=m->low)
@@ -390,70 +390,70 @@
m->mapfunc(rint(val*65536.f),255,&outc);
}
- return m->mixfunc( (ucolor)(u_int32_t)((outc.a<<24) + (outc.r<<16) + (outc.g<<8) + outc.b),
- (ucolor)mix).u | 0xff000000;
+ return m->mixfunc( (_sv_ucolor_t)(u_int32_t)((outc.a<<24) + (outc.r<<16) + (outc.g<<8) + outc.b),
+ (_sv_ucolor_t)mix).u | 0xff000000;
}
-int mapping_inactive_p(mapping *m){
- if(m->mapfunc == inactive)return 1;
+int _sv_mapping_inactive_p(_sv_mapping_t *m){
+ if(m->mapfunc == _sv_mapping_inactive)return 1;
return 0;
}
-static void (*mapsolid[])(int, int, lcolor *)={
- black_a,
- red_a,
- green_a,
- blue_a,
- yellow_a,
- cyan_a,
- purple_a,
- gray_a,
- white_a,
- inactive
+static void (*mapsolid[])(int, int, _sv_lcolor_t *)={
+ _sv_mapping_black_a,
+ _sv_mapping_red_a,
+ _sv_mapping_green_a,
+ _sv_mapping_blue_a,
+ _sv_mapping_yellow_a,
+ _sv_mapping_cyan_a,
+ _sv_mapping_purple_a,
+ _sv_mapping_gray_a,
+ _sv_mapping_white_a,
+ _sv_mapping_inactive
};
-static ucolor (*mixsolid[])(ucolor, ucolor)={
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- normal_mix,
- inactive_mix
+static _sv_ucolor_t (*mixsolid[])(_sv_ucolor_t, _sv_ucolor_t)={
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_normal_mix,
+ _sv_mapping_inactive_mix
};
-static propmap *solidnames[]={
- &(propmap){"black",0, NULL,NULL,NULL},
- &(propmap){"red",1, NULL,NULL,NULL},
- &(propmap){"green",2, NULL,NULL,NULL},
- &(propmap){"blue",3, NULL,NULL,NULL},
- &(propmap){"yellow",4, NULL,NULL,NULL},
- &(propmap){"cyan",5, NULL,NULL,NULL},
- &(propmap){"purple",6, NULL,NULL,NULL},
- &(propmap){"gray",7, NULL,NULL,NULL},
- &(propmap){"white",8, NULL,NULL,NULL},
- &(propmap){"inactive",9, NULL,NULL,NULL},
+static _sv_propmap_t *solidnames[]={
+ &(_sv_propmap_t){"black",0, NULL,NULL,NULL},
+ &(_sv_propmap_t){"red",1, NULL,NULL,NULL},
+ &(_sv_propmap_t){"green",2, NULL,NULL,NULL},
+ &(_sv_propmap_t){"blue",3, NULL,NULL,NULL},
+ &(_sv_propmap_t){"yellow",4, NULL,NULL,NULL},
+ &(_sv_propmap_t){"cyan",5, NULL,NULL,NULL},
+ &(_sv_propmap_t){"purple",6, NULL,NULL,NULL},
+ &(_sv_propmap_t){"gray",7, NULL,NULL,NULL},
+ &(_sv_propmap_t){"white",8, NULL,NULL,NULL},
+ &(_sv_propmap_t){"inactive",9, NULL,NULL,NULL},
NULL
};
-int num_solids(){
+int _sv_solid_names(){
int i=0;
while(solidnames[i])i++;
return i;
}
-char *solid_name(int i){
+char *_sv_solid_name(int i){
return solidnames[i]->left;
}
-propmap **solid_map(){
+_sv_propmap_t **_sv_solid_map(){
return solidnames;
}
-void solid_setup(mapping *m, float lo, float hi, int funcnum){
+void _sv_solid_setup(_sv_mapping_t *m, float lo, float hi, int funcnum){
m->low = lo;
m->high = hi;
m->i_range = 1./(hi-lo);
@@ -461,7 +461,7 @@
m->mixfunc = mixsolid[funcnum];
}
-void solid_set_func(mapping *m, int funcnum){
+void _sv_solid_set_func(_sv_mapping_t *m, int funcnum){
m->mapnum = funcnum;
m->mapfunc = mapsolid[funcnum];
m->mixfunc = mixsolid[funcnum];
Modified: trunk/sushivision/mapping.h
===================================================================
--- trunk/sushivision/mapping.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/mapping.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -27,52 +27,52 @@
unsigned char g;
unsigned char r;
unsigned char a;
-} ccolor;
+} _sv_ccolor_t;
#else
typedef struct{
unsigned char a;
unsigned char r;
unsigned char g;
unsigned char b;
-} ccolor;
+} _sv_ccolor_t;
#endif
typedef union {
- ccolor c;
+ _sv_ccolor_t c;
u_int32_t u;
-} ucolor;
+} _sv_ucolor_t;
typedef struct{
long a;
long r;
long g;
long b;
-} lcolor;
+} _sv_lcolor_t;
typedef struct {
int mapnum;
float low;
float high;
float i_range;
- void (*mapfunc)(int val,int mul, lcolor *out);
- ucolor (*mixfunc)(ucolor in, ucolor mix);
-} mapping;
+ void (*mapfunc)(int val,int mul, _sv_lcolor_t *out);
+ _sv_ucolor_t (*mixfunc)(_sv_ucolor_t in, _sv_ucolor_t mix);
+} _sv_mapping_t;
-extern int num_mappings();
-extern char *mapping_name(int i);
-extern void mapping_setup(mapping *m, float lo, float hi, int funcnum);
-extern void mapping_set_lo(mapping *m, float lo);
-extern void mapping_set_hi(mapping *m, float hi);
-extern void mapping_set_func(mapping *m, int funcnum);
-extern float mapping_val(mapping *m, float in);
-extern u_int32_t mapping_calc(mapping *m, float in, u_int32_t mix);
-extern int mapping_inactive_p(mapping *m);
+extern int _sv_mapping_names();
+extern char *_sv_mapping_name(int i);
+extern void _sv_mapping_setup(_sv_mapping_t *m, float lo, float hi, int funcnum);
+extern void _sv_mapping_set_lo(_sv_mapping_t *m, float lo);
+extern void _sv_mapping_set_hi(_sv_mapping_t *m, float hi);
+extern void _sv_mapping_set_func(_sv_mapping_t *m, int funcnum);
+extern float _sv_mapping_val(_sv_mapping_t *m, float in);
+extern u_int32_t _sv_mapping_calc(_sv_mapping_t *m, float in, u_int32_t mix);
+extern int _sv_mapping_inactive_p(_sv_mapping_t *m);
-extern int num_solids();
-extern char *solid_name(int i);
-extern void solid_setup(mapping *m, float lo, float hi, int funcnum);
-extern void solid_set_func(mapping *m, int funcnum);
+extern int _sv_solid_names();
+extern char *_sv_solid_name(int i);
+extern void _sv_solid_setup(_sv_mapping_t *m, float lo, float hi, int funcnum);
+extern void _sv_solid_set_func(_sv_mapping_t *m, int funcnum);
-extern propmap **mapping_map();
-extern propmap **solid_map();
+extern _sv_propmap_t **_sv_mapping_map();
+extern _sv_propmap_t **_sv_solid_map();
Modified: trunk/sushivision/objective.c
===================================================================
--- trunk/sushivision/objective.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/objective.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -25,29 +25,31 @@
#include <errno.h>
#include "internal.h"
-int sushiv_new_objective(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned scalevals,
- double *scaleval_list,
- int *function_map,
- int *output_map,
- char *output_types,
- unsigned flags){
- sushiv_objective_t *o;
- sushiv_objective_internal_t *p;
+sv_obj_t *sv_obj_new(sv_instance_t *in,
+ int number,
+ char *name,
+ sv_func_t **function_map,
+ int *function_output_map,
+ char *output_type_map,
+ unsigned flags){
+
+ sv_instance_t *s = (sv_instance_t *)in; // unwrap
+ sv_obj_t *o;
+ sv_obj_internal_t *p;
int i;
- int outputs = strlen(output_types);
+ int outputs = strlen(output_type_map);
if(number<0){
fprintf(stderr,"Objective number must be >= 0\n");
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
if(number<s->objectives){
if(s->objective_list[number]!=NULL){
fprintf(stderr,"Objective number %d already exists\n",number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
}else{
if(s->objectives == 0){
@@ -64,72 +66,77 @@
/* sanity check the maps */
for(i=0;i<outputs;i++){
- if(function_map[i]<0 ||
- function_map[i]>=s->functions ||
- !s->function_list[function_map[i]]){
- fprintf(stderr,"Objectve %d: function %d does not exist.\n",
- number,function_map[i]);
- return -EINVAL;
+ if(!function_map[i]){
+ fprintf(stderr,"Objectve %d (\"%s\"): function %d missing.\n",
+ number,name,i);
+ errno = -EINVAL;
+ return NULL;
}
- if(output_map[i]<0 ||
- output_map[i]>=s->function_list[function_map[i]]->outputs){
- fprintf(stderr,"Objectve %d: function %d does not have an output %d.\n",
- number,function_map[i],output_map[i]);
- return -EINVAL;
+ if(function_output_map[i]<0 ||
+ function_output_map[i]>=function_map[i]->outputs){
+ fprintf(stderr,"Objectve %d (\"%s\"): function %d does not have an output %d.\n",
+ number,name,function_map[i]->number,function_output_map[i]);
+ errno = -EINVAL;
+ return NULL;
}
- switch(output_types[i]){
+ switch(output_type_map[i]){
case 'X':
if(p->x_func){
fprintf(stderr,"Objective %d: More than one X dimension specified.\n",
number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
- p->x_fout = output_map[i];
- p->x_func = s->function_list[function_map[i]];
+ p->x_fout = function_output_map[i];
+ p->x_func = (sv_func_t *)function_map[i];
break;
case 'Y':
if(p->y_func){
fprintf(stderr,"Objective %d: More than one Y dimension specified.\n",
number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
- p->y_fout = output_map[i];
- p->y_func = s->function_list[function_map[i]];
+ p->y_fout = function_output_map[i];
+ p->y_func = (sv_func_t *)function_map[i];
break;
case 'Z':
if(p->z_func){
fprintf(stderr,"Objective %d: More than one Z dimension specified.\n",
number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
- p->z_fout = output_map[i];
- p->z_func = s->function_list[function_map[i]];
+ p->z_fout = function_output_map[i];
+ p->z_func = (sv_func_t *)function_map[i];
break;
case 'M':
if(p->m_func){
fprintf(stderr,"Objective %d: More than one magnitude [M] dimension specified.\n",
number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
- p->m_fout = output_map[i];
- p->m_func = s->function_list[function_map[i]];
+ p->m_fout = function_output_map[i];
+ p->m_func = (sv_func_t *)function_map[i];
break;
case 'E':
if(p->e2_func){
fprintf(stderr,"Objective %d: More than two error [E] dimensions specified.\n",
number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
if(p->e1_func){
- p->e2_fout = output_map[i];
- p->e2_func = s->function_list[function_map[i]];
+ p->e2_fout = function_output_map[i];
+ p->e2_func = (sv_func_t *)function_map[i];
}else{
- p->e1_fout = output_map[i];
- p->e1_func = s->function_list[function_map[i]];
+ p->e1_fout = function_output_map[i];
+ p->e1_func = (sv_func_t *)function_map[i];
}
break;
@@ -137,40 +144,74 @@
if(p->p2_func){
fprintf(stderr,"Objective %d: More than two phase [P] dimensions specified.\n",
number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
if(p->p1_func){
- p->p2_fout = output_map[i];
- p->p2_func = s->function_list[function_map[i]];
+ p->p2_fout = function_output_map[i];
+ p->p2_func = (sv_func_t *)function_map[i];
}else{
- p->p1_fout = output_map[i];
- p->p1_func = s->function_list[function_map[i]];
+ p->p1_fout = function_output_map[i];
+ p->p1_func = (sv_func_t *)function_map[i];
}
break;
default:
fprintf(stderr,"Objective %d: '%c' is an usupported output type.\n",
- number,output_types[i]);
- return -EINVAL;
+ number,output_type_map[i]);
+ errno = -EINVAL;
+ return NULL;
}
}
o->number = number;
o->name = strdup(name);
- o->output_types = strdup(output_types);
- o->type = SUSHIV_OBJ_BASIC;
+ o->output_types = strdup(output_type_map);
+ o->type = SV_OBJ_BASIC;
o->outputs = outputs;
o->flags = flags;
o->sushi = s;
- if(scalevals>0 && scaleval_list)
- o->scale=scale_new(scalevals, scaleval_list, name);
-
/* copy in the maps */
o->function_map = malloc(outputs * sizeof(*o->function_map));
o->output_map = malloc(outputs * sizeof(*o->output_map));
- memcpy(o->function_map,function_map,outputs * sizeof(*o->function_map));
- memcpy(o->output_map,output_map,outputs * sizeof(*o->output_map));
+ memcpy(o->output_map,function_output_map,outputs * sizeof(*o->output_map));
+
+ for(i=0;i<outputs;i++)
+ o->function_map[i] = function_map[i]->number;
+
+ return o;
+}
+// XXXX need to recompute after
+// XXXX need to add scale cloning to compute to make this safe in callbacks
+int sv_obj_set_scale(sv_obj_t *in,
+ sv_scale_t *scale){
+ sv_obj_t *o = (sv_obj_t *)in; // unwrap
+
+ if(o->scale)
+ sv_scale_free(o->scale); // always a deep copy we own
+
+ o->scale = (sv_scale_t *)sv_scale_copy(scale);
+
+ // redraw the slider
+
return 0;
}
+
+// XXXX need to recompute after
+// XXXX need to add scale cloning to compute to make this safe in callbacks
+int sv_obj_make_scale(sv_obj_t *in,
+ unsigned scalevals,
+ double *scaleval_list,
+ char **scalelabel_list,
+ unsigned flags){
+ sv_obj_t *o = (sv_obj_t *)in; //unwrap
+
+ sv_scale_t *scale = sv_scale_new(o->name,scalevals,scaleval_list,scalelabel_list,0);
+ if(!scale)return errno;
+
+ int ret = sv_obj_set_scale(o,scale);
+ sv_scale_free(scale);
+ return ret;
+}
Modified: trunk/sushivision/objective.h
===================================================================
--- trunk/sushivision/objective.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/objective.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -19,15 +19,15 @@
*
*/
-struct sushiv_objective_internal {
- sushiv_function_t *x_func;
- sushiv_function_t *y_func;
- sushiv_function_t *z_func;
- sushiv_function_t *e1_func;
- sushiv_function_t *e2_func;
- sushiv_function_t *p1_func;
- sushiv_function_t *p2_func;
- sushiv_function_t *m_func;
+struct _sv_obj_internal {
+ sv_func_t *x_func;
+ sv_func_t *y_func;
+ sv_func_t *z_func;
+ sv_func_t *e1_func;
+ sv_func_t *e2_func;
+ sv_func_t *p1_func;
+ sv_func_t *p2_func;
+ sv_func_t *m_func;
int x_fout;
int y_fout;
Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/panel-1d.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -33,27 +33,27 @@
#include "internal.h"
#define LINETYPES 6
-static propmap *line_name[LINETYPES+1] = {
- &(propmap){"line", 0, NULL,NULL,NULL},
- &(propmap){"fat line", 1, NULL,NULL,NULL},
- &(propmap){"fill above", 2, NULL,NULL,NULL},
- &(propmap){"fill below", 3, NULL,NULL,NULL},
- &(propmap){"fill to zero", 4, NULL,NULL,NULL},
- &(propmap){"no line", 5, NULL,NULL,NULL},
+static _sv_propmap_t *line_name[LINETYPES+1] = {
+ &(_sv_propmap_t){"line", 0, NULL,NULL,NULL},
+ &(_sv_propmap_t){"fat line", 1, NULL,NULL,NULL},
+ &(_sv_propmap_t){"fill above", 2, NULL,NULL,NULL},
+ &(_sv_propmap_t){"fill below", 3, NULL,NULL,NULL},
+ &(_sv_propmap_t){"fill to zero", 4, NULL,NULL,NULL},
+ &(_sv_propmap_t){"no line", 5, NULL,NULL,NULL},
NULL
};
#define POINTTYPES 9
-static propmap *point_name[POINTTYPES+1] = {
- &(propmap){"dot", 0, NULL,NULL,NULL},
- &(propmap){"cross", 1, NULL,NULL,NULL},
- &(propmap){"plus", 2, NULL,NULL,NULL},
- &(propmap){"open circle", 3, NULL,NULL,NULL},
- &(propmap){"open square", 4, NULL,NULL,NULL},
- &(propmap){"open triangle", 5, NULL,NULL,NULL},
- &(propmap){"solid circle", 6, NULL,NULL,NULL},
- &(propmap){"solid square", 7, NULL,NULL,NULL},
- &(propmap){"solid triangle", 8, NULL,NULL,NULL},
+static _sv_propmap_t *point_name[POINTTYPES+1] = {
+ &(_sv_propmap_t){"dot", 0, NULL,NULL,NULL},
+ &(_sv_propmap_t){"cross", 1, NULL,NULL,NULL},
+ &(_sv_propmap_t){"plus", 2, NULL,NULL,NULL},
+ &(_sv_propmap_t){"open circle", 3, NULL,NULL,NULL},
+ &(_sv_propmap_t){"open square", 4, NULL,NULL,NULL},
+ &(_sv_propmap_t){"open triangle", 5, NULL,NULL,NULL},
+ &(_sv_propmap_t){"solid circle", 6, NULL,NULL,NULL},
+ &(_sv_propmap_t){"solid square", 7, NULL,NULL,NULL},
+ &(_sv_propmap_t){"solid triangle", 8, NULL,NULL,NULL},
NULL
};
@@ -80,9 +80,9 @@
// called internally, assumes we hold lock
// redraws the data, does not compute the data
-static int _sushiv_panel1d_remap(sushiv_panel_t *p, cairo_t *c){
- sushiv_panel1d_t *p1 = p->subtype->p1;
- Plot *plot = PLOT(p->private->graph);
+static int _sv_panel1d_remap(sv_panel_t *p, cairo_t *c){
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int plot_serialno = p->private->plot_serialno;
int map_serialno = p->private->map_serialno;
@@ -92,13 +92,13 @@
int dw = p1->data_size;
double r = (p1->flip?p1->panel_w:p1->panel_h);
- scalespace rx = (p1->flip?p1->y:p1->x);
- scalespace ry = (p1->flip?p1->x:p1->y);
- scalespace sx = p1->x;
- scalespace sy = p1->y;
- scalespace sx_v = p1->x_v;
- scalespace px = plot->x;
- scalespace py = plot->y;
+ _sv_scalespace_t rx = (p1->flip?p1->y:p1->x);
+ _sv_scalespace_t ry = (p1->flip?p1->x:p1->y);
+ _sv_scalespace_t sx = p1->x;
+ _sv_scalespace_t sy = p1->y;
+ _sv_scalespace_t sx_v = p1->x_v;
+ _sv_scalespace_t px = plot->x;
+ _sv_scalespace_t py = plot->y;
/* do the panel and plot scales match? If not, redraw the plot
scales */
@@ -110,21 +110,21 @@
plot->y = ry;
gdk_threads_leave();
- plot_draw_scales(plot);
+ _sv_plot_draw_scales(plot);
}else
gdk_threads_leave();
/* blank frame to selected bg */
switch(p->private->bg_type){
- case SUSHIV_BG_WHITE:
+ case SV_BG_WHITE:
cairo_set_source_rgb (c, 1.,1.,1.);
cairo_paint(c);
break;
- case SUSHIV_BG_BLACK:
+ case SV_BG_BLACK:
cairo_set_source_rgb (c, 0,0,0);
cairo_paint(c);
break;
- case SUSHIV_BG_CHECKS:
+ case SV_BG_CHECKS:
render_checks(c,pw,ph);
break;
}
@@ -137,12 +137,12 @@
/* by objective */
for(j=0;j<p->objectives;j++){
- if(p1->data_vec[j] && !mapping_inactive_p(p1->mappings+j)){
+ if(p1->data_vec[j] && !_sv_mapping_inactive_p(p1->mappings+j)){
- double alpha = slider_get_value(p1->alpha_scale[j],0);
+ double alpha = _sv_slider_get_value(p1->alpha_scale[j],0);
int linetype = p1->linetype[j];
int pointtype = p1->pointtype[j];
- u_int32_t color = mapping_calc(p1->mappings+j,1.,0);
+ u_int32_t color = _sv_mapping_calc(p1->mappings+j,1.,0);
double xv[dw];
double yv[dw];
@@ -158,11 +158,11 @@
double ypixel = NAN;
/* map data vector bin to x pixel location in the plot */
- xpixel = scalespace_pixel(&sx,scalespace_value(&sx_v,xpixel))+.5;
+ xpixel = _sv_scalespace_pixel(&sx,_sv_scalespace_value(&sx_v,xpixel))+.5;
/* map/render result */
if(!isnan(val))
- ypixel = scalespace_pixel(&sy,val)+.5;
+ ypixel = _sv_scalespace_pixel(&sy,val)+.5;
xv[xi] = xpixel;
yv[xi] = ypixel;
@@ -176,7 +176,7 @@
if(linetype == 3) /* fill below */
yA = (p1->flip?-1:r);
if(linetype == 4) /* fill to zero */
- yA = scalespace_pixel(&sy,0.)+.5;
+ yA = _sv_scalespace_pixel(&sy,0.)+.5;
cairo_set_source_rgba(c,
((color>>16)&0xff)/255.,
@@ -327,7 +327,7 @@
}
if(pointtype>0){
- if(p->private->bg_type == SUSHIV_BG_WHITE)
+ if(p->private->bg_type == SV_BG_WHITE)
cairo_set_source_rgba(c,0.,0.,0.,alpha);
else
cairo_set_source_rgba(c,1.,1.,1.,alpha);
@@ -349,8 +349,8 @@
return 1;
}
-static void sushiv_panel1d_print(sushiv_panel_t *p, cairo_t *c, int w, int h){
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel1d_print(sv_panel_t *p, cairo_t *c, int w, int h){
+ _sv_plot_t *plot = PLOT(p->private->graph);
double pw = p->private->graph->allocation.width;
double ph = p->private->graph->allocation.height;
double scale;
@@ -365,25 +365,25 @@
cairo_matrix_scale(&m,scale,scale);
cairo_set_matrix(c,&m);
- plot_print(plot, c, ph*scale, (void(*)(void *, cairo_t *))_sushiv_panel1d_remap, p);
+ _sv_plot_print(plot, c, ph*scale, (void(*)(void *, cairo_t *))_sv_panel1d_remap, p);
}
-static void update_legend(sushiv_panel_t *p){
- sushiv_panel1d_t *p1 = p->subtype->p1;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel1d_update_legend(sv_panel_t *p){
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ _sv_plot_t *plot = PLOT(p->private->graph);
gdk_threads_enter ();
if(plot){
int i,depth=0;
char buffer[320];
- plot_legend_clear(plot);
+ _sv_plot_legend_clear(plot);
if(3-p1->x_v.decimal_exponent > depth) depth = 3-p1->x_v.decimal_exponent;
// add each dimension to the legend
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
// display decimal precision relative to bracket
//int depth = del_depth(p->dimension_list[i].d->bracket[0],
// p->dimension_list[i].d->bracket[1]) + offset;
@@ -394,13 +394,13 @@
p->dimension_list[i].d->name,
depth,
p->dimension_list[i].d->val);
- plot_legend_add(plot,buffer);
+ _sv_plot_legend_add(plot,buffer);
}
}
// linked? add the linked dimension value to the legend
if(p1->link_x || p1->link_y){
- sushiv_dimension_t *d;
+ sv_dim_t *d;
int depth=0;
if(p1->link_x)
d = p1->link_x->subtype->p2->x_d;
@@ -414,21 +414,21 @@
d->name,
depth,
d->val);
- plot_legend_add(plot,buffer);
+ _sv_plot_legend_add(plot,buffer);
}
// one space
- plot_legend_add(plot,NULL);
+ _sv_plot_legend_add(plot,NULL);
// add each active objective to the legend
// choose the value under the crosshairs
if(plot->cross_active){
double val = (p1->flip?plot->sely:plot->selx);
- int bin = rint(scalespace_pixel(&p1->x_v, val));
+ int bin = rint(_sv_scalespace_pixel(&p1->x_v, val));
for(i=0;i<p->objectives;i++){
- if(!mapping_inactive_p(p1->mappings+i)){
- u_int32_t color = mapping_calc(p1->mappings+i,1.,0);
+ if(!_sv_mapping_inactive_p(p1->mappings+i)){
+ u_int32_t color = _sv_mapping_calc(p1->mappings+i,1.,0);
snprintf(buffer,320,"%s",
p->objective_list[i].o->name);
@@ -444,7 +444,7 @@
}
}
- plot_legend_add_with_color(plot,buffer,color | 0xff000000);
+ _sv_plot_legend_add_with_color(plot,buffer,color | 0xff000000);
}
}
}
@@ -452,122 +452,122 @@
}
}
-static void mapchange_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;
+static void _sv_panel1d_mapchange_callback(GtkWidget *w,gpointer in){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ sv_panel_t *p = optr->p;
+ _sv_panel1d_t *p1 = p->subtype->p1;
int onum = optr - p->objective_list;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
// update colormap
// 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]);
+ _sv_solid_set_func(&p1->mappings[onum],
+ gtk_combo_box_get_active(GTK_COMBO_BOX(w)));
+ _sv_slider_set_gradient(p1->alpha_scale[onum], &p1->mappings[onum]);
- _sushiv_panel_dirty_map(p);
- _sushiv_panel_dirty_legend(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_panel_dirty_map(p);
+ _sv_panel_dirty_legend(p);
+ _sv_undo_resume(p->sushi);
}
-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;
+static void _sv_panel1d_alpha_callback(void * in, int buttonstate){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ sv_panel_t *p = optr->p;
+ // _sv_panel1d_t *p1 = p->subtype->p1;
// int onum = optr - p->objective_list;
if(buttonstate == 0){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
}
- _sushiv_panel_dirty_map(p);
- _sushiv_panel_dirty_legend(p);
+ _sv_panel_dirty_map(p);
+ _sv_panel_dirty_legend(p);
if(buttonstate == 2)
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-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;
- sushiv_panel1d_t *p1 = p->subtype->p1;
+static void _sv_panel1d_linetype_callback(GtkWidget *w,gpointer in){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ sv_panel_t *p = optr->p;
+ _sv_panel1d_t *p1 = p->subtype->p1;
int onum = optr - p->objective_list;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
// update colormap
int pos = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
p1->linetype[onum] = line_name[pos]->value;
- _sushiv_panel_dirty_map(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_panel_dirty_map(p);
+ _sv_undo_resume(p->sushi);
}
-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;
+static void _sv_panel1d_pointtype_callback(GtkWidget *w,gpointer in){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ sv_panel_t *p = optr->p;
+ _sv_panel1d_t *p1 = p->subtype->p1;
int onum = optr - p->objective_list;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
// update colormap
int pos = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
p1->pointtype[onum] = point_name[pos]->value;
- _sushiv_panel_dirty_map(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_panel_dirty_map(p);
+ _sv_undo_resume(p->sushi);
}
-static void map_callback_1d(void *in,int buttonstate){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
- sushiv_panel1d_t *p1 = p->subtype->p1;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel1d_map_callback(void *in,int buttonstate){
+ sv_panel_t *p = (sv_panel_t *)in;
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(buttonstate == 0){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
}
// has new bracketing changed the plot range scale?
- if(p1->range_bracket[0] != slider_get_value(p1->range_slider,0) ||
- p1->range_bracket[1] != slider_get_value(p1->range_slider,1)){
+ if(p1->range_bracket[0] != _sv_slider_get_value(p1->range_slider,0) ||
+ p1->range_bracket[1] != _sv_slider_get_value(p1->range_slider,1)){
int w = plot->w.allocation.width;
int h = plot->w.allocation.height;
- p1->range_bracket[0] = slider_get_value(p1->range_slider,0);
- p1->range_bracket[1] = slider_get_value(p1->range_slider,1);
+ p1->range_bracket[0] = _sv_slider_get_value(p1->range_slider,0);
+ p1->range_bracket[1] = _sv_slider_get_value(p1->range_slider,1);
if(p1->flip)
- p1->y = scalespace_linear(p1->range_bracket[0],
- p1->range_bracket[1],
- w,
- plot->scalespacing,
- p1->range_scale->legend);
+ p1->y = _sv_scalespace_linear(p1->range_bracket[0],
+ p1->range_bracket[1],
+ w,
+ plot->scalespacing,
+ p1->range_scale->legend);
else
- p1->y = scalespace_linear(p1->range_bracket[1],
- p1->range_bracket[0],
- h,
- plot->scalespacing,
- p1->range_scale->legend);
-
+ p1->y = _sv_scalespace_linear(p1->range_bracket[1],
+ p1->range_bracket[0],
+ h,
+ plot->scalespacing,
+ p1->range_scale->legend);
+
}
-
+
//redraw the plot
- _sushiv_panel_dirty_map(p);
+ _sv_panel_dirty_map(p);
if(buttonstate == 2)
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void update_x_sel(sushiv_panel_t *p){
- sushiv_panel1d_t *p1 = p->subtype->p1;
+static void _sv_panel1d_update_xsel(sv_panel_t *p){
+ _sv_panel1d_t *p1 = p->subtype->p1;
int i;
// enable/disable dimension slider thumbs
@@ -585,37 +585,37 @@
if(p1->dim_xb[i] &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p1->dim_xb[i]))){
// make all thumbs visible
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,1);
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,1);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,1);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,1);
}else{
// make bracket thumbs invisible */
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,0);
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,0);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,0);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,0);
}
}
}
-static void compute_1d(sushiv_panel_t *p,
- int serialno,
- int x_d,
- scalespace sxi,
- int w,
- double *dim_vals,
- _sushiv_bythread_cache_1d *c){
- sushiv_panel1d_t *p1 = p->subtype->p1;
+static void _sv_panel1d_compute_line(sv_panel_t *p,
+ int serialno,
+ int x_d,
+ _sv_scalespace_t sxi,
+ int w,
+ double *dim_vals,
+ _sv_bythread_cache_1d_t *c){
+ _sv_panel1d_t *p1 = p->subtype->p1;
double work[w];
int i,j,fn=p->sushi->functions;
/* by function */
for(i=0;i<fn;i++){
if(c->call[i]){
- sushiv_function_t *f = p->sushi->function_list[i];
+ sv_func_t *f = p->sushi->function_list[i];
int step = f->outputs;
double *fout = c->fout[i];
/* by x */
for(j=0;j<w;j++){
- dim_vals[x_d] = scalespace_value(&sxi,j);
+ dim_vals[x_d] = _sv_scalespace_value(&sxi,j);
c->call[i](dim_vals,fout);
fout+=step;
}
@@ -626,9 +626,9 @@
/* 1d panels currently only care about the Y output value; in the
future, Z may also be relevant */
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
int offset = o->private->y_fout;
- sushiv_function_t *f = o->private->y_func;
+ sv_func_t *f = o->private->y_func;
if(f){
int step = f->outputs;
double *fout = c->fout[f->number]+offset;
@@ -653,15 +653,15 @@
}
// call only from main gtk thread
-void _mark_recompute_1d(sushiv_panel_t *p){
+void _sv_panel1d_mark_recompute(sv_panel_t *p){
if(!p->private->realized) return;
- sushiv_panel1d_t *p1 = p->subtype->p1;
- Plot *plot = PLOT(p->private->graph);
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int w = plot->w.allocation.width;
int h = plot->w.allocation.height;
int dw = w;
- sushiv_panel_t *link = (p1->link_x ? p1->link_x : p1->link_y);
- sushiv_panel2d_t *p2 = (link?link->subtype->p2:NULL);
+ sv_panel_t *link = (p1->link_x ? p1->link_x : p1->link_y);
+ _sv_panel2d_t *p2 = (link?link->subtype->p2:NULL);
int i,j;
if(p1->link_x){
@@ -677,24 +677,24 @@
if(plot && GTK_WIDGET_REALIZED(GTK_WIDGET(plot))){
if(p1->flip){
- dw = _sushiv_dimension_scales(p1->x_d,
- p1->x_d->bracket[1],
- p1->x_d->bracket[0],
- h,dw * p->private->oversample_n / p->private->oversample_d,
+ dw = _sv_dim_scales(p1->x_d,
+ p1->x_d->bracket[1],
+ p1->x_d->bracket[0],
+ h,dw * p->private->oversample_n / p->private->oversample_d,
+ plot->scalespacing,
+ p1->x_d->name,
+ &p1->x,
+ &p1->x_v,
+ &p1->x_i);
+
+ p1->y = _sv_scalespace_linear(p1->range_bracket[0],
+ p1->range_bracket[1],
+ w,
plot->scalespacing,
- p1->x_d->name,
- &p1->x,
- &p1->x_v,
- &p1->x_i);
+ p1->range_scale->legend);
- p1->y = scalespace_linear(p1->range_bracket[0],
- p1->range_bracket[1],
- w,
- plot->scalespacing,
- p1->range_scale->legend);
-
}else{
- dw = _sushiv_dimension_scales(p1->x_d,
+ dw = _sv_dim_scales(p1->x_d,
p1->x_d->bracket[0],
p1->x_d->bracket[1],
w,dw * p->private->oversample_n / p->private->oversample_d,
@@ -704,7 +704,7 @@
&p1->x_v,
&p1->x_i);
- p1->y = scalespace_linear(p1->range_bracket[1],
+ p1->y = _sv_scalespace_linear(p1->range_bracket[1],
p1->range_bracket[0],
h,
plot->scalespacing,
@@ -743,38 +743,38 @@
for(j=0;j<dw;j++)
p1->data_vec[i][j]=NAN;
- _sushiv_panel_dirty_plot(p);
+ _sv_panel_dirty_plot(p);
}
}
-static void recompute_callback_1d(void *ptr){
- sushiv_panel_t *p = (sushiv_panel_t *)ptr;
- _mark_recompute_1d(p);
+static void _sv_panel1d_recompute_callback(void *ptr){
+ sv_panel_t *p = (sv_panel_t *)ptr;
+ _sv_panel1d_mark_recompute(p);
}
-void _sushiv_panel1d_mark_recompute_linked(sushiv_panel_t *p){
+void _sv_panel1d_mark_recompute_linked(sv_panel_t *p){
int i;
/* look to see if any 1d panels link to passed in panel */
- sushiv_instance_t *s = p->sushi;
+ sv_instance_t *s = p->sushi;
for(i=0;i<s->panels;i++){
- sushiv_panel_t *q = s->panel_list[i];
- if(q != p && q->type == SUSHIV_PANEL_1D){
- sushiv_panel1d_t *q1 = q->subtype->p1;
+ sv_panel_t *q = s->panel_list[i];
+ if(q != p && q->type == SV_PANEL_1D){
+ _sv_panel1d_t *q1 = q->subtype->p1;
if(q1->link_x == p)
- _mark_recompute_1d(q);
+ _sv_panel1d_mark_recompute(q);
else{
if(q1->link_y == p)
- _mark_recompute_1d(q);
+ _sv_panel1d_mark_recompute(q);
}
}
}
}
-static void update_crosshair(sushiv_panel_t *p){
- sushiv_panel1d_t *p1 = p->subtype->p1;
- sushiv_panel_t *link=p1->link_x;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel1d_update_crosshair(sv_panel_t *p){
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ sv_panel_t *link=p1->link_x;
+ _sv_plot_t *plot = PLOT(p->private->graph);
double x=0;
int i;
@@ -784,22 +784,22 @@
if(link){
for(i=0;i<link->dimensions;i++){
- sushiv_dimension_t *d = link->dimension_list[i].d;
+ sv_dim_t *d = link->dimension_list[i].d;
if(d == p1->x_d)
x = link->dimension_list[i].d->val;
}
}else{
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
if(d == p1->x_d)
x = p->dimension_list[i].d->val;
}
}
if(p1->flip)
- plot_set_crosshairs(plot,0,x);
+ _sv_plot_set_crosshairs(plot,0,x);
else
- plot_set_crosshairs(plot,x,0);
+ _sv_plot_set_crosshairs(plot,x,0);
// in independent panels, crosshairs snap to a pixel position; the
// cached dimension value should be accurate with respect to the
@@ -807,34 +807,34 @@
// position in the master panel; that is handled in the master, not
// here.
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
- sushiv_panel1d_t *p1 = p->subtype->p1;
+ sv_dim_t *d = p->dimension_list[i].d;
+ _sv_panel1d_t *p1 = p->subtype->p1;
if(d == p1->x_d){
if(p1->flip)
- d->val = scalespace_value(&plot->x,plot_get_crosshair_ypixel(plot));
+ d->val = _sv_scalespace_value(&plot->x,_sv_plot_get_crosshair_ypixel(plot));
else
- d->val = scalespace_value(&plot->x,plot_get_crosshair_xpixel(plot));
+ d->val = _sv_scalespace_value(&plot->x,_sv_plot_get_crosshair_xpixel(plot));
}
}
- _sushiv_panel_dirty_legend(p);
+ _sv_panel_dirty_legend(p);
}
-void _sushiv_panel1d_update_linked_crosshairs(sushiv_panel_t *p, int xflag, int yflag){
+void _sv_panel1d_update_linked_crosshairs(sv_panel_t *p, int xflag, int yflag){
int i;
/* look to see if any 1d panels link to passed in panel */
- sushiv_instance_t *s = p->sushi;
+ sv_instance_t *s = p->sushi;
for(i=0;i<s->panels;i++){
- sushiv_panel_t *q = s->panel_list[i];
- if(q != p && q->type == SUSHIV_PANEL_1D){
- sushiv_panel1d_t *q1 = q->subtype->p1;
+ sv_panel_t *q = s->panel_list[i];
+ if(q != p && q->type == SV_PANEL_1D){
+ _sv_panel1d_t *q1 = q->subtype->p1;
if(q1->link_x == p){
- update_crosshair(q);
+ _sv_panel1d_update_crosshair(q);
if(yflag)
q->private->request_compute(q);
}else{
if(q1->link_y == p){
- update_crosshair(q);
+ _sv_panel1d_update_crosshair(q);
if(xflag)
q->private->request_compute(q);
}
@@ -843,52 +843,52 @@
}
}
-static void center_callback_1d(sushiv_dimension_list_t *dptr){
- sushiv_dimension_t *d = dptr->d;
- sushiv_panel_t *p = dptr->p;
- sushiv_panel1d_t *p1 = p->subtype->p1;
+static void _sv_panel1d_center_callback(sv_dim_list_t *dptr){
+ sv_dim_t *d = dptr->d;
+ sv_panel_t *p = dptr->p;
+ _sv_panel1d_t *p1 = p->subtype->p1;
int axisp = (d == p1->x_d);
if(!axisp){
// mid slider of a non-axis dimension changed, rerender
- _mark_recompute_1d(p);
+ _sv_panel1d_mark_recompute(p);
}else{
// mid slider of an axis dimension changed, move crosshairs
- update_crosshair(p);
+ _sv_panel1d_update_crosshair(p);
}
}
-static void bracket_callback_1d(sushiv_dimension_list_t *dptr){
- sushiv_dimension_t *d = dptr->d;
- sushiv_panel_t *p = dptr->p;
- sushiv_panel1d_t *p1 = p->subtype->p1;
+static void _sv_panel1d_bracket_callback(sv_dim_list_t *dptr){
+ sv_dim_t *d = dptr->d;
+ sv_panel_t *p = dptr->p;
+ _sv_panel1d_t *p1 = p->subtype->p1;
int axisp = d == p1->x_d;
if(axisp)
- _mark_recompute_1d(p);
+ _sv_panel1d_mark_recompute(p);
}
-static void dimchange_callback_1d(GtkWidget *button,gpointer in){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
+static void _sv_panel1d_dimchange_callback(GtkWidget *button,gpointer in){
+ sv_panel_t *p = (sv_panel_t *)in;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- update_x_sel(p);
- update_crosshair(p);
- plot_unset_box(PLOT(p->private->graph));
- _mark_recompute_1d(p);
+ _sv_panel1d_update_xsel(p);
+ _sv_panel1d_update_crosshair(p);
+ _sv_plot_unset_box(PLOT(p->private->graph));
+ _sv_panel1d_mark_recompute(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
}
-static void crosshair_callback(sushiv_panel_t *p){
- sushiv_panel1d_t *p1 = p->subtype->p1;
- sushiv_panel_t *link = p1->link_x;
+static void _sv_panel1d_crosshair_callback(sv_panel_t *p){
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ sv_panel_t *link = p1->link_x;
double x=PLOT(p->private->graph)->selx;
int i;
@@ -897,64 +897,64 @@
if(p1->link_y)
link=p1->link_y;
- _sushiv_panel_dirty_legend(p);
+ _sv_panel_dirty_legend(p);
if(p1->link_x){
// make it the master panel's problem.
- plot_set_crosshairs_snap(PLOT(link->private->graph),
+ _sv_plot_set_crosshairs_snap(PLOT(link->private->graph),
x,
PLOT(link->private->graph)->sely);
link->private->crosshair_action(link);
}else if (p1->link_y){
// make it the master panel's problem.
- plot_set_crosshairs_snap(PLOT(link->private->graph),
+ _sv_plot_set_crosshairs_snap(PLOT(link->private->graph),
PLOT(link->private->graph)->selx,
x);
link->private->crosshair_action(link);
}else{
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
- sushiv_panel1d_t *p1 = p->subtype->p1;
+ sv_dim_t *d = p->dimension_list[i].d;
+ _sv_panel1d_t *p1 = p->subtype->p1;
if(d == p1->x_d)
- _sushiv_dimension_set_value(p->private->dim_scales[i],1,x);
+ _sv_dim_set_value(p->private->dim_scales[i],1,x);
p->private->oldbox_active = 0;
}
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
}
-static void box_callback(void *in, int state){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
- sushiv_panel1d_t *p1 = p->subtype->p1;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel1d_box_callback(void *in, int state){
+ sv_panel_t *p = (sv_panel_t *)in;
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ _sv_plot_t *plot = PLOT(p->private->graph);
switch(state){
case 0: // box set
- _sushiv_undo_push(p->sushi);
- plot_box_vals(plot,p1->oldbox);
+ _sv_undo_push(p->sushi);
+ _sv_plot_box_vals(plot,p1->oldbox);
p->private->oldbox_active = plot->box_active;
break;
case 1: // box activate
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- crosshair_callback(p);
+ _sv_panel1d_crosshair_callback(p);
- _sushiv_dimension_set_value(p1->x_scale,0,p1->oldbox[0]);
- _sushiv_dimension_set_value(p1->x_scale,2,p1->oldbox[1]);
+ _sv_dim_set_value(p1->x_scale,0,p1->oldbox[0]);
+ _sv_dim_set_value(p1->x_scale,2,p1->oldbox[1]);
p->private->oldbox_active = 0;
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
break;
}
- _sushiv_panel_update_menus(p);
+ _sv_panel_update_menus(p);
}
-void _maintain_cache_1d(sushiv_panel_t *p, _sushiv_bythread_cache_1d *c, int w){
+void _sv_panel1d_maintain_cache(sv_panel_t *p, _sv_bythread_cache_1d_t *c, int w){
/* toplevel initialization */
if(c->fout == 0){
@@ -964,7 +964,7 @@
c->call = calloc(p->sushi->functions,sizeof(*c->call));
c->fout = calloc(p->sushi->functions,sizeof(*c->fout));
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
for(j=0;j<o->outputs;j++)
c->call[o->function_map[j]]=
p->sushi->function_list[o->function_map[j]]->callback;
@@ -987,19 +987,19 @@
}
// subtype entry point for plot remaps; lock held
-int _sushiv_panel1d_map_redraw(sushiv_panel_t *p, _sushiv_bythread_cache *c){
+int _sv_panel1d_map_redraw(sv_panel_t *p, _sv_bythread_cache_t *c){
if(p->private->map_progress_count)return 0;
p->private->map_progress_count++;
// render to a temp surface so that we can release the lock occasionally
- Plot *plot = PLOT(p->private->graph);
+ _sv_plot_t *plot = PLOT(p->private->graph);
cairo_surface_t *back = plot->back;
cairo_surface_t *cs = cairo_surface_create_similar(back,CAIRO_CONTENT_COLOR,
cairo_image_surface_get_width(back),
cairo_image_surface_get_height(back));
cairo_t *ct = cairo_create(cs);
- if(_sushiv_panel1d_remap(p,ct) == -1){ // returns -1 on abort
+ if(_sv_panel1d_remap(p,ct) == -1){ // returns -1 on abort
cairo_destroy(ct);
cairo_surface_destroy(cs);
}else{
@@ -1008,44 +1008,44 @@
plot->back = cs;
cairo_destroy(ct);
- _sushiv_panel_clean_map(p);
- plot_expose_request(plot);
+ _sv_panel_clean_map(p);
+ _sv_plot_expose_request(plot);
}
return 1;
}
// subtype entry point for legend redraws; lock held
-int _sushiv_panel1d_legend_redraw(sushiv_panel_t *p){
- Plot *plot = PLOT(p->private->graph);
+int _sv_panel1d_legend_redraw(sv_panel_t *p){
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(p->private->legend_progress_count)return 0;
p->private->legend_progress_count++;
- update_legend(p);
- _sushiv_panel_clean_legend(p);
+ _sv_panel1d_update_legend(p);
+ _sv_panel_clean_legend(p);
gdk_threads_leave();
- plot_draw_scales(plot);
+ _sv_plot_draw_scales(plot);
gdk_threads_enter();
- plot_expose_request(plot);
+ _sv_plot_expose_request(plot);
return 1;
}
// subtype entry point for recomputation; lock held
-int _sushiv_panel1d_compute(sushiv_panel_t *p,
- _sushiv_bythread_cache *c){
- sushiv_panel1d_t *p1 = p->subtype->p1;
- Plot *plot;
+int _sv_panel1d_compute(sv_panel_t *p,
+ _sv_bythread_cache_t *c){
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ _sv_plot_t *plot;
int dw,w,h,i,d;
int serialno;
int x_d=-1;
- scalespace sy;
+ _sv_scalespace_t sy;
- scalespace sx;
- scalespace sxv;
- scalespace sxi;
+ _sv_scalespace_t sx;
+ _sv_scalespace_t sxv;
+ _sv_scalespace_t sxi;
dw = p1->data_size;
w = p1->panel_w;
@@ -1086,29 +1086,29 @@
// Initialize local dimension value array
for(i=0;i<p->sushi->dimensions;i++){
- sushiv_dimension_t *dim = p->sushi->dimension_list[i];
+ sv_dim_t *dim = p->sushi->dimension_list[i];
dim_vals[i]=dim->val;
}
- _maintain_cache_1d(p,&c->p1,dw);
+ _sv_panel1d_maintain_cache(p,&c->p1,dw);
/* unlock for computation */
gdk_threads_leave ();
- compute_1d(p, serialno, x_d, sxi, dw, dim_vals, &c->p1);
+ _sv_panel1d_compute_line(p, serialno, x_d, sxi, dw, dim_vals, &c->p1);
gdk_threads_enter ();
if(serialno == p->private->plot_serialno){
- _sushiv_panel_dirty_map(p);
- _sushiv_panel_dirty_legend(p);
- _sushiv_panel_clean_plot(p);
+ _sv_panel_dirty_map(p);
+ _sv_panel_dirty_legend(p);
+ _sv_panel_clean_plot(p);
}
return 1;
}
-static void panel1d_undo_log(sushiv_panel_undo_t *u, sushiv_panel_t *p){
- sushiv_panel1d_t *p1 = p->subtype->p1;
+static void _sv_panel1d_undo_log(_sv_panel_undo_t *u, sv_panel_t *p){
+ _sv_panel1d_t *p1 = p->subtype->p1;
int i;
// alloc fields as necessary
@@ -1122,15 +1122,15 @@
u->scale_vals[2] = calloc(p->objectives,sizeof(**u->scale_vals));
// populate undo
- u->scale_vals[0][0] = slider_get_value(p1->range_slider,0);
- u->scale_vals[1][0] = slider_get_value(p1->range_slider,1);
+ u->scale_vals[0][0] = _sv_slider_get_value(p1->range_slider,0);
+ u->scale_vals[1][0] = _sv_slider_get_value(p1->range_slider,1);
for(i=0;i<p->objectives;i++){
u->mappings[i] =
(p1->mappings[i].mapnum<<24) |
(p1->linetype[i]<<16) |
(p1->pointtype[i]<<8);
- u->scale_vals[2][i] = slider_get_value(p1->alpha_scale[i],0);
+ u->scale_vals[2][i] = _sv_slider_get_value(p1->alpha_scale[i],0);
}
u->x_d = p1->x_dnum;
@@ -1141,49 +1141,49 @@
}
-static void panel1d_undo_restore(sushiv_panel_undo_t *u, sushiv_panel_t *p){
- sushiv_panel1d_t *p1 = p->subtype->p1;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel1d_undo_restore(_sv_panel_undo_t *u, sv_panel_t *p){
+ _sv_panel1d_t *p1 = p->subtype->p1;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int i;
// go in through widgets
- slider_set_value(p1->range_slider,0,u->scale_vals[0][0]);
- slider_set_value(p1->range_slider,1,u->scale_vals[1][0]);
+ _sv_slider_set_value(p1->range_slider,0,u->scale_vals[0][0]);
+ _sv_slider_set_value(p1->range_slider,1,u->scale_vals[1][0]);
for(i=0;i<p->objectives;i++){
gtk_combo_box_set_active(GTK_COMBO_BOX(p1->map_pulldowns[i]), (u->mappings[i]>>24)&0xff );
gtk_combo_box_set_active(GTK_COMBO_BOX(p1->line_pulldowns[i]), (u->mappings[i]>>16)&0xff );
gtk_combo_box_set_active(GTK_COMBO_BOX(p1->point_pulldowns[i]), (u->mappings[i]>>8)&0xff );
- slider_set_value(p1->alpha_scale[i],0,u->scale_vals[2][i]);
+ _sv_slider_set_value(p1->alpha_scale[i],0,u->scale_vals[2][i]);
}
if(p1->dim_xb && u->x_d<p->dimensions && p1->dim_xb[u->x_d])
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p1->dim_xb[u->x_d]),TRUE);
- update_x_sel(p);
+ _sv_panel1d_update_xsel(p);
if(u->box_active){
p1->oldbox[0] = u->box[0];
p1->oldbox[1] = u->box[1];
- plot_box_set(plot,u->box);
+ _sv_plot_box_set(plot,u->box);
p->private->oldbox_active = 1;
}else{
- plot_unset_box(plot);
+ _sv_plot_unset_box(plot);
p->private->oldbox_active = 0;
}
}
-void _sushiv_realize_panel1d(sushiv_panel_t *p){
- sushiv_panel1d_t *p1 = p->subtype->p1;
+void _sv_panel1d_realize(sv_panel_t *p){
+ _sv_panel1d_t *p1 = p->subtype->p1;
char buffer[160];
int i;
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_suspend(p->sushi);
p->private->toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect_swapped (G_OBJECT (p->private->toplevel), "delete-event",
- G_CALLBACK (_sushiv_clean_exit), (void *)SIGINT);
+ G_CALLBACK (_sv_clean_exit), (void *)SIGINT);
// add border to sides with hbox/padding
GtkWidget *borderbox = gtk_hbox_new(0,0);
@@ -1205,17 +1205,17 @@
{
unsigned flags = 0;
if(p1->flip)
- flags |= PLOT_NO_X_CROSS;
+ flags |= _SV_PLOT_NO_X_CROSS;
else
- flags |= PLOT_NO_Y_CROSS;
+ flags |= _SV_PLOT_NO_Y_CROSS;
p1->graph_table = gtk_table_new(2,2,0);
p->private->plotbox = p1->graph_table;
gtk_box_pack_start(GTK_BOX(p->private->topbox), p->private->plotbox, 1,1,2);
- p->private->graph = GTK_WIDGET(plot_new(recompute_callback_1d,p,
- (void *)(void *)crosshair_callback,p,
- box_callback,p,flags));
+ p->private->graph = GTK_WIDGET(_sv_plot_new(_sv_panel1d_recompute_callback,p,
+ (void *)(void *)_sv_panel1d_crosshair_callback,p,
+ _sv_panel1d_box_callback,p,flags));
if(p1->flip){
gtk_table_attach(GTK_TABLE(p1->graph_table),p->private->graph,0,2,0,1,
GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,0,1);
@@ -1233,8 +1233,8 @@
int hi = p1->range_scale->val_list[p1->range_scale->vals-1];
/* the range slices/slider */
- sl[0] = slice_new(map_callback_1d,p);
- sl[1] = slice_new(map_callback_1d,p);
+ sl[0] = _sv_slice_new(_sv_panel1d_map_callback,p);
+ sl[1] = _sv_slice_new(_sv_panel1d_map_callback,p);
if(p1->flip){
gtk_table_attach(GTK_TABLE(p1->graph_table),sl[0],0,1,1,2,
@@ -1249,14 +1249,14 @@
gtk_table_set_col_spacing(GTK_TABLE(p1->graph_table),0,4);
}
- p1->range_slider = slider_new((Slice **)sl,2,
- p1->range_scale->label_list,
- p1->range_scale->val_list,
- p1->range_scale->vals,
- (p1->flip?0:SLIDER_FLAG_VERTICAL));
-
- slice_thumb_set((Slice *)sl[0],lo);
- slice_thumb_set((Slice *)sl[1],hi);
+ p1->range_slider = _sv_slider_new((_sv_slice_t **)sl,2,
+ p1->range_scale->label_list,
+ p1->range_scale->val_list,
+ p1->range_scale->vals,
+ (p1->flip?0:_SV_SLIDER_FLAG_VERTICAL));
+
+ _sv_slice_thumb_set((_sv_slice_t *)sl[0],lo);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[1],hi);
}
/* obj box */
@@ -1274,7 +1274,7 @@
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;
+ sv_obj_t *o = p->objective_list[i].o;
/* label */
GtkWidget *label = gtk_label_new(o->name);
@@ -1284,23 +1284,24 @@
/* mapping pulldown */
{
- GtkWidget *menu=gtk_combo_box_new_markup();
+ GtkWidget *menu=_gtk_combo_box_new_markup();
int j;
- for(j=0;j<num_solids();j++){
- if(strcmp(solid_name(j),"inactive"))
- snprintf(buffer,sizeof(buffer),"<span foreground=\"%s\">%s</span>",solid_name(j),solid_name(j));
+ for(j=0;j<_sv_solid_names();j++){
+ if(strcmp(_sv_solid_name(j),"inactive"))
+ snprintf(buffer,sizeof(buffer),"<span foreground=\"%s\">%s</span>",
+ _sv_solid_name(j),_sv_solid_name(j));
else
- snprintf(buffer,sizeof(buffer),"%s",solid_name(j));
+ snprintf(buffer,sizeof(buffer),"%s",_sv_solid_name(j));
gtk_combo_box_append_text (GTK_COMBO_BOX (menu), buffer);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
g_signal_connect (G_OBJECT (menu), "changed",
- G_CALLBACK (mapchange_callback_1d), p->objective_list+i);
+ G_CALLBACK (_sv_panel1d_mapchange_callback), p->objective_list+i);
gtk_table_attach(GTK_TABLE(p1->obj_table),menu,1,2,i,i+1,
GTK_SHRINK,GTK_SHRINK,5,0);
p1->map_pulldowns[i] = menu;
- solid_setup(&p1->mappings[i],0.,1.,0);
+ _sv_solid_setup(&p1->mappings[i],0.,1.,0);
}
/* line pulldown */
@@ -1311,7 +1312,7 @@
gtk_combo_box_append_text (GTK_COMBO_BOX (menu), line_name[j]->left);
gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
g_signal_connect (G_OBJECT (menu), "changed",
- G_CALLBACK (linetype_callback_1d), p->objective_list+i);
+ G_CALLBACK (_sv_panel1d_linetype_callback), p->objective_list+i);
gtk_table_attach(GTK_TABLE(p1->obj_table),menu,2,3,i,i+1,
GTK_SHRINK,GTK_SHRINK,5,0);
p1->line_pulldowns[i] = menu;
@@ -1325,7 +1326,7 @@
gtk_combo_box_append_text (GTK_COMBO_BOX (menu), point_name[j]->left);
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);
+ G_CALLBACK (_sv_panel1d_pointtype_callback), 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;
@@ -1334,18 +1335,18 @@
/* alpha slider */
{
GtkWidget **sl = calloc(1, sizeof(*sl));
- sl[0] = slice_new(alpha_callback_1d,p->objective_list+i);
+ sl[0] = _sv_slice_new(_sv_panel1d_alpha_callback,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);
+ p1->alpha_scale[i] = _sv_slider_new((_sv_slice_t **)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.);
+ _sv_slider_set_gradient(p1->alpha_scale[i], &p1->mappings[i]);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[0],1.);
}
}
@@ -1361,7 +1362,7 @@
GtkWidget *first_x = NULL;
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
/* label */
GtkWidget *label = gtk_label_new(d->name);
@@ -1370,7 +1371,7 @@
GTK_FILL,0,5,0);
/* x radio buttons */
- if(!(d->flags & SUSHIV_DIM_NO_X) && !p1->link_x && !p1->link_y){
+ if(!(d->flags & SV_DIM_NO_X) && !p1->link_x && !p1->link_y){
if(first_x)
p1->dim_xb[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_x),"X");
else{
@@ -1382,7 +1383,7 @@
}
p->private->dim_scales[i] =
- _sushiv_new_dimension_widget(p->dimension_list+i,center_callback_1d,bracket_callback_1d);
+ _sv_dim_widget_new(p->dimension_list+i,_sv_panel1d_center_callback,_sv_panel1d_bracket_callback);
gtk_table_attach(GTK_TABLE(p1->dim_table),
GTK_WIDGET(p->private->dim_scales[i]->t),
@@ -1394,9 +1395,9 @@
for(i=0;i<p->dimensions;i++)
if(p1->dim_xb[i])
g_signal_connect (G_OBJECT (p1->dim_xb[i]), "toggled",
- G_CALLBACK (dimchange_callback_1d), p);
+ G_CALLBACK (_sv_panel1d_dimchange_callback), p);
- update_x_sel(p);
+ _sv_panel1d_update_xsel(p);
}
gtk_widget_realize(p->private->toplevel);
@@ -1404,12 +1405,12 @@
gtk_widget_realize(GTK_WIDGET(p->private->spinner));
gtk_widget_show_all(p->private->toplevel);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static int _save_panel1d(sushiv_panel_t *p, xmlNodePtr pn){
- sushiv_panel1d_t *p1 = p->subtype->p1;
+static int _sv_panel1d_save(sv_panel_t *p, xmlNodePtr pn){
+ _sv_panel1d_t *p1 = p->subtype->p1;
int ret=0,i;
xmlNodePtr n;
@@ -1419,56 +1420,56 @@
// box
if(p->private->oldbox_active){
xmlNodePtr boxn = xmlNewChild(pn, NULL, (xmlChar *) "box", NULL);
- xmlNewPropF(boxn, "x1", p1->oldbox[0]);
- xmlNewPropF(boxn, "x2", p1->oldbox[1]);
+ _xmlNewPropF(boxn, "x1", p1->oldbox[0]);
+ _xmlNewPropF(boxn, "x2", p1->oldbox[1]);
}
// objective map settings
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
xmlNodePtr on = xmlNewChild(pn, NULL, (xmlChar *) "objective", NULL);
- xmlNewPropI(on, "position", i);
- xmlNewPropI(on, "number", o->number);
- xmlNewPropS(on, "name", o->name);
- xmlNewPropS(on, "type", o->output_types);
+ _xmlNewPropI(on, "position", i);
+ _xmlNewPropI(on, "number", o->number);
+ _xmlNewPropS(on, "name", o->name);
+ _xmlNewPropS(on, "type", o->output_types);
// right now Y is the only type; the below is Y-specific
n = xmlNewChild(on, NULL, (xmlChar *) "y-map", NULL);
- xmlNewMapProp(n, "color", solid_map(), p1->mappings[i].mapnum);
- xmlNewMapProp(n, "line", line_name, p1->linetype[i]);
- xmlNewMapProp(n, "point", point_name, p1->pointtype[i]);
- xmlNewPropF(n, "alpha", slider_get_value(p1->alpha_scale[i],0));
+ _xmlNewMapProp(n, "color", _sv_solid_map(), p1->mappings[i].mapnum);
+ _xmlNewMapProp(n, "line", line_name, p1->linetype[i]);
+ _xmlNewMapProp(n, "point", point_name, p1->pointtype[i]);
+ _xmlNewPropF(n, "alpha", _sv_slider_get_value(p1->alpha_scale[i],0));
}
// y scale
n = xmlNewChild(pn, NULL, (xmlChar *) "range", NULL);
- xmlNewPropF(n, "low-bracket", slider_get_value(p1->range_slider,0));
- xmlNewPropF(n, "high-bracket", slider_get_value(p1->range_slider,1));
+ _xmlNewPropF(n, "low-bracket", _sv_slider_get_value(p1->range_slider,0));
+ _xmlNewPropF(n, "high-bracket", _sv_slider_get_value(p1->range_slider,1));
// x/y dim selection
n = xmlNewChild(pn, NULL, (xmlChar *) "axes", NULL);
- xmlNewPropI(n, "xpos", p1->x_dnum);
+ _xmlNewPropI(n, "xpos", p1->x_dnum);
return ret;
}
-int _load_panel1d(sushiv_panel_t *p,
- sushiv_panel_undo_t *u,
- xmlNodePtr pn,
- int warn){
+int _sv_panel1d_load(sv_panel_t *p,
+ _sv_panel_undo_t *u,
+ xmlNodePtr pn,
+ int warn){
int i;
// check type
- xmlCheckPropS(pn,"type","1d", "Panel %d type mismatch in save file.",p->number,&warn);
+ _xmlCheckPropS(pn,"type","1d", "Panel %d type mismatch in save file.",p->number,&warn);
// box
u->box_active = 0;
- xmlGetChildPropFPreserve(pn, "box", "x1", &u->box[0]);
- xmlGetChildPropFPreserve(pn, "box", "x2", &u->box[1]);
+ _xmlGetChildPropFPreserve(pn, "box", "x1", &u->box[0]);
+ _xmlGetChildPropFPreserve(pn, "box", "x2", &u->box[1]);
- xmlNodePtr n = xmlGetChildS(pn, "box", NULL, NULL);
+ xmlNodePtr n = _xmlGetChildS(pn, "box", NULL, NULL);
if(n){
u->box_active = 1;
xmlFree(n);
@@ -1476,15 +1477,15 @@
// objective map settings
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
- xmlNodePtr on = xmlGetChildI(pn, "objective", "position", i);
+ sv_obj_t *o = p->objective_list[i].o;
+ xmlNodePtr on = _xmlGetChildI(pn, "objective", "position", i);
if(!on){
- first_load_warning(&warn);
+ _sv_first_load_warning(&warn);
fprintf(stderr,"No save data found for panel %d objective \"%s\".\n",p->number, o->name);
}else{
// check name, type
- xmlCheckPropS(on,"name",o->name, "Objectve position %d name mismatch in save file.",i,&warn);
- xmlCheckPropS(on,"type",o->output_types, "Objectve position %d type mismatch in save file.",i,&warn);
+ _xmlCheckPropS(on,"name",o->name, "Objectve position %d name mismatch in save file.",i,&warn);
+ _xmlCheckPropS(on,"type",o->output_types, "Objectve position %d type mismatch in save file.",i,&warn);
// right now Y is the only type; the below is Y-specific
// load maptype, values
@@ -1492,13 +1493,13 @@
int line = (u->mappings[i]>>16)&0xff;
int point = (u->mappings[i]>>8)&0xff;
- xmlGetChildMapPreserve(on, "y-map", "color", solid_map(), &color,
+ _xmlGetChildMapPreserve(on, "y-map", "color", _sv_solid_map(), &color,
"Panel %d objective unknown mapping setting", p->number, &warn);
- xmlGetChildMapPreserve(on, "y-map", "line", line_name, &line,
+ _xmlGetChildMapPreserve(on, "y-map", "line", line_name, &line,
"Panel %d objective unknown mapping setting", p->number, &warn);
- xmlGetChildMapPreserve(on, "y-map", "point", point_name, &point,
+ _xmlGetChildMapPreserve(on, "y-map", "point", point_name, &point,
"Panel %d objective unknown mapping setting", p->number, &warn);
- xmlGetChildPropF(on, "y-map", "alpha", &u->scale_vals[2][i]);
+ _xmlGetChildPropF(on, "y-map", "alpha", &u->scale_vals[2][i]);
u->mappings[i] = (color<<24) | (line<<16) | (point<<8);
@@ -1507,88 +1508,94 @@
}
// y scale
- xmlGetChildPropFPreserve(pn, "range", "low-bracket", &u->scale_vals[0][0]);
- xmlGetChildPropF(pn, "range", "high-bracket", &u->scale_vals[1][0]);
+ _xmlGetChildPropFPreserve(pn, "range", "low-bracket", &u->scale_vals[0][0]);
+ _xmlGetChildPropF(pn, "range", "high-bracket", &u->scale_vals[1][0]);
// x/y dim selection
- xmlGetChildPropI(pn, "axes", "xpos", &u->x_d);
+ _xmlGetChildPropI(pn, "axes", "xpos", &u->x_d);
return warn;
}
-int sushiv_new_panel_1d(sushiv_instance_t *s,
- int number,
- const char *name,
- sushiv_scale_t *scale,
- int *objectives,
- int *dimensions,
- unsigned flags){
+sv_panel_t *sv_panel_new_1d(sv_instance_t *s,
+ int number,
+ char *name,
+ sv_scale_t *scale,
+ sv_obj_t **objectives,
+ sv_dim_t **dimensions,
+ unsigned flags){
+
+ sv_panel_t *p = _sv_panel_new(s,number,name,objectives,dimensions,flags);
+ _sv_panel1d_t *p1;
- int ret = _sushiv_new_panel(s,number,name,objectives,dimensions,flags);
- sushiv_panel_t *p;
- sushiv_panel1d_t *p1;
-
- if(ret<0)return ret;
- p = s->panel_list[number];
+ if(!p)return p;
p1 = calloc(1, sizeof(*p1));
p->subtype = calloc(1, sizeof(*p->subtype));
p->subtype->p1 = p1;
- p->type = SUSHIV_PANEL_1D;
- p1->range_scale = scale;
- p->private->bg_type = SUSHIV_BG_WHITE;
+ p->type = SV_PANEL_1D;
+ p1->range_scale = (sv_scale_t *)scale;
+ p->private->bg_type = SV_BG_WHITE;
- if(p->flags && SUSHIV_PANEL_FLIP)
+ if(p->flags && SV_PANEL_FLIP)
p1->flip=1;
- p->private->realize = _sushiv_realize_panel1d;
- p->private->map_action = _sushiv_panel1d_map_redraw;
- p->private->legend_action = _sushiv_panel1d_legend_redraw;
- p->private->compute_action = _sushiv_panel1d_compute;
- p->private->request_compute = _mark_recompute_1d;
- p->private->crosshair_action = crosshair_callback;
- p->private->print_action = sushiv_panel1d_print;
- p->private->save_action = _save_panel1d;
- p->private->load_action = _load_panel1d;
+ p->private->realize = _sv_panel1d_realize;
+ p->private->map_action = _sv_panel1d_map_redraw;
+ p->private->legend_action = _sv_panel1d_legend_redraw;
+ p->private->compute_action = _sv_panel1d_compute;
+ p->private->request_compute = _sv_panel1d_mark_recompute;
+ p->private->crosshair_action = _sv_panel1d_crosshair_callback;
+ p->private->print_action = _sv_panel1d_print;
+ p->private->save_action = _sv_panel1d_save;
+ p->private->load_action = _sv_panel1d_load;
- p->private->undo_log = panel1d_undo_log;
- p->private->undo_restore = panel1d_undo_restore;
+ p->private->undo_log = _sv_panel1d_undo_log;
+ p->private->undo_restore = _sv_panel1d_undo_restore;
p->private->def_oversample_n = p->private->oversample_n = 1;
p->private->def_oversample_d = p->private->oversample_d = 8;
return 0;
}
-int sushiv_new_panel_1d_linked(sushiv_instance_t *s,
- int number,
- const char *name,
- sushiv_scale_t *scale,
- int *objectives,
- int link,
- unsigned flags){
-
- if(link < 0 ||
- link >= s->panels ||
- s->panel_list[link]==NULL ||
- s->panel_list[link]->type != SUSHIV_PANEL_2D){
- fprintf(stderr,"1d linked panel must be linked to preexisting 2d panel.\n");
- return -EINVAL;
+int sv_panel_link_1d (sv_panel_t *p,
+ sv_panel_t *panel_2d,
+ unsigned flags){
+
+
+ if(!p){
+ fprintf(stderr,"Cannot link to a NULL 1d panel\n");
+ errno = -EINVAL;
+ return errno;
}
- int ret = sushiv_new_panel_1d(s,number,name,scale,objectives,(int []){-1},flags);
+ if(panel_2d->type != SV_PANEL_2D){
+ fprintf(stderr,"Panel %d (\"%s\"): Can only link to a 2d paenl\n",
+ p->number,p->name);
+ errno = -EINVAL;
+ return errno;
+ }
- sushiv_panel_t *p;
- sushiv_panel1d_t *p1;
- sushiv_panel_t *p2 = s->panel_list[link];
+ if(!panel_2d){
+ fprintf(stderr,"Panel %d (\"%s\"): Attempted to link NULL panel\n",
+ p->number,p->name);
+ errno = -EINVAL;
+ return errno;
+ }
- if(ret<0)return ret;
- p = s->panel_list[number];
- p1 = p->subtype->p1;
+ if(panel_2d->sushi != p->sushi){
+ fprintf(stderr,"Panel %d (\"%s\"): Cannot link panel number %d (\"%s\") from a differnet instance\n",
+ p->number,p->name,panel_2d->number, panel_2d->name);
+ errno = -EINVAL;
+ return errno;
+ }
- if(flags && SUSHIV_PANEL_LINK_Y)
- p1->link_y = p2;
+ _sv_panel1d_t *p1 = p->subtype->p1;
+
+ if(flags && SV_PANEL_LINK_Y)
+ p1->link_y = (sv_panel_t *)panel_2d;
else
- p1->link_x = p2;
+ p1->link_x = (sv_panel_t *)panel_2d;
return 0;
}
Modified: trunk/sushivision/panel-1d.h
===================================================================
--- trunk/sushivision/panel-1d.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/panel-1d.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -19,10 +19,10 @@
*
*/
-typedef struct sushiv_panel1d {
+typedef struct {
- sushiv_panel_t *link_x;
- sushiv_panel_t *link_y;
+ sv_panel_t *link_x;
+ sv_panel_t *link_y;
GtkWidget *graph_table;
GtkWidget *obj_table;
@@ -33,39 +33,39 @@
int data_size;
double **data_vec;
- scalespace y;
+ _sv_scalespace_t y;
- scalespace x; // the x scale aligned to panel's pixel context
- scalespace x_v; // the x scale aligned to data vector's bins
- scalespace x_i; // the 'counting' scale used to iterate for compute
+ _sv_scalespace_t x; // the x scale aligned to panel's pixel context
+ _sv_scalespace_t x_v; // the x scale aligned to data vector's bins
+ _sv_scalespace_t x_i; // the 'counting' scale used to iterate for compute
int scales_init;
double oldbox[4];
int flip;
- sushiv_scale_t *range_scale;
- Slider *range_slider;
+ sv_scale_t *range_scale;
+ _sv_slider_t *range_slider;
double range_bracket[2];
- mapping *mappings;
+ _sv_mapping_t *mappings;
int *linetype;
int *pointtype;
GtkWidget **map_pulldowns;
GtkWidget **line_pulldowns;
GtkWidget **point_pulldowns;
- Slider **alpha_scale;
+ _sv_slider_t **alpha_scale;
GtkWidget **dim_xb;
- sushiv_dimension_t *x_d;
- sushiv_dim_widget_t *x_scale;
+ sv_dim_t *x_d;
+ _sv_dim_widget_t *x_scale;
int x_dnum; // number of dimension within panel, not global instance
-} sushiv_panel1d_t;
+} _sv_panel1d_t;
typedef struct {
void (**call)(double *, double *);
double **fout; // [function number][outval_number*x]
int storage_width;
-} _sushiv_bythread_cache_1d;
+} _sv_bythread_cache_1d_t;
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/panel-2d.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -35,16 +35,16 @@
/* helper functions for performing progressive computation */
// enter unlocked
-static void compute_one_data_line_2d(sushiv_panel_t *p,
+static void _sv_panel2d_compute_line(sv_panel_t *p,
int serialno,
int dw,
int y,
int x_d,
- scalespace sxi,
+ _sv_scalespace_t sxi,
double *dim_vals,
- _sushiv_bythread_cache_2d *c){
+ _sv_bythread_cache_2d_t *c){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+ _sv_panel2d_t *p2 = p->subtype->p2;
int i,j;
/* cache access is unlocked because the cache is private to this
@@ -52,12 +52,12 @@
for(j=0;j<dw;j++){
double *fout = c->fout;
- sushiv_function_t **f = p2->used_function_list;
+ sv_func_t **f = p2->used_function_list;
int *obj_y_off = p2->y_fout_offset;
int *onum = p2->y_obj_to_panel;
/* by function */
- dim_vals[x_d] = scalespace_value(&sxi,j);
+ dim_vals[x_d] = _sv_scalespace_value(&sxi,j);
for(i=0;i<p2->used_functions;i++){
(*f)->callback(dim_vals,fout);
fout += (*f)->outputs;
@@ -69,7 +69,7 @@
/* slider map */
for(i=0;i<p2->y_obj_num;i++){
- float val = (float)slider_val_to_del(p2->range_scales[*onum++], c->fout[*obj_y_off++]);
+ float val = (float)_sv_slider_val_to_del(p2->range_scales[*onum++], c->fout[*obj_y_off++]);
if(isnan(val)){
c->y_map[i][j] = -1;
}else{
@@ -94,13 +94,13 @@
}
// call with lock
-static void clear_pane(sushiv_panel_t *p){
+static void _sv_panel2d_clear_pane(sv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+ _sv_panel2d_t *p2 = p->subtype->p2;
int pw = p2->x.pixels;
int ph = p2->y.pixels;
int i;
- Plot *plot = PLOT(p->private->graph);
+ _sv_plot_t *plot = PLOT(p->private->graph);
for(i=0;i<p2->y_obj_num;i++){
// map is freed and nulled to avoid triggering a fast-scale on an empty data pane
@@ -141,9 +141,9 @@
// used by the legend code. this lets us get away with having only a mapped display pane
// call with lock
-static void compute_single_point(sushiv_panel_t *p,sushiv_objective_t *o, double x, double y, compute_result *out){
+static void _sv_panel2d_compute_point(sv_panel_t *p,sv_obj_t *o, double x, double y, compute_result *out){
double dim_vals[p->sushi->dimensions];
- sushiv_panel2d_t *p2 = p->subtype->p2;
+ _sv_panel2d_t *p2 = p->subtype->p2;
int i,j;
int pflag=0;
int eflag=0;
@@ -153,7 +153,7 @@
int y_d = p2->y_d->number;
for(i=0;i<p->sushi->dimensions;i++){
- sushiv_dimension_t *dim = p->sushi->dimension_list[i];
+ sv_dim_t *dim = p->sushi->dimension_list[i];
dim_vals[i]=dim->val;
}
@@ -166,7 +166,7 @@
// compute
for(i=0;i<p->sushi->functions;i++){
- sushiv_function_t *f = p->sushi->function_list[i];
+ sv_func_t *f = p->sushi->function_list[i];
int compflag = 0;
double fout[f->outputs];
double val;
@@ -216,17 +216,17 @@
/* functions that perform actual graphical rendering */
-static float resample_helpers_init(scalespace *to, scalespace *from,
- unsigned char *delA, unsigned char *delB,
- int *posA, int *posB,
- int xymul){
+static float _sv_panel2d_resample_helpers_init(_sv_scalespace_t *to, _sv_scalespace_t *from,
+ unsigned char *delA, unsigned char *delB,
+ int *posA, int *posB,
+ int xymul){
int i;
int dw = from->pixels;
int pw = to->pixels;
- long scalenum = scalespace_scalenum(to,from);
- long scaleden = scalespace_scaleden(to,from);
- long del = scalespace_scaleoff(to,from);
+ long scalenum = _sv_scalespace_scalenum(to,from);
+ long scaleden = _sv_scalespace_scaleden(to,from);
+ long del = _sv_scalespace_scaleoff(to,from);
int bin = del / scaleden;
del -= bin * scaleden;
int discscale = (scaleden>scalenum?scalenum:scaleden);
@@ -290,8 +290,8 @@
/* x resample helpers are put in the per-thread cache because locking it would
be relatively expensive. */
// call while locked
-static void resample_helpers_manage_x(sushiv_panel_t *p, _sushiv_bythread_cache_2d *c){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_resample_helpers_manage_x(sv_panel_t *p, _sv_bythread_cache_2d_t *c){
+ _sv_panel2d_t *p2 = p->subtype->p2;
if(p->private->plot_serialno != c->serialno){
int pw = p2->x.pixels;
c->serialno = p->private->plot_serialno;
@@ -309,14 +309,14 @@
c->xdelB = calloc(pw,sizeof(*c->xdelB));
c->xnumA = calloc(pw,sizeof(*c->xnumA));
c->xnumB = calloc(pw,sizeof(*c->xnumB));
- c->xscalemul = resample_helpers_init(&p2->x, &p2->x_v, c->xdelA, c->xdelB, c->xnumA, c->xnumB, 17);
+ c->xscalemul = _sv_panel2d_resample_helpers_init(&p2->x, &p2->x_v, c->xdelA, c->xdelB, c->xnumA, c->xnumB, 17);
}
}
/* y resample is in the panel struct as per-row access is already locked */
// call while locked
-static void resample_helpers_manage_y(sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_resample_helpers_manage_y(sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
if(p->private->plot_serialno != p2->resample_serialno){
int ph = p2->y.pixels;
p2->resample_serialno = p->private->plot_serialno;
@@ -334,17 +334,17 @@
p2->ydelB = calloc(ph,sizeof(*p2->ydelB));
p2->ynumA = calloc(ph,sizeof(*p2->ynumA));
p2->ynumB = calloc(ph,sizeof(*p2->ynumB));
- p2->yscalemul = resample_helpers_init(&p2->y, &p2->y_v, p2->ydelA, p2->ydelB, p2->ynumA, p2->ynumB, 15);
+ p2->yscalemul = _sv_panel2d_resample_helpers_init(&p2->y, &p2->y_v, p2->ydelA, p2->ydelB, p2->ynumA, p2->ynumB, 15);
}
}
-static inline void l_mapping_calc( void (*m)(int,int, lcolor*),
- int low,
- float range,
- int in,
- int alpha,
- int mul,
- lcolor *outc){
+static inline void _sv_panel2d_mapping_calc( void (*m)(int,int, _sv_lcolor_t *),
+ int low,
+ float range,
+ int in,
+ int alpha,
+ int mul,
+ _sv_lcolor_t *outc){
if(mul && in>=alpha){
int val = rint((in - low) * range);
if(val<0)val=0;
@@ -360,10 +360,10 @@
1 == plane fully dispatched (possibly not complete) */
/* enter with lock */
-static int resample_render_y_plane_line(sushiv_panel_t *p, _sushiv_bythread_cache_2d *c,
- int plot_serialno, int map_serialno, int y_no){
-
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static int _sv_panel2d_resample_render_y_plane_line(sv_panel_t *p, _sv_bythread_cache_2d_t *c,
+ int plot_serialno, int map_serialno, int y_no){
+
+ _sv_panel2d_t *p2 = p->subtype->p2;
int objnum = p2->y_obj_to_panel[y_no];
int *in_data = p2->y_map[y_no];
int ph = p2->y.pixels;
@@ -389,17 +389,17 @@
p2->y_next_line++;
/* row [i] needs to be updated; marshal */
- mapping *map = p2->mappings+objnum;
- void (*mapfunc)(int,int, lcolor *) = map->mapfunc;
+ _sv_mapping_t *map = p2->mappings+objnum;
+ void (*mapfunc)(int,int, _sv_lcolor_t *) = map->mapfunc;
int ol_alpha = rint(p2->alphadel[y_no] * 16777216.f);
- ucolor *panel = p2->y_planes[y_no];
+ _sv_ucolor_t *panel = p2->y_planes[y_no];
int ol_low = rint(map->low * 16777216.f);
float ol_range = map->i_range * (1.f/256.f);
int pw = p2->x.pixels;
int dw = p2->x_v.pixels;
int dh = p2->y_v.pixels;
- ccolor work[pw];
+ _sv_ccolor_t work[pw];
if(!panel)
panel = p2->y_planes[y_no] = calloc(pw*ph, sizeof(**p2->y_planes));
@@ -407,8 +407,8 @@
if(ph!=dh || pw!=dw){
/* resampled row computation; may involve multiple data rows */
- resample_helpers_manage_y(p);
- resample_helpers_manage_x(p,c);
+ _sv_panel2d_resample_helpers_manage_y(p);
+ _sv_panel2d_resample_helpers_manage_x(p,c);
float idel = p2->yscalemul * c->xscalemul;
@@ -431,8 +431,8 @@
/* by panel col */
for(j=0;j<pw;j++){
-
- lcolor out = (lcolor){0,0,0,0};
+
+ _sv_lcolor_t out = (_sv_lcolor_t){0,0,0,0};
int xstart = xnumA[j];
int xend = xnumB[j];
int dx = xstart;
@@ -443,13 +443,13 @@
// first line
if(y<yend){
if(dx<xend)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx++], ol_alpha, ydelA*xA, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx++], ol_alpha, ydelA*xA, &out);
for(; dx < xend-1; dx++)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, ydelA*17, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, ydelA*17, &out);
if(dx<xend)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, ydelA*xB, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, ydelA*xB, &out);
y++;
}
@@ -458,13 +458,13 @@
dx = xstart += dw;
xend += dw;
if(dx<xend)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx++], ol_alpha, 15*xA, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx++], ol_alpha, 15*xA, &out);
for(; dx < xend-1; dx++)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, 255, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, 255, &out);
if(dx<xend)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, 15*xB, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, 15*xB, &out);
}
// last line
@@ -472,13 +472,13 @@
dx = xstart += dw;
xend += dw;
if(dx<xend)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx++], ol_alpha, ydelB*xA, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx++], ol_alpha, ydelB*xA, &out);
for(; dx < xend-1; dx++)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, ydelB*17, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, ydelB*17, &out);
if(dx<xend)
- l_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, ydelB*xB, &out);
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[dx], ol_alpha, ydelB*xB, &out);
}
work[j].a = (u_int32_t)(out.a*idel);
@@ -497,8 +497,8 @@
for(j=0;j<pw;j++){
- lcolor out = (lcolor){0,0,0,0};
- l_mapping_calc(mapfunc, ol_low, ol_range, data[j], ol_alpha, 255, &out);
+ _sv_lcolor_t out = (_sv_lcolor_t){0,0,0,0};
+ _sv_panel2d_mapping_calc(mapfunc, ol_low, ol_range, data[j], ol_alpha, 255, &out);
work[j].a = (u_int32_t)(out.a);
work[j].r = (u_int32_t)(out.r);
@@ -520,7 +520,7 @@
return 0;
}
-static void render_checks(ucolor *c, int w, int y){
+static void render_checks(_sv_ucolor_t *c, int w, int y){
/* default checked background */
/* 16x16 'mid-checks' */
int x,j;
@@ -536,9 +536,9 @@
}
// enter with lock
-static int render_bg_line(sushiv_panel_t *p, int plot_serialno, int map_serialno){
- sushiv_panel2d_t *p2 = p->subtype->p2;
- Plot *plot = PLOT(p->private->graph);
+static int _sv_panel2d_render_bg_line(sv_panel_t *p, int plot_serialno, int map_serialno){
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(plot_serialno != p->private->plot_serialno ||
map_serialno != p->private->map_serialno) return -1;
@@ -546,8 +546,8 @@
int pw = p2->x.pixels;
unsigned char *todo = p2->bg_todo;
int i = p2->bg_next_line,j;
- ucolor work_bg[pw];
- ucolor work_pl[pw];
+ _sv_ucolor_t work_bg[pw];
+ _sv_ucolor_t work_pl[pw];
int bgmode = p->private->bg_type;
/* find a row that needs to be updated */
@@ -568,11 +568,11 @@
gdk_threads_leave();
switch(bgmode){
- case SUSHIV_BG_WHITE:
+ case SV_BG_WHITE:
for(j=0;j<pw;j++)
work_bg[j].u = 0xffffffffU;
break;
- case SUSHIV_BG_BLACK:
+ case SV_BG_BLACK:
for(j=0;j<pw;j++)
work_bg[j].u = 0xff000000U;
break;
@@ -593,8 +593,8 @@
if(p2->y_planes[o_ynum]){
int x;
- ucolor (*mixfunc)(ucolor,ucolor) = p2->mappings[j].mixfunc;
- ucolor *rect = p2->y_planes[o_ynum] + i*pw;
+ _sv_ucolor_t (*mixfunc)(_sv_ucolor_t,_sv_ucolor_t) = p2->mappings[j].mixfunc;
+ _sv_ucolor_t *rect = p2->y_planes[o_ynum] + i*pw;
memcpy(work_pl,rect,sizeof(work_pl));
gdk_threads_leave();
@@ -626,11 +626,12 @@
return 0;
}
-static void _dirty_map_full(sushiv_panel_t *p);
+static void _sv_panel2d_mark_map_full(sv_panel_t *p);
+
// enter with lock; returns zero if thread should sleep / get distracted
-static int _sushiv_panel2d_remap(sushiv_panel_t *p, _sushiv_bythread_cache_2d *thread_cache){
- sushiv_panel2d_t *p2 = p->subtype->p2;
- Plot *plot = PLOT(p->private->graph);
+static int _sv_panel2d_remap(sv_panel_t *p, _sv_bythread_cache_2d_t *thread_cache){
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(!plot) goto abort;
int ph = plot->y.pixels;
@@ -655,16 +656,16 @@
p2->bg_last_line = 0;
if(!p2->partial_remap)
- _dirty_map_full(p);
+ _sv_panel2d_mark_map_full(p);
}
/* by plane, by line; each plane renders independently */
/* Y planes */
if(p2->y_planetodo){
if(p2->y_next_plane < p2->y_obj_num){
- int status = resample_render_y_plane_line(p, thread_cache,
- plot_serialno, map_serialno,
- p2->y_next_plane);
+ int status = _sv_panel2d_resample_render_y_plane_line(p, thread_cache,
+ plot_serialno, map_serialno,
+ p2->y_next_plane);
if(status == -1) goto abort;
if(status == 1){
p2->y_next_plane++;
@@ -693,13 +694,13 @@
p->private->map_complete_count = ph; // [ph] lines to render in bg plane
p2->bg_next_line = 0;
- _sushiv_wake_workers();
+ _sv_wake_workers();
}
}
/* mix new background, again line by line */
if(p2->bg_next_line < ph){
- int status = render_bg_line(p, plot_serialno, map_serialno);
+ int status = _sv_panel2d_render_bg_line(p, plot_serialno, map_serialno);
if(status == -1) goto abort;
if(p->private->map_complete_count)return status;
}else
@@ -708,7 +709,7 @@
// entirely finished.
// remap completed; flush background to screen
- plot_expose_request_partial (plot,0,p2->bg_first_line,
+ _sv_plot_expose_request_partial (plot,0,p2->bg_first_line,
pw,p2->bg_last_line - p2->bg_first_line);
gdk_flush();
@@ -717,7 +718,7 @@
// clear 'panel in progress' flag
p2->partial_remap = 0;
- _sushiv_panel_clean_map(p);
+ _sv_panel_clean_map(p);
return 0;
abort:
@@ -727,8 +728,8 @@
// looks like a cop-out but is actually the correct thing to do; the
// data *must* be WYSIWYG from panel display.
-static void sushiv_panel2d_print_bg(sushiv_panel_t *p, cairo_t *c){
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel2d_print_bg(sv_panel_t *p, cairo_t *c){
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(!plot) return;
@@ -740,9 +741,9 @@
cairo_pattern_destroy(pattern);
}
-static void sushiv_panel2d_print(sushiv_panel_t *p, cairo_t *c, int w, int h){
- sushiv_panel2d_t *p2 = p->subtype->p2;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel2d_print(sv_panel_t *p, cairo_t *c, int w, int h){
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ _sv_plot_t *plot = PLOT(p->private->graph);
double pw = p->private->graph->allocation.width;
double ph = p->private->graph->allocation.height;
double scale;
@@ -761,14 +762,14 @@
cairo_matrix_scale(&m,scale,scale);
cairo_set_matrix(c,&m);
- plot_print(plot, c, ph*scale, (void(*)(void *, cairo_t *))sushiv_panel2d_print_bg, p);
+ _sv_plot_print(plot, c, ph*scale, (void(*)(void *, cairo_t *))_sv_panel2d_print_bg, p);
cairo_restore(c);
// find extents widths for objective scale labels
cairo_set_font_size(c,10);
for(i=0;i<p->objectives;i++){
cairo_text_extents_t ex;
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
cairo_text_extents(c, o->name, &ex);
if(ex.width > maxlabelw) maxlabelw=ex.width;
}
@@ -777,11 +778,11 @@
y = ph * scale + 10;
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
- Slider *s = p2->range_scales[i];
+ sv_obj_t *o = p->objective_list[i].o;
+ _sv_slider_t *s = p2->range_scales[i];
// get scale height
- double labelh = slider_print_height(s);
+ double labelh = _sv_slider_print_height(s);
cairo_text_extents_t ex;
cairo_text_extents (c, o->name, &ex);
@@ -797,7 +798,7 @@
// set translation
cairo_save(c);
cairo_translate (c, maxlabelw + 10, y);
- slider_print(s, c, pw*scale - maxlabelw - 10, labelh);
+ _sv_slider_print(s, c, pw*scale - maxlabelw - 10, labelh);
cairo_restore(c);
y += labelh;
@@ -806,8 +807,8 @@
}
// call while locked
-static void _dirty_map_one_plane(sushiv_panel_t *p, int onum, int y, int z, int v){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_mark_map_plane(sv_panel_t *p, int onum, int y, int z, int v){
+ _sv_panel2d_t *p2 = p->subtype->p2;
int ph = p2->y.pixels;
if(y && p2->y_planetodo){
@@ -819,9 +820,9 @@
}
// call while locked
-static void _dirty_map_one_data_line_y(sushiv_panel_t *p, int line){
+static void _sv_panel2d_mark_map_line_y(sv_panel_t *p, int line){
// determine all panel lines this y data line affects
- sushiv_panel2d_t *p2 = p->subtype->p2;
+ _sv_panel2d_t *p2 = p->subtype->p2;
int ph = p2->y.pixels;
int pw = p2->x.pixels;
int dw = p2->x_v.pixels;
@@ -833,7 +834,7 @@
if(ph!=dh || pw!=dw){
/* resampled row computation; may involve multiple data rows */
if(p2->y_planetodo){
- resample_helpers_manage_y(p);
+ _sv_panel2d_resample_helpers_manage_y(p);
for(i=0;i<ph;i++)
if(p2->ynumA[i]<=line &&
@@ -854,8 +855,8 @@
}
// call while locked
-static void _dirty_map_full(sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_mark_map_full(sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
int ph = p2->y.pixels;
int i,j;
@@ -873,15 +874,15 @@
}
// enter with lock
-static void update_legend(sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel2d_update_legend(sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(plot){
int i;
char buffer[320];
int depth = 0;
- plot_legend_clear(plot);
+ _sv_plot_legend_clear(plot);
// potentially add each dimension to the legend; add axis
// dimensions only if crosshairs are active
@@ -890,14 +891,14 @@
if(3-p2->x.decimal_exponent > depth) depth = 3-p2->x.decimal_exponent;
if(3-p2->y.decimal_exponent > depth) depth = 3-p2->y.decimal_exponent;
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
if( (d!=p2->x_d && d!=p2->y_d) ||
plot->cross_active){
snprintf(buffer,320,"%s = %+.*f",
p->dimension_list[i].d->name,
depth,
p->dimension_list[i].d->val);
- plot_legend_add(plot,buffer);
+ _sv_plot_legend_add(plot,buffer);
}
}
@@ -905,20 +906,20 @@
// choose the value under the crosshairs
if(plot->cross_active){
// one space
- plot_legend_add(plot,NULL);
+ _sv_plot_legend_add(plot,NULL);
for(i=0;i<p->objectives;i++){
- if(!mapping_inactive_p(p2->mappings+i)){
+ if(!_sv_mapping_inactive_p(p2->mappings+i)){
compute_result vals;
- compute_single_point(p,p->objective_list[i].o, plot->selx, plot->sely, &vals);
+ _sv_panel2d_compute_point(p,p->objective_list[i].o, plot->selx, plot->sely, &vals);
if(!isnan(vals.y)){
snprintf(buffer,320,"%s = %f",
p->objective_list[i].o->name,
vals.y);
- plot_legend_add(plot,buffer);
+ _sv_plot_legend_add(plot,buffer);
}
}
}
@@ -926,59 +927,58 @@
}
}
-static void mapchange_callback_2d(GtkWidget *w,gpointer in){
- 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 = p->subtype->p2;
+static void _sv_panel2d_mapchange_callback(GtkWidget *w,gpointer in){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ //sv_obj_t *o = optr->o;
+ sv_panel_t *p = optr->p;
+ _sv_panel2d_t *p2 = p->subtype->p2;
int onum = optr - p->objective_list;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- mapping_set_func(&p2->mappings[onum],gtk_combo_box_get_active(GTK_COMBO_BOX(w)));
+ _sv_mapping_set_func(&p2->mappings[onum],gtk_combo_box_get_active(GTK_COMBO_BOX(w)));
//redraw the map slider
- slider_draw_background(p2->range_scales[onum]);
- slider_draw(p2->range_scales[onum]);
- slider_expose(p2->range_scales[onum]);
-
- _sushiv_panel_dirty_legend(p);
+ _sv_slider_set_gradient(p2->range_scales[onum], &p2->mappings[onum]);
+ // in the event the mapping active state changed
+ _sv_panel_dirty_legend(p);
+
//redraw the plot
- _dirty_map_one_plane(p,onum,1,0,0);
- _sushiv_panel_dirty_map(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_panel2d_mark_map_plane(p,onum,1,0,0);
+ _sv_panel_dirty_map(p);
+ _sv_undo_resume(p->sushi);
}
-static void map_callback_2d(void *in,int buttonstate){
- 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 = p->subtype->p2;
+static void _sv_panel2d_map_callback(void *in,int buttonstate){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ //sv_obj_t *o = optr->o;
+ sv_panel_t *p = optr->p;
+ _sv_panel2d_t *p2 = p->subtype->p2;
int onum = optr - p->objective_list;
if(buttonstate == 0){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
}
// recache alpha del */
p2->alphadel[onum] =
- slider_val_to_del(p2->range_scales[onum],
- slider_get_value(p2->range_scales[onum],1));
+ _sv_slider_val_to_del(p2->range_scales[onum],
+ _sv_slider_get_value(p2->range_scales[onum],1));
// redraw the plot on motion
if(buttonstate == 1){
- _dirty_map_one_plane(p,onum,1,0,0);
- _sushiv_panel_dirty_map(p);
+ _sv_panel2d_mark_map_plane(p,onum,1,0,0);
+ _sv_panel_dirty_map(p);
}
if(buttonstate == 2)
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void update_xy_availability(sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_update_xysel(sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
int i;
// update which x/y buttons are pressable */
// enable/disable dimension slider thumbs
@@ -988,7 +988,7 @@
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p2->dim_xb[i]))){
// make the y insensitive
if(p2->dim_yb[i])
- gtk_widget_set_sensitive_fixup(p2->dim_yb[i],FALSE);
+ _gtk_widget_set_sensitive_fixup(p2->dim_yb[i],FALSE);
// set the x dim flag
p2->x_d = p->dimension_list[i].d;
@@ -997,13 +997,13 @@
}else{
// if there is a y, make it sensitive
if(p2->dim_yb[i])
- gtk_widget_set_sensitive_fixup(p2->dim_yb[i],TRUE);
+ _gtk_widget_set_sensitive_fixup(p2->dim_yb[i],TRUE);
}
if(p2->dim_yb[i] &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p2->dim_yb[i]))){
// make the x insensitive
if(p2->dim_xb[i])
- gtk_widget_set_sensitive_fixup(p2->dim_xb[i],FALSE);
+ _gtk_widget_set_sensitive_fixup(p2->dim_xb[i],FALSE);
// set the y dim
p2->y_d = p->dimension_list[i].d;
@@ -1012,24 +1012,24 @@
}else{
// if there is a x, make it sensitive
if(p2->dim_xb[i])
- gtk_widget_set_sensitive_fixup(p2->dim_xb[i],TRUE);
+ _gtk_widget_set_sensitive_fixup(p2->dim_xb[i],TRUE);
}
if((p2->dim_xb[i] &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p2->dim_xb[i]))) ||
(p2->dim_yb[i] &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p2->dim_yb[i])))){
// make all thumbs visible
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,1);
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,1);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,1);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,1);
}else{
// make bracket thumbs invisible */
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,0);
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,0);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,0);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,0);
}
}
}
-static int v_swizzle(int y, int height){
+static int _v_swizzle(int y, int height){
int yy = height >> 5;
if(y < yy)
return (y<<5)+31;
@@ -1059,12 +1059,12 @@
}
// assumes data is locked
-static void fast_scale_x(Spinner *sp,
- int *data,
- int w,
- int h,
- scalespace new,
- scalespace old){
+static void _sv_panel2d_fast_scale_x(_sv_spinner_t *sp,
+ int *data,
+ int w,
+ int h,
+ _sv_scalespace_t new,
+ _sv_scalespace_t old){
int x,y;
int work[w];
int mapbase[w];
@@ -1072,10 +1072,10 @@
double old_w = old.pixels;
double new_w = new.pixels;
- double old_lo = scalespace_value(&old,0);
- double old_hi = scalespace_value(&old,old_w);
- double new_lo = scalespace_value(&new,0);
- double new_hi = scalespace_value(&new,new_w);
+ double old_lo = _sv_scalespace_value(&old,0);
+ double old_hi = _sv_scalespace_value(&old,old_w);
+ double new_lo = _sv_scalespace_value(&new,0);
+ double new_hi = _sv_scalespace_value(&new,new_w);
double newscale = (new_hi-new_lo)/new_w;
double oldscale = old_w/(old_hi-old_lo);
for(x=0;x<w;x++){
@@ -1096,7 +1096,7 @@
for(y=0;y<h;y++){
int *data_line = data+y*w;
- spinner_set_busy(sp);
+ _sv_spinner_set_busy(sp);
for(x=0;x<w;x++){
if(mapbase[x]<0 || mapbase[x]>=(w-1)){
work[x]=-1;
@@ -1115,13 +1115,13 @@
}
}
-static void fast_scale_y(Spinner *sp,
- int *olddata,
- int *newdata,
- int oldw,
- int neww,
- scalespace new,
- scalespace old){
+static void _sv_panel2d_fast_scale_y(_sv_spinner_t *sp,
+ int *olddata,
+ int *newdata,
+ int oldw,
+ int neww,
+ _sv_scalespace_t new,
+ _sv_scalespace_t old){
int x,y;
int w = (oldw<neww?oldw:neww);
@@ -1131,10 +1131,10 @@
int mapbase[new_h];
int mapdel[new_h];
- double old_lo = scalespace_value(&old,0);
- double old_hi = scalespace_value(&old,(double)old_h);
- double new_lo = scalespace_value(&new,0);
- double new_hi = scalespace_value(&new,(double)new_h);
+ double old_lo = _sv_scalespace_value(&old,0);
+ double old_hi = _sv_scalespace_value(&old,(double)old_h);
+ double new_lo = _sv_scalespace_value(&new,0);
+ double new_hi = _sv_scalespace_value(&new,(double)new_h);
double newscale = (new_hi-new_lo)/new_h;
double oldscale = old_h/(old_hi-old_lo);
@@ -1158,7 +1158,7 @@
for(y=0;y<new_h;y++){
int base = mapbase[y];
int *new_column = &newdata[y*neww];
- spinner_set_busy(sp);
+ _sv_spinner_set_busy(sp);
if(base<0 || base>=(old_h-1)){
for(x=0;x<w;x++)
@@ -1179,13 +1179,13 @@
}
}
-static void fast_scale(Spinner *sp,
- int *newdata,
- scalespace xnew,
- scalespace ynew,
- int *olddata,
- scalespace xold,
- scalespace yold){
+static void _sv_panel2d_fast_scale(_sv_spinner_t *sp,
+ int *newdata,
+ _sv_scalespace_t xnew,
+ _sv_scalespace_t ynew,
+ int *olddata,
+ _sv_scalespace_t xold,
+ _sv_scalespace_t yold){
int new_w = xnew.pixels;
int new_h = ynew.pixels;
@@ -1193,33 +1193,33 @@
int old_h = yold.pixels;
if(new_w > old_w){
- fast_scale_y(sp,olddata,newdata,old_w,new_w,ynew,yold);
- fast_scale_x(sp,newdata,new_w,new_h,xnew,xold);
+ _sv_panel2d_fast_scale_y(sp,olddata,newdata,old_w,new_w,ynew,yold);
+ _sv_panel2d_fast_scale_x(sp,newdata,new_w,new_h,xnew,xold);
}else{
- fast_scale_x(sp,olddata,old_w,old_h,xnew,xold);
- fast_scale_y(sp,olddata,newdata,old_w,new_w,ynew,yold);
+ _sv_panel2d_fast_scale_x(sp,olddata,old_w,old_h,xnew,xold);
+ _sv_panel2d_fast_scale_y(sp,olddata,newdata,old_w,new_w,ynew,yold);
}
}
// call only from main gtk thread
-static void _mark_recompute_2d(sushiv_panel_t *p){
+static void _sv_panel2d_mark_recompute(sv_panel_t *p){
if(!p->private->realized) return;
- Plot *plot = PLOT(p->private->graph);
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(plot && GTK_WIDGET_REALIZED(GTK_WIDGET(plot))){
- _sushiv_panel1d_mark_recompute_linked(p);
- _sushiv_panel_dirty_plot(p);
+ _sv_panel1d_mark_recompute_linked(p);
+ _sv_panel_dirty_plot(p);
}
}
-static void update_crosshairs(sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel2d_update_crosshairs(sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ _sv_plot_t *plot = PLOT(p->private->graph);
double x=0,y=0;
int i;
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
if(d == p2->x_d)
x = d->val;
if(d == p2->y_d)
@@ -1227,77 +1227,77 @@
}
- plot_set_crosshairs(plot,x,y);
- _sushiv_panel1d_update_linked_crosshairs(p,0,0);
- _sushiv_panel_dirty_legend(p);
+ _sv_plot_set_crosshairs(plot,x,y);
+ _sv_panel1d_update_linked_crosshairs(p,0,0);
+ _sv_panel_dirty_legend(p);
}
-static void center_callback_2d(sushiv_dimension_list_t *dptr){
- sushiv_dimension_t *d = dptr->d;
- sushiv_panel_t *p = dptr->p;
- sushiv_panel2d_t *p2 = p->subtype->p2;
- //Plot *plot = PLOT(p->private->graph);
+static void _sv_panel2d_center_callback(sv_dim_list_t *dptr){
+ sv_dim_t *d = dptr->d;
+ sv_panel_t *p = dptr->p;
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ //_sv_plot_t *plot = PLOT(p->private->graph);
int axisp = (d == p2->x_d || d == p2->y_d);
if(!axisp){
// mid slider of a non-axis dimension changed, rerender
- _mark_recompute_2d(p);
+ _sv_panel2d_mark_recompute(p);
}else{
// mid slider of an axis dimension changed, move crosshairs
- update_crosshairs(p);
- _sushiv_panel1d_update_linked_crosshairs(p,d==p2->x_d,d==p2->y_d);
+ _sv_panel2d_update_crosshairs(p);
+ _sv_panel1d_update_linked_crosshairs(p,d==p2->x_d,d==p2->y_d);
}
}
-static void bracket_callback_2d(sushiv_dimension_list_t *dptr){
- sushiv_dimension_t *d = dptr->d;
- sushiv_panel_t *p = dptr->p;
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_bracket_callback(sv_dim_list_t *dptr){
+ sv_dim_t *d = dptr->d;
+ sv_panel_t *p = dptr->p;
+ _sv_panel2d_t *p2 = p->subtype->p2;
int axisp = (d == p2->x_d || d == p2->y_d);
if(axisp)
- _mark_recompute_2d(p);
+ _sv_panel2d_mark_recompute(p);
}
-static void dimchange_callback_2d(GtkWidget *button,gpointer in){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
+static void _sv_panel2d_dimchange_callback(GtkWidget *button,gpointer in){
+ sv_panel_t *p = (sv_panel_t *)in;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- plot_unset_box(PLOT(p->private->graph));
- update_xy_availability(p);
+ _sv_plot_unset_box(PLOT(p->private->graph));
+ _sv_panel2d_update_xysel(p);
- clear_pane(p);
- _mark_recompute_2d(p);
- update_crosshairs(p);
+ _sv_panel2d_clear_pane(p);
+ _sv_panel2d_mark_recompute(p);
+ _sv_panel2d_update_crosshairs(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
}
-static void _sushiv_panel2d_crosshairs_callback(sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_crosshairs_callback(sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
double x=PLOT(p->private->graph)->selx;
double y=PLOT(p->private->graph)->sely;
int i;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
//plot_snap_crosshairs(PLOT(p->private->graph));
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
if(d == p2->x_d){
- _sushiv_dimension_set_value(p->private->dim_scales[i],1,x);
+ _sv_dim_set_value(p->private->dim_scales[i],1,x);
}
if(d == p2->y_d){
- _sushiv_dimension_set_value(p->private->dim_scales[i],1,y);
+ _sv_dim_set_value(p->private->dim_scales[i],1,y);
}
p->private->oldbox_active = 0;
@@ -1308,42 +1308,42 @@
x = p2->x_d->val;
y = p2->y_d->val;
- plot_set_crosshairs(PLOT(p->private->graph),x,y);
+ _sv_plot_set_crosshairs(PLOT(p->private->graph),x,y);
- _sushiv_panel_dirty_legend(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_panel_dirty_legend(p);
+ _sv_undo_resume(p->sushi);
}
-static void box_callback(void *in, int state){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
- sushiv_panel2d_t *p2 = p->subtype->p2;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel2d_box_callback(void *in, int state){
+ sv_panel_t *p = (sv_panel_t *)in;
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ _sv_plot_t *plot = PLOT(p->private->graph);
switch(state){
case 0: // box set
- _sushiv_undo_push(p->sushi);
- plot_box_vals(plot,p2->oldbox);
+ _sv_undo_push(p->sushi);
+ _sv_plot_box_vals(plot,p2->oldbox);
p->private->oldbox_active = plot->box_active;
break;
case 1: // box activate
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- _sushiv_panel2d_crosshairs_callback(p);
+ _sv_panel2d_crosshairs_callback(p);
- _sushiv_dimension_set_value(p2->x_scale,0,p2->oldbox[0]);
- _sushiv_dimension_set_value(p2->x_scale,2,p2->oldbox[1]);
- _sushiv_dimension_set_value(p2->y_scale,0,p2->oldbox[2]);
- _sushiv_dimension_set_value(p2->y_scale,2,p2->oldbox[3]);
+ _sv_dim_set_value(p2->x_scale,0,p2->oldbox[0]);
+ _sv_dim_set_value(p2->x_scale,2,p2->oldbox[1]);
+ _sv_dim_set_value(p2->y_scale,0,p2->oldbox[2]);
+ _sv_dim_set_value(p2->y_scale,2,p2->oldbox[3]);
p->private->oldbox_active = 0;
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
break;
}
- _sushiv_panel_update_menus(p);
+ _sv_panel_update_menus(p);
}
-void _maintain_compute_cache_2d(sushiv_panel_t *p, _sushiv_bythread_cache_2d *c, int w){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+void _sv_panel2d_maintain_cache(sv_panel_t *p, _sv_bythread_cache_2d_t *c, int w){
+ _sv_panel2d_t *p2 = p->subtype->p2;
/* toplevel initialization */
if(c->fout == 0){
@@ -1352,7 +1352,7 @@
/* allocate output temporary buffer */
for(i=0;i<p2->used_functions;i++){
int fnum = p2->used_function_list[i]->number;
- sushiv_function_t *f = p->sushi->function_list[fnum];
+ sv_func_t *f = p->sushi->function_list[fnum];
count += f->outputs;
}
c->fout = calloc(count, sizeof(*c->fout));
@@ -1377,41 +1377,41 @@
// subtype entry point for plot remaps; lock held
-static int _sushiv_panel2d_map_redraw(sushiv_panel_t *p, _sushiv_bythread_cache *c){
- return _sushiv_panel2d_remap(p,&c->p2);
+static int _sv_panel2d_map_redraw(sv_panel_t *p, _sv_bythread_cache_t *c){
+ return _sv_panel2d_remap(p,&c->p2);
}
// subtype entry point for legend redraws; lock held
-static int _sushiv_panel2d_legend_redraw(sushiv_panel_t *p){
- Plot *plot = PLOT(p->private->graph);
+static int _sv_panel2d_legend_redraw(sv_panel_t *p){
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(p->private->legend_progress_count)return 0;
p->private->legend_progress_count++;
- update_legend(p);
- _sushiv_panel_clean_legend(p);
+ _sv_panel2d_update_legend(p);
+ _sv_panel_clean_legend(p);
gdk_threads_leave();
- plot_draw_scales(plot);
+ _sv_plot_draw_scales(plot);
gdk_threads_enter();
- plot_expose_request(plot);
+ _sv_plot_expose_request(plot);
return 1;
}
// subtype entry point for recomputation; lock held
-static int _sushiv_panel2d_compute(sushiv_panel_t *p,
- _sushiv_bythread_cache *c){
+static int _sv_panel2d_compute(sv_panel_t *p,
+ _sv_bythread_cache_t *c){
- sushiv_panel2d_t *p2 = p->subtype->p2;
- Plot *plot;
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ _sv_plot_t *plot;
int pw,ph,dw,dh,i,d;
int serialno;
double x_min, x_max;
double y_min, y_max;
int x_d=-1, y_d=-1;
- scalespace sx,sx_v,sx_i;
- scalespace sy,sy_v,sy_i;
+ _sv_scalespace_t sx,sx_v,sx_i;
+ _sv_scalespace_t sy,sy_v,sy_i;
plot = PLOT(p->private->graph);
pw = plot->x.pixels;
@@ -1424,30 +1424,30 @@
if(p->private->plot_progress_count==0){
int remapflag = 0;
- scalespace old_x = p2->x;
- scalespace old_y = p2->y;
- scalespace old_xv = p2->x_v;
- scalespace old_yv = p2->y_v;
+ _sv_scalespace_t old_x = p2->x;
+ _sv_scalespace_t old_y = p2->y;
+ _sv_scalespace_t old_xv = p2->x_v;
+ _sv_scalespace_t old_yv = p2->y_v;
// generate new scales
- _sushiv_dimension_scales(p2->x_d,
- p2->x_d->bracket[0],
- p2->x_d->bracket[1],
- pw,pw * p->private->oversample_n / p->private->oversample_d,
- plot->scalespacing,
- p2->x_d->name,
- &sx,
- &sx_v,
- &sx_i);
- _sushiv_dimension_scales(p2->y_d,
- p2->y_d->bracket[1],
- p2->y_d->bracket[0],
- ph,ph * p->private->oversample_n / p->private->oversample_d,
- plot->scalespacing,
- p2->y_d->name,
- &sy,
- &sy_v,
- &sy_i);
+ _sv_dim_scales(p2->x_d,
+ p2->x_d->bracket[0],
+ p2->x_d->bracket[1],
+ pw,pw * p->private->oversample_n / p->private->oversample_d,
+ plot->scalespacing,
+ p2->x_d->name,
+ &sx,
+ &sx_v,
+ &sx_i);
+ _sv_dim_scales(p2->y_d,
+ p2->y_d->bracket[1],
+ p2->y_d->bracket[0],
+ ph,ph * p->private->oversample_n / p->private->oversample_d,
+ plot->scalespacing,
+ p2->y_d->name,
+ &sy,
+ &sy_v,
+ &sy_i);
p2->x = sx;
p2->x_v = sx_v;
@@ -1479,8 +1479,8 @@
// zoom scale data in map planes as placeholder for render
if(oldmap){
- fast_scale(p->private->spinner,newmap, sx_v, sy_v,
- oldmap,old_xv, old_yv);
+ _sv_panel2d_fast_scale(p->private->spinner,newmap, sx_v, sy_v,
+ oldmap,old_xv, old_yv);
free(oldmap);
}
p2->y_map[i] = newmap;
@@ -1512,15 +1512,14 @@
}
if(remapflag){
- _dirty_map_full(p);
+ _sv_panel2d_mark_map_full(p);
+ _sv_panel_dirty_map(p);
- _sushiv_panel_dirty_map(p);
-
gdk_threads_leave ();
- plot_draw_scales(plot); // this should happen outside lock
+ _sv_plot_draw_scales(plot); // this should happen outside lock
gdk_threads_enter ();
}
- set_map_throttle_time(p); // swallow the first 'throttled' remap which would only be a single line;
+ _sv_map_set_throttle_time(p); // swallow the first 'throttled' remap which would only be a single line;
return 1;
}else{
@@ -1538,71 +1537,71 @@
if(p->private->plot_progress_count>dh) return 0;
- _maintain_compute_cache_2d(p,&c->p2,dw);
+ _sv_panel2d_maintain_cache(p,&c->p2,dw);
d = p->dimensions;
/* render using local dimension array; several threads will be
computing objectives */
double dim_vals[p->sushi->dimensions];
- int y = v_swizzle(p->private->plot_progress_count-1,dh);
+ int y = _v_swizzle(p->private->plot_progress_count-1,dh);
p->private->plot_progress_count++;
- x_min = scalespace_value(&p2->x_i,0);
- x_max = scalespace_value(&p2->x_i,dw);
+ x_min = _sv_scalespace_value(&p2->x_i,0);
+ x_max = _sv_scalespace_value(&p2->x_i,dw);
- y_min = scalespace_value(&p2->y_i,0);
- y_max = scalespace_value(&p2->y_i,dh);
+ y_min = _sv_scalespace_value(&p2->y_i,0);
+ y_max = _sv_scalespace_value(&p2->y_i,dh);
// Initialize local dimension value array
for(i=0;i<p->sushi->dimensions;i++){
- sushiv_dimension_t *dim = p->sushi->dimension_list[i];
+ sv_dim_t *dim = p->sushi->dimension_list[i];
dim_vals[i]=dim->val;
}
/* unlock for computation */
gdk_threads_leave ();
- dim_vals[y_d]=scalespace_value(&sy_i, y);
- compute_one_data_line_2d(p, serialno, dw, y, x_d, sx_i, dim_vals, &c->p2);
+ dim_vals[y_d]=_sv_scalespace_value(&sy_i, y);
+ _sv_panel2d_compute_line(p, serialno, dw, y, x_d, sx_i, dim_vals, &c->p2);
gdk_threads_enter ();
if(p->private->plot_serialno == serialno){
p->private->plot_complete_count++;
- _dirty_map_one_data_line_y(p,y);
+ _sv_panel2d_mark_map_line_y(p,y);
if(p->private->plot_complete_count>=dh){
- _sushiv_panel_dirty_map(p);
- _sushiv_panel_dirty_legend(p);
- _sushiv_panel_clean_plot(p);
+ _sv_panel_dirty_map(p);
+ _sv_panel_dirty_legend(p);
+ _sv_panel_clean_plot(p);
}else
- _sushiv_panel_dirty_map_throttled(p);
+ _sv_panel_dirty_map_throttled(p);
}
return 1;
}
// only called for resize events
-static void recompute_callback_2d(void *ptr){
- sushiv_panel_t *p = (sushiv_panel_t *)ptr;
+static void _sv_panel2d_recompute_callback(void *ptr){
+ sv_panel_t *p = (sv_panel_t *)ptr;
int i;
gdk_threads_enter ();
- _mark_recompute_2d(p);
- _sushiv_panel2d_compute(p,NULL); // initial scale setup
+ _sv_panel2d_mark_recompute(p);
+ _sv_panel2d_compute(p,NULL); // initial scale setup
// temporary: blank background to checks
- Plot *plot = PLOT(p->private->graph);
+ _sv_plot_t *plot = PLOT(p->private->graph);
int pw = plot->x.pixels;
int ph = plot->y.pixels;
for(i=0;i<ph;i++)
- render_checks((ucolor *)plot->datarect+pw*i, pw, i);
+ render_checks((_sv_ucolor_t *)plot->datarect+pw*i, pw, i);
gdk_threads_leave();
}
-static void panel2d_undo_log(sushiv_panel_undo_t *u, sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_undo_log(_sv_panel_undo_t *u, sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
int i;
// alloc fields as necessary
@@ -1619,9 +1618,9 @@
// populate undo
for(i=0;i<p->objectives;i++){
u->mappings[i] = p2->mappings[i].mapnum;
- u->scale_vals[0][i] = slider_get_value(p2->range_scales[i],0);
- u->scale_vals[1][i] = slider_get_value(p2->range_scales[i],1);
- u->scale_vals[2][i] = slider_get_value(p2->range_scales[i],2);
+ u->scale_vals[0][i] = _sv_slider_get_value(p2->range_scales[i],0);
+ u->scale_vals[1][i] = _sv_slider_get_value(p2->range_scales[i],1);
+ u->scale_vals[2][i] = _sv_slider_get_value(p2->range_scales[i],2);
}
u->x_d = p2->x_dnum;
@@ -1633,46 +1632,46 @@
u->box_active = p->private->oldbox_active;
}
-static void panel2d_undo_restore(sushiv_panel_undo_t *u, sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panel2d_undo_restore(_sv_panel_undo_t *u, sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int i;
// go in through widgets
for(i=0;i<p->objectives;i++){
gtk_combo_box_set_active(GTK_COMBO_BOX(p2->range_pulldowns[i]),u->mappings[i]);
- slider_set_value(p2->range_scales[i],0,u->scale_vals[0][i]);
- slider_set_value(p2->range_scales[i],1,u->scale_vals[1][i]);
- slider_set_value(p2->range_scales[i],2,u->scale_vals[2][i]);
+ _sv_slider_set_value(p2->range_scales[i],0,u->scale_vals[0][i]);
+ _sv_slider_set_value(p2->range_scales[i],1,u->scale_vals[1][i]);
+ _sv_slider_set_value(p2->range_scales[i],2,u->scale_vals[2][i]);
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_xb[u->x_d]),TRUE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_yb[u->y_d]),TRUE);
- update_xy_availability(p);
+ _sv_panel2d_update_xysel(p);
if(u->box_active){
p2->oldbox[0] = u->box[0];
p2->oldbox[1] = u->box[1];
p2->oldbox[2] = u->box[2];
p2->oldbox[3] = u->box[3];
- plot_box_set(plot,u->box);
+ _sv_plot_box_set(plot,u->box);
p->private->oldbox_active = 1;
}else{
- plot_unset_box(plot);
+ _sv_plot_unset_box(plot);
p->private->oldbox_active = 0;
}
}
-static void _sushiv_realize_panel2d(sushiv_panel_t *p){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static void _sv_panel2d_realize(sv_panel_t *p){
+ _sv_panel2d_t *p2 = p->subtype->p2;
int i;
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_suspend(p->sushi);
p->private->toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect_swapped (G_OBJECT (p->private->toplevel), "delete-event",
- G_CALLBACK (_sushiv_clean_exit), (void *)SIGINT);
+ G_CALLBACK (_sv_clean_exit), (void *)SIGINT);
// add border to sides with hbox/padding
GtkWidget *borderbox = gtk_hbox_new(0,0);
@@ -1692,9 +1691,9 @@
/* plotbox, graph */
{
- p->private->graph = GTK_WIDGET(plot_new(recompute_callback_2d,p,
- (void *)(void *)_sushiv_panel2d_crosshairs_callback,p,
- box_callback,p,0));
+ p->private->graph = GTK_WIDGET(_sv_plot_new(_sv_panel2d_recompute_callback,p,
+ (void *)(void *)_sv_panel2d_crosshairs_callback,p,
+ _sv_panel2d_box_callback,p,0));
p->private->plotbox = p->private->graph;
gtk_box_pack_start(GTK_BOX(p->private->topbox), p->private->plotbox, 1,1,2);
}
@@ -1711,7 +1710,7 @@
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].o;
+ sv_obj_t *o = p->objective_list[i].o;
int lo = o->scale->val_list[0];
int hi = o->scale->val_list[o->scale->vals-1];
@@ -1723,22 +1722,22 @@
/* mapping pulldown */
{
- GtkWidget *menu=gtk_combo_box_new_markup();
+ GtkWidget *menu=_gtk_combo_box_new_markup();
int j;
- for(j=0;j<num_mappings();j++)
- gtk_combo_box_append_text (GTK_COMBO_BOX (menu), mapping_name(j));
+ for(j=0;j<_sv_mapping_names();j++)
+ gtk_combo_box_append_text (GTK_COMBO_BOX (menu), _sv_mapping_name(j));
gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
g_signal_connect (G_OBJECT (menu), "changed",
- G_CALLBACK (mapchange_callback_2d), p->objective_list+i);
+ G_CALLBACK (_sv_panel2d_mapchange_callback), p->objective_list+i);
gtk_table_attach(GTK_TABLE(p2->obj_table),menu,4,5,i,i+1,
GTK_SHRINK,GTK_SHRINK,0,0);
p2->range_pulldowns[i] = menu;
}
/* the range mapping slices/slider */
- sl[0] = slice_new(map_callback_2d,p->objective_list+i);
- sl[1] = slice_new(map_callback_2d,p->objective_list+i);
- sl[2] = slice_new(map_callback_2d,p->objective_list+i);
+ sl[0] = _sv_slice_new(_sv_panel2d_map_callback,p->objective_list+i);
+ sl[1] = _sv_slice_new(_sv_panel2d_map_callback,p->objective_list+i);
+ sl[2] = _sv_slice_new(_sv_panel2d_map_callback,p->objective_list+i);
gtk_table_attach(GTK_TABLE(p2->obj_table),sl[0],1,2,i,i+1,
GTK_EXPAND|GTK_FILL,0,0,0);
@@ -1746,15 +1745,15 @@
GTK_EXPAND|GTK_FILL,0,0,0);
gtk_table_attach(GTK_TABLE(p2->obj_table),sl[2],3,4,i,i+1,
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] = _sv_slider_new((_sv_slice_t **)sl,3,o->scale->label_list,o->scale->val_list,
+ o->scale->vals,_SV_SLIDER_FLAG_INDEPENDENT_MIDDLE);
gtk_table_set_col_spacing(GTK_TABLE(p2->obj_table),3,5);
- slice_thumb_set((Slice *)sl[0],lo);
- slice_thumb_set((Slice *)sl[1],lo);
- slice_thumb_set((Slice *)sl[2],hi);
- mapping_setup(&p2->mappings[i],0.,1.,0);
- slider_set_gradient(p2->range_scales[i], &p2->mappings[i]);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[0],lo);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[1],lo);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[2],hi);
+ _sv_mapping_setup(&p2->mappings[i],0.,1.,0);
+ _sv_slider_set_gradient(p2->range_scales[i], &p2->mappings[i]);
}
}
@@ -1771,7 +1770,7 @@
p2->dim_yb = calloc(p->dimensions,sizeof(*p2->dim_yb));
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
/* label */
GtkWidget *label = gtk_label_new(d->name);
@@ -1780,7 +1779,7 @@
GTK_FILL,0,5,0);
/* x/y radio buttons */
- if(!(d->flags & SUSHIV_DIM_NO_X)){
+ if(!(d->flags & SV_DIM_NO_X)){
if(first_x)
p2->dim_xb[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_x),"X");
else{
@@ -1791,7 +1790,7 @@
GTK_SHRINK,0,3,0);
}
- if(!(d->flags & SUSHIV_DIM_NO_Y)){
+ if(!(d->flags & SV_DIM_NO_Y)){
if(first_y)
p2->dim_yb[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_y),"Y");
else
@@ -1805,7 +1804,7 @@
}
p->private->dim_scales[i] =
- _sushiv_new_dimension_widget(p->dimension_list+i,center_callback_2d,bracket_callback_2d);
+ _sv_dim_widget_new(p->dimension_list+i,_sv_panel2d_center_callback,_sv_panel2d_bracket_callback);
gtk_table_attach(GTK_TABLE(p2->dim_table),
p->private->dim_scales[i]->t,
@@ -1816,29 +1815,29 @@
for(i=0;i<p->dimensions;i++){
if(p2->dim_xb[i])
g_signal_connect (G_OBJECT (p2->dim_xb[i]), "toggled",
- G_CALLBACK (dimchange_callback_2d), p);
+ G_CALLBACK (_sv_panel2d_dimchange_callback), p);
if(p2->dim_yb[i])
g_signal_connect (G_OBJECT (p2->dim_yb[i]), "toggled",
- G_CALLBACK (dimchange_callback_2d), p);
+ G_CALLBACK (_sv_panel2d_dimchange_callback), p);
}
}
- update_xy_availability(p);
+ _sv_panel2d_update_xysel(p);
gtk_widget_realize(p->private->toplevel);
gtk_widget_realize(p->private->graph);
gtk_widget_realize(GTK_WIDGET(p->private->spinner));
gtk_widget_show_all(p->private->toplevel);
- update_xy_availability(p); // yes, this was already done; however,
- // gtk clobbered the event setup on the
- // insensitive buttons when it realized
- // them. This call will restore them.
+ _sv_panel2d_update_xysel(p); // yes, this was already done; however,
+ // gtk clobbered the event setup on the
+ // insensitive buttons when it realized
+ // them. This call will restore them.
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static int _save_panel2d(sushiv_panel_t *p, xmlNodePtr pn){
- sushiv_panel2d_t *p2 = p->subtype->p2;
+static int _sv_panel2d_save(sv_panel_t *p, xmlNodePtr pn){
+ _sv_panel2d_t *p2 = p->subtype->p2;
int ret=0,i;
xmlNodePtr n;
@@ -1848,54 +1847,54 @@
// box
if(p->private->oldbox_active){
xmlNodePtr boxn = xmlNewChild(pn, NULL, (xmlChar *) "box", NULL);
- xmlNewPropF(boxn, "x1", p2->oldbox[0]);
- xmlNewPropF(boxn, "x2", p2->oldbox[1]);
- xmlNewPropF(boxn, "y1", p2->oldbox[2]);
- xmlNewPropF(boxn, "y2", p2->oldbox[3]);
+ _xmlNewPropF(boxn, "x1", p2->oldbox[0]);
+ _xmlNewPropF(boxn, "x2", p2->oldbox[1]);
+ _xmlNewPropF(boxn, "y1", p2->oldbox[2]);
+ _xmlNewPropF(boxn, "y2", p2->oldbox[3]);
}
// objective map settings
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
xmlNodePtr on = xmlNewChild(pn, NULL, (xmlChar *) "objective", NULL);
- xmlNewPropI(on, "position", i);
- xmlNewPropI(on, "number", o->number);
- xmlNewPropS(on, "name", o->name);
- xmlNewPropS(on, "type", o->output_types);
+ _xmlNewPropI(on, "position", i);
+ _xmlNewPropI(on, "number", o->number);
+ _xmlNewPropS(on, "name", o->name);
+ _xmlNewPropS(on, "type", o->output_types);
// right now Y is the only type; the below is Y-specific
n = xmlNewChild(on, NULL, (xmlChar *) "y-map", NULL);
- xmlNewPropS(n, "color", mapping_name(p2->mappings[i].mapnum));
- xmlNewPropF(n, "low-bracket", slider_get_value(p2->range_scales[i],0));
- xmlNewPropF(n, "alpha", slider_get_value(p2->range_scales[i],1));
- xmlNewPropF(n, "high-bracket", slider_get_value(p2->range_scales[i],2));
+ _xmlNewPropS(n, "color", _sv_mapping_name(p2->mappings[i].mapnum));
+ _xmlNewPropF(n, "low-bracket", _sv_slider_get_value(p2->range_scales[i],0));
+ _xmlNewPropF(n, "alpha", _sv_slider_get_value(p2->range_scales[i],1));
+ _xmlNewPropF(n, "high-bracket", _sv_slider_get_value(p2->range_scales[i],2));
}
// x/y dim selection
n = xmlNewChild(pn, NULL, (xmlChar *) "axes", NULL);
- xmlNewPropI(n, "xpos", p2->x_dnum);
- xmlNewPropI(n, "ypos", p2->y_dnum);
+ _xmlNewPropI(n, "xpos", p2->x_dnum);
+ _xmlNewPropI(n, "ypos", p2->y_dnum);
return ret;
}
-int _load_panel2d(sushiv_panel_t *p,
- sushiv_panel_undo_t *u,
- xmlNodePtr pn,
- int warn){
+int _sv_panel2d_load(sv_panel_t *p,
+ _sv_panel_undo_t *u,
+ xmlNodePtr pn,
+ int warn){
int i;
// check type
- xmlCheckPropS(pn,"type","2d", "Panel %d type mismatch in save file.",p->number,&warn);
+ _xmlCheckPropS(pn,"type","2d", "Panel %d type mismatch in save file.",p->number,&warn);
// box
u->box_active = 0;
- xmlGetChildPropFPreserve(pn, "box", "x1", &u->box[0]);
- xmlGetChildPropFPreserve(pn, "box", "x2", &u->box[1]);
- xmlGetChildPropFPreserve(pn, "box", "y1", &u->box[2]);
- xmlGetChildPropFPreserve(pn, "box", "y2", &u->box[3]);
+ _xmlGetChildPropFPreserve(pn, "box", "x1", &u->box[0]);
+ _xmlGetChildPropFPreserve(pn, "box", "x2", &u->box[1]);
+ _xmlGetChildPropFPreserve(pn, "box", "y1", &u->box[2]);
+ _xmlGetChildPropFPreserve(pn, "box", "y2", &u->box[3]);
- xmlNodePtr n = xmlGetChildS(pn, "box", NULL, NULL);
+ xmlNodePtr n = _xmlGetChildS(pn, "box", NULL, NULL);
if(n){
u->box_active = 1;
xmlFree(n);
@@ -1903,22 +1902,22 @@
// objective map settings
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
- xmlNodePtr on = xmlGetChildI(pn, "objective", "position", i);
+ sv_obj_t *o = p->objective_list[i].o;
+ xmlNodePtr on = _xmlGetChildI(pn, "objective", "position", i);
if(!on){
- first_load_warning(&warn);
+ _sv_first_load_warning(&warn);
fprintf(stderr,"No save data found for panel %d objective \"%s\".\n",p->number, o->name);
}else{
// check name, type
- xmlCheckPropS(on,"name",o->name, "Objectve position %d name mismatch in save file.",i,&warn);
- xmlCheckPropS(on,"type",o->output_types, "Objectve position %d type mismatch in save file.",i,&warn);
+ _xmlCheckPropS(on,"name",o->name, "Objectve position %d name mismatch in save file.",i,&warn);
+ _xmlCheckPropS(on,"type",o->output_types, "Objectve position %d type mismatch in save file.",i,&warn);
// right now Y is the only type; the below is Y-specific
// load maptype, values
- xmlGetChildPropFPreserve(on, "y-map", "low-bracket", &u->scale_vals[0][i]);
- xmlGetChildPropFPreserve(on, "y-map", "alpha", &u->scale_vals[1][i]);
- xmlGetChildPropFPreserve(on, "y-map", "high-bracket", &u->scale_vals[2][i]);
- xmlGetChildMap(on, "y-map", "color", mapping_map(), &u->mappings[i],
+ _xmlGetChildPropFPreserve(on, "y-map", "low-bracket", &u->scale_vals[0][i]);
+ _xmlGetChildPropFPreserve(on, "y-map", "alpha", &u->scale_vals[1][i]);
+ _xmlGetChildPropFPreserve(on, "y-map", "high-bracket", &u->scale_vals[2][i]);
+ _xmlGetChildMap(on, "y-map", "color", _sv_mapping_map(), &u->mappings[i],
"Panel %d objective unknown mapping setting", p->number, &warn);
xmlFreeNode(on);
@@ -1926,56 +1925,54 @@
}
// x/y dim selection
- xmlGetChildPropIPreserve(pn, "axes", "xpos", &u->x_d);
- xmlGetChildPropI(pn, "axes", "ypos", &u->y_d);
+ _xmlGetChildPropIPreserve(pn, "axes", "xpos", &u->x_d);
+ _xmlGetChildPropI(pn, "axes", "ypos", &u->y_d);
return warn;
}
-int sushiv_new_panel_2d(sushiv_instance_t *s,
- int number,
- const char *name,
- int *objectives,
- int *dimensions,
- unsigned flags){
+sv_panel_t *sv_panel_new_2d(sv_instance_t *s,
+ int number,
+ char *name,
+ sv_obj_t **objectives,
+ sv_dim_t **dimensions,
+ unsigned flags){
int i,j;
- int ret = _sushiv_new_panel(s,number,name,objectives,dimensions,flags);
- sushiv_panel_t *p;
- sushiv_panel2d_t *p2;
- int fout_offsets[s->functions];
+ sv_panel_t *p = _sv_panel_new(s,number,name,objectives,dimensions,flags);
+ if(!p)return NULL;
- if(ret<0)return ret;
- p = s->panel_list[number];
- p2 = calloc(1, sizeof(*p2));
+ _sv_panel2d_t *p2 = calloc(1, sizeof(*p2));
+ int fout_offsets[s->functions];
+
p->subtype =
calloc(1, sizeof(*p->subtype)); /* the union is alloced not
embedded as its internal
- structure must be hidden */
-
+ structure must be hidden */
p->subtype->p2 = p2;
- p->type = SUSHIV_PANEL_2D;
- p->private->bg_type = SUSHIV_BG_CHECKS;
+ p->type = SV_PANEL_2D;
+ p->private->bg_type = SV_BG_CHECKS;
// 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;
+ errno = -EINVAL;
+ return NULL;
}
}
- p->private->realize = _sushiv_realize_panel2d;
- p->private->map_action = _sushiv_panel2d_map_redraw;
- p->private->legend_action = _sushiv_panel2d_legend_redraw;
- p->private->compute_action = _sushiv_panel2d_compute;
- p->private->request_compute = _mark_recompute_2d;
- p->private->crosshair_action = _sushiv_panel2d_crosshairs_callback;
- p->private->print_action = sushiv_panel2d_print;
- p->private->undo_log = panel2d_undo_log;
- p->private->undo_restore = panel2d_undo_restore;
- p->private->save_action = _save_panel2d;
- p->private->load_action = _load_panel2d;
+ p->private->realize = _sv_panel2d_realize;
+ p->private->map_action = _sv_panel2d_map_redraw;
+ p->private->legend_action = _sv_panel2d_legend_redraw;
+ p->private->compute_action = _sv_panel2d_compute;
+ p->private->request_compute = _sv_panel2d_mark_recompute;
+ p->private->crosshair_action = _sv_panel2d_crosshairs_callback;
+ p->private->print_action = _sv_panel2d_print;
+ p->private->undo_log = _sv_panel2d_undo_log;
+ p->private->undo_restore = _sv_panel2d_undo_restore;
+ p->private->save_action = _sv_panel2d_save;
+ p->private->load_action = _sv_panel2d_load;
/* set up helper data structures for rendering */
@@ -1988,14 +1985,14 @@
memset(fout_offsets,-1,sizeof(fout_offsets));
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
for(j=0;j<o->outputs;j++)
used[o->function_map[j]]=1;
}
for(i=0;i<fn;i++)
if(used[i]){
- sushiv_function_t *f = p->sushi->function_list[i];
+ sv_func_t *f = p->sushi->function_list[i];
fout_offsets[i] = offcount;
offcount += f->outputs;
count++;
@@ -2018,7 +2015,7 @@
int yobj_count = 0;
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
if(o->private->y_func) yobj_count++;
}
@@ -2029,7 +2026,7 @@
yobj_count=0;
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
if(o->private->y_func){
p2->y_obj_list[yobj_count] = o;
p2->y_obj_to_panel[yobj_count] = i;
@@ -2045,7 +2042,7 @@
{
p2->y_fout_offset = calloc(p2->y_obj_num, sizeof(*p2->y_fout_offset));
for(i=0;i<p2->y_obj_num;i++){
- sushiv_objective_t *o = p2->y_obj_list[i];
+ sv_obj_t *o = p2->y_obj_list[i];
int funcnum = o->private->y_func->number;
p2->y_fout_offset[i] = fout_offsets[funcnum] + o->private->y_fout;
}
Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/panel-2d.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -19,14 +19,14 @@
*
*/
-typedef struct sushiv_panel2d {
+typedef struct {
GtkWidget *obj_table;
GtkWidget *dim_table;
/* only run those functions used by this panel */
int used_functions;
- sushiv_function_t **used_function_list;
+ sv_func_t **used_function_list;
unsigned char *bg_todo;
int bg_next_line;
@@ -36,14 +36,14 @@
/**** Y PLANES ******/
int y_obj_num;
int **y_map; // indirected, dw*dh
- ucolor **y_planes; // indirected, dw*dh
+ _sv_ucolor_t **y_planes; // indirected, dw*dh
unsigned char **y_planetodo; // indirected, dh
int partial_remap;
int y_next_plane; // which y plane to issue next render
int y_next_line; // incremented when a line is claimed, per plane [0-ph)
- sushiv_objective_t **y_obj_list; // list of objectives with a y plane
+ sv_obj_t **y_obj_list; // list of objectives with a y plane
int *y_obj_to_panel; /* maps from position in condensed list to position in full list */
int *y_obj_from_panel; /* maps from position in full list to position in condensed list */
int *y_fout_offset;
@@ -57,32 +57,32 @@
float yscalemul;
/* scales and data -> display scale mapping */
- scalespace x;
- scalespace x_v;
- scalespace x_i;
- scalespace y;
- scalespace y_v;
- scalespace y_i;
+ _sv_scalespace_t x;
+ _sv_scalespace_t x_v;
+ _sv_scalespace_t x_i;
+ _sv_scalespace_t y;
+ _sv_scalespace_t y_v;
+ _sv_scalespace_t y_i;
int scales_init;
double oldbox[4];
- mapping *mappings;
- Slider **range_scales;
+ _sv_mapping_t *mappings;
+ _sv_slider_t **range_scales;
GtkWidget **range_pulldowns;
double *alphadel;
GtkWidget **dim_xb;
GtkWidget **dim_yb;
- sushiv_dimension_t *x_d;
- sushiv_dimension_t *y_d;
- sushiv_dim_widget_t *x_scale;
- sushiv_dim_widget_t *y_scale;
+ sv_dim_t *x_d;
+ sv_dim_t *y_d;
+ _sv_dim_widget_t *x_scale;
+ _sv_dim_widget_t *y_scale;
int x_dnum; // panel, not global list context
int y_dnum; // panel, not global list context
-} sushiv_panel2d_t;
+} _sv_panel2d_t;
typedef struct {
double *fout; // [function number * outval_number]
@@ -99,5 +99,5 @@
int *xnumB;
float xscalemul;
-} _sushiv_bythread_cache_2d;
+} _sv_bythread_cache_2d_t;
Modified: trunk/sushivision/panel-xy.c
===================================================================
--- trunk/sushivision/panel-xy.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/panel-xy.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -33,29 +33,29 @@
#include "internal.h"
#define LINETYPES 3
-static propmap *line_name[LINETYPES+1] = {
- &(propmap){"line", 0, NULL,NULL,NULL},
- &(propmap){"fat line", 1, NULL,NULL,NULL},
- &(propmap){"no line", 5, NULL,NULL,NULL},
+static _sv_propmap_t *line_name[LINETYPES+1] = {
+ &(_sv_propmap_t){"line", 0, NULL,NULL,NULL},
+ &(_sv_propmap_t){"fat line", 1, NULL,NULL,NULL},
+ &(_sv_propmap_t){"no line", 5, NULL,NULL,NULL},
NULL
};
#define POINTTYPES 9
-static propmap *point_name[POINTTYPES+1] = {
- &(propmap){"dot", 0, NULL,NULL,NULL},
- &(propmap){"cross", 1, NULL,NULL,NULL},
- &(propmap){"plus", 2, NULL,NULL,NULL},
- &(propmap){"open circle", 3, NULL,NULL,NULL},
- &(propmap){"open square", 4, NULL,NULL,NULL},
- &(propmap){"open triangle", 5, NULL,NULL,NULL},
- &(propmap){"solid circle", 6, NULL,NULL,NULL},
- &(propmap){"solid square", 7, NULL,NULL,NULL},
- &(propmap){"solid triangle", 8, NULL,NULL,NULL},
+static _sv_propmap_t *point_name[POINTTYPES+1] = {
+ &(_sv_propmap_t){"dot", 0, NULL,NULL,NULL},
+ &(_sv_propmap_t){"cross", 1, NULL,NULL,NULL},
+ &(_sv_propmap_t){"plus", 2, NULL,NULL,NULL},
+ &(_sv_propmap_t){"open circle", 3, NULL,NULL,NULL},
+ &(_sv_propmap_t){"open square", 4, NULL,NULL,NULL},
+ &(_sv_propmap_t){"open triangle", 5, NULL,NULL,NULL},
+ &(_sv_propmap_t){"solid circle", 6, NULL,NULL,NULL},
+ &(_sv_propmap_t){"solid square", 7, NULL,NULL,NULL},
+ &(_sv_propmap_t){"solid triangle", 8, NULL,NULL,NULL},
NULL
};
-static void clear_xy_data(sushiv_panel_t *p){
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_clear_data(sv_panel_t *p){
+ _sv_panelxy_t *xy = p->subtype->xy;
int i;
if(xy->x_vec){
@@ -100,9 +100,9 @@
// called internally, assumes we hold lock
// redraws the data, does not compute the data
-static int _sushiv_panelxy_remap(sushiv_panel_t *p, cairo_t *c){
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static int _sv_panelxy_remap(sv_panel_t *p, cairo_t *c){
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int plot_serialno = p->private->plot_serialno;
int map_serialno = p->private->map_serialno;
@@ -111,11 +111,11 @@
int ph = plot->y.pixels;
int ret = 1;
- scalespace sx = xy->x;
- scalespace sy = xy->y;
- scalespace data_v = xy->data_v;
- scalespace px = plot->x;
- scalespace py = plot->y;
+ _sv_scalespace_t sx = xy->x;
+ _sv_scalespace_t sy = xy->y;
+ _sv_scalespace_t data_v = xy->data_v;
+ _sv_scalespace_t px = plot->x;
+ _sv_scalespace_t py = plot->y;
/* do the panel and plot scales match? If not, redraw the plot
scales */
@@ -127,21 +127,21 @@
plot->y = sy;
gdk_threads_leave();
- plot_draw_scales(plot);
+ _sv_plot_draw_scales(plot);
}else
gdk_threads_leave();
/* blank frame to selected bg */
switch(p->private->bg_type){
- case SUSHIV_BG_WHITE:
+ case SV_BG_WHITE:
cairo_set_source_rgb (c, 1.,1.,1.);
cairo_paint(c);
break;
- case SUSHIV_BG_BLACK:
+ case SV_BG_BLACK:
cairo_set_source_rgb (c, 0,0,0);
cairo_paint(c);
break;
- case SUSHIV_BG_CHECKS:
+ case SV_BG_CHECKS:
render_checks(c,pw,ph);
break;
}
@@ -157,12 +157,12 @@
/* by objective */
for(j=0;j<p->objectives;j++){
- if(xy->x_vec[j] && xy->y_vec[j] && !mapping_inactive_p(xy->mappings+j)){
+ if(xy->x_vec[j] && xy->y_vec[j] && !_sv_mapping_inactive_p(xy->mappings+j)){
- double alpha = slider_get_value(xy->alpha_scale[j],0);
+ double alpha = _sv_slider_get_value(xy->alpha_scale[j],0);
int linetype = xy->linetype[j];
int pointtype = xy->pointtype[j];
- u_int32_t color = mapping_calc(xy->mappings+j,1.,0);
+ u_int32_t color = _sv_mapping_calc(xy->mappings+j,1.,0);
// copy the list data over
memcpy(xv,xy->x_vec[j],dw*sizeof(*xv));
@@ -176,10 +176,10 @@
/* map data vector bin to x pixel location in the plot */
if(!isnan(xpixel))
- xpixel = scalespace_pixel(&sx,xpixel)+.5;
+ xpixel = _sv_scalespace_pixel(&sx,xpixel)+.5;
if(!isnan(ypixel))
- ypixel = scalespace_pixel(&sy,ypixel)+.5;
+ ypixel = _sv_scalespace_pixel(&sy,ypixel)+.5;
xv[xi] = xpixel;
yv[xi] = ypixel;
@@ -271,7 +271,7 @@
}
if(pointtype>0){
- if(p->private->bg_type == SUSHIV_BG_WHITE)
+ if(p->private->bg_type == SV_BG_WHITE)
cairo_set_source_rgba(c,0.,0.,0.,alpha);
else
cairo_set_source_rgba(c,1.,1.,1.,alpha);
@@ -297,8 +297,8 @@
return ret;
}
-static void sushiv_panelxy_print(sushiv_panel_t *p, cairo_t *c, int w, int h){
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panelxy_print(sv_panel_t *p, cairo_t *c, int w, int h){
+ _sv_plot_t *plot = PLOT(p->private->graph);
double pw = p->private->graph->allocation.width;
double ph = p->private->graph->allocation.height;
double scale;
@@ -313,19 +313,19 @@
cairo_matrix_scale(&m,scale,scale);
cairo_set_matrix(c,&m);
- plot_print(plot, c, ph*scale, (void(*)(void *, cairo_t *))_sushiv_panelxy_remap, p);
+ _sv_plot_print(plot, c, ph*scale, (void(*)(void *, cairo_t *))_sv_panelxy_remap, p);
}
-static void update_legend(sushiv_panel_t *p){
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panelxy_update_legend(sv_panel_t *p){
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
gdk_threads_enter ();
if(plot){
int i,depth=0;
char buffer[320];
- plot_legend_clear(plot);
+ _sv_plot_legend_clear(plot);
if(3-xy->x.decimal_exponent > depth) depth = 3-xy->x.decimal_exponent;
if(3-xy->y.decimal_exponent > depth) depth = 3-xy->y.decimal_exponent;
@@ -338,7 +338,7 @@
legend,
depth,
plot->selx);
- plot_legend_add(plot,buffer);
+ _sv_plot_legend_add(plot,buffer);
legend = xy->y_scale->legend;
if(!strcmp(legend,""))legend = "Y";
@@ -346,16 +346,16 @@
legend,
depth,
plot->sely);
- plot_legend_add(plot,buffer);
+ _sv_plot_legend_add(plot,buffer);
if(p->dimensions)
- plot_legend_add(plot,NULL);
+ _sv_plot_legend_add(plot,NULL);
}
// add each dimension to the legend
if(-xy->data_v.decimal_exponent > depth) depth = -xy->data_v.decimal_exponent;
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
if(d != xy->x_d ||
plot->cross_active){
@@ -364,7 +364,7 @@
p->dimension_list[i].d->name,
depth,
p->dimension_list[i].d->val);
- plot_legend_add(plot,buffer);
+ _sv_plot_legend_add(plot,buffer);
}
}
@@ -373,8 +373,8 @@
}
// call with lock
-static double _determine_rerender_metric(sushiv_panel_t *p, int off){
- sushiv_panelxy_t *xy = p->subtype->xy;
+static double _sv_panelxy_zoom_metric(sv_panel_t *p, int off){
+ _sv_panelxy_t *xy = p->subtype->xy;
int on = p->objectives;
double pw = p->private->graph->allocation.width;
double ph = p->private->graph->allocation.height;
@@ -382,14 +382,14 @@
// if this is a discrete data set, size/view changes cannot affect
// the data spacing; that's set by the discrete scale
- if(xy->x_d->type != SUSHIV_DIM_CONTINUOUS) return -1;
+ if(xy->x_d->type != SV_DIM_CONTINUOUS) return -1;
- double xscale = scalespace_pixel(&xy->x,1.) - scalespace_pixel(&xy->x,0.);
- double yscale = scalespace_pixel(&xy->y,1.) - scalespace_pixel(&xy->y,0.);
- double lox = scalespace_value(&xy->x,0.);
- double loy = scalespace_value(&xy->y,ph);
- double hix = scalespace_value(&xy->x,pw);
- double hiy = scalespace_value(&xy->y,0.);
+ double xscale = _sv_scalespace_pixel(&xy->x,1.) - _sv_scalespace_pixel(&xy->x,0.);
+ double yscale = _sv_scalespace_pixel(&xy->y,1.) - _sv_scalespace_pixel(&xy->y,0.);
+ double lox = _sv_scalespace_value(&xy->x,0.);
+ double loy = _sv_scalespace_value(&xy->y,ph);
+ double hix = _sv_scalespace_value(&xy->x,pw);
+ double hiy = _sv_scalespace_value(&xy->y,0.);
// by plane, look at the spacing between visible x/y points
double max = -1;
@@ -431,17 +431,16 @@
}
// call while locked
-static int _mark_recompute_by_metric(sushiv_panel_t *p, int recursing){
+static int _sv_panelxy_mark_recompute_by_metric(sv_panel_t *p, int recursing){
if(!p->private->realized) return 0;
- sushiv_panelxy_t *xy = p->subtype->xy;
+ _sv_panelxy_t *xy = p->subtype->xy;
// discrete val dimensions are immune to rerender by metric changes
- if(xy->x_d->type != SUSHIV_DIM_CONTINUOUS) return 0;
+ if(xy->x_d->type != SV_DIM_CONTINUOUS) return 0;
double target = (double) p->private->oversample_d / p->private->oversample_n;
- double full = _determine_rerender_metric(p, 1);
- double half = _determine_rerender_metric(p, 2);
+ double full = _sv_panelxy_zoom_metric(p, 1);
if(full > target){
// we want to halve the sample spacing. But first make sure we're
@@ -453,9 +452,11 @@
xy->req_zoom = xy->curr_zoom+1;
- _sushiv_panel_dirty_plot(p); // trigger recompute
+ _sv_panel_dirty_plot(p); // trigger recompute
return 1;
} else {
+
+ double half = _sv_panelxy_zoom_metric(p, 2);
if(half < target){
// we want to double the sample spacing. But first make sure we're
// not looping due to uncertainties in the metric.
@@ -466,7 +467,7 @@
xy->req_zoom = xy->curr_zoom-1;
- _sushiv_panel_dirty_plot(p); // trigger recompute
+ _sv_panel_dirty_plot(p); // trigger recompute
return 1;
}
@@ -476,114 +477,114 @@
return 0;
}
-static void mapchange_callback_xy(GtkWidget *w,gpointer in){
- sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
- sushiv_panel_t *p = optr->p;
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_mapchange_callback(GtkWidget *w,gpointer in){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ sv_panel_t *p = optr->p;
+ _sv_panelxy_t *xy = p->subtype->xy;
int onum = optr - p->objective_list;
- Plot *plot = PLOT(p->private->graph);
+ _sv_plot_t *plot = PLOT(p->private->graph);
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
// update colormap
// oh, the wasteful
int pos = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
- solid_set_func(&xy->mappings[onum],pos);
- slider_set_gradient(xy->alpha_scale[onum], &xy->mappings[onum]);
+ _sv_solid_set_func(&xy->mappings[onum],pos);
+ _sv_slider_set_gradient(xy->alpha_scale[onum], &xy->mappings[onum]);
// if the mapping has become inactive and the crosshairs point to
// this objective, inactivate the crosshairs.
if(xy->cross_objnum == onum)
plot->cross_active = 0;
- _sushiv_panel_dirty_map(p);
- _sushiv_panel_dirty_legend(p);
+ _sv_panel_dirty_map(p);
+ _sv_panel_dirty_legend(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void alpha_callback_xy(void * in, int buttonstate){
- sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
- sushiv_panel_t *p = optr->p;
+static void _sv_panelxy_alpha_callback(void * in, int buttonstate){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ sv_panel_t *p = optr->p;
if(buttonstate == 0){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
}
- _sushiv_panel_dirty_map(p);
- _sushiv_panel_dirty_legend(p);
+ _sv_panel_dirty_map(p);
+ _sv_panel_dirty_legend(p);
if(buttonstate == 2)
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void linetype_callback_xy(GtkWidget *w,gpointer in){
- sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
- sushiv_panel_t *p = optr->p;
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_linetype_callback(GtkWidget *w,gpointer in){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ sv_panel_t *p = optr->p;
+ _sv_panelxy_t *xy = p->subtype->xy;
int onum = optr - p->objective_list;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
// update colormap
int pos = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
xy->linetype[onum] = line_name[pos]->value;
- _sushiv_panel_dirty_map(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_panel_dirty_map(p);
+ _sv_undo_resume(p->sushi);
}
-static void pointtype_callback_xy(GtkWidget *w,gpointer in){
- sushiv_objective_list_t *optr = (sushiv_objective_list_t *)in;
- sushiv_panel_t *p = optr->p;
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_pointtype_callback(GtkWidget *w,gpointer in){
+ sv_obj_list_t *optr = (sv_obj_list_t *)in;
+ sv_panel_t *p = optr->p;
+ _sv_panelxy_t *xy = p->subtype->xy;
int onum = optr - p->objective_list;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
// update colormap
int pos = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
xy->pointtype[onum] = point_name[pos]->value;
- _sushiv_panel_dirty_map(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_panel_dirty_map(p);
+ _sv_undo_resume(p->sushi);
}
-static void map_callback_xy(void *in,int buttonstate){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panelxy_map_callback(void *in,int buttonstate){
+ sv_panel_t *p = (sv_panel_t *)in;
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(buttonstate == 0){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
}
// has new bracketing changed the plot range scale?
- if(xy->x_bracket[0] != slider_get_value(xy->x_slider,0) ||
- xy->x_bracket[1] != slider_get_value(xy->x_slider,1) ||
- xy->y_bracket[0] != slider_get_value(xy->y_slider,0) ||
- xy->y_bracket[1] != slider_get_value(xy->y_slider,1)){
+ if(xy->x_bracket[0] != _sv_slider_get_value(xy->x_slider,0) ||
+ xy->x_bracket[1] != _sv_slider_get_value(xy->x_slider,1) ||
+ xy->y_bracket[0] != _sv_slider_get_value(xy->y_slider,0) ||
+ xy->y_bracket[1] != _sv_slider_get_value(xy->y_slider,1)){
int w = plot->w.allocation.width;
int h = plot->w.allocation.height;
- xy->x_bracket[0] = slider_get_value(xy->x_slider,0);
- xy->x_bracket[1] = slider_get_value(xy->x_slider,1);
- xy->y_bracket[0] = slider_get_value(xy->y_slider,0);
- xy->y_bracket[1] = slider_get_value(xy->y_slider,1);
+ xy->x_bracket[0] = _sv_slider_get_value(xy->x_slider,0);
+ xy->x_bracket[1] = _sv_slider_get_value(xy->x_slider,1);
+ xy->y_bracket[0] = _sv_slider_get_value(xy->y_slider,0);
+ xy->y_bracket[1] = _sv_slider_get_value(xy->y_slider,1);
- xy->x = scalespace_linear(xy->x_bracket[0],
+ xy->x = _sv_scalespace_linear(xy->x_bracket[0],
xy->x_bracket[1],
w,
plot->scalespacing,
xy->x_scale->legend);
- xy->y = scalespace_linear(xy->y_bracket[1],
+ xy->y = _sv_scalespace_linear(xy->y_bracket[1],
xy->y_bracket[0],
h,
plot->scalespacing,
@@ -591,17 +592,17 @@
// a map view size change may trigger a progressive up/down render,
// but will at least cause a remap
- _mark_recompute_by_metric(p,0);
- _sushiv_panel_dirty_map(p);
+ _sv_panelxy_mark_recompute_by_metric(p,0);
+ _sv_panel_dirty_map(p);
}
if(buttonstate == 2)
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void update_dim_sel(sushiv_panel_t *p){
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_update_xsel(sv_panel_t *p){
+ _sv_panelxy_t *xy = p->subtype->xy;
int i;
// enable/disable dimension slider thumbs
@@ -618,25 +619,25 @@
if(xy->dim_xb[i] &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(xy->dim_xb[i]))){
// make all thumbs visible
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,1);
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,1);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,1);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,1);
}else{
// make bracket thumbs invisible */
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,0);
- _sushiv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,0);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],0,0);
+ _sv_dim_widget_set_thumb_active(p->private->dim_scales[i],2,0);
}
}
}
-static void compute_xy(sushiv_panel_t *p,
- int serialno,
- int x_d,
- scalespace sxi,
- double *dim_vals,
- char *prefilled,
- double **x_vec,
- double **y_vec,
- _sushiv_bythread_cache_xy *c){
+static void _sv_panelxy_compute_line(sv_panel_t *p,
+ int serialno,
+ int x_d,
+ _sv_scalespace_t sxi,
+ double *dim_vals,
+ char *prefilled,
+ double **x_vec,
+ double **y_vec,
+ _sv_bythread_cache_xy_t *c){
int i,j,fn=p->sushi->functions;
int w = sxi.pixels;
@@ -644,7 +645,7 @@
/* by x */
for(j=0;j<w;j++){
if(!prefilled[j]){
- dim_vals[x_d] = scalespace_value(&sxi,j);
+ dim_vals[x_d] = _sv_scalespace_value(&sxi,j);
/* by function */
for(i=0;i<fn;i++){
@@ -658,11 +659,11 @@
/* xy panels currently only care about the XY output values; in the
future, Z and others may also be relevant */
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
int xoff = o->private->x_fout;
int yoff = o->private->y_fout;
- sushiv_function_t *xf = o->private->x_func;
- sushiv_function_t *yf = o->private->y_func;
+ sv_func_t *xf = o->private->x_func;
+ sv_func_t *yf = o->private->y_func;
x_vec[i][j] = c->fout[xf->number][xoff];
y_vec[i][j] = c->fout[yf->number][yoff];
}
@@ -676,47 +677,47 @@
return;
}
- spinner_set_busy(p->private->spinner);
+ _sv_spinner_set_busy(p->private->spinner);
gdk_threads_leave();
}
}
}
// call with lock
-void _mark_recompute_xy(sushiv_panel_t *p){
+void _sv_panelxy_mark_recompute(sv_panel_t *p){
if(!p->private->realized) return;
- sushiv_panelxy_t *xy = p->subtype->xy;
+ _sv_panelxy_t *xy = p->subtype->xy;
xy->req_zoom = xy->prev_zoom = xy->curr_zoom;
- _sushiv_panel_dirty_plot(p);
+ _sv_panel_dirty_plot(p);
}
-static void recompute_callback_xy(void *ptr){
- sushiv_panel_t *p = (sushiv_panel_t *)ptr;
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panelxy_recompute_callback(void *ptr){
+ sv_panel_t *p = (sv_panel_t *)ptr;
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int w = plot->w.allocation.width;
int h = plot->w.allocation.height;
- plot->x = xy->x = scalespace_linear(xy->x_bracket[0],
+ plot->x = xy->x = _sv_scalespace_linear(xy->x_bracket[0],
xy->x_bracket[1],
w,
plot->scalespacing,
xy->x_scale->legend);
- plot->y = xy->y = scalespace_linear(xy->y_bracket[1],
+ plot->y = xy->y = _sv_scalespace_linear(xy->y_bracket[1],
xy->y_bracket[0],
h,
plot->scalespacing,
xy->y_scale->legend);
// always recompute, but also update zoom
- if(!_mark_recompute_by_metric(p,0))
- _mark_recompute_xy(p);
+ if(!_sv_panelxy_mark_recompute_by_metric(p,0))
+ _sv_panelxy_mark_recompute(p);
}
-static void update_crosshair(sushiv_panel_t *p){
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panelxy_update_crosshair(sv_panel_t *p){
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(!p->private->realized)return;
@@ -733,78 +734,78 @@
if(!xy->x_vec[xy->cross_objnum] || !xy->y_vec[xy->cross_objnum])return;
// get bin number of dim value
- int x_bin = rint(scalespace_pixel(&xy->data_v, xy->x_d->val));
+ int x_bin = rint(_sv_scalespace_pixel(&xy->data_v, xy->x_d->val));
double x = xy->x_vec[xy->cross_objnum][x_bin];
double y = xy->y_vec[xy->cross_objnum][x_bin];
- plot_set_crosshairs(plot,x,y);
- sushiv_dimension_set_value(p->sushi,xy->x_d->number,1,scalespace_value(&xy->data_v, x_bin));
+ _sv_plot_set_crosshairs(plot,x,y);
+ sv_dim_set_value(xy->x_d,1,_sv_scalespace_value(&xy->data_v, x_bin));
- _sushiv_panel_dirty_legend(p);
+ _sv_panel_dirty_legend(p);
}
-static void center_callback_xy(sushiv_dimension_list_t *dptr){
- sushiv_dimension_t *d = dptr->d;
- sushiv_panel_t *p = dptr->p;
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_center_callback(sv_dim_list_t *dptr){
+ sv_dim_t *d = dptr->d;
+ sv_panel_t *p = dptr->p;
+ _sv_panelxy_t *xy = p->subtype->xy;
int axisp = (d == xy->x_d);
if(!axisp){
// mid slider of a non-axis dimension changed, rerender
- clear_xy_data(p);
- _mark_recompute_xy(p);
+ _sv_panelxy_clear_data(p);
+ _sv_panelxy_mark_recompute(p);
}else{
// mid slider of an axis dimension changed, move crosshairs
- update_crosshair(p);
+ _sv_panelxy_update_crosshair(p);
}
}
-static void bracket_callback_xy(sushiv_dimension_list_t *dptr){
- sushiv_dimension_t *d = dptr->d;
- sushiv_panel_t *p = dptr->p;
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_bracket_callback(sv_dim_list_t *dptr){
+ sv_dim_t *d = dptr->d;
+ sv_panel_t *p = dptr->p;
+ _sv_panelxy_t *xy = p->subtype->xy;
int axisp = (d == xy->x_d);
// always need to recompute, may also need to update zoom
if(axisp)
- if(!_mark_recompute_by_metric(p,0))
- _mark_recompute_xy(p);
+ if(!_sv_panelxy_mark_recompute_by_metric(p,0))
+ _sv_panelxy_mark_recompute(p);
}
-static void dimchange_callback_xy(GtkWidget *button,gpointer in){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_dimchange_callback(GtkWidget *button,gpointer in){
+ sv_panel_t *p = (sv_panel_t *)in;
+ _sv_panelxy_t *xy = p->subtype->xy;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- update_dim_sel(p);
+ _sv_panelxy_update_xsel(p);
// clear data vectors so that none of the data is reused.
- clear_xy_data(p);
+ _sv_panelxy_clear_data(p);
- update_crosshair(p); // which is to say, deactivate it
- plot_unset_box(PLOT(p->private->graph));
+ _sv_panelxy_update_crosshair(p); // which is to say, deactivate it
+ _sv_plot_unset_box(PLOT(p->private->graph));
xy->curr_zoom = xy->prev_zoom = xy->req_zoom = 0;
- _mark_recompute_xy(p);
+ _sv_panelxy_mark_recompute(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
}
-static void crosshair_callback(sushiv_panel_t *p){
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_crosshair_callback(sv_panel_t *p){
+ _sv_panelxy_t *xy = p->subtype->xy;
double x=PLOT(p->private->graph)->selx;
double y=PLOT(p->private->graph)->sely;
int i,j;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
// snap crosshairs to the closest plotted x/y point
int besto=-1;
@@ -812,7 +813,7 @@
double bestdist;
for(i=0;i<p->objectives;i++){
- if(xy->x_vec[i] && xy->y_vec[i] && !mapping_inactive_p(xy->mappings+i)){
+ if(xy->x_vec[i] && xy->y_vec[i] && !_sv_mapping_inactive_p(xy->mappings+i)){
for(j=0;j<xy->data_v.pixels;j++){
double xd = x - xy->x_vec[i][j];
double yd = y - xy->y_vec[i][j];
@@ -834,46 +835,46 @@
PLOT(p->private->graph)->sely = y;
xy->cross_objnum = besto;
- double dimval = scalespace_value(&xy->data_v, bestbin);
- sushiv_dimension_set_value(p->sushi,xy->x_d->number,1,dimval);
+ double dimval = _sv_scalespace_value(&xy->data_v, bestbin);
+ sv_dim_set_value(xy->x_d,1,dimval);
}
p->private->oldbox_active = 0;
- _sushiv_undo_resume(p->sushi);
- _sushiv_panel_dirty_legend(p);
+ _sv_undo_resume(p->sushi);
+ _sv_panel_dirty_legend(p);
}
-static void box_callback(void *in, int state){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panelxy_box_callback(void *in, int state){
+ sv_panel_t *p = (sv_panel_t *)in;
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
switch(state){
case 0: // box set
- _sushiv_undo_push(p->sushi);
- plot_box_vals(plot,xy->oldbox);
+ _sv_undo_push(p->sushi);
+ _sv_plot_box_vals(plot,xy->oldbox);
p->private->oldbox_active = plot->box_active;
break;
case 1: // box activate
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- crosshair_callback(p);
+ _sv_panelxy_crosshair_callback(p);
- slider_set_value(xy->x_slider,0,xy->oldbox[0]);
- slider_set_value(xy->x_slider,1,xy->oldbox[1]);
- slider_set_value(xy->y_slider,0,xy->oldbox[2]);
- slider_set_value(xy->y_slider,1,xy->oldbox[3]);
+ _sv_slider_set_value(xy->x_slider,0,xy->oldbox[0]);
+ _sv_slider_set_value(xy->x_slider,1,xy->oldbox[1]);
+ _sv_slider_set_value(xy->y_slider,0,xy->oldbox[2]);
+ _sv_slider_set_value(xy->y_slider,1,xy->oldbox[3]);
p->private->oldbox_active = 0;
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
break;
}
- _sushiv_panel_update_menus(p);
+ _sv_panel_update_menus(p);
}
-void _maintain_cache_xy(sushiv_panel_t *p, _sushiv_bythread_cache_xy *c, int w){
+void _sv_panelxy_maintain_cache(sv_panel_t *p, _sv_bythread_cache_xy_t *c, int w){
/* toplevel initialization */
if(c->fout == 0){
@@ -883,7 +884,7 @@
c->call = calloc(p->sushi->functions,sizeof(*c->call));
c->fout = calloc(p->sushi->functions,sizeof(*c->fout));
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
for(j=0;j<o->outputs;j++)
c->call[o->function_map[j]]=
p->sushi->function_list[o->function_map[j]]->callback;
@@ -899,19 +900,19 @@
}
// subtype entry point for plot remaps; lock held
-int _sushiv_panelxy_map_redraw(sushiv_panel_t *p, _sushiv_bythread_cache *c){
+int _sv_panelxy_map_redraw(sv_panel_t *p, _sv_bythread_cache_t *c){
if(p->private->map_progress_count)return 0;
p->private->map_progress_count++;
// render to a temp surface so that we can release the lock occasionally
- Plot *plot = PLOT(p->private->graph);
+ _sv_plot_t *plot = PLOT(p->private->graph);
cairo_surface_t *back = plot->back;
cairo_surface_t *cs = cairo_surface_create_similar(back,CAIRO_CONTENT_COLOR,
cairo_image_surface_get_width(back),
cairo_image_surface_get_height(back));
cairo_t *ct = cairo_create(cs);
- if(_sushiv_panelxy_remap(p,ct) == -1){ // returns -1 on abort
+ if(_sv_panelxy_remap(p,ct) == -1){ // returns -1 on abort
cairo_destroy(ct);
cairo_surface_destroy(cs);
}else{
@@ -920,46 +921,46 @@
plot->back = cs;
cairo_destroy(ct);
- _sushiv_panel_clean_map(p);
- plot_expose_request(plot);
+ _sv_panel_clean_map(p);
+ _sv_plot_expose_request(plot);
}
return 1;
}
// subtype entry point for legend redraws; lock held
-int _sushiv_panelxy_legend_redraw(sushiv_panel_t *p){
- Plot *plot = PLOT(p->private->graph);
+int _sv_panelxy_legend_redraw(sv_panel_t *p){
+ _sv_plot_t *plot = PLOT(p->private->graph);
if(p->private->legend_progress_count)return 0;
p->private->legend_progress_count++;
- update_legend(p);
- _sushiv_panel_clean_legend(p);
+ _sv_panelxy_update_legend(p);
+ _sv_panel_clean_legend(p);
gdk_threads_leave();
- plot_draw_scales(plot);
+ _sv_plot_draw_scales(plot);
gdk_threads_enter();
- plot_expose_request(plot);
+ _sv_plot_expose_request(plot);
return 1;
}
// dim scales are autozoomed; we want the initial values to quantize
// to the same grid regardless of zoom level or starting bracket as
// well as only encompass the desired range
-static int _generate_dimscale_xy(sushiv_dimension_t *d, int zoom, scalespace *v, scalespace *i){
- scalespace x;
+static int _sv_panelxy_generate_dimscale(sv_dim_t *d, int zoom, _sv_scalespace_t *v, _sv_scalespace_t *i){
+ _sv_scalespace_t x;
- if(d->type != SUSHIV_DIM_CONTINUOUS){
+ if(d->type != SV_DIM_CONTINUOUS){
// non-continuous is unaffected by zoom
- _sushiv_dimension_scales(d, d->bracket[0], d->bracket[1], 2, 2, 1, d->name, &x, v, i);
+ _sv_dim_scales(d, d->bracket[0], d->bracket[1], 2, 2, 1, d->name, &x, v, i);
return 0;
}
// continuous dimensions are, in some ways, handled like a discrete dim.
double lo = d->scale->val_list[0];
double hi = d->scale->val_list[d->scale->vals-1];
- _sushiv_dimension_scales(d, lo, hi, 2, 2, 1, d->name, &x, v, i);
+ _sv_dim_scales(d, lo, hi, 2, 2, 1, d->name, &x, v, i);
// this is iterative, not direct computation, so that at each level
// we have a small adjustment (as opposed to one huge adjustment at
@@ -969,27 +970,27 @@
while (sofar<zoom){
// double scale resolution
- scalespace_double(v);
- scalespace_double(i);
+ _sv_scalespace_double(v);
+ _sv_scalespace_double(i);
if(v->massaged)return 1;
// clip scales down the the desired part of the range
// an assumption: v->step_pixel == 1 because spacing is 1. We can
// increment first_val instead of first_pixel.
- while(scalespace_value(v,1)*neg < d->bracket[0]*neg){
+ while(_sv_scalespace_value(v,1)*neg < d->bracket[0]*neg){
v->first_val += v->step_val*neg;
i->first_val += v->step_val*neg;
v->pixels--;
i->pixels--;
}
- while(v->pixels>2 && scalespace_value(v,v->pixels-1)*neg > d->bracket[1]*neg){
+ while(v->pixels>2 && _sv_scalespace_value(v,v->pixels-1)*neg > d->bracket[1]*neg){
v->pixels--;
i->pixels--;
}
- while(scalespace_value(v,v->pixels-1)*neg < d->bracket[1]*neg){
+ while(_sv_scalespace_value(v,v->pixels-1)*neg < d->bracket[1]*neg){
v->pixels++;
i->pixels++;
}
@@ -1000,9 +1001,9 @@
return 0;
}
-static void _rescale_xy(scalespace *old, double **oldx, double **oldy,
- scalespace *new, double **newx, double **newy,
- char *prefilled, int objectives){
+static void _sv_panelxy_rescale(_sv_scalespace_t *old, double **oldx, double **oldy,
+ _sv_scalespace_t *new, double **newx, double **newy,
+ char *prefilled, int objectives){
if(!oldx || !oldy)return;
@@ -1014,9 +1015,9 @@
if(!oldx[j] || !oldy[j])
return;
- long num = scalespace_scalenum(new,old);
- long den = scalespace_scaleden(new,old);
- long oldpos = -scalespace_scalebin(new,old);
+ long num = _sv_scalespace_scalenum(new,old);
+ long den = _sv_scalespace_scaleden(new,old);
+ long oldpos = -_sv_scalespace_scalebin(new,old);
long newpos = 0;
while(newi < new->pixels && oldi < old->pixels){
@@ -1047,10 +1048,10 @@
}
// subtype entry point for recomputation; lock held
-int _sushiv_panelxy_compute(sushiv_panel_t *p,
- _sushiv_bythread_cache *c){
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot;
+int _sv_panelxy_compute(sv_panel_t *p,
+ _sv_bythread_cache_t *c){
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot;
int dw,w,h,i,d;
int serialno;
@@ -1058,7 +1059,7 @@
int prev_zoom = xy->curr_zoom;
int zoom = xy->req_zoom;
- scalespace sxv = xy->data_v;
+ _sv_scalespace_t sxv = xy->data_v;
plot = PLOT(p->private->graph);
dw = sxv.pixels;
@@ -1081,9 +1082,9 @@
x_d = xy->x_d->number;
/* generate a new data_v/data_i */
- scalespace newv;
- scalespace newi;
- _generate_dimscale_xy(xy->x_d, zoom, &newv, &newi);
+ _sv_scalespace_t newv;
+ _sv_scalespace_t newi;
+ _sv_panelxy_generate_dimscale(xy->x_d, zoom, &newv, &newi);
dw = newv.pixels;
/* compare new/old data scales; pre-fill the data vec with values
@@ -1095,16 +1096,16 @@
new_x_vec[i] = calloc(dw,sizeof(**new_x_vec));
new_y_vec[i] = calloc(dw,sizeof(**new_y_vec));
}
- _rescale_xy(&sxv,xy->x_vec,xy->y_vec,
- &newv,new_x_vec,new_y_vec,prefilled, p->objectives);
+ _sv_panelxy_rescale(&sxv,xy->x_vec,xy->y_vec,
+ &newv,new_x_vec,new_y_vec,prefilled, p->objectives);
// Initialize local dimension value array
for(i=0;i<p->sushi->dimensions;i++){
- sushiv_dimension_t *dim = p->sushi->dimension_list[i];
+ sv_dim_t *dim = p->sushi->dimension_list[i];
dim_vals[i]=dim->val;
}
- _maintain_cache_xy(p,&c->xy,dw);
+ _sv_panelxy_maintain_cache(p,&c->xy,dw);
plot->x = xy->x;
plot->y = xy->y;
@@ -1112,14 +1113,14 @@
/* unlock for computation */
gdk_threads_leave ();
- compute_xy(p, serialno, x_d, newi, dim_vals, prefilled, new_x_vec, new_y_vec, &c->xy);
+ _sv_panelxy_compute_line(p, serialno, x_d, newi, dim_vals, prefilled, new_x_vec, new_y_vec, &c->xy);
gdk_threads_enter ();
if(serialno == p->private->plot_serialno){
// replace data vectors
p->private->plot_serialno++;
- clear_xy_data(p);
+ _sv_panelxy_clear_data(p);
if(!xy->x_vec)
xy->x_vec = calloc(p->objectives, sizeof(*xy->x_vec));
if(!xy->y_vec)
@@ -1136,12 +1137,12 @@
xy->prev_zoom = prev_zoom;
xy->curr_zoom = zoom;
- _sushiv_panel_clean_plot(p);
- if(!_mark_recompute_by_metric(p, 1)){
- _sushiv_panel_dirty_legend(p);
- _sushiv_panel_dirty_map(p);
+ _sv_panel_clean_plot(p);
+ if(!_sv_panelxy_mark_recompute_by_metric(p, 1)){
+ _sv_panel_dirty_legend(p);
+ _sv_panel_dirty_map(p);
}else{
- _sushiv_panel_dirty_map_throttled(p);
+ _sv_panel_dirty_map_throttled(p);
}
}else{
@@ -1155,9 +1156,9 @@
return 1;
}
-static void panelxy_undo_log(sushiv_panel_undo_t *u, sushiv_panel_t *p){
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panelxy_undo_log(_sv_panel_undo_t *u, sv_panel_t *p){
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int i;
// alloc fields as necessary
@@ -1171,19 +1172,19 @@
u->scale_vals[2] = calloc(p->objectives,sizeof(**u->scale_vals));
// populate undo
- u->scale_vals[0][0] = slider_get_value(xy->x_slider,0);
- u->scale_vals[1][0] = slider_get_value(xy->x_slider,1);
+ u->scale_vals[0][0] = _sv_slider_get_value(xy->x_slider,0);
+ u->scale_vals[1][0] = _sv_slider_get_value(xy->x_slider,1);
u->scale_vals[0][1] = plot->selx;
u->scale_vals[1][1] = plot->sely;
- u->scale_vals[0][2] = slider_get_value(xy->y_slider,0);
- u->scale_vals[1][2] = slider_get_value(xy->y_slider,1);
+ u->scale_vals[0][2] = _sv_slider_get_value(xy->y_slider,0);
+ u->scale_vals[1][2] = _sv_slider_get_value(xy->y_slider,1);
for(i=0;i<p->objectives;i++){
u->mappings[i] =
(xy->mappings[i].mapnum<<24) |
(xy->linetype[i]<<16) |
(xy->pointtype[i]<<8);
- u->scale_vals[2][i] = slider_get_value(xy->alpha_scale[i],0);
+ u->scale_vals[2][i] = _sv_slider_get_value(xy->alpha_scale[i],0);
}
u->x_d = xy->x_dnum;
@@ -1196,56 +1197,56 @@
}
-static void panelxy_undo_restore(sushiv_panel_undo_t *u, sushiv_panel_t *p){
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static void _sv_panelxy_undo_restore(_sv_panel_undo_t *u, sv_panel_t *p){
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int i;
// go in through widgets
- slider_set_value(xy->x_slider,0,u->scale_vals[0][0]);
- slider_set_value(xy->x_slider,1,u->scale_vals[1][0]);
+ _sv_slider_set_value(xy->x_slider,0,u->scale_vals[0][0]);
+ _sv_slider_set_value(xy->x_slider,1,u->scale_vals[1][0]);
plot->selx = u->scale_vals[0][1];
plot->sely = u->scale_vals[1][1];
- slider_set_value(xy->y_slider,0,u->scale_vals[0][2]);
- slider_set_value(xy->y_slider,1,u->scale_vals[1][2]);
+ _sv_slider_set_value(xy->y_slider,0,u->scale_vals[0][2]);
+ _sv_slider_set_value(xy->y_slider,1,u->scale_vals[1][2]);
for(i=0;i<p->objectives;i++){
gtk_combo_box_set_active(GTK_COMBO_BOX(xy->map_pulldowns[i]), (u->mappings[i]>>24)&0xff );
gtk_combo_box_set_active(GTK_COMBO_BOX(xy->line_pulldowns[i]), (u->mappings[i]>>16)&0xff );
gtk_combo_box_set_active(GTK_COMBO_BOX(xy->point_pulldowns[i]), (u->mappings[i]>>8)&0xff );
- slider_set_value(xy->alpha_scale[i],0,u->scale_vals[2][i]);
+ _sv_slider_set_value(xy->alpha_scale[i],0,u->scale_vals[2][i]);
}
if(xy->dim_xb && u->x_d<p->dimensions && xy->dim_xb[u->x_d])
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(xy->dim_xb[u->x_d]),TRUE);
- update_dim_sel(p);
- crosshair_callback(p);
+ _sv_panelxy_update_xsel(p);
+ _sv_panelxy_crosshair_callback(p);
if(u->box_active){
xy->oldbox[0] = u->box[0];
xy->oldbox[1] = u->box[1];
xy->oldbox[2] = u->box[2];
xy->oldbox[3] = u->box[3];
- plot_box_set(plot,u->box);
+ _sv_plot_box_set(plot,u->box);
p->private->oldbox_active = 1;
}else{
- plot_unset_box(plot);
+ _sv_plot_unset_box(plot);
p->private->oldbox_active = 0;
}
}
-void _sushiv_realize_panelxy(sushiv_panel_t *p){
- sushiv_panelxy_t *xy = p->subtype->xy;
+static void _sv_panelxy_realize(sv_panel_t *p){
+ _sv_panelxy_t *xy = p->subtype->xy;
char buffer[160];
int i;
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_suspend(p->sushi);
p->private->toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect_swapped (G_OBJECT (p->private->toplevel), "delete-event",
- G_CALLBACK (_sushiv_clean_exit), (void *)SIGINT);
+ G_CALLBACK (_sv_clean_exit), (void *)SIGINT);
// add border to sides with hbox/padding
GtkWidget *borderbox = gtk_hbox_new(0,0);
@@ -1269,9 +1270,9 @@
p->private->plotbox = xy->graph_table;
gtk_box_pack_start(GTK_BOX(p->private->topbox), p->private->plotbox, 1,1,2);
- p->private->graph = GTK_WIDGET(plot_new(recompute_callback_xy,p,
- (void *)(void *)crosshair_callback,p,
- box_callback,p,0));
+ p->private->graph = GTK_WIDGET(_sv_plot_new(_sv_panelxy_recompute_callback,p,
+ (void *)(void *)_sv_panelxy_crosshair_callback,p,
+ _sv_panelxy_box_callback,p,0));
gtk_table_attach(GTK_TABLE(xy->graph_table),p->private->graph,1,3,0,2,
GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,0,1);
@@ -1284,10 +1285,10 @@
GtkWidget **sly = calloc(2,sizeof(*sly));
/* the range slices/slider */
- slx[0] = slice_new(map_callback_xy,p);
- slx[1] = slice_new(map_callback_xy,p);
- sly[0] = slice_new(map_callback_xy,p);
- sly[1] = slice_new(map_callback_xy,p);
+ slx[0] = _sv_slice_new(_sv_panelxy_map_callback,p);
+ slx[1] = _sv_slice_new(_sv_panelxy_map_callback,p);
+ sly[0] = _sv_slice_new(_sv_panelxy_map_callback,p);
+ sly[1] = _sv_slice_new(_sv_panelxy_map_callback,p);
gtk_table_attach(GTK_TABLE(xy->graph_table),slx[0],1,2,2,3,
GTK_EXPAND|GTK_FILL,0,0,0);
@@ -1299,25 +1300,25 @@
GTK_SHRINK,GTK_EXPAND|GTK_FILL,0,0);
gtk_table_set_col_spacing(GTK_TABLE(xy->graph_table),0,4);
- xy->x_slider = slider_new((Slice **)slx,2,
+ xy->x_slider = _sv_slider_new((_sv_slice_t **)slx,2,
xy->x_scale->label_list,
xy->x_scale->val_list,
xy->x_scale->vals,0);
- xy->y_slider = slider_new((Slice **)sly,2,
+ xy->y_slider = _sv_slider_new((_sv_slice_t **)sly,2,
xy->y_scale->label_list,
xy->y_scale->val_list,
xy->y_scale->vals,
- SLIDER_FLAG_VERTICAL);
+ _SV_SLIDER_FLAG_VERTICAL);
int lo = xy->x_scale->val_list[0];
int hi = xy->x_scale->val_list[xy->x_scale->vals-1];
- slice_thumb_set((Slice *)slx[0],lo);
- slice_thumb_set((Slice *)slx[1],hi);
+ _sv_slice_thumb_set((_sv_slice_t *)slx[0],lo);
+ _sv_slice_thumb_set((_sv_slice_t *)slx[1],hi);
lo = xy->y_scale->val_list[0];
hi = xy->y_scale->val_list[xy->y_scale->vals-1];
- slice_thumb_set((Slice *)sly[0],lo);
- slice_thumb_set((Slice *)sly[1],hi);
+ _sv_slice_thumb_set((_sv_slice_t *)sly[0],lo);
+ _sv_slice_thumb_set((_sv_slice_t *)sly[1],hi);
}
/* obj box */
@@ -1335,7 +1336,7 @@
xy->alpha_scale = calloc(p->objectives,sizeof(*xy->alpha_scale));
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
/* label */
GtkWidget *label = gtk_label_new(o->name);
@@ -1345,23 +1346,23 @@
/* mapping pulldown */
{
- GtkWidget *menu=gtk_combo_box_new_markup();
+ GtkWidget *menu=_gtk_combo_box_new_markup();
int j;
- for(j=0;j<num_solids();j++){
- if(strcmp(solid_name(j),"inactive"))
- snprintf(buffer,sizeof(buffer),"<span foreground=\"%s\">%s</span>",solid_name(j),solid_name(j));
+ for(j=0;j<_sv_solid_names();j++){
+ if(strcmp(_sv_solid_name(j),"inactive"))
+ snprintf(buffer,sizeof(buffer),"<span foreground=\"%s\">%s</span>",_sv_solid_name(j),_sv_solid_name(j));
else
- snprintf(buffer,sizeof(buffer),"%s",solid_name(j));
+ snprintf(buffer,sizeof(buffer),"%s",_sv_solid_name(j));
gtk_combo_box_append_text (GTK_COMBO_BOX (menu), buffer);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
g_signal_connect (G_OBJECT (menu), "changed",
- G_CALLBACK (mapchange_callback_xy), p->objective_list+i);
+ G_CALLBACK (_sv_panelxy_mapchange_callback), p->objective_list+i);
gtk_table_attach(GTK_TABLE(xy->obj_table),menu,1,2,i,i+1,
GTK_SHRINK,GTK_SHRINK,5,0);
xy->map_pulldowns[i] = menu;
- solid_setup(&xy->mappings[i],0.,1.,0);
+ _sv_solid_setup(&xy->mappings[i],0.,1.,0);
}
/* line pulldown */
@@ -1372,7 +1373,7 @@
gtk_combo_box_append_text (GTK_COMBO_BOX (menu), line_name[j]->left);
gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
g_signal_connect (G_OBJECT (menu), "changed",
- G_CALLBACK (linetype_callback_xy), p->objective_list+i);
+ G_CALLBACK (_sv_panelxy_linetype_callback), p->objective_list+i);
gtk_table_attach(GTK_TABLE(xy->obj_table),menu,2,3,i,i+1,
GTK_SHRINK,GTK_SHRINK,5,0);
xy->line_pulldowns[i] = menu;
@@ -1386,7 +1387,7 @@
gtk_combo_box_append_text (GTK_COMBO_BOX (menu), point_name[j]->left);
gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
g_signal_connect (G_OBJECT (menu), "changed",
- G_CALLBACK (pointtype_callback_xy), p->objective_list+i);
+ G_CALLBACK (_sv_panelxy_pointtype_callback), p->objective_list+i);
gtk_table_attach(GTK_TABLE(xy->obj_table),menu,3,4,i,i+1,
GTK_SHRINK,GTK_SHRINK,5,0);
xy->point_pulldowns[i] = menu;
@@ -1395,18 +1396,18 @@
/* alpha slider */
{
GtkWidget **sl = calloc(1, sizeof(*sl));
- sl[0] = slice_new(alpha_callback_xy,p->objective_list+i);
+ sl[0] = _sv_slice_new(_sv_panelxy_alpha_callback,p->objective_list+i);
gtk_table_attach(GTK_TABLE(xy->obj_table),sl[0],4,5,i,i+1,
GTK_EXPAND|GTK_FILL,0,0,0);
- xy->alpha_scale[i] = slider_new((Slice **)sl,1,
+ xy->alpha_scale[i] = _sv_slider_new((_sv_slice_t **)sl,1,
(char *[]){"transparent","solid"},
(double []){0.,1.},
2,0);
- slider_set_gradient(xy->alpha_scale[i], &xy->mappings[i]);
- slice_thumb_set((Slice *)sl[0],1.);
+ _sv_slider_set_gradient(xy->alpha_scale[i], &xy->mappings[i]);
+ _sv_slice_thumb_set((_sv_slice_t *)sl[0],1.);
}
}
@@ -1422,7 +1423,7 @@
GtkWidget *first_x = NULL;
for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
+ sv_dim_t *d = p->dimension_list[i].d;
/* label */
GtkWidget *label = gtk_label_new(d->name);
@@ -1431,7 +1432,7 @@
GTK_FILL,0,5,0);
/* x radio buttons */
- if(!(d->flags & SUSHIV_DIM_NO_X)){
+ if(!(d->flags & SV_DIM_NO_X)){
if(first_x)
xy->dim_xb[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_x),"X");
else{
@@ -1443,7 +1444,7 @@
}
p->private->dim_scales[i] =
- _sushiv_new_dimension_widget(p->dimension_list+i,center_callback_xy,bracket_callback_xy);
+ _sv_dim_widget_new(p->dimension_list+i,_sv_panelxy_center_callback,_sv_panelxy_bracket_callback);
gtk_table_attach(GTK_TABLE(xy->dim_table),
GTK_WIDGET(p->private->dim_scales[i]->t),
@@ -1455,9 +1456,9 @@
for(i=0;i<p->dimensions;i++)
if(xy->dim_xb[i])
g_signal_connect (G_OBJECT (xy->dim_xb[i]), "toggled",
- G_CALLBACK (dimchange_callback_xy), p);
+ G_CALLBACK (_sv_panelxy_dimchange_callback), p);
- update_dim_sel(p);
+ _sv_panelxy_update_xsel(p);
}
gtk_widget_realize(p->private->toplevel);
@@ -1465,13 +1466,13 @@
gtk_widget_realize(GTK_WIDGET(p->private->spinner));
gtk_widget_show_all(p->private->toplevel);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static int _save_panelxy(sushiv_panel_t *p, xmlNodePtr pn){
- sushiv_panelxy_t *xy = p->subtype->xy;
- Plot *plot = PLOT(p->private->graph);
+static int _sv_panelxy_save(sv_panel_t *p, xmlNodePtr pn){
+ _sv_panelxy_t *xy = p->subtype->xy;
+ _sv_plot_t *plot = PLOT(p->private->graph);
int ret=0,i;
xmlNodePtr n;
@@ -1481,64 +1482,64 @@
// box
if(p->private->oldbox_active){
xmlNodePtr boxn = xmlNewChild(pn, NULL, (xmlChar *) "box", NULL);
- xmlNewPropF(boxn, "x1", xy->oldbox[0]);
- xmlNewPropF(boxn, "x2", xy->oldbox[1]);
- xmlNewPropF(boxn, "y1", xy->oldbox[2]);
- xmlNewPropF(boxn, "y2", xy->oldbox[3]);
+ _xmlNewPropF(boxn, "x1", xy->oldbox[0]);
+ _xmlNewPropF(boxn, "x2", xy->oldbox[1]);
+ _xmlNewPropF(boxn, "y1", xy->oldbox[2]);
+ _xmlNewPropF(boxn, "y2", xy->oldbox[3]);
}
// objective map settings
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
+ sv_obj_t *o = p->objective_list[i].o;
xmlNodePtr on = xmlNewChild(pn, NULL, (xmlChar *) "objective", NULL);
- xmlNewPropI(on, "position", i);
- xmlNewPropI(on, "number", o->number);
- xmlNewPropS(on, "name", o->name);
- xmlNewPropS(on, "type", o->output_types);
+ _xmlNewPropI(on, "position", i);
+ _xmlNewPropI(on, "number", o->number);
+ _xmlNewPropS(on, "name", o->name);
+ _xmlNewPropS(on, "type", o->output_types);
// right now Y is the only type; the below is Y-specific
n = xmlNewChild(on, NULL, (xmlChar *) "y-map", NULL);
- xmlNewMapProp(n, "color", solid_map(), xy->mappings[i].mapnum);
- xmlNewMapProp(n, "line", line_name, xy->linetype[i]);
- xmlNewMapProp(n, "point", point_name, xy->pointtype[i]);
- xmlNewPropF(n, "alpha", slider_get_value(xy->alpha_scale[i],0));
+ _xmlNewMapProp(n, "color", _sv_solid_map(), xy->mappings[i].mapnum);
+ _xmlNewMapProp(n, "line", line_name, xy->linetype[i]);
+ _xmlNewMapProp(n, "point", point_name, xy->pointtype[i]);
+ _xmlNewPropF(n, "alpha", _sv_slider_get_value(xy->alpha_scale[i],0));
}
// x/y scale
n = xmlNewChild(pn, NULL, (xmlChar *) "range", NULL);
- xmlNewPropF(n, "x-low-bracket", slider_get_value(xy->x_slider,0));
- xmlNewPropF(n, "x-high-bracket", slider_get_value(xy->x_slider,1));
- xmlNewPropF(n, "y-low-bracket", slider_get_value(xy->y_slider,0));
- xmlNewPropF(n, "y-high-bracket", slider_get_value(xy->y_slider,1));
- xmlNewPropF(n, "x-cross", plot->selx);
- xmlNewPropF(n, "y-cross", plot->sely);
+ _xmlNewPropF(n, "x-low-bracket", _sv_slider_get_value(xy->x_slider,0));
+ _xmlNewPropF(n, "x-high-bracket", _sv_slider_get_value(xy->x_slider,1));
+ _xmlNewPropF(n, "y-low-bracket", _sv_slider_get_value(xy->y_slider,0));
+ _xmlNewPropF(n, "y-high-bracket", _sv_slider_get_value(xy->y_slider,1));
+ _xmlNewPropF(n, "x-cross", plot->selx);
+ _xmlNewPropF(n, "y-cross", plot->sely);
// x/y dim selection
n = xmlNewChild(pn, NULL, (xmlChar *) "axes", NULL);
- xmlNewPropI(n, "xpos", xy->x_dnum);
+ _xmlNewPropI(n, "xpos", xy->x_dnum);
return ret;
}
-int _load_panelxy(sushiv_panel_t *p,
- sushiv_panel_undo_t *u,
- xmlNodePtr pn,
- int warn){
+int _sv_panelxy_load(sv_panel_t *p,
+ _sv_panel_undo_t *u,
+ xmlNodePtr pn,
+ int warn){
int i;
// check type
- xmlCheckPropS(pn,"type","xy", "Panel %d type mismatch in save file.",p->number,&warn);
+ _xmlCheckPropS(pn,"type","xy", "Panel %d type mismatch in save file.",p->number,&warn);
// box
u->box_active = 0;
- xmlGetChildPropFPreserve(pn, "box", "x1", &u->box[0]);
- xmlGetChildPropFPreserve(pn, "box", "x2", &u->box[1]);
- xmlGetChildPropFPreserve(pn, "box", "y1", &u->box[2]);
- xmlGetChildPropFPreserve(pn, "box", "y2", &u->box[3]);
+ _xmlGetChildPropFPreserve(pn, "box", "x1", &u->box[0]);
+ _xmlGetChildPropFPreserve(pn, "box", "x2", &u->box[1]);
+ _xmlGetChildPropFPreserve(pn, "box", "y1", &u->box[2]);
+ _xmlGetChildPropFPreserve(pn, "box", "y2", &u->box[3]);
- xmlNodePtr n = xmlGetChildS(pn, "box", NULL, NULL);
+ xmlNodePtr n = _xmlGetChildS(pn, "box", NULL, NULL);
if(n){
u->box_active = 1;
xmlFree(n);
@@ -1546,15 +1547,15 @@
// objective map settings
for(i=0;i<p->objectives;i++){
- sushiv_objective_t *o = p->objective_list[i].o;
- xmlNodePtr on = xmlGetChildI(pn, "objective", "position", i);
+ sv_obj_t *o = p->objective_list[i].o;
+ xmlNodePtr on = _xmlGetChildI(pn, "objective", "position", i);
if(!on){
- first_load_warning(&warn);
+ _sv_first_load_warning(&warn);
fprintf(stderr,"No save data found for panel %d objective \"%s\".\n",p->number, o->name);
}else{
// check name, type
- xmlCheckPropS(on,"name",o->name, "Objectve position %d name mismatch in save file.",i,&warn);
- xmlCheckPropS(on,"type",o->output_types, "Objectve position %d type mismatch in save file.",i,&warn);
+ _xmlCheckPropS(on,"name",o->name, "Objectve position %d name mismatch in save file.",i,&warn);
+ _xmlCheckPropS(on,"type",o->output_types, "Objectve position %d type mismatch in save file.",i,&warn);
// right now Y is the only type; the below is Y-specific
// load maptype, values
@@ -1562,69 +1563,67 @@
int line = (u->mappings[i]>>16)&0xff;
int point = (u->mappings[i]>>8)&0xff;
- xmlGetChildMapPreserve(on, "y-map", "color", solid_map(), &color,
+ _xmlGetChildMapPreserve(on, "y-map", "color", _sv_solid_map(), &color,
"Panel %d objective unknown mapping setting", p->number, &warn);
- xmlGetChildMapPreserve(on, "y-map", "line", line_name, &line,
+ _xmlGetChildMapPreserve(on, "y-map", "line", line_name, &line,
"Panel %d objective unknown mapping setting", p->number, &warn);
- xmlGetChildMapPreserve(on, "y-map", "point", point_name, &point,
+ _xmlGetChildMapPreserve(on, "y-map", "point", point_name, &point,
"Panel %d objective unknown mapping setting", p->number, &warn);
- xmlGetChildPropF(on, "y-map", "alpha", &u->scale_vals[2][i]);
+ _xmlGetChildPropF(on, "y-map", "alpha", &u->scale_vals[2][i]);
u->mappings[i] = (color<<24) | (line<<16) | (point<<8);
xmlFreeNode(on);
}
}
+
+ _xmlGetChildPropFPreserve(pn, "range", "x-low-bracket", &u->scale_vals[0][0]);
+ _xmlGetChildPropFPreserve(pn, "range", "x-high-bracket", &u->scale_vals[1][0]);
+ _xmlGetChildPropFPreserve(pn, "range", "y-low-bracket", &u->scale_vals[0][2]);
+ _xmlGetChildPropFPreserve(pn, "range", "y-high-bracket", &u->scale_vals[1][2]);
+ _xmlGetChildPropFPreserve(pn, "range", "x-cross", &u->scale_vals[0][1]);
+ _xmlGetChildPropF(pn, "range", "y-cross", &u->scale_vals[1][1]);
- xmlGetChildPropFPreserve(pn, "range", "x-low-bracket", &u->scale_vals[0][0]);
- xmlGetChildPropFPreserve(pn, "range", "x-high-bracket", &u->scale_vals[1][0]);
- xmlGetChildPropFPreserve(pn, "range", "y-low-bracket", &u->scale_vals[0][2]);
- xmlGetChildPropFPreserve(pn, "range", "y-high-bracket", &u->scale_vals[1][2]);
- xmlGetChildPropFPreserve(pn, "range", "x-cross", &u->scale_vals[0][1]);
- xmlGetChildPropF(pn, "range", "y-cross", &u->scale_vals[1][1]);
-
// x/y dim selection
- xmlGetChildPropI(pn, "axes", "xpos", &u->x_d);
+ _xmlGetChildPropI(pn, "axes", "xpos", &u->x_d);
return warn;
}
-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){
+sv_panel_t *sv_panel_new_xy(sv_instance_t *s,
+ int number,
+ char *name,
+ sv_scale_t *xscale,
+ sv_scale_t *yscale,
+ sv_obj_t **objectives,
+ sv_dim_t **dimensions,
+ unsigned flags){
- int ret = _sushiv_new_panel(s,number,name,objectives,dimensions,flags);
- sushiv_panel_t *p;
- sushiv_panelxy_t *xy;
+ sv_panel_t *p = _sv_panel_new(s,number,name,objectives,dimensions,flags);
+ _sv_panelxy_t *xy;
- if(ret<0)return ret;
- p = s->panel_list[number];
+ if(!p)return NULL;
xy = calloc(1, sizeof(*xy));
p->subtype = calloc(1, sizeof(*p->subtype));
p->subtype->xy = xy;
- p->type = SUSHIV_PANEL_XY;
- xy->x_scale = xscale;
- xy->y_scale = yscale;
- p->private->bg_type = SUSHIV_BG_WHITE;
+ p->type = SV_PANEL_XY;
+ xy->x_scale = (sv_scale_t *)xscale;
+ xy->y_scale = (sv_scale_t *)yscale;
+ p->private->bg_type = SV_BG_WHITE;
- p->private->realize = _sushiv_realize_panelxy;
- p->private->map_action = _sushiv_panelxy_map_redraw;
- p->private->legend_action = _sushiv_panelxy_legend_redraw;
- p->private->compute_action = _sushiv_panelxy_compute;
- p->private->request_compute = _mark_recompute_xy;
- p->private->crosshair_action = crosshair_callback;
- p->private->print_action = sushiv_panelxy_print;
- p->private->save_action = _save_panelxy;
- p->private->load_action = _load_panelxy;
+ p->private->realize = _sv_panelxy_realize;
+ p->private->map_action = _sv_panelxy_map_redraw;
+ p->private->legend_action = _sv_panelxy_legend_redraw;
+ p->private->compute_action = _sv_panelxy_compute;
+ p->private->request_compute = _sv_panelxy_mark_recompute;
+ p->private->crosshair_action = _sv_panelxy_crosshair_callback;
+ p->private->print_action = _sv_panelxy_print;
+ p->private->save_action = _sv_panelxy_save;
+ p->private->load_action = _sv_panelxy_load;
- p->private->undo_log = panelxy_undo_log;
- p->private->undo_restore = panelxy_undo_restore;
+ p->private->undo_log = _sv_panelxy_undo_log;
+ p->private->undo_restore = _sv_panelxy_undo_restore;
p->private->def_oversample_n = p->private->oversample_n = 1;
p->private->def_oversample_d = p->private->oversample_d = 8;
Modified: trunk/sushivision/panel-xy.h
===================================================================
--- trunk/sushivision/panel-xy.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/panel-xy.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -19,7 +19,7 @@
*
*/
-typedef struct sushiv_panelxy {
+typedef struct {
GtkWidget *graph_table;
GtkWidget *obj_table;
GtkWidget *dim_table;
@@ -28,43 +28,43 @@
int panel_h;
// panel x/y don't correspond to dimensions like on other panels
- scalespace x;
- scalespace y;
+ _sv_scalespace_t x;
+ _sv_scalespace_t y;
double oldbox[4];
- sushiv_scale_t *x_scale;
- sushiv_scale_t *y_scale;
- Slider *x_slider;
- Slider *y_slider;
+ sv_scale_t *x_scale;
+ sv_scale_t *y_scale;
+ _sv_slider_t *x_slider;
+ _sv_slider_t *y_slider;
double x_bracket[2];
double y_bracket[2];
int cross_objnum;
- scalespace data_v; // the x scale aligned to data vector's bins
- scalespace data_i; // the 'counting' scale used to iterate for compute
+ _sv_scalespace_t data_v; // the x scale aligned to data vector's bins
+ _sv_scalespace_t data_i; // the 'counting' scale used to iterate for compute
double **x_vec;
double **y_vec;
int req_zoom;
int curr_zoom;
int prev_zoom;
- mapping *mappings;
+ _sv_mapping_t *mappings;
int *linetype;
int *pointtype;
GtkWidget **map_pulldowns;
GtkWidget **line_pulldowns;
GtkWidget **point_pulldowns;
- Slider **alpha_scale;
+ _sv_slider_t **alpha_scale;
GtkWidget **dim_xb;
- sushiv_dimension_t *x_d;
- sushiv_dim_widget_t *x_widget;
+ sv_dim_t *x_d;
+ _sv_dim_widget_t *x_widget;
int x_dnum; // number of dimension within panel, not global instance
-} sushiv_panelxy_t;
+} _sv_panelxy_t;
typedef struct {
void (**call)(double *, double *);
double **fout; // [function number][outval_number]
-} _sushiv_bythread_cache_xy;
+} _sv_bythread_cache_xy_t;
Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/panel.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -34,40 +34,40 @@
#include <cairo-ft.h>
#include "internal.h"
-extern void _sushiv_wake_workers(void);
-static void wrap_exit(sushiv_panel_t *dummy, GtkWidget *dummyw);
-static void wrap_bg(sushiv_panel_t *p, GtkWidget *w);
-static void wrap_grid(sushiv_panel_t *p, GtkWidget *w);
-static void wrap_text(sushiv_panel_t *p, GtkWidget *w);
-static void wrap_res(sushiv_panel_t *p, GtkWidget *w);
-static void do_load(sushiv_panel_t *p, GtkWidget *dummy);
-static void do_save(sushiv_panel_t *p, GtkWidget *dummy);
-static void _sushiv_panel_print(sushiv_panel_t *p, GtkWidget *dummy);
-static void wrap_undo_up(sushiv_panel_t *p, GtkWidget *dummy);
-static void wrap_undo_down(sushiv_panel_t *p, GtkWidget *dummy);
-static void wrap_legend(sushiv_panel_t *p, GtkWidget *dummy);
-static void wrap_escape(sushiv_panel_t *p, GtkWidget *dummy);
-static void wrap_enter(sushiv_panel_t *p, GtkWidget *dummy);
+extern void _sv_wake_workers(void);
+static void wrap_exit(sv_panel_t *dummy, GtkWidget *dummyw);
+static void wrap_bg(sv_panel_t *p, GtkWidget *w);
+static void wrap_grid(sv_panel_t *p, GtkWidget *w);
+static void wrap_text(sv_panel_t *p, GtkWidget *w);
+static void wrap_res(sv_panel_t *p, GtkWidget *w);
+static void wrap_load(sv_panel_t *p, GtkWidget *dummy);
+static void wrap_save(sv_panel_t *p, GtkWidget *dummy);
+static void _sv_panel_print(sv_panel_t *p, GtkWidget *dummy);
+static void wrap_undo_up(sv_panel_t *p, GtkWidget *dummy);
+static void wrap_undo_down(sv_panel_t *p, GtkWidget *dummy);
+static void wrap_legend(sv_panel_t *p, GtkWidget *dummy);
+static void wrap_escape(sv_panel_t *p, GtkWidget *dummy);
+static void wrap_enter(sv_panel_t *p, GtkWidget *dummy);
-static propmap *bgmap[]={
- &(propmap){"white",SUSHIV_BG_WHITE, "[<i>b</i>]",NULL,wrap_bg},
- &(propmap){"black",SUSHIV_BG_BLACK, "[<i>b</i>]",NULL,wrap_bg},
- &(propmap){"checks",SUSHIV_BG_CHECKS, "[<i>b</i>]",NULL,wrap_bg},
+static _sv_propmap_t *bgmap[]={
+ &(_sv_propmap_t){"white",SV_BG_WHITE, "[<i>b</i>]",NULL,wrap_bg},
+ &(_sv_propmap_t){"black",SV_BG_BLACK, "[<i>b</i>]",NULL,wrap_bg},
+ &(_sv_propmap_t){"checks",SV_BG_CHECKS, "[<i>b</i>]",NULL,wrap_bg},
NULL
};
-static propmap *gridmap[]={
- &(propmap){"light",PLOT_GRID_LIGHT, "[<i>g</i>]",NULL,wrap_grid},
- &(propmap){"normal",PLOT_GRID_NORMAL, "[<i>g</i>]",NULL,wrap_grid},
- &(propmap){"dark",PLOT_GRID_DARK, "[<i>g</i>]",NULL,wrap_grid},
- &(propmap){"tics",PLOT_GRID_TICS, "[<i>g</i>]",NULL,wrap_grid},
- &(propmap){"none",PLOT_GRID_NONE, "[<i>g</i>]",NULL,wrap_grid},
+static _sv_propmap_t *gridmap[]={
+ &(_sv_propmap_t){"light",_SV_PLOT_GRID_LIGHT, "[<i>g</i>]",NULL,wrap_grid},
+ &(_sv_propmap_t){"normal",_SV_PLOT_GRID_NORMAL, "[<i>g</i>]",NULL,wrap_grid},
+ &(_sv_propmap_t){"dark",_SV_PLOT_GRID_DARK, "[<i>g</i>]",NULL,wrap_grid},
+ &(_sv_propmap_t){"tics",_SV_PLOT_GRID_TICS, "[<i>g</i>]",NULL,wrap_grid},
+ &(_sv_propmap_t){"none",_SV_PLOT_GRID_NONE, "[<i>g</i>]",NULL,wrap_grid},
NULL
};
-static propmap *textmap[]={
- &(propmap){"dark",PLOT_TEXT_DARK, "[<i>t</i>]",NULL,wrap_text},
- &(propmap){"light",PLOT_TEXT_LIGHT, "[<i>t</i>]",NULL,wrap_text},
+static _sv_propmap_t *textmap[]={
+ &(_sv_propmap_t){"dark",_SV_PLOT_TEXT_DARK, "[<i>t</i>]",NULL,wrap_text},
+ &(_sv_propmap_t){"light",_SV_PLOT_TEXT_LIGHT, "[<i>t</i>]",NULL,wrap_text},
NULL
};
@@ -82,221 +82,221 @@
#define RES_4_1 8
// only used for the menus
-static propmap *resmap[]={
- &(propmap){"default",RES_DEF, "[<i>m</i>]",NULL,wrap_res},
- &(propmap){"1:32",RES_1_32, "[<i>m</i>]",NULL,wrap_res},
- &(propmap){"1:16",RES_1_16, "[<i>m</i>]",NULL,wrap_res},
- &(propmap){"1:8",RES_1_8, "[<i>m</i>]",NULL,wrap_res},
- &(propmap){"1:4",RES_1_4, "[<i>m</i>]",NULL,wrap_res},
- &(propmap){"1:2",RES_1_2, "[<i>m</i>]",NULL,wrap_res},
- &(propmap){"1",RES_1_1, "[<i>m</i>]",NULL,wrap_res},
- &(propmap){"2:1",RES_2_1, "[<i>m</i>]",NULL,wrap_res},
- &(propmap){"4:1",RES_4_1, "[<i>m</i>]",NULL,wrap_res},
+static _sv_propmap_t *resmap[]={
+ &(_sv_propmap_t){"default",RES_DEF, "[<i>m</i>]",NULL,wrap_res},
+ &(_sv_propmap_t){"1:32",RES_1_32, "[<i>m</i>]",NULL,wrap_res},
+ &(_sv_propmap_t){"1:16",RES_1_16, "[<i>m</i>]",NULL,wrap_res},
+ &(_sv_propmap_t){"1:8",RES_1_8, "[<i>m</i>]",NULL,wrap_res},
+ &(_sv_propmap_t){"1:4",RES_1_4, "[<i>m</i>]",NULL,wrap_res},
+ &(_sv_propmap_t){"1:2",RES_1_2, "[<i>m</i>]",NULL,wrap_res},
+ &(_sv_propmap_t){"1",RES_1_1, "[<i>m</i>]",NULL,wrap_res},
+ &(_sv_propmap_t){"2:1",RES_2_1, "[<i>m</i>]",NULL,wrap_res},
+ &(_sv_propmap_t){"4:1",RES_4_1, "[<i>m</i>]",NULL,wrap_res},
NULL,
};
-static propmap *crossmap[]={
- &(propmap){"no",0 ,NULL,NULL,NULL},
- &(propmap){"yes",1 ,NULL,NULL,NULL},
+static _sv_propmap_t *crossmap[]={
+ &(_sv_propmap_t){"no",0 ,NULL,NULL,NULL},
+ &(_sv_propmap_t){"yes",1 ,NULL,NULL,NULL},
NULL
};
-static propmap *legendmap[]={
- &(propmap){"none",PLOT_LEGEND_NONE, NULL,NULL,NULL},
- &(propmap){"shadowed",PLOT_LEGEND_SHADOW, NULL,NULL,NULL},
- &(propmap){"boxed",PLOT_LEGEND_BOX, NULL,NULL,NULL},
+static _sv_propmap_t *legendmap[]={
+ &(_sv_propmap_t){"none",_SV_PLOT_LEGEND_NONE, NULL,NULL,NULL},
+ &(_sv_propmap_t){"shadowed",_SV_PLOT_LEGEND_SHADOW, NULL,NULL,NULL},
+ &(_sv_propmap_t){"boxed",_SV_PLOT_LEGEND_BOX, NULL,NULL,NULL},
NULL
};
-static propmap *menu[]={
- &(propmap){"Open",0,"[<i>o</i>]",NULL,do_load},
- &(propmap){"Save",1,"[<i>s</i>]",NULL,do_save},
- &(propmap){"Print/Export",2,"[<i>p</i>]",NULL,_sushiv_panel_print},
+static _sv_propmap_t *menu[]={
+ &(_sv_propmap_t){"Open",0,"[<i>o</i>]",NULL,wrap_load},
+ &(_sv_propmap_t){"Save",1,"[<i>s</i>]",NULL,wrap_save},
+ &(_sv_propmap_t){"Print/Export",2,"[<i>p</i>]",NULL,_sv_panel_print},
- &(propmap){"",3,NULL,NULL,NULL},
+ &(_sv_propmap_t){"",3,NULL,NULL,NULL},
- &(propmap){"Undo",4,"[<i>bksp</i>]",NULL,&wrap_undo_down},
- &(propmap){"Redo",5,"[<i>space</i>]",NULL,&wrap_undo_up},
- &(propmap){"Start zoom box",6,"[<i>enter</i>]",NULL,&wrap_enter},
- &(propmap){"Clear selection",7,"[<i>escape</i>]",NULL,&wrap_escape},
- &(propmap){"Toggle Legend",8,"[<i>l</i>]",NULL,&wrap_legend},
+ &(_sv_propmap_t){"Undo",4,"[<i>bksp</i>]",NULL,&wrap_undo_down},
+ &(_sv_propmap_t){"Redo",5,"[<i>space</i>]",NULL,&wrap_undo_up},
+ &(_sv_propmap_t){"Start zoom box",6,"[<i>enter</i>]",NULL,&wrap_enter},
+ &(_sv_propmap_t){"Clear selection",7,"[<i>escape</i>]",NULL,&wrap_escape},
+ &(_sv_propmap_t){"Toggle Legend",8,"[<i>l</i>]",NULL,&wrap_legend},
- &(propmap){"",9,NULL,NULL,NULL},
+ &(_sv_propmap_t){"",9,NULL,NULL,NULL},
- &(propmap){"Background",10,"...",bgmap,NULL},
- &(propmap){"Text color",11,"...",textmap,NULL},
- &(propmap){"Grid mode",12,"...",gridmap,NULL},
- &(propmap){"Sampling",13,"...",resmap,NULL},
+ &(_sv_propmap_t){"Background",10,"...",bgmap,NULL},
+ &(_sv_propmap_t){"Text color",11,"...",textmap,NULL},
+ &(_sv_propmap_t){"Grid mode",12,"...",gridmap,NULL},
+ &(_sv_propmap_t){"Sampling",13,"...",resmap,NULL},
- &(propmap){"",14,NULL,NULL,NULL},
+ &(_sv_propmap_t){"",14,NULL,NULL,NULL},
- &(propmap){"Quit",15,"[<i>q</i>]",NULL,&wrap_exit},
+ &(_sv_propmap_t){"Quit",15,"[<i>q</i>]",NULL,&wrap_exit},
NULL
};
-static void decide_text_inv(sushiv_panel_t *p){
+static void decide_text_inv(sv_panel_t *p){
if(p->private->graph){
- Plot *plot = PLOT(p->private->graph);
- if(p->private->bg_type == SUSHIV_BG_WHITE)
- plot_set_bg_invert(plot,PLOT_TEXT_DARK);
+ _sv_plot_t *plot = PLOT(p->private->graph);
+ if(p->private->bg_type == SV_BG_WHITE)
+ _sv_plot_set_bg_invert(plot,_SV_PLOT_TEXT_DARK);
else
- plot_set_bg_invert(plot,PLOT_TEXT_LIGHT);
+ _sv_plot_set_bg_invert(plot,_SV_PLOT_TEXT_LIGHT);
}
}
-static void recompute_if_running(sushiv_panel_t *p){
+static void recompute_if_running(sv_panel_t *p){
if(p->private->realized && p->private->graph)
- _sushiv_panel_recompute(p);
+ _sv_panel_recompute(p);
}
-static void redraw_if_running(sushiv_panel_t *p){
+static void redraw_if_running(sv_panel_t *p){
if(p->private->realized && p->private->graph){
- plot_draw_scales(PLOT(p->private->graph));
- _sushiv_panel_dirty_map(p);
- _sushiv_panel_dirty_legend(p);
+ _sv_plot_draw_scales(PLOT(p->private->graph));
+ _sv_panel_dirty_map(p);
+ _sv_panel_dirty_legend(p);
}
}
-static void refg_if_running(sushiv_panel_t *p){
+static void refg_if_running(sv_panel_t *p){
if(p->private->realized && p->private->graph){
- plot_draw_scales(PLOT(p->private->graph));
- _sushiv_panel_dirty_legend(p);
+ _sv_plot_draw_scales(PLOT(p->private->graph));
+ _sv_panel_dirty_legend(p);
}
}
-static void wrap_exit(sushiv_panel_t *dummy, GtkWidget *dummyw){
- _sushiv_clean_exit(SIGINT);
+static void wrap_exit(sv_panel_t *dummy, GtkWidget *dummyw){
+ _sv_clean_exit(SIGINT);
}
// precipitated actions perform undo push
-static void wrap_enter(sushiv_panel_t *p, GtkWidget *dummy){
- plot_do_enter(PLOT(p->private->graph));
+static void wrap_enter(sv_panel_t *p, GtkWidget *dummy){
+ _sv_plot_do_enter(PLOT(p->private->graph));
}
-static void wrap_escape(sushiv_panel_t *p, GtkWidget *dummy){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+static void wrap_escape(sv_panel_t *p, GtkWidget *dummy){
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- plot_set_crossactive(PLOT(p->private->graph),0);
- _sushiv_panel_dirty_legend(p);
+ _sv_plot_set_crossactive(PLOT(p->private->graph),0);
+ _sv_panel_dirty_legend(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void wrap_legend(sushiv_panel_t *p, GtkWidget *dummy){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+static void wrap_legend(sv_panel_t *p, GtkWidget *dummy){
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- plot_toggle_legend(PLOT(p->private->graph));
- _sushiv_panel_dirty_legend(p);
+ _sv_plot_toggle_legend(PLOT(p->private->graph));
+ _sv_panel_dirty_legend(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void set_grid(sushiv_panel_t *p, int mode){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+static void set_grid(sv_panel_t *p, int mode){
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- plot_set_grid(PLOT(p->private->graph),mode);
- _sushiv_panel_update_menus(p);
+ _sv_plot_set_grid(PLOT(p->private->graph),mode);
+ _sv_panel_update_menus(p);
refg_if_running(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void wrap_grid(sushiv_panel_t *p, GtkWidget *w){
- int pos = gtk_menu_item_position(w);
+static void wrap_grid(sv_panel_t *p, GtkWidget *w){
+ int pos = _gtk_menu_item_position(w);
set_grid(p, gridmap[pos]->value);
}
-static int set_background(sushiv_panel_t *p,
- enum sushiv_background bg){
+static int set_background(sv_panel_t *p,
+ enum sv_background bg){
- sushiv_panel_internal_t *pi = p->private;
+ sv_panel_internal_t *pi = p->private;
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
pi->bg_type = bg;
decide_text_inv(p);
- set_grid(p,PLOT_GRID_NORMAL);
+ set_grid(p,_SV_PLOT_GRID_NORMAL);
redraw_if_running(p);
- _sushiv_panel_update_menus(p);
+ _sv_panel_update_menus(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
return 0;
}
-static void wrap_bg(sushiv_panel_t *p, GtkWidget *w){
- int pos = gtk_menu_item_position(w);
+static void wrap_bg(sv_panel_t *p, GtkWidget *w){
+ int pos = _gtk_menu_item_position(w);
set_background(p, bgmap[pos]->value);
}
-static void cycle_bg(sushiv_panel_t *p){
- int menupos = propmap_pos(bgmap, p->private->bg_type) + 1;
+static void cycle_bg(sv_panel_t *p){
+ int menupos = _sv_propmap_pos(bgmap, p->private->bg_type) + 1;
if(bgmap[menupos] == NULL) menupos = 0;
set_background(p, bgmap[menupos]->value);
}
-static void cycleB_bg(sushiv_panel_t *p){
- int menupos = propmap_pos(bgmap, p->private->bg_type) - 1;
- if(menupos<0) menupos = propmap_last(bgmap);
+static void cycleB_bg(sv_panel_t *p){
+ int menupos = _sv_propmap_pos(bgmap, p->private->bg_type) - 1;
+ if(menupos<0) menupos = _sv_propmap_last(bgmap);
set_background(p, bgmap[menupos]->value);
}
-static void set_text(sushiv_panel_t *p, int mode){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+static void set_text(sv_panel_t *p, int mode){
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
- plot_set_bg_invert(PLOT(p->private->graph),mode);
- _sushiv_panel_update_menus(p);
+ _sv_plot_set_bg_invert(PLOT(p->private->graph),mode);
+ _sv_panel_update_menus(p);
refg_if_running(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
-static void wrap_text(sushiv_panel_t *p, GtkWidget *w){
- int pos = gtk_menu_item_position(w);
+static void wrap_text(sv_panel_t *p, GtkWidget *w){
+ int pos = _gtk_menu_item_position(w);
set_text(p, textmap[pos]->value);
}
-static void cycle_text(sushiv_panel_t *p){
- int menupos = propmap_pos(textmap, PLOT(p->private->graph)->bg_inv) + 1;
+static void cycle_text(sv_panel_t *p){
+ int menupos = _sv_propmap_pos(textmap, PLOT(p->private->graph)->bg_inv) + 1;
if(textmap[menupos] == NULL) menupos = 0;
set_text(p, textmap[menupos]->value);
}
-static void cycle_grid(sushiv_panel_t *p){
- int menupos = propmap_pos(gridmap, PLOT(p->private->graph)->grid_mode) + 1;
+static void cycle_grid(sv_panel_t *p){
+ int menupos = _sv_propmap_pos(gridmap, PLOT(p->private->graph)->grid_mode) + 1;
if(gridmap[menupos] == NULL) menupos = 0;
set_grid(p, gridmap[menupos]->value);
}
-static void cycleB_grid(sushiv_panel_t *p){
- int menupos = propmap_pos(gridmap, PLOT(p->private->graph)->grid_mode) - 1;
- if(menupos<0) menupos = propmap_last(gridmap);
+static void cycleB_grid(sv_panel_t *p){
+ int menupos = _sv_propmap_pos(gridmap, PLOT(p->private->graph)->grid_mode) - 1;
+ if(menupos<0) menupos = _sv_propmap_last(gridmap);
set_grid(p, gridmap[menupos]->value);
}
-static void res_set(sushiv_panel_t *p, int n, int d){
+static void res_set(sv_panel_t *p, int n, int d){
if(n != p->private->oversample_n ||
d != p->private->oversample_d){
- _sushiv_undo_push(p->sushi);
- _sushiv_undo_suspend(p->sushi);
+ _sv_undo_push(p->sushi);
+ _sv_undo_suspend(p->sushi);
p->private->oversample_n = n;
p->private->oversample_d = d;
- _sushiv_panel_update_menus(p);
+ _sv_panel_update_menus(p);
recompute_if_running(p);
- _sushiv_undo_resume(p->sushi);
+ _sv_undo_resume(p->sushi);
}
}
// a little different; the menu value is not the internal setting
-static void res_set_pos(sushiv_panel_t *p, int pos){
+static void res_set_pos(sv_panel_t *p, int pos){
p->private->menu_cursamp = pos;
switch(pos){
case RES_DEF:
@@ -329,20 +329,20 @@
}
}
-static void wrap_res(sushiv_panel_t *p, GtkWidget *w){
- int pos = gtk_menu_item_position(w);
+static void wrap_res(sv_panel_t *p, GtkWidget *w){
+ int pos = _gtk_menu_item_position(w);
res_set_pos(p, resmap[pos]->value);
}
-static void cycle_res(sushiv_panel_t *p){
- int menupos = propmap_pos(resmap, p->private->menu_cursamp) + 1;
+static void cycle_res(sv_panel_t *p){
+ int menupos = _sv_propmap_pos(resmap, p->private->menu_cursamp) + 1;
if(resmap[menupos] == NULL) menupos = 0;
res_set_pos(p, resmap[menupos]->value);
}
-static void cycleB_res(sushiv_panel_t *p){
- int menupos = propmap_pos(resmap, p->private->menu_cursamp) - 1;
- if(menupos<0) menupos = propmap_last(resmap);
+static void cycleB_res(sv_panel_t *p){
+ int menupos = _sv_propmap_pos(resmap, p->private->menu_cursamp) - 1;
+ if(menupos<0) menupos = _sv_propmap_last(resmap);
res_set_pos(p, resmap[menupos]->value);
}
@@ -362,7 +362,7 @@
cairo_t *c;
gdouble w, h;
- sushiv_panel_t *p = (sushiv_panel_t *)user_data;
+ sv_panel_t *p = (sv_panel_t *)user_data;
c = gtk_print_context_get_cairo_context (context);
w = gtk_print_context_get_width (context);
@@ -371,7 +371,7 @@
p->private->print_action(p,c,w,h);
}
-static void _sushiv_panel_print(sushiv_panel_t *p, GtkWidget *dummy){
+static void _sv_panel_print(sv_panel_t *p, GtkWidget *dummy){
GtkPrintOperation *op = gtk_print_operation_new ();
if (printset != NULL)
@@ -403,14 +403,14 @@
g_object_unref (op);
}
-static void wrap_undo_down(sushiv_panel_t *p, GtkWidget *dummy){
- _sushiv_undo_down(p->sushi);
+static void wrap_undo_down(sv_panel_t *p, GtkWidget *dummy){
+ _sv_undo_down(p->sushi);
}
-static void wrap_undo_up(sushiv_panel_t *p, GtkWidget *dummy){
- _sushiv_undo_up(p->sushi);
+static void wrap_undo_up(sv_panel_t *p, GtkWidget *dummy){
+ _sv_undo_up(p->sushi);
}
-static void do_save(sushiv_panel_t *p, GtkWidget *dummy){
+static void wrap_save(sv_panel_t *p, GtkWidget *dummy){
GtkWidget *dialog = gtk_file_chooser_dialog_new ("Save",
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
@@ -419,26 +419,26 @@
NULL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
- gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), cwdname, NULL);
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dirname);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filebase);
+ gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), _sv_cwdname, NULL);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), _sv_dirname);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), _sv_filebase);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT){
- if(filebase)free(filebase);
- if(filename)free(filename);
- if(dirname)free(dirname);
+ if(_sv_filebase)free(_sv_filebase);
+ if(_sv_filename)free(_sv_filename);
+ if(_sv_dirname)free(_sv_dirname);
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- dirname = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
- filebase = g_path_get_basename(filename);
- save_main();
+ _sv_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ _sv_dirname = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
+ _sv_filebase = g_path_get_basename(_sv_filename);
+ _sv_main_save();
}
gtk_widget_destroy (dialog);
}
-static void do_load(sushiv_panel_t *p, GtkWidget *dummy){
+static void wrap_load(sv_panel_t *p, GtkWidget *dummy){
GtkWidget *dialog = gtk_file_chooser_dialog_new ("Open",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -446,26 +446,26 @@
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
- gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), cwdname, NULL);
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dirname);
+ gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), _sv_cwdname, NULL);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), _sv_dirname);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT){
- char *temp_filebase = filebase;
- char *temp_filename = filename;
- char *temp_dirname = dirname;
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- dirname = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
- filebase = g_path_get_basename(filename);
+ char *temp_filebase = _sv_filebase;
+ char *temp_filename = _sv_filename;
+ char *temp_dirname = _sv_dirname;
+ _sv_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ _sv_dirname = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
+ _sv_filebase = g_path_get_basename(_sv_filename);
- if(load_main()){
+ if(_sv_main_load()){
- free(filebase);
- free(filename);
- free(dirname);
+ free(_sv_filebase);
+ free(_sv_filename);
+ free(_sv_dirname);
- filebase = temp_filebase;
- filename = temp_filename;
- dirname = temp_dirname;
+ _sv_filebase = temp_filebase;
+ _sv_filename = temp_filename;
+ _sv_dirname = temp_dirname;
}else{
free(temp_filebase);
@@ -478,60 +478,60 @@
}
-void _sushiv_panel_update_menus(sushiv_panel_t *p){
+void _sv_panel_update_menus(sv_panel_t *p){
// is undo active?
if(!p->sushi->private->undo_stack ||
!p->sushi->private->undo_level){
- gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p->private->popmenu),4),FALSE);
+ gtk_widget_set_sensitive(_gtk_menu_get_item(GTK_MENU(p->private->popmenu),4),FALSE);
}else{
- gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p->private->popmenu),4),TRUE);
+ gtk_widget_set_sensitive(_gtk_menu_get_item(GTK_MENU(p->private->popmenu),4),TRUE);
}
// is redo active?
if(!p->sushi->private->undo_stack ||
!p->sushi->private->undo_stack[p->sushi->private->undo_level] ||
!p->sushi->private->undo_stack[p->sushi->private->undo_level+1]){
- gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p->private->popmenu),5),FALSE);
+ gtk_widget_set_sensitive(_gtk_menu_get_item(GTK_MENU(p->private->popmenu),5),FALSE);
}else{
- gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p->private->popmenu),5),TRUE);
+ gtk_widget_set_sensitive(_gtk_menu_get_item(GTK_MENU(p->private->popmenu),5),TRUE);
}
// are we starting or enacting a zoom box?
if(p->private->oldbox_active){
- gtk_menu_alter_item_label(GTK_MENU(p->private->popmenu),6,"Zoom to box");
+ _gtk_menu_alter_item_label(GTK_MENU(p->private->popmenu),6,"Zoom to box");
}else{
- gtk_menu_alter_item_label(GTK_MENU(p->private->popmenu),6,"Start zoom box");
+ _gtk_menu_alter_item_label(GTK_MENU(p->private->popmenu),6,"Start zoom box");
}
// make sure menu reflects plot configuration
- gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),
- propmap_label_pos(menu,"Background"),
- bgmap[propmap_pos(bgmap,p->private->bg_type)]->left);
+ _gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),
+ _sv_propmap_label_pos(menu,"Background"),
+ bgmap[_sv_propmap_pos(bgmap,p->private->bg_type)]->left);
- gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),
- propmap_label_pos(menu,"Text color"),
- textmap[propmap_pos(textmap,PLOT(p->private->graph)->bg_inv)]->left);
+ _gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),
+ _sv_propmap_label_pos(menu,"Text color"),
+ textmap[_sv_propmap_pos(textmap,PLOT(p->private->graph)->bg_inv)]->left);
- gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),
- propmap_label_pos(menu,"Grid mode"),
- gridmap[propmap_pos(gridmap,PLOT(p->private->graph)->grid_mode)]->left);
+ _gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),
+ _sv_propmap_label_pos(menu,"Grid mode"),
+ gridmap[_sv_propmap_pos(gridmap,PLOT(p->private->graph)->grid_mode)]->left);
{
char buffer[80];
snprintf(buffer,60,"%d:%d",p->private->oversample_n,p->private->oversample_d);
if(p->private->def_oversample_n == p->private->oversample_n &&
p->private->def_oversample_d == p->private->oversample_d)
strcat(buffer," (default)");
- gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),
- propmap_label_pos(menu,"Sampling"),buffer);
+ _gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),
+ _sv_propmap_label_pos(menu,"Sampling"),buffer);
}
}
static gboolean panel_keypress(GtkWidget *widget,
GdkEventKey *event,
gpointer in){
- sushiv_panel_t *p = (sushiv_panel_t *)in;
- // sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
+ sv_panel_t *p = (sv_panel_t *)in;
+ // sv_panel2d_t *p2 = (sv_panel2d_t *)p->internal;
// check if the widget with focus is an Entry
GtkWidget *focused = gtk_window_get_focus(GTK_WINDOW(widget));
@@ -603,10 +603,10 @@
return TRUE;
case GDK_s:
- do_save(p,NULL);
+ wrap_save(p,NULL);
return TRUE;
case GDK_o:
- do_load(p,NULL);
+ wrap_load(p,NULL);
return TRUE;
case GDK_Escape:
@@ -620,22 +620,22 @@
case GDK_Q:
case GDK_q:
// quit
- _sushiv_clean_exit(SIGINT);
+ _sv_clean_exit(SIGINT);
return TRUE;
case GDK_BackSpace:
// undo
- _sushiv_undo_down(p->sushi);
+ _sv_undo_down(p->sushi);
return TRUE;
case GDK_r:
case GDK_space:
// redo/forward
- _sushiv_undo_up(p->sushi);
+ _sv_undo_up(p->sushi);
return TRUE;
case GDK_p:
- _sushiv_panel_print(p,NULL);
+ _sv_panel_print(p,NULL);
return TRUE;
case GDK_l:
@@ -646,7 +646,7 @@
return FALSE;
}
-void _sushiv_realize_panel(sushiv_panel_t *p){
+void _sv_panel_realize(sv_panel_t *p){
if(p && !p->private->realized){
p->private->realize(p);
@@ -660,20 +660,20 @@
// text black or white in the plot?
decide_text_inv(p);
- p->private->popmenu = gtk_menu_new_twocol(p->private->toplevel, menu, p);
- _sushiv_panel_update_menus(p);
+ p->private->popmenu = _gtk_menu_new_twocol(p->private->toplevel, menu, p);
+ _sv_panel_update_menus(p);
}
}
-void set_map_throttle_time(sushiv_panel_t *p){
+void _sv_map_set_throttle_time(sv_panel_t *p){
struct timeval now;
gettimeofday(&now,NULL);
p->private->last_map_throttle = now.tv_sec*1000 + now.tv_usec/1000;
}
-static int test_throttle_time(sushiv_panel_t *p){
+static int test_throttle_time(sv_panel_t *p){
struct timeval now;
long test;
gettimeofday(&now,NULL);
@@ -687,7 +687,7 @@
/* request a recomputation with full setup (eg, linking, scales,
etc) */
-void _sushiv_panel_recompute(sushiv_panel_t *p){
+void _sv_panel_recompute(sv_panel_t *p){
gdk_threads_enter ();
p->private->request_compute(p);
gdk_threads_leave ();
@@ -698,83 +698,83 @@
request will eventually trigger a call here to kick off the actual
computation. Do panel subtype-specific setup, then wake workers
with one of the below */
-void _sushiv_panel_dirty_plot(sushiv_panel_t *p){
+void _sv_panel_dirty_plot(sv_panel_t *p){
gdk_threads_enter ();
p->private->plot_active = 1;
p->private->plot_serialno++;
p->private->plot_progress_count=0;
p->private->plot_complete_count=0;
gdk_threads_leave ();
- _sushiv_wake_workers();
+ _sv_wake_workers();
}
-void _sushiv_panel_dirty_map(sushiv_panel_t *p){
+void _sv_panel_dirty_map(sv_panel_t *p){
gdk_threads_enter ();
p->private->map_active = 1;
p->private->map_serialno++;
p->private->map_progress_count=0;
p->private->map_complete_count=0;
gdk_threads_leave ();
- _sushiv_wake_workers();
+ _sv_wake_workers();
}
-void _sushiv_panel_dirty_map_throttled(sushiv_panel_t *p){
+void _sv_panel_dirty_map_throttled(sv_panel_t *p){
gdk_threads_enter ();
if(!p->private->map_active && test_throttle_time(p)){
- _sushiv_panel_dirty_map(p);
+ _sv_panel_dirty_map(p);
}
gdk_threads_leave ();
}
-void _sushiv_panel_dirty_legend(sushiv_panel_t *p){
+void _sv_panel_dirty_legend(sv_panel_t *p){
gdk_threads_enter ();
p->private->legend_active = 1;
p->private->legend_serialno++;
p->private->legend_progress_count=0;
p->private->legend_complete_count=0;
gdk_threads_leave ();
- _sushiv_wake_workers();
+ _sv_wake_workers();
}
/* use these to signal a computation is completed */
-void _sushiv_panel_clean_plot(sushiv_panel_t *p){
+void _sv_panel_clean_plot(sv_panel_t *p){
gdk_threads_enter ();
p->private->plot_active = 0;
gdk_threads_leave ();
}
-void _sushiv_panel_clean_map(sushiv_panel_t *p){
+void _sv_panel_clean_map(sv_panel_t *p){
gdk_threads_enter ();
p->private->map_active = 0;
gdk_threads_leave ();
}
-void _sushiv_panel_clean_legend(sushiv_panel_t *p){
+void _sv_panel_clean_legend(sv_panel_t *p){
gdk_threads_enter ();
p->private->legend_active = 0;
gdk_threads_leave ();
}
-int sushiv_panel_oversample(sushiv_instance_t *s,
+int sv_panel_oversample(sv_instance_t *s,
int number,
int numer,
int denom){
if(number<0){
- fprintf(stderr,"sushiv_panel_background: Panel number must be >= 0\n");
+ fprintf(stderr,"sv_panel_background: Panel number must be >= 0\n");
return -EINVAL;
}
if(number>s->panels || !s->panel_list[number]){
- fprintf(stderr,"sushiv_panel_background: Panel number %d does not exist\n",number);
+ fprintf(stderr,"sv_panel_background: Panel number %d does not exist\n",number);
return -EINVAL;
}
- sushiv_panel_t *p = s->panel_list[number];
- sushiv_panel_internal_t *pi = p->private;
+ sv_panel_t *p = s->panel_list[number];
+ sv_panel_internal_t *pi = p->private;
if(denom == 0){
- fprintf(stderr,"sushiv_panel_oversample: A denominator of zero is invalid\n");
+ fprintf(stderr,"sv_panel_oversample: A denominator of zero is invalid\n");
return -EINVAL;
}
@@ -784,43 +784,46 @@
return 0;
}
-int sushiv_panel_background(sushiv_instance_t *s,
+int sv_panel_background(sv_instance_t *s,
int number,
- enum sushiv_background bg){
+ enum sv_background bg){
if(number<0){
- fprintf(stderr,"sushiv_panel_background: Panel number must be >= 0\n");
+ fprintf(stderr,"sv_panel_background: Panel number must be >= 0\n");
return -EINVAL;
}
if(number>s->panels || !s->panel_list[number]){
- fprintf(stderr,"sushiv_panel_background: Panel number %d does not exist\n",number);
+ fprintf(stderr,"sv_panel_background: Panel number %d does not exist\n",number);
return -EINVAL;
}
- sushiv_panel_t *p = s->panel_list[number];
+ sv_panel_t *p = s->panel_list[number];
return set_background(p,bg);
}
-int _sushiv_new_panel(sushiv_instance_t *s,
- int number,
- const char *name,
- int *objectives,
- int *dimensions,
- unsigned flags){
-
- sushiv_panel_t *p;
+sv_panel_t * _sv_panel_new(sv_instance_t *in,
+ int number,
+ char *name,
+ sv_obj_t **objectives,
+ sv_dim_t **dimensions,
+ unsigned flags){
+
+ sv_instance_t *s = (sv_instance_t *)in; // unwrap
+ sv_panel_t *p;
int i;
if(number<0){
fprintf(stderr,"Panel number must be >= 0\n");
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
if(number<s->panels){
if(s->panel_list[number]!=NULL){
fprintf(stderr,"Panel number %d already exists\n",number);
- return -EINVAL;
+ errno = -EINVAL;
+ return NULL;
}
}else{
if(s->panels == 0){
@@ -839,46 +842,53 @@
p->flags = flags;
p->sushi = s;
p->private = calloc(1, sizeof(*p->private));
- p->private->spinner = spinner_new();
+ p->private->spinner = _sv_spinner_new();
p->private->def_oversample_n = p->private->oversample_n = 1;
p->private->def_oversample_d = p->private->oversample_d = 1;
i=0;
- while(objectives && objectives[i]>=0)i++;
+ while(objectives && objectives[i])i++;
p->objectives = i;
p->objective_list = malloc(i*sizeof(*p->objective_list));
for(i=0;i<p->objectives;i++){
- if(objectives[i]<0 || objectives[i]>=s->objectives ||
- s->objective_list[objectives[i]] == NULL){
- fprintf(stderr,"Panel %d: Objective number %d does not exist\n",number, objectives[i]);
- return -EINVAL;
+ if(objectives[i]->sushi != s){
+ fprintf(stderr,"Panel %d (\"%s\"): Objective number %d (\"%s\") belongs to a differnet instance\n",
+ number,p->name,objectives[i]->number,objectives[i]->name);
+ errno = -EINVAL;
+ return NULL;
}
- sushiv_objective_t *o = s->objective_list[objectives[i]];
- p->objective_list[i].o = o;
+ p->objective_list[i].o = (sv_obj_t *)objectives[i];
p->objective_list[i].p = p;
}
i=0;
- while(dimensions && dimensions[i]>=0)i++;
+ while(dimensions && dimensions[i])i++;
p->dimensions = i;
p->dimension_list = malloc(i*sizeof(*p->dimension_list));
for(i=0;i<p->dimensions;i++){
- if(dimensions[i]<0 || dimensions[i]>=s->dimensions ||
- s->dimension_list[dimensions[i]] == NULL){
- fprintf(stderr,"Panel %d: Objective number %d does not exist\n",number, objectives[i]);
- return -EINVAL;
+ if(dimensions[i]->sushi != s){
+ fprintf(stderr,"Panel %d (\"%s\"): Dimension number %d (\"%s\") belongs to a differnet instance\n",
+ number,p->name,dimensions[i]->number,dimensions[i]->name);
+ errno = -EINVAL;
+ return NULL;
}
- sushiv_dimension_t *d = s->dimension_list[dimensions[i]];
- p->dimension_list[i].d = d;
+ if(!dimensions[i]->scale){
+ fprintf(stderr,"Panel %d (\"%s\"): Dimension number %d (\"%s\") has a NULL scale\n",
+ number,p->name,dimensions[i]->number,dimensions[i]->name);
+ errno = -EINVAL;
+ return NULL;
+ }
+
+ p->dimension_list[i].d = (sv_dim_t *)dimensions[i];
p->dimension_list[i].p = p;
}
- return number;
+ return p;
}
-void _sushiv_panel_undo_log(sushiv_panel_t *p, sushiv_panel_undo_t *u){
+void _sv_panel_undo_log(sv_panel_t *p, _sv_panel_undo_t *u){
u->cross_mode = PLOT(p->private->graph)->cross_active;
u->legend_mode = PLOT(p->private->graph)->legend_active;
u->grid_mode = PLOT(p->private->graph)->grid_mode;
@@ -892,10 +902,10 @@
p->private->undo_log(u,p);
}
-void _sushiv_panel_undo_restore(sushiv_panel_t *p, sushiv_panel_undo_t *u){
+void _sv_panel_undo_restore(sv_panel_t *p, _sv_panel_undo_t *u){
// go in through setting routines
- plot_set_crossactive(PLOT(p->private->graph),u->cross_mode);
- plot_set_legendactive(PLOT(p->private->graph),u->legend_mode);
+ _sv_plot_set_crossactive(PLOT(p->private->graph),u->cross_mode);
+ _sv_plot_set_legendactive(PLOT(p->private->graph),u->legend_mode);
set_background(p, u->bg_mode); // must be first; it can frob grid and test
set_text(p, u->text_mode);
set_grid(p, u->grid_mode);
@@ -905,10 +915,10 @@
// panel-subtype-specific restore
p->private->undo_restore(u,p);
- _sushiv_panel_dirty_legend(p);
+ _sv_panel_dirty_legend(p);
}
-int _save_panel(sushiv_panel_t *p, xmlNodePtr instance){
+int _sv_panel_save(sv_panel_t *p, xmlNodePtr instance){
if(!p) return 0;
char buffer[80];
int ret=0;
@@ -916,31 +926,31 @@
xmlNodePtr pn = xmlNewChild(instance, NULL, (xmlChar *) "panel", NULL);
xmlNodePtr n;
- xmlNewPropI(pn, "number", p->number);
- xmlNewPropS(pn, "name", p->name);
+ _xmlNewPropI(pn, "number", p->number);
+ _xmlNewPropS(pn, "name", p->name);
// let the panel subtype handler fill in type
// we're only saving settings independent of subtype
// background
n = xmlNewChild(pn, NULL, (xmlChar *) "background", NULL);
- xmlNewMapProp(n, "color", bgmap, p->private->bg_type);
+ _xmlNewMapProp(n, "color", bgmap, p->private->bg_type);
// grid
n = xmlNewChild(pn, NULL, (xmlChar *) "grid", NULL);
- xmlNewMapProp(n, "mode", gridmap, PLOT(p->private->graph)->grid_mode);
+ _xmlNewMapProp(n, "mode", gridmap, PLOT(p->private->graph)->grid_mode);
// crosshairs
n = xmlNewChild(pn, NULL, (xmlChar *) "crosshairs", NULL);
- xmlNewMapProp(n, "active", crossmap, PLOT(p->private->graph)->cross_active);
+ _xmlNewMapProp(n, "active", crossmap, PLOT(p->private->graph)->cross_active);
// legend
n = xmlNewChild(pn, NULL, (xmlChar *) "legend", NULL);
- xmlNewMapProp(n,"mode", legendmap, PLOT(p->private->graph)->legend_active);
+ _xmlNewMapProp(n,"mode", legendmap, PLOT(p->private->graph)->legend_active);
// text
n = xmlNewChild(pn, NULL, (xmlChar *) "text", NULL);
- xmlNewMapProp(n,"color", textmap, PLOT(p->private->graph)->bg_inv);
+ _xmlNewMapProp(n,"color", textmap, PLOT(p->private->graph)->bg_inv);
// resample
n = xmlNewChild(pn, NULL, (xmlChar *) "sampling", NULL);
@@ -955,32 +965,32 @@
return ret;
}
-int _load_panel(sushiv_panel_t *p,
- sushiv_panel_undo_t *u,
- xmlNodePtr pn,
- int warn){
+int _sv_panel_load(sv_panel_t *p,
+ _sv_panel_undo_t *u,
+ xmlNodePtr pn,
+ int warn){
// check name
- xmlCheckPropS(pn,"name",p->name,"Panel %d name mismatch in save file.",p->number,&warn);
+ _xmlCheckPropS(pn,"name",p->name,"Panel %d name mismatch in save file.",p->number,&warn);
// background
- xmlGetChildMap(pn, "background", "color", bgmap, &u->bg_mode,
- "Panel %d unknown background setting", p->number, &warn);
+ _xmlGetChildMap(pn, "background", "color", bgmap, &u->bg_mode,
+ "Panel %d unknown background setting", p->number, &warn);
// grid
- xmlGetChildMap(pn, "grid", "mode", gridmap, &u->grid_mode,
- "Panel %d unknown grid mode setting", p->number, &warn);
+ _xmlGetChildMap(pn, "grid", "mode", gridmap, &u->grid_mode,
+ "Panel %d unknown grid mode setting", p->number, &warn);
// crosshairs
- xmlGetChildMap(pn, "crosshairs", "active", crossmap, &u->cross_mode,
- "Panel %d unknown crosshair setting", p->number, &warn);
+ _xmlGetChildMap(pn, "crosshairs", "active", crossmap, &u->cross_mode,
+ "Panel %d unknown crosshair setting", p->number, &warn);
// legend
- xmlGetChildMap(pn, "legend", "mode", legendmap, &u->legend_mode,
- "Panel %d unknown legend setting", p->number, &warn);
+ _xmlGetChildMap(pn, "legend", "mode", legendmap, &u->legend_mode,
+ "Panel %d unknown legend setting", p->number, &warn);
// text
- xmlGetChildMap(pn, "text", "color", textmap, &u->text_mode,
- "Panel %d unknown text color setting", p->number, &warn);
+ _xmlGetChildMap(pn, "text", "color", textmap, &u->text_mode,
+ "Panel %d unknown text color setting", p->number, &warn);
// resample
char *prop = NULL;
- xmlGetChildPropS(pn, "sampling", "ratio", &prop);
+ _xmlGetChildPropS(pn, "sampling", "ratio", &prop);
if(prop){
int res = sscanf(prop,"%d:%d", &u->oversample_n, &u->oversample_d);
if(res<2){
@@ -1001,7 +1011,7 @@
while(n){
if (n->type == XML_ELEMENT_NODE) {
- first_load_warning(&warn);
+ _sv_first_load_warning(&warn);
fprintf(stderr,"Unknown option (%s) set for panel %d.\n",n->name,p->number);
}
n = n->next;
Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/plot.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -39,34 +39,34 @@
// data scale is undersampled or discrete), we want the demarks from
// the data scale (plotted in terms of the panel scale). In most
// cases they will be the same, but not always.
-static double scale_demark(scalespace *panel, scalespace *data, int i, char *buffer){
+static double scale_demark(_sv_scalespace_t *panel, _sv_scalespace_t *data, int i, char *buffer){
if(abs(data->step_val*data->m) > abs(panel->step_val*panel->m)){
- double x=scalespace_mark(data,i);
- if(buffer) scalespace_label(data,i,buffer);
- return scalespace_pixel(panel, scalespace_value(data, x));
+ double x=_sv_scalespace_mark(data,i);
+ if(buffer) _sv_scalespace_label(data,i,buffer);
+ return _sv_scalespace_pixel(panel, _sv_scalespace_value(data, x));
}else{
- if(buffer) scalespace_label(panel,i,buffer);
- return scalespace_mark(panel,i);
+ if(buffer) _sv_scalespace_label(panel,i,buffer);
+ return _sv_scalespace_mark(panel,i);
}
}
-void plot_set_bg_invert(Plot *p, int setp){
+void _sv_plot_set_bg_invert(_sv_plot_t *p, int setp){
p->bg_inv = setp;
}
-void plot_set_grid(Plot *p, int mode){
+void _sv_plot_set_grid(_sv_plot_t *p, int mode){
p->grid_mode = mode;
}
static void set_text(int inv, cairo_t *c){
- if(inv == PLOT_TEXT_LIGHT)
+ if(inv == _SV_PLOT_TEXT_LIGHT)
cairo_set_source_rgba(c,1.,1.,1.,1.);
else
cairo_set_source_rgba(c,0.,0.,0.,1.);
}
static void set_shadow(int inv, cairo_t *c){
- if(inv == PLOT_TEXT_LIGHT)
+ if(inv == _SV_PLOT_TEXT_LIGHT)
cairo_set_source_rgba(c,0.,0.,0.,.6);
else
cairo_set_source_rgba(c,1.,1.,1.,.8);
@@ -75,14 +75,14 @@
static void draw_scales_work(cairo_t *c, int w, int h,
double page_h,
int inv_text, int grid,
- scalespace xs, scalespace ys,
- scalespace xs_v, scalespace ys_v){
+ _sv_scalespace_t xs, _sv_scalespace_t ys,
+ _sv_scalespace_t xs_v, _sv_scalespace_t ys_v){
int i=0,x,y;
char buffer[80];
int y_width=0;
int x_height=0;
- int off = (grid == PLOT_GRID_TICS?6:0);
+ int off = (grid == _SV_PLOT_GRID_TICS?6:0);
cairo_set_miter_limit(c,2.);
@@ -90,7 +90,7 @@
if(grid){
cairo_set_line_width(c,1.);
- if(grid & PLOT_GRID_NORMAL){
+ if(grid & _SV_PLOT_GRID_NORMAL){
cairo_save(c);
//cairo_set_operator(c,CAIRO_OPERATOR_XOR);
switch(grid&0xf00){
@@ -226,7 +226,7 @@
cairo_show_text (c, xs.legend);
}
- if(grid == PLOT_GRID_TICS){
+ if(grid == _SV_PLOT_GRID_TICS){
cairo_set_line_width(c,1.);
set_text(inv_text,c);
@@ -256,7 +256,7 @@
}
}
-static void draw_legend_work(Plot *p, cairo_t *c, int w){
+static void draw_legend_work(_sv_plot_t *p, cairo_t *c, int w){
if(p->legend_entries && p->legend_list && p->legend_active){
int i;
int textw=0, texth=0;
@@ -340,13 +340,13 @@
}
}
-void plot_draw_scales(Plot *p){
+void _sv_plot_draw_scales(_sv_plot_t *p){
// render into a temporary surface; do it [potentially] outside the global Gtk lock.
gdk_threads_enter();
- scalespace x = p->x;
- scalespace y = p->y;
- scalespace xv = p->x_v;
- scalespace yv = p->y_v;
+ _sv_scalespace_t x = p->x;
+ _sv_scalespace_t y = p->y;
+ _sv_scalespace_t xv = p->x_v;
+ _sv_scalespace_t yv = p->y_v;
int w = GTK_WIDGET(p)->allocation.width;
int h = GTK_WIDGET(p)->allocation.height;
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,w,h);
@@ -370,23 +370,23 @@
cairo_surface_t *temp = p->fore;
p->fore = s;
cairo_surface_destroy(temp);
- //plot_expose_request(p);
+ //_sv_plot_expose_request(p);
gdk_threads_leave();
}
-static void plot_init (Plot *p){
+static void _sv_plot_init (_sv_plot_t *p){
// instance initialization
p->scalespacing = 50;
- p->x_v = p->x = scalespace_linear(0.0,1.0,400,p->scalespacing,NULL);
- p->y_v = p->y = scalespace_linear(0.0,1.0,200,p->scalespacing,NULL);
+ p->x_v = p->x = _sv_scalespace_linear(0.0,1.0,400,p->scalespacing,NULL);
+ p->y_v = p->y = _sv_scalespace_linear(0.0,1.0,200,p->scalespacing,NULL);
}
-static void plot_destroy (GtkObject *object){
+static void _sv_plot_destroy (GtkObject *object){
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
GtkWidget *widget = GTK_WIDGET(object);
- Plot *p = PLOT (widget);
+ _sv_plot_t *p = PLOT (widget);
// free local resources
if(p->wc){
cairo_destroy(p->wc);
@@ -407,31 +407,31 @@
}
-static void box_corners(Plot *p, double vals[4]){
+static void box_corners(_sv_plot_t *p, double vals[4]){
GtkWidget *widget = GTK_WIDGET(p);
- double x1 = scalespace_pixel(&p->x,p->box_x1);
- double x2 = scalespace_pixel(&p->x,p->box_x2);
- double y1 = scalespace_pixel(&p->y,p->box_y1);
- double y2 = scalespace_pixel(&p->y,p->box_y2);
+ double x1 = _sv_scalespace_pixel(&p->x,p->box_x1);
+ double x2 = _sv_scalespace_pixel(&p->x,p->box_x2);
+ double y1 = _sv_scalespace_pixel(&p->y,p->box_y1);
+ double y2 = _sv_scalespace_pixel(&p->y,p->box_y2);
vals[0] = (x1<x2 ? x1 : x2);
vals[1] = (y1<y2 ? y1 : y2);
vals[2] = fabs(x1-x2);
vals[3] = fabs(y1-y2);
- if(p->flags & PLOT_NO_X_CROSS){
+ if(p->flags & _SV_PLOT_NO_X_CROSS){
vals[0]=-1;
vals[2]=widget->allocation.width+2;
}
- if(p->flags & PLOT_NO_Y_CROSS){
+ if(p->flags & _SV_PLOT_NO_Y_CROSS){
vals[1]=-1;
vals[3]=widget->allocation.height+2;
}
}
-static int inside_box(Plot *p, int x, int y){
+static int inside_box(_sv_plot_t *p, int x, int y){
double vals[4];
box_corners(p,vals);
@@ -441,14 +441,14 @@
y <= vals[1]+vals[3]);
}
-int plot_print(Plot *p, cairo_t *c, double page_h, void (*datarender)(void *, cairo_t *), void *data){
+int _sv_plot_print(_sv_plot_t *p, cairo_t *c, double page_h, void (*datarender)(void *, cairo_t *), void *data){
GtkWidget *widget = GTK_WIDGET(p);
int pw = widget->allocation.width;
int ph = widget->allocation.height;
- scalespace x = p->x;
- scalespace y = p->y;
- scalespace xv = p->x_v;
- scalespace yv = p->y_v;
+ _sv_scalespace_t x = p->x;
+ _sv_scalespace_t y = p->y;
+ _sv_scalespace_t xv = p->x_v;
+ _sv_scalespace_t yv = p->y_v;
int inv = p->bg_inv;
int grid = p->grid_mode;
@@ -469,18 +469,18 @@
// transient foreground crosshairs
if(p->cross_active){
- double sx = plot_get_crosshair_xpixel(p);
- double sy = plot_get_crosshair_ypixel(p);
+ double sx = _sv_plot_get_crosshair_xpixel(p);
+ double sy = _sv_plot_get_crosshair_ypixel(p);
cairo_set_source_rgba(c,1.,1.,0.,.8);
cairo_set_line_width(c,1.);
- if(! (p->flags & PLOT_NO_Y_CROSS)){
+ if(! (p->flags & _SV_PLOT_NO_Y_CROSS)){
cairo_move_to(c,0,sy+.5);
cairo_line_to(c,widget->allocation.width,sy+.5);
}
- if(! (p->flags & PLOT_NO_X_CROSS)){
+ if(! (p->flags & _SV_PLOT_NO_X_CROSS)){
cairo_move_to(c,sx+.5,0);
cairo_line_to(c,sx+.5,widget->allocation.height);
}
@@ -523,7 +523,7 @@
return 0;
}
-static void plot_draw (Plot *p,
+static void _sv_plot_draw (_sv_plot_t *p,
int x, int y, int w, int h){
GtkWidget *widget = GTK_WIDGET(p);
@@ -537,18 +537,18 @@
// transient foreground
if(p->cross_active){
- double sx = plot_get_crosshair_xpixel(p);
- double sy = plot_get_crosshair_ypixel(p);
+ double sx = _sv_plot_get_crosshair_xpixel(p);
+ double sy = _sv_plot_get_crosshair_ypixel(p);
cairo_set_source_rgba(c,1.,1.,0.,.8);
cairo_set_line_width(c,1.);
- if(! (p->flags & PLOT_NO_Y_CROSS)){
+ if(! (p->flags & _SV_PLOT_NO_Y_CROSS)){
cairo_move_to(c,0,sy+.5);
cairo_line_to(c,widget->allocation.width,sy+.5);
}
- if(! (p->flags & PLOT_NO_X_CROSS)){
+ if(! (p->flags & _SV_PLOT_NO_X_CROSS)){
cairo_move_to(c,sx+.5,0);
cairo_line_to(c,sx+.5,widget->allocation.height);
}
@@ -606,25 +606,25 @@
}
}
-static gint plot_expose (GtkWidget *widget,
+static gint _sv_plot_expose (GtkWidget *widget,
GdkEventExpose *event){
if (GTK_WIDGET_REALIZED (widget)){
- Plot *p = PLOT (widget);
+ _sv_plot_t *p = PLOT (widget);
int x = event->area.x;
int y = event->area.y;
int w = event->area.width;
int h = event->area.height;
- plot_draw(p, x, y, w, h);
+ _sv_plot_draw(p, x, y, w, h);
}
return FALSE;
}
-static void plot_size_request (GtkWidget *widget,
+static void _sv_plot_size_request (GtkWidget *widget,
GtkRequisition *requisition){
- Plot *p = PLOT (widget);
+ _sv_plot_t *p = PLOT (widget);
if(p->resizable || !p->wc){
requisition->width = 400;
requisition->height = 200;
@@ -634,7 +634,7 @@
}
}
-static void plot_realize (GtkWidget *widget){
+static void _sv_plot_realize (GtkWidget *widget){
GdkWindowAttr attributes;
gint attributes_mask;
@@ -670,9 +670,9 @@
gtk_widget_set_double_buffered (widget, FALSE);
}
-static void plot_size_allocate (GtkWidget *widget,
+static void _sv_plot_size_allocate (GtkWidget *widget,
GtkAllocation *allocation){
- Plot *p = PLOT (widget);
+ _sv_plot_t *p = PLOT (widget);
if (GTK_WIDGET_REALIZED (widget)){
@@ -717,15 +717,15 @@
}
widget->allocation = *allocation;
- p->x = scalespace_linear(p->x.lo,p->x.hi,widget->allocation.width,p->scalespacing,p->x.legend);
- p->y = scalespace_linear(p->y.lo,p->y.hi,widget->allocation.height,p->scalespacing,p->y.legend);
- plot_unset_box(p);
+ p->x = _sv_scalespace_linear(p->x.lo,p->x.hi,widget->allocation.width,p->scalespacing,p->x.legend);
+ p->y = _sv_scalespace_linear(p->y.lo,p->y.hi,widget->allocation.height,p->scalespacing,p->y.legend);
+ _sv_plot_unset_box(p);
if(p->recompute_callback)p->recompute_callback(p->app_data);
- //plot_draw_scales(p); geenrally done in callback after scale massaging
+ //_sv_plot_draw_scales(p); geenrally done in callback after scale massaging
}
-static void box_check(Plot *p, int x, int y){
+static void box_check(_sv_plot_t *p, int x, int y){
if(p->box_active){
double vals[4];
box_corners(p,vals);
@@ -735,7 +735,7 @@
else
p->box_active = 1;
- plot_expose_request_partial(p,
+ _sv_plot_expose_request_partial(p,
(int)(vals[0]),
(int)(vals[1]),
(int)(vals[2]+3), // account for floor/ceil *and* roundoff potential
@@ -745,12 +745,12 @@
static gint mouse_motion(GtkWidget *widget,
GdkEventMotion *event){
- Plot *p = PLOT (widget);
+ _sv_plot_t *p = PLOT (widget);
int x = event->x;
int y = event->y;
- int bx = scalespace_pixel(&p->x,p->box_x1);
- int by = scalespace_pixel(&p->y,p->box_y1);
+ int bx = _sv_scalespace_pixel(&p->x,p->box_x1);
+ int by = _sv_scalespace_pixel(&p->y,p->box_y1);
if(p->button_down){
if(abs(bx - x)>5 ||
@@ -760,15 +760,15 @@
if(p->box_active){
double vals[4];
box_corners(p,vals);
- plot_expose_request_partial(p,
+ _sv_plot_expose_request_partial(p,
(int)(vals[0]),
(int)(vals[1]),
(int)(vals[2]+3), // account for floor/ceil *and* roundoff potential
(int)(vals[3]+3));
}
- p->box_x2 = scalespace_value(&p->x,x);
- p->box_y2 = scalespace_value(&p->y,y);
+ p->box_x2 = _sv_scalespace_value(&p->x,x);
+ p->box_y2 = _sv_scalespace_value(&p->y,y);
}
box_check(p,x,y);
@@ -782,13 +782,13 @@
if (event->button == 3) return FALSE;
if (event->button == 1){
- Plot *p = PLOT (widget);
+ _sv_plot_t *p = PLOT (widget);
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,event->y);
- plot_snap_crosshairs(p);
+ p->selx = _sv_scalespace_value(&p->x,event->x);
+ p->sely = _sv_scalespace_value(&p->y,event->y);
+ _sv_plot_snap_crosshairs(p);
p->cross_active=1;
if(p->box_callback)
@@ -798,8 +798,8 @@
p->box_active=0;
}else{
- p->box_x2=p->box_x1 = scalespace_value(&p->x,event->x);
- p->box_y2=p->box_y1 = scalespace_value(&p->y,event->y);
+ p->box_x2=p->box_x1 = _sv_scalespace_value(&p->x,event->x);
+ p->box_y2=p->box_y1 = _sv_scalespace_value(&p->y,event->y);
p->box_active = 0;
p->button_down=1;
}
@@ -812,19 +812,19 @@
GdkEventButton *event){
if (event->button == 3) return FALSE;
- Plot *p = PLOT (widget);
- plot_expose_request(p);
+ _sv_plot_t *p = PLOT (widget);
+ _sv_plot_expose_request(p);
if(!p->box_active && p->button_down){
- p->selx = scalespace_value(&p->x,event->x);
- p->sely = scalespace_value(&p->y,event->y);
- plot_snap_crosshairs(p);
+ p->selx = _sv_scalespace_value(&p->x,event->x);
+ p->sely = _sv_scalespace_value(&p->y,event->y);
+ _sv_plot_snap_crosshairs(p);
if(p->crosshairs_callback)
p->crosshairs_callback(p->cross_data);
p->cross_active=1;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
}
p->button_down=0;
@@ -839,7 +839,7 @@
return TRUE;
}
-void plot_do_enter(Plot *p){
+void _sv_plot_do_enter(_sv_plot_t *p){
// if box is active, effect it
if(p->box_active){
@@ -853,8 +853,8 @@
}else{
if(p->button_down){
GdkEventButton event;
- event.x = scalespace_pixel(&p->x,p->selx);
- event.y = scalespace_pixel(&p->y,p->sely);
+ event.x = _sv_scalespace_pixel(&p->x,p->selx);
+ event.y = _sv_scalespace_pixel(&p->y,p->sely);
mouse_release(GTK_WIDGET(p),&event);
}else{
@@ -866,32 +866,32 @@
}
}
-void plot_set_crossactive(Plot *p, int active){
+void _sv_plot_set_crossactive(_sv_plot_t *p, int active){
if(!active){
p->button_down=0;
p->box_active=0;
}
p->cross_active=active;
- plot_draw_scales(p);
- plot_expose_request(p);
+ _sv_plot_draw_scales(p);
+ _sv_plot_expose_request(p);
}
-void plot_toggle_legend(Plot *p){
+void _sv_plot_toggle_legend(_sv_plot_t *p){
p->legend_active++;
if (p->legend_active>2)
p->legend_active=0;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
}
-void plot_set_legendactive(Plot *p, int active){
+void _sv_plot_set_legendactive(_sv_plot_t *p, int active){
p->legend_active=active;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
}
-static gboolean key_press(GtkWidget *widget,
- GdkEventKey *event){
- Plot *p = PLOT(widget);
+static gboolean _sv_plot_key_press(GtkWidget *widget,
+ GdkEventKey *event){
+ _sv_plot_t *p = PLOT(widget);
int shift = (event->state&GDK_SHIFT_MASK);
if(event->state&GDK_MOD1_MASK) return FALSE;
@@ -902,11 +902,11 @@
case GDK_Left:
{
- double x = scalespace_pixel(&p->x_v,p->selx)-1;
+ double x = _sv_scalespace_pixel(&p->x_v,p->selx)-1;
p->cross_active=1;
if(shift)
x-=9;
- p->selx = scalespace_value(&p->x_v,x);
+ p->selx = _sv_scalespace_value(&p->x_v,x);
if(p->crosshairs_callback)
p->crosshairs_callback(p->cross_data);
@@ -916,17 +916,17 @@
}else
p->box_active=0;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
}
return TRUE;
case GDK_Right:
{
- double x = scalespace_pixel(&p->x_v,p->selx)+1;
+ double x = _sv_scalespace_pixel(&p->x_v,p->selx)+1;
p->cross_active=1;
if(shift)
x+=9;
- p->selx = scalespace_value(&p->x_v,x);
+ p->selx = _sv_scalespace_value(&p->x_v,x);
if(p->crosshairs_callback)
p->crosshairs_callback(p->cross_data);
@@ -936,17 +936,17 @@
}else
p->box_active=0;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
}
return TRUE;
case GDK_Up:
{
- double y = scalespace_pixel(&p->y_v,p->sely)-1;
+ double y = _sv_scalespace_pixel(&p->y_v,p->sely)-1;
p->cross_active=1;
if(shift)
y-=9;
- p->sely = scalespace_value(&p->y_v,y);
+ p->sely = _sv_scalespace_value(&p->y_v,y);
if(p->crosshairs_callback)
p->crosshairs_callback(p->cross_data);
@@ -956,16 +956,16 @@
}else
p->box_active=0;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
}
return TRUE;
case GDK_Down:
{
- double y = scalespace_pixel(&p->y_v,p->sely)+1;
+ double y = _sv_scalespace_pixel(&p->y_v,p->sely)+1;
p->cross_active=1;
if(shift)
y+=9;
- p->sely = scalespace_value(&p->y_v,y);
+ p->sely = _sv_scalespace_value(&p->y_v,y);
if(p->crosshairs_callback)
p->crosshairs_callback(p->cross_data);
@@ -975,7 +975,7 @@
}else
p->box_active=0;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
}
return TRUE;
@@ -985,23 +985,23 @@
return FALSE;
}
-static gboolean plot_unfocus(GtkWidget *widget,
+static gboolean _sv_plot_unfocus(GtkWidget *widget,
GdkEventFocus *event){
- Plot *p=PLOT(widget);
+ _sv_plot_t *p=PLOT(widget);
p->widgetfocus=0;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
return TRUE;
}
-static gboolean plot_refocus(GtkWidget *widget,
+static gboolean _sv_plot_refocus(GtkWidget *widget,
GdkEventFocus *event){
- Plot *p=PLOT(widget);
+ _sv_plot_t *p=PLOT(widget);
p->widgetfocus=1;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
return TRUE;
}
-static void plot_class_init (PlotClass * class) {
+static void _sv_plot_class_init (_sv_plot_class_t * class) {
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
@@ -1011,56 +1011,56 @@
parent_class = gtk_type_class (GTK_TYPE_WIDGET);
- object_class->destroy = plot_destroy;
+ object_class->destroy = _sv_plot_destroy;
- widget_class->realize = plot_realize;
- widget_class->expose_event = plot_expose;
- widget_class->size_request = plot_size_request;
- widget_class->size_allocate = plot_size_allocate;
+ widget_class->realize = _sv_plot_realize;
+ widget_class->expose_event = _sv_plot_expose;
+ widget_class->size_request = _sv_plot_size_request;
+ widget_class->size_allocate = _sv_plot_size_allocate;
widget_class->button_press_event = mouse_press;
widget_class->button_release_event = mouse_release;
widget_class->motion_notify_event = mouse_motion;
- //widget_class->enter_notify_event = plot_enter;
- //widget_class->leave_notify_event = plot_leave;
- widget_class->key_press_event = key_press;
+ //widget_class->enter_notify_event = _sv_plot_enter;
+ //widget_class->leave_notify_event = _sv_plot_leave;
+ widget_class->key_press_event = _sv_plot_key_press;
- widget_class->focus_out_event = plot_unfocus;
- widget_class->focus_in_event = plot_refocus;
+ widget_class->focus_out_event = _sv_plot_unfocus;
+ widget_class->focus_in_event = _sv_plot_refocus;
}
-GType plot_get_type (void){
+GType _sv_plot_get_type (void){
static GType plot_type = 0;
if (!plot_type)
{
static const GTypeInfo plot_info = {
- sizeof (PlotClass),
+ sizeof (_sv_plot_class_t),
NULL,
NULL,
- (GClassInitFunc) plot_class_init,
+ (GClassInitFunc) _sv_plot_class_init,
NULL,
NULL,
- sizeof (Plot),
+ sizeof (_sv_plot_t),
0,
- (GInstanceInitFunc) plot_init,
+ (GInstanceInitFunc) _sv_plot_init,
0
};
plot_type = g_type_register_static (GTK_TYPE_WIDGET, "Plot",
- &plot_info, 0);
+ &plot_info, 0);
}
return plot_type;
}
-Plot *plot_new (void (*callback)(void *),void *app_data,
+_sv_plot_t *_sv_plot_new (void (*callback)(void *),void *app_data,
void (*cross_callback)(void *),void *cross_data,
void (*box_callback)(void *, int),void *box_data,
unsigned flags) {
GtkWidget *g = GTK_WIDGET (g_object_new (PLOT_TYPE, NULL));
- Plot *p = PLOT (g);
+ _sv_plot_t *p = PLOT (g);
p->recompute_callback = callback;
p->app_data = app_data;
p->crosshairs_callback = cross_callback;
@@ -1068,14 +1068,14 @@
p->box_callback = box_callback;
p->box_data = box_data;
p->flags = flags;
- p->grid_mode = PLOT_GRID_NORMAL;
+ p->grid_mode = _SV_PLOT_GRID_NORMAL;
p->resizable = 1;
p->legend_active = 1;
return p;
}
-void plot_expose_request(Plot *p){
+void _sv_plot_expose_request(_sv_plot_t *p){
gdk_threads_enter();
GtkWidget *widget = GTK_WIDGET(p);
@@ -1092,7 +1092,7 @@
gdk_threads_leave();
}
-void plot_expose_request_partial(Plot *p,int x, int y, int w, int h){
+void _sv_plot_expose_request_partial(_sv_plot_t *p,int x, int y, int w, int h){
gdk_threads_enter();
GtkWidget *widget = GTK_WIDGET(p);
@@ -1107,45 +1107,45 @@
gdk_threads_leave();
}
-void plot_set_crosshairs(Plot *p, double x, double y){
+void _sv_plot_set_crosshairs(_sv_plot_t *p, double x, double y){
gdk_threads_enter();
p->selx = x;
p->sely = y;
p->cross_active=1;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
gdk_threads_leave();
}
-void plot_set_crosshairs_snap(Plot *p, double x, double y){
+void _sv_plot_set_crosshairs_snap(_sv_plot_t *p, double x, double y){
gdk_threads_enter();
- double xpixel = rint(scalespace_pixel(&p->x_v,x));
- double ypixel = rint(scalespace_pixel(&p->y_v,y));
+ double xpixel = rint(_sv_scalespace_pixel(&p->x_v,x));
+ double ypixel = rint(_sv_scalespace_pixel(&p->y_v,y));
- p->selx = scalespace_value(&p->x_v,xpixel);
- p->sely = scalespace_value(&p->y_v,ypixel);
+ p->selx = _sv_scalespace_value(&p->x_v,xpixel);
+ p->sely = _sv_scalespace_value(&p->y_v,ypixel);
p->cross_active=1;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
gdk_threads_leave();
}
-void plot_snap_crosshairs(Plot *p){
+void _sv_plot_snap_crosshairs(_sv_plot_t *p){
gdk_threads_enter();
- double xpixel = rint(scalespace_pixel(&p->x_v,p->selx));
- double ypixel = rint(scalespace_pixel(&p->y_v,p->sely));
+ double xpixel = rint(_sv_scalespace_pixel(&p->x_v,p->selx));
+ double ypixel = rint(_sv_scalespace_pixel(&p->y_v,p->sely));
- p->selx = scalespace_value(&p->x_v,xpixel);
- p->sely = scalespace_value(&p->y_v,ypixel);
+ p->selx = _sv_scalespace_value(&p->x_v,xpixel);
+ p->sely = _sv_scalespace_value(&p->y_v,ypixel);
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
gdk_threads_leave();
}
-int plot_get_crosshair_xpixel(Plot *p){
- scalespace x;
+int _sv_plot_get_crosshair_xpixel(_sv_plot_t *p){
+ _sv_scalespace_t x;
double v;
gdk_threads_enter();
@@ -1153,11 +1153,11 @@
v = p->selx;
gdk_threads_leave();
- return (int)rint(scalespace_pixel(&x,v));
+ return (int)rint(_sv_scalespace_pixel(&x,v));
}
-int plot_get_crosshair_ypixel(Plot *p){
- scalespace y;
+int _sv_plot_get_crosshair_ypixel(_sv_plot_t *p){
+ _sv_scalespace_t y;
double v;
gdk_threads_enter();
@@ -1165,16 +1165,16 @@
v = p->sely;
gdk_threads_leave();
- return (int)rint(scalespace_pixel(&y,v));
+ return (int)rint(_sv_scalespace_pixel(&y,v));
}
-void plot_unset_box(Plot *p){
+void _sv_plot_unset_box(_sv_plot_t *p){
gdk_threads_enter();
p->box_active = 0;
gdk_threads_leave();
}
-void plot_box_vals(Plot *p, double ret[4]){
+void _sv_plot_box_vals(_sv_plot_t *p, double ret[4]){
gdk_threads_enter();
int n = p->x.neg;
@@ -1187,7 +1187,7 @@
gdk_threads_leave();
}
-void plot_box_set(Plot *p, double vals[4]){
+void _sv_plot_box_set(_sv_plot_t *p, double vals[4]){
gdk_threads_enter();
p->box_x1=vals[0];
@@ -1196,11 +1196,11 @@
p->box_y2=vals[3];
p->box_active = 1;
- plot_expose_request(p);
+ _sv_plot_expose_request(p);
gdk_threads_leave();
}
-void plot_legend_clear(Plot *p){
+void _sv_plot_legend_clear(_sv_plot_t *p){
int i;
if(p->legend_list){
for(i=0;i<p->legend_entries;i++)
@@ -1212,11 +1212,11 @@
p->legend_entries=0;
}
-void plot_legend_add(Plot *p, char *entry){
- plot_legend_add_with_color(p,entry,0xffffffffUL);
+void _sv_plot_legend_add(_sv_plot_t *p, char *entry){
+ _sv_plot_legend_add_with_color(p,entry,0xffffffffUL);
}
-void plot_legend_add_with_color(Plot *p, char *entry, u_int32_t color){
+void _sv_plot_legend_add_with_color(_sv_plot_t *p, char *entry, u_int32_t color){
if(!p->legend_list || !p->legend_colors){
p->legend_list = calloc(1, sizeof(*p->legend_list));
p->legend_colors = calloc(1, sizeof(*p->legend_colors));
@@ -1234,7 +1234,7 @@
p->legend_colors[p->legend_entries-1] = color;
}
-void plot_resizable(Plot *p, int rp){
+void _sv_plot_resizable(_sv_plot_t *p, int rp){
GtkWidget *widget = GTK_WIDGET(p);
if(!rp){
Modified: trunk/sushivision/plot.h
===================================================================
--- trunk/sushivision/plot.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/plot.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -28,16 +28,16 @@
G_BEGIN_DECLS
-#define PLOT_TYPE (plot_get_type ())
-#define PLOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLOT_TYPE, Plot))
-#define PLOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLOT_TYPE, PlotClass))
+#define PLOT_TYPE (_sv_plot_get_type ())
+#define PLOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLOT_TYPE, _sv_plot_t))
+#define PLOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLOT_TYPE, _sv_plot_class_t))
#define IS_PLOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLOT_TYPE))
#define IS_PLOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLOT_TYPE))
-typedef struct _Plot Plot;
-typedef struct _PlotClass PlotClass;
+typedef struct _sv_plot _sv_plot_t;
+typedef struct _sv_plot_class _sv_plot_class_t;
-struct _Plot{
+struct _sv_plot{
GtkWidget w;
cairo_t *wc;
cairo_surface_t *back;
@@ -49,10 +49,10 @@
int resizable;
int scalespacing;
- scalespace x;
- scalespace x_v;
- scalespace y;
- scalespace y_v;
+ _sv_scalespace_t x;
+ _sv_scalespace_t x_v;
+ _sv_scalespace_t y;
+ _sv_scalespace_t y_v;
char *namex;
char *namey;
@@ -83,66 +83,66 @@
unsigned flags;
};
-struct _PlotClass{
+struct _sv_plot_class{
GtkWidgetClass parent_class;
- void (*plot) (Plot *m);
+ void (*plot) (_sv_plot_t *m);
};
-GType plot_get_type (void);
-Plot *plot_new (void (*callback)(void *),void *app_data,
- void (*cross_callback)(void *),void *cross_data,
- void (*box_callback)(void *,int),void *box_data,
- unsigned flags);
+GType _sv_plot_get_type (void);
+_sv_plot_t *_sv_plot_new (void (*callback)(void *),void *app_data,
+ void (*cross_callback)(void *),void *cross_data,
+ void (*box_callback)(void *,int),void *box_data,
+ unsigned flags);
G_END_DECLS
// the widget subclass half
-int plot_print(Plot *p, cairo_t *c, double page_h, void (*datarender)(void *data,cairo_t *c), void *data);
-void plot_set_bg_invert(Plot *p, int setp);
-void plot_expose_request(Plot *p);
-void plot_expose_request_partial(Plot *p,int x, int y, int w, int h);
-void plot_set_x_scale(Plot *p, scalespace x);
-void plot_set_y_scale(Plot *p, scalespace y);
-void plot_set_x_name(Plot *p, char *name);
-void plot_set_y_name(Plot *p, char *name);
-u_int32_t * plot_get_background_line(Plot *p, int num);
-cairo_t *plot_get_background_cairo(Plot *p);
-void plot_set_crosshairs(Plot *p, double x, double y);
-void plot_set_crosshairs_snap(Plot *p, double x, double y);
-void plot_snap_crosshairs(Plot *p);
-void plot_draw_scales(Plot *p);
-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_add_with_color(Plot *p, char *entry, u_int32_t color);
-void plot_legend_clear(Plot *p);
-int plot_get_crosshair_xpixel(Plot *p);
-int plot_get_crosshair_ypixel(Plot *p);
-void plot_set_grid(Plot *p, int mode);
+int _sv_plot_print(_sv_plot_t *p, cairo_t *c, double page_h, void (*datarender)(void *data,cairo_t *c), void *data);
+void _sv_plot_set_bg_invert(_sv_plot_t *p, int setp);
+void _sv_plot_expose_request(_sv_plot_t *p);
+void _sv_plot_expose_request_partial(_sv_plot_t *p,int x, int y, int w, int h);
+void _sv_plot_set_x_scale(_sv_plot_t *p, _sv_scalespace_t x);
+void _sv_plot_set_y_scale(_sv_plot_t *p, _sv_scalespace_t y);
+void _sv_plot_set_x_name(_sv_plot_t *p, char *name);
+void _sv_plot_set_y_name(_sv_plot_t *p, char *name);
+u_int32_t * _sv_plot_get_background_line(_sv_plot_t *p, int num);
+cairo_t *_sv_plot_get_background_cairo(_sv_plot_t *p);
+void _sv_plot_set_crosshairs(_sv_plot_t *p, double x, double y);
+void _sv_plot_set_crosshairs_snap(_sv_plot_t *p, double x, double y);
+void _sv_plot_snap_crosshairs(_sv_plot_t *p);
+void _sv_plot_draw_scales(_sv_plot_t *p);
+void _sv_plot_unset_box(_sv_plot_t *p);
+void _sv_plot_box_vals(_sv_plot_t *p, double ret[4]);
+void _sv_plot_box_set(_sv_plot_t *p, double vals[4]);
+void _sv_plot_legend_add(_sv_plot_t *p, char *entry);
+void _sv_plot_legend_add_with_color(_sv_plot_t *p, char *entry, u_int32_t color);
+void _sv_plot_legend_clear(_sv_plot_t *p);
+int _sv_plot_get_crosshair_xpixel(_sv_plot_t *p);
+int _sv_plot_get_crosshair_ypixel(_sv_plot_t *p);
+void _sv_plot_set_grid(_sv_plot_t *p, int mode);
-void plot_do_enter(Plot *p);
-void plot_set_crossactive(Plot *p, int active);
-void plot_toggle_legend(Plot *p);
-void plot_set_legendactive(Plot *p, int active);
+void _sv_plot_do_enter(_sv_plot_t *p);
+void _sv_plot_set_crossactive(_sv_plot_t *p, int active);
+void _sv_plot_toggle_legend(_sv_plot_t *p);
+void _sv_plot_set_legendactive(_sv_plot_t *p, int active);
-void plot_resizable(Plot *p, int rp);
+void _sv_plot_resizable(_sv_plot_t *p, int rp);
-#define PLOT_NO_X_CROSS 1
-#define PLOT_NO_Y_CROSS 2
+#define _SV_PLOT_NO_X_CROSS 1
+#define _SV_PLOT_NO_Y_CROSS 2
-#define PLOT_GRID_NONE 0
-#define PLOT_GRID_NORMAL 4
-#define PLOT_GRID_TICS 8
-#define PLOT_GRID_LIGHT (256+4)
-#define PLOT_GRID_DARK (512+4)
+#define _SV_PLOT_GRID_NONE 0
+#define _SV_PLOT_GRID_NORMAL 4
+#define _SV_PLOT_GRID_TICS 8
+#define _SV_PLOT_GRID_LIGHT (256+4)
+#define _SV_PLOT_GRID_DARK (512+4)
-#define PLOT_GRID_MODEMASK 0x00fc
-#define PLOT_GRID_COLORMASK 0x0f00
+#define _SV_PLOT_GRID_MODEMASK 0x00fc
+#define _SV_PLOT_GRID_COLORMASK 0x0f00
-#define PLOT_TEXT_DARK 0
-#define PLOT_TEXT_LIGHT 1
+#define _SV_PLOT_TEXT_DARK 0
+#define _SV_PLOT_TEXT_LIGHT 1
-#define PLOT_LEGEND_NONE 0
-#define PLOT_LEGEND_SHADOW 1
-#define PLOT_LEGEND_BOX 2
+#define _SV_PLOT_LEGEND_NONE 0
+#define _SV_PLOT_LEGEND_SHADOW 1
+#define _SV_PLOT_LEGEND_BOX 2
Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/scale.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -42,7 +42,7 @@
}
/* depth, at a minimum, must capture the difference between consecutive scale values */
-int del_depth(double A, double B){
+static int del_depth(double A, double B){
int depth = 0;
double del = B-A;
@@ -111,7 +111,7 @@
/* default scale label generation is hard, but fill it in in an ad-hoc
fashion. Add flags to help out later */
-char **scale_generate_labels(unsigned scalevals, double *scaleval_list){
+static char **scale_generate_labels(unsigned scalevals, double *scaleval_list){
unsigned i;
int depth;
char **ret;
@@ -145,7 +145,8 @@
return ret;
}
-void scale_free(sushiv_scale_t *s){
+void sv_scale_free(sv_scale_t *in){
+ sv_scale_t *s = (sv_scale_t *)in;
int i;
if(s){
@@ -160,10 +161,12 @@
}
}
-sushiv_scale_t *scale_new(unsigned scalevals, double *scaleval_list, const char *legend){
+sv_scale_t *sv_scale_new(char *legend,
+ unsigned scalevals, double *scaleval_list, char **labels,
+ unsigned flags){
int i;
- sushiv_scale_t *s = NULL;
+ sv_scale_t *s = NULL;
if(scalevals<2){
fprintf(stderr,"Scale requires at least two scale values.");
@@ -178,33 +181,40 @@
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);
+ if(labels){
+ // copy labels
+ s->label_list = calloc(scalevals,sizeof(*s->label_list));
+ for(i=0;i<(int)scalevals;i++)
+ if(labels[i]){
+ s->label_list[i] = strdup(labels[i]);
+ }else{
+ s->label_list[i] = strdup("");
+ }
+ }else{
+ // generate labels
+ s->label_list = scale_generate_labels(scalevals,scaleval_list);
+ }
if(legend)
s->legend=strdup(legend);
else
s->legend=strdup("");
+
+ s->flags = flags;
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;
+sv_scale_t *sv_scale_copy(sv_scale_t *s){
+ return sv_scale_new(s->legend, s->vals, s->val_list, (char **)s->label_list, s->flags);
}
/* plot and graph scales */
-double scalespace_value(scalespace *s, double pixel){
+double _sv_scalespace_value(_sv_scalespace_t *s, double pixel){
double val = (double)(pixel-s->first_pixel)*s->step_val/s->step_pixel + s->first_val;
return val * s->m;
}
-void scalespace_double(scalespace *s){
+void _sv_scalespace_double(_sv_scalespace_t *s){
// mildly complicated by mantissa being powers of ten
if(s->step_val & 0x1){ // ie, not divisible by two
s->decimal_exponent--;
@@ -217,7 +227,7 @@
s->pixels <<= 1;
}
-double scalespace_pixel(scalespace *s, double val){
+double _sv_scalespace_pixel(_sv_scalespace_t *s, double val){
val /= s->m;
val -= s->first_val;
val *= s->step_pixel;
@@ -227,11 +237,11 @@
return val;
}
-double scalespace_scaledel(scalespace *from, scalespace *to){
+double _sv_scalespace_scaledel(_sv_scalespace_t *from, _sv_scalespace_t *to){
return (double)from->step_val / from->step_pixel * from->m / to->m * to->step_pixel / to->step_val;
}
-long scalespace_scalenum(scalespace *from, scalespace *to){
+long _sv_scalespace_scalenum(_sv_scalespace_t *from, _sv_scalespace_t *to){
int dec = from->decimal_exponent - to->decimal_exponent;
long ret = from->step_val * to->step_pixel * from->neg;
while(dec-->0)
@@ -239,7 +249,7 @@
return ret*2;
}
-long scalespace_scaleden(scalespace *from, scalespace *to){
+long _sv_scalespace_scaleden(_sv_scalespace_t *from, _sv_scalespace_t *to){
int dec = to->decimal_exponent - from->decimal_exponent;
long ret = from->step_pixel * to->step_val * to->neg;
while(dec-->0)
@@ -247,7 +257,7 @@
return ret*2;
}
-long scalespace_scaleoff(scalespace *from, scalespace *to){
+long _sv_scalespace_scaleoff(_sv_scalespace_t *from, _sv_scalespace_t *to){
int decF = from->decimal_exponent - to->decimal_exponent;
int decT = to->decimal_exponent - from->decimal_exponent;
long expF = 1;
@@ -262,7 +272,7 @@
* expT * from->step_pixel * to->neg;
}
-long scalespace_scalebin(scalespace *from, scalespace *to){
+long _sv_scalespace_scalebin(_sv_scalespace_t *from, _sv_scalespace_t *to){
int decF = from->decimal_exponent - to->decimal_exponent;
int decT = to->decimal_exponent - from->decimal_exponent;
long expF = 1;
@@ -277,13 +287,13 @@
* expT * from->step_pixel * to->neg;
}
-int scalespace_mark(scalespace *s, int num){
+int _sv_scalespace_mark(_sv_scalespace_t *s, int num){
return s->first_pixel + s->step_pixel*num;
}
-double scalespace_label(scalespace *s, int num, char *buffer){
- int pixel = scalespace_mark(s,num);
- double val = scalespace_value(s,pixel);
+double _sv_scalespace_label(_sv_scalespace_t *s, int num, char *buffer){
+ int pixel = _sv_scalespace_mark(s,num);
+ double val = _sv_scalespace_value(s,pixel);
if(s->decimal_exponent<0){
sprintf(buffer,"%.*f",-s->decimal_exponent,val);
@@ -294,9 +304,9 @@
}
// name is *not* copied
-scalespace scalespace_linear (double lowpoint, double highpoint, int pixels, int max_spacing, char *name){
+_sv_scalespace_t _sv_scalespace_linear (double lowpoint, double highpoint, int pixels, int max_spacing, char *name){
double orange = fabs(highpoint - lowpoint), range;
- scalespace ret;
+ _sv_scalespace_t ret;
int place;
int step;
Modified: trunk/sushivision/scale.h
===================================================================
--- trunk/sushivision/scale.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/scale.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -38,18 +38,17 @@
int pixels;
int spacing;
int massaged; // set if range had to be adjusted to avoid underflows
-} scalespace;
+} _sv_scalespace_t;
-int del_depth(double A, double B);
-extern char **scale_generate_labels(unsigned scalevals, double *scaleval_list);
-extern double scalespace_scaledel(scalespace *from, scalespace *to);
-extern long scalespace_scalenum(scalespace *from, scalespace *to);
-extern long scalespace_scaleden(scalespace *from, scalespace *to);
-extern long scalespace_scaleoff(scalespace *from, scalespace *to);
-extern long scalespace_scalebin(scalespace *from, scalespace *to);
-extern double scalespace_value(scalespace *s, double pixel);
-extern double scalespace_pixel(scalespace *s, double val);
-extern int scalespace_mark(scalespace *s, int num);
-extern double scalespace_label(scalespace *s, int num, char *buffer);
-extern scalespace scalespace_linear (double lowpoint, double highpoint, int pixels, int max_spacing,char *name);
-extern void scalespace_double(scalespace *s);
+extern char **_sv_scale_generate_labels(unsigned scalevals, double *scaleval_list);
+extern double _sv_scalespace_scaledel(_sv_scalespace_t *from, _sv_scalespace_t *to);
+extern long _sv_scalespace_scalenum(_sv_scalespace_t *from, _sv_scalespace_t *to);
+extern long _sv_scalespace_scaleden(_sv_scalespace_t *from, _sv_scalespace_t *to);
+extern long _sv_scalespace_scaleoff(_sv_scalespace_t *from, _sv_scalespace_t *to);
+extern long _sv_scalespace_scalebin(_sv_scalespace_t *from, _sv_scalespace_t *to);
+extern double _sv_scalespace_value(_sv_scalespace_t *s, double pixel);
+extern double _sv_scalespace_pixel(_sv_scalespace_t *s, double val);
+extern int _sv_scalespace_mark(_sv_scalespace_t *s, int num);
+extern double _sv_scalespace_label(_sv_scalespace_t *s, int num, char *buffer);
+extern _sv_scalespace_t _sv_scalespace_linear (double lowpoint, double highpoint, int pixels, int max_spacing,char *name);
+extern void _sv_scalespace_double(_sv_scalespace_t *s);
Modified: trunk/sushivision/slice.c
===================================================================
--- trunk/sushivision/slice.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/slice.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -25,105 +25,105 @@
#include <gdk/gdkkeysyms.h>
#include "internal.h"
-static void draw_and_expose(GtkWidget *widget){
- Slice *s=SLICE(widget);
+static void _sv_slice_draw_and_expose(GtkWidget *widget){
+ _sv_slice_t *s=SLICE(widget);
- slider_draw(s->slider);
- slider_expose(s->slider);
+ _sv_slider_draw(s->slider);
+ _sv_slider_expose(s->slider);
}
-static gboolean slice_expose(GtkWidget *widget, GdkEventExpose *event ){
- Slice *s=SLICE(widget);
- slider_expose_slice(s->slider,s->slicenum);
+static gboolean _sv_slice_expose(GtkWidget *widget, GdkEventExpose *event ){
+ _sv_slice_t *s=SLICE(widget);
+ _sv_slider_expose_slice(s->slider,s->slicenum);
return FALSE;
}
-static void slice_size_request (GtkWidget *widget,GtkRequisition *requisition){
- Slice *s=SLICE(widget);
+static void _sv_slice_size_request (GtkWidget *widget,GtkRequisition *requisition){
+ _sv_slice_t *s=SLICE(widget);
- slider_size_request_slice(s->slider,requisition);
+ _sv_slider_size_request_slice(s->slider,requisition);
}
-static gint slice_motion(GtkWidget *widget,
+static gint _sv_slice_motion(GtkWidget *widget,
GdkEventMotion *event){
- Slice *s=SLICE(widget);
- slider_motion(s->slider,s->slicenum,event->x,event->y);
+ _sv_slice_t *s=SLICE(widget);
+ _sv_slider_motion(s->slider,s->slicenum,event->x,event->y);
return TRUE;
}
-static gint slice_enter(GtkWidget *widget,
+static gint _sv_slice_enter(GtkWidget *widget,
GdkEventCrossing *event){
- Slice *s=SLICE(widget);
- slider_lightme(s->slider,s->slicenum,event->x,event->y);
- draw_and_expose(widget);
+ _sv_slice_t *s=SLICE(widget);
+ _sv_slider_lightme(s->slider,s->slicenum,event->x,event->y);
+ _sv_slice_draw_and_expose(widget);
return TRUE;
}
-static gint slice_leave(GtkWidget *widget,
+static gint _sv_slice_leave(GtkWidget *widget,
GdkEventCrossing *event){
- Slice *s=SLICE(widget);
+ _sv_slice_t *s=SLICE(widget);
- slider_unlight(s->slider);
- slider_draw(s->slider);
- slider_expose(s->slider);
+ _sv_slider_unlight(s->slider);
+ _sv_slider_draw(s->slider);
+ _sv_slider_expose(s->slider);
return TRUE;
}
-static gboolean slice_button_press(GtkWidget *widget,
+static gboolean _sv_slice_button_press(GtkWidget *widget,
GdkEventButton *event){
- Slice *s=SLICE(widget);
+ _sv_slice_t *s=SLICE(widget);
if(event->button == 3)return FALSE;
if(event->button == 1)
- slider_button_press(s->slider,s->slicenum,event->x,event->y);
+ _sv_slider_button_press(s->slider,s->slicenum,event->x,event->y);
return TRUE;
}
-static gboolean slice_button_release(GtkWidget *widget,
+static gboolean _sv_slice_button_release(GtkWidget *widget,
GdkEventButton *event){
- Slice *s=SLICE(widget);
+ _sv_slice_t *s=SLICE(widget);
if(event->button == 3)return FALSE;
if(event->button == 1)
- slider_button_release(s->slider,s->slicenum,event->x,event->y);
+ _sv_slider_button_release(s->slider,s->slicenum,event->x,event->y);
return TRUE;
}
-static gboolean slice_unfocus(GtkWidget *widget,
+static gboolean _sv_slice_unfocus(GtkWidget *widget,
GdkEventFocus *event){
- Slice *s=SLICE(widget);
+ _sv_slice_t *s=SLICE(widget);
if(s->thumb_focus){
s->thumb_focus=0;
- draw_and_expose(widget);
+ _sv_slice_draw_and_expose(widget);
}
return TRUE;
}
-static gboolean slice_refocus(GtkWidget *widget,
+static gboolean _sv_slice_refocus(GtkWidget *widget,
GdkEventFocus *event){
- Slice *s=SLICE(widget);
+ _sv_slice_t *s=SLICE(widget);
if(!s->thumb_focus){
s->thumb_focus=1;
- draw_and_expose(widget);
+ _sv_slice_draw_and_expose(widget);
}
return TRUE;
}
-static gboolean slice_key_press(GtkWidget *widget,GdkEventKey *event){
- Slice *s=SLICE(widget);
+static gboolean _sv_slice_key_press(GtkWidget *widget,GdkEventKey *event){
+ _sv_slice_t *s=SLICE(widget);
- return slider_key_press(s->slider,event,s->slicenum);
+ return _sv_slider_key_press(s->slider,event,s->slicenum);
}
-static void slice_state_changed(GtkWidget *w,GtkStateType ps){
- draw_and_expose(w);
+static void _sv_slice_state_changed(GtkWidget *w,GtkStateType ps){
+ _sv_slice_draw_and_expose(w);
}
-static void slice_realize (GtkWidget *widget){
+static void _sv_slice_realize (GtkWidget *widget){
GdkWindowAttr attributes;
gint attributes_mask;
@@ -160,9 +160,9 @@
gtk_widget_set_double_buffered (widget, FALSE);
}
-static void slice_size_allocate (GtkWidget *widget,
+static void _sv_slice_size_allocate (GtkWidget *widget,
GtkAllocation *allocation){
- //Slice *s = SLICE (widget);
+ //_sv_slice_t *s = SLICE (widget);
if (GTK_WIDGET_REALIZED (widget)){
gdk_window_move_resize (widget->window, allocation->x, allocation->y,
@@ -176,44 +176,44 @@
static GtkWidgetClass *parent_class = NULL;
-static void slice_class_init (SliceClass *class){
+static void _sv_slice_class_init (_sv_slice_class_t *class){
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
//GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
parent_class = g_type_class_peek_parent (class);
//object_class->destroy = slice_destroy;
- widget_class->realize = slice_realize;
- widget_class->expose_event = slice_expose;
- widget_class->size_request = slice_size_request;
- widget_class->size_allocate = slice_size_allocate;
- widget_class->key_press_event = slice_key_press;
- widget_class->button_press_event = slice_button_press;
- widget_class->button_release_event = slice_button_release;
- widget_class->enter_notify_event = slice_enter;
- widget_class->leave_notify_event = slice_leave;
- widget_class->motion_notify_event = slice_motion;
- widget_class->focus_out_event = slice_unfocus;
- widget_class->focus_in_event = slice_refocus;
- widget_class->state_changed = slice_state_changed;
+ widget_class->realize = _sv_slice_realize;
+ widget_class->expose_event = _sv_slice_expose;
+ widget_class->size_request = _sv_slice_size_request;
+ widget_class->size_allocate = _sv_slice_size_allocate;
+ widget_class->key_press_event = _sv_slice_key_press;
+ widget_class->button_press_event = _sv_slice_button_press;
+ widget_class->button_release_event = _sv_slice_button_release;
+ widget_class->enter_notify_event = _sv_slice_enter;
+ widget_class->leave_notify_event = _sv_slice_leave;
+ widget_class->motion_notify_event = _sv_slice_motion;
+ widget_class->focus_out_event = _sv_slice_unfocus;
+ widget_class->focus_in_event = _sv_slice_refocus;
+ widget_class->state_changed = _sv_slice_state_changed;
}
-static void slice_init (Slice *s){
+static void _sv_slice_init (_sv_slice_t *s){
}
-GType slice_get_type (void){
+GType _sv_slice_get_type (void){
static GType m_type = 0;
if (!m_type){
static const GTypeInfo m_info={
- sizeof (SliceClass),
+ sizeof (_sv_slice_class_t),
NULL, /* base_init */
NULL, /* base_finalize */
- (GClassInitFunc) slice_class_init,
+ (GClassInitFunc) _sv_slice_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
- sizeof (Slice),
+ sizeof (_sv_slice_t),
0,
- (GInstanceInitFunc) slice_init,
+ (GInstanceInitFunc) _sv_slice_init,
0
};
@@ -223,35 +223,35 @@
return m_type;
}
-GtkWidget* slice_new (void (*callback)(void *,int), void *data){
- GtkWidget *ret= GTK_WIDGET (g_object_new (slice_get_type (), NULL));
- Slice *s=SLICE(ret);
+GtkWidget* _sv_slice_new (void (*callback)(void *,int), void *data){
+ GtkWidget *ret= GTK_WIDGET (g_object_new (_sv_slice_get_type (), NULL));
+ _sv_slice_t *s=SLICE(ret);
s->callback = callback;
s->callback_data = data;
s->thumb_active = 1;
return ret;
}
-void slice_set_active(Slice *s, int activep){
+void _sv_slice_set_active(_sv_slice_t *s, int activep){
s->thumb_active = activep;
if(s->active_callback)
s->active_callback(s->active_callback_data, activep);
- draw_and_expose(GTK_WIDGET(s));
+ _sv_slice_draw_and_expose(GTK_WIDGET(s));
}
-void slice_thumb_set(Slice *s,double v){
+void _sv_slice_thumb_set(_sv_slice_t *s,double v){
GtkWidget *w=GTK_WIDGET(s);
if(s->thumb_val != v){
s->thumb_val=v;
- slider_vals_bound(s->slider,s->slicenum);
+ _sv_slider_vals_bound(s->slider,s->slicenum);
if(s->callback)s->callback(s->callback_data,1);
- draw_and_expose(w);
+ _sv_slice_draw_and_expose(w);
}
}
-void slice_set_active_callback(Slice *s, void (*callback)(void *,int), void *data){
+void _sv_slice_set_active_callback(_sv_slice_t *s, void (*callback)(void *,int), void *data){
s->active_callback = callback;
s->active_callback_data = data;
}
Modified: trunk/sushivision/slice.h
===================================================================
--- trunk/sushivision/slice.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/slice.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -31,21 +31,21 @@
G_BEGIN_DECLS
-#define SLICE_TYPE (slice_get_type ())
-#define SLICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SLICE_TYPE, Slice))
-#define SLICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SLICE_TYPE, SliceClass))
+#define SLICE_TYPE (_sv_slice_get_type ())
+#define SLICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SLICE_TYPE, _sv_slice_t))
+#define SLICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SLICE_TYPE, _sv_slice_class_t))
#define IS_SLICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SLICE_TYPE))
#define IS_SLICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SLICE_TYPE))
-typedef struct _Slice Slice;
-typedef struct _SliceClass SliceClass;
+typedef struct _sv_slice _sv_slice_t;
+typedef struct _sv_slice_class _sv_slice_class_t;
-typedef struct _Slider Slider;
+typedef struct _sv_slider _sv_slider_t;
-struct _Slice{
+struct _sv_slice {
GtkWidget widget;
- Slider *slider;
+ _sv_slider_t *slider;
int slicenum;
int thumb_active;
@@ -62,15 +62,15 @@
};
-struct _SliceClass{
+struct _sv_slice_class{
GtkWidgetClass parent_class;
- void (*slice) (Slice *s);
+ void (*slice) (_sv_slice_t *s);
};
-extern GType slice_get_type (void);
-extern GtkWidget* slice_new (void (*callback)(void *,int), void *data);
-extern void slice_set_active(Slice *s, int activep);
-extern void slice_thumb_set(Slice *s,double v);
-extern void slice_set_active_callback(Slice *s, void (*callback)(void *,int), void *data);
+extern GType _sv_slice_get_type (void);
+extern GtkWidget* _sv_slice_new (void (*callback)(void *,int), void *data);
+extern void _sv_slice_set_active(_sv_slice_t *s, int activep);
+extern void _sv_slice_thumb_set(_sv_slice_t *s,double v);
+extern void _sv_slice_set_active_callback(_sv_slice_t *s, void (*callback)(void *,int), void *data);
G_END_DECLS
#endif
Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/slider.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -27,9 +27,9 @@
#include <gdk/gdkkeysyms.h>
#include "internal.h"
-static double val_to_pixel(Slider *s, double val);
+static double val_to_pixel(_sv_slider_t *s, double val);
-static int total_slice_width(Slider *s){
+static int total_slice_width(_sv_slider_t *s){
int i;
int count=0;
if(s->flip)
@@ -41,7 +41,7 @@
return count;
}
-static int slice_width(Slider *s,int slices){
+static int slice_width(_sv_slider_t *s,int slices){
int i;
int count=0;
if(s->flip)
@@ -53,7 +53,7 @@
return count;
}
-static int total_slice_height(Slider *s){
+static int total_slice_height(_sv_slider_t *s){
int i;
int max=0;
if(s->flip){
@@ -80,10 +80,10 @@
cairo_arc (c, x+radius, y+radius, radius, M_PI, M_PI * 1.5);
}
-double shades[] = {1.15, 0.95, 0.896, 0.82, 0.7, 0.665, 0.5, 0.45, 0.4};
+static double shades[] = {1.15, 0.95, 0.896, 0.82, 0.7, 0.665, 0.5, 0.45, 0.4};
static void bg_set(GtkWidget *w, cairo_t *c){
- Slice *sl = SLICE(w);
+ _sv_slice_t *sl = SLICE(w);
GdkColor *bg = &w->style->bg[sl->thumb_state?GTK_STATE_ACTIVE:GTK_STATE_NORMAL];
double shade_r=bg->red/65535.;
double shade_g=bg->green/65535.;
@@ -93,7 +93,7 @@
}
static void fg_shade(GtkWidget *w, cairo_t *c, int shade){
- Slice *sl = SLICE(w);
+ _sv_slice_t *sl = SLICE(w);
GdkColor *fg = &w->style->fg[sl->thumb_state?GTK_STATE_ACTIVE:GTK_STATE_NORMAL];
double shade_r=fg->red*shades[shade]/65535;
double shade_g=fg->green*shades[shade]/65535;
@@ -102,7 +102,7 @@
cairo_set_source_rgb (c, shade_r,shade_g,shade_b);
}
-static void parent_shade(Slider *s, cairo_t *c, int shade){
+static void parent_shade(_sv_slider_t *s, cairo_t *c, int shade){
GtkWidget *parent=gtk_widget_get_parent(s->slices[0]);
GdkColor *bg = &parent->style->bg[GTK_STATE_NORMAL];
double shade_r=bg->red*shades[shade]/65535;
@@ -112,9 +112,9 @@
cairo_set_source_rgb (c, shade_r,shade_g,shade_b);
}
-void slider_draw_background(Slider *s){
+static void _sv_slider_draw_background(_sv_slider_t *s){
if(!s->realized)return;
-
+
int i;
GtkWidget *parent=gtk_widget_get_parent(s->slices[0]);
GdkColor *text = &s->slices[0]->style->text[0];
@@ -155,7 +155,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,i), pixel[i]);
+ pixel[i]=_sv_mapping_calc(s->gradient,_sv_slider_pixel_to_del(s,i), pixel[i]);
for(i=ty+1;i<ty+th;i++){
memcpy(pixel+w,pixel,w*4);
@@ -228,91 +228,7 @@
cairo_destroy(c);
}
-void slider_realize(Slider *s){
- int w = total_slice_width(s);
- int h = total_slice_height(s);
- if(s->background == 0 || w != s->w || h != s->h){
-
- if(s->background)
- cairo_surface_destroy(s->background);
-
- if(s->foreground)
- cairo_surface_destroy(s->foreground);
-
- if(s->backdata)
- free(s->backdata);
-
- s->backdata = calloc(w*h,4);
-
- s->background = cairo_image_surface_create_for_data ((unsigned char *)s->backdata,
- CAIRO_FORMAT_RGB24,
- w,h,w*4);
- if(s->flip){
- s->foreground = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
- h,w);
- }else{
- s->foreground = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
- w,h);
- }
-
- s->w=w;
- s->h=h;
-
- s->xpad=h*.45;
- if(s->xpad<4)s->xpad=4;
- s->realized = 1;
- slider_draw_background(s);
- slider_draw(s);
-
- }
- s->realized = 1;
-}
-
-static double val_to_pixel(Slider *s,double v){
- int j;
- double ret=0;
- double neg = (s->neg? -1.: 1.);
- int tx=s->xpad;
- int tw=s->w - tx*2;
-
- v*=neg;
-
- if( v<s->label_vals[0]*neg){
- ret=0;
- }else if(v>s->label_vals[s->labels-1]*neg){
- ret=tw;
- }else{
- for(j=0;j<s->labels;j++){
- if(v>=s->label_vals[j]*neg && v<=s->label_vals[j+1]*neg){
- v*=neg;
- double del=(v-s->label_vals[j])/(s->label_vals[j+1]-s->label_vals[j]);
- double pixlo=rint((double)(j)/(s->labels-1)*tw);
- double pixhi=rint((double)(j+1)/(s->labels-1)*tw);
- ret=pixlo*(1.-del)+pixhi*del+tx;
- break;
- }
- }
- }
-
- return ret;
-}
-
-double slider_val_to_del(Slider *s,double v){
- if(isnan(v))return NAN;
- int j;
- int flip = (s->neg? 1: 0);
-
- for(j=0;j<s->labels;j++){
- if(((v<=s->label_vals[j+1]) ^ flip) || (j+2)==s->labels){
- double del=(v-s->label_vals[j])/(s->label_vals[j+1]-s->label_vals[j]);
- return (j+del)/(s->labels-1);
- }
- }
-
- return NAN;
-}
-
-void slider_draw(Slider *s){
+void _sv_slider_draw(_sv_slider_t *s){
if(!s->realized)return;
int i;
@@ -335,7 +251,7 @@
// thumbs
for(i=0;i<s->num_slices;i++){
GtkWidget *sl = s->slices[i];
- double x = rint(val_to_pixel(s,((Slice *)(s->slices[i]))->thumb_val))+.5;
+ double x = rint(val_to_pixel(s,((_sv_slice_t *)(s->slices[i]))->thumb_val))+.5;
double rad = 2.;
@@ -358,7 +274,7 @@
cairo_set_line_width(c,1);
fg_shade(sl,c,7);
- if(((Slice *)s->slices[i])->thumb_focus)
+ if(((_sv_slice_t *)s->slices[i])->thumb_focus)
cairo_set_source_rgba(c,0,0,0,1);
cairo_stroke_preserve(c);
@@ -409,7 +325,7 @@
cairo_set_line_width(c,1);
cairo_fill_preserve(c);
fg_shade(sl,c,7);
- if(((Slice *)s->slices[i])->thumb_focus)
+ if(((_sv_slice_t *)s->slices[i])->thumb_focus)
cairo_set_source_rgba(c,0,0,0,1);
cairo_stroke_preserve(c);
@@ -443,7 +359,7 @@
cairo_set_line_width(c,1);
cairo_fill_preserve(c);
fg_shade(sl,c,7);
- if(((Slice *)s->slices[i])->thumb_focus)
+ if(((_sv_slice_t *)s->slices[i])->thumb_focus)
cairo_set_source_rgba(c,0,0,0,1);
cairo_stroke_preserve(c);
@@ -484,14 +400,98 @@
cairo_destroy(c);
}
-void slider_expose_slice(Slider *s, int slicenum){
- Slice *slice = (Slice *)(s->slices[slicenum]);
+void _sv_slider_realize(_sv_slider_t *s){
+ int w = total_slice_width(s);
+ int h = total_slice_height(s);
+ if(s->background == 0 || w != s->w || h != s->h){
+
+ if(s->background)
+ cairo_surface_destroy(s->background);
+
+ if(s->foreground)
+ cairo_surface_destroy(s->foreground);
+
+ if(s->backdata)
+ free(s->backdata);
+
+ s->backdata = calloc(w*h,4);
+
+ s->background = cairo_image_surface_create_for_data ((unsigned char *)s->backdata,
+ CAIRO_FORMAT_RGB24,
+ w,h,w*4);
+ if(s->flip){
+ s->foreground = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
+ h,w);
+ }else{
+ s->foreground = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
+ w,h);
+ }
+
+ s->w=w;
+ s->h=h;
+
+ s->xpad=h*.45;
+ if(s->xpad<4)s->xpad=4;
+ s->realized = 1;
+ _sv_slider_draw_background(s);
+ _sv_slider_draw(s);
+
+ }
+ s->realized = 1;
+}
+
+static double val_to_pixel(_sv_slider_t *s,double v){
+ int j;
+ double ret=0;
+ double neg = (s->neg? -1.: 1.);
+ int tx=s->xpad;
+ int tw=s->w - tx*2;
+
+ v*=neg;
+
+ if( v<s->label_vals[0]*neg){
+ ret=0;
+ }else if(v>s->label_vals[s->labels-1]*neg){
+ ret=tw;
+ }else{
+ for(j=0;j<s->labels;j++){
+ if(v>=s->label_vals[j]*neg && v<=s->label_vals[j+1]*neg){
+ v*=neg;
+ double del=(v-s->label_vals[j])/(s->label_vals[j+1]-s->label_vals[j]);
+ double pixlo=rint((double)(j)/(s->labels-1)*tw);
+ double pixhi=rint((double)(j+1)/(s->labels-1)*tw);
+ ret=pixlo*(1.-del)+pixhi*del+tx;
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+
+double _sv_slider_val_to_del(_sv_slider_t *s,double v){
+ if(isnan(v))return NAN;
+ int j;
+ int flip = (s->neg? 1: 0);
+
+ for(j=0;j<s->labels;j++){
+ if(((v<=s->label_vals[j+1]) ^ flip) || (j+2)==s->labels){
+ double del=(v-s->label_vals[j])/(s->label_vals[j+1]-s->label_vals[j]);
+ return (j+del)/(s->labels-1);
+ }
+ }
+
+ return NAN;
+}
+
+void _sv_slider_expose_slice(_sv_slider_t *s, int slicenum){
+ _sv_slice_t *slice = (_sv_slice_t *)(s->slices[slicenum]);
GtkWidget *w = GTK_WIDGET(slice);
if(GTK_WIDGET_REALIZED(w)){
cairo_t *c = gdk_cairo_create(w->window);
- slider_realize(s);
+ _sv_slider_realize(s);
if(s->flip){
cairo_set_source_surface(c,s->foreground,0, slice_width(s,slicenum+1)-total_slice_width(s));
}else{
@@ -504,13 +504,13 @@
}
}
-void slider_expose(Slider *s){
+void _sv_slider_expose(_sv_slider_t *s){
int i;
for(i=0;i<s->num_slices;i++)
- slider_expose_slice(s,i);
+ _sv_slider_expose_slice(s,i);
}
-void slider_size_request_slice(Slider *s,GtkRequisition *requisition){
+void _sv_slider_size_request_slice(_sv_slider_t *s,GtkRequisition *requisition){
int maxx=0,x0=0,x1=0,maxy=0,i,w;
// need a dummy surface to find text sizes
@@ -545,12 +545,12 @@
cairo_surface_destroy(dummy);
}
-static double slice_adjust_pixel(Slider *s,int slicenum, double x){
+static double slice_adjust_pixel(_sv_slider_t *s,int slicenum, double x){
double width = slice_width(s,slicenum);
return x+width;
}
-static double quant(Slider *s, double val){
+static double quant(_sv_slider_t *s, double val){
if(s->quant_denom!=0.){
val *= s->quant_denom;
val /= s->quant_num;
@@ -563,7 +563,7 @@
return val;
}
-double slider_pixel_to_val(Slider *s,double x){
+double _sv_slider_pixel_to_val(_sv_slider_t *s,double x){
int tx=s->xpad;
int tw=s->w - tx*2;
double del = (double)(x-tx)/tw;
@@ -571,10 +571,10 @@
return quant(s,s->label_vals[0]);
if(del>=1.)
return quant(s,(s->label_vals[s->labels-1]));
- return slider_del_to_val(s,del);
+ return _sv_slider_del_to_val(s,del);
}
-double slider_pixel_to_del(Slider *s,double x){
+double _sv_slider_pixel_to_del(_sv_slider_t *s,double x){
int tx=s->xpad;
int tw=s->w - tx*2;
x-=tx;
@@ -587,7 +587,7 @@
return x/tw;
}
-double slider_del_to_val(Slider *s, double del){
+double _sv_slider_del_to_val(_sv_slider_t *s, double del){
int base;
if(isnan(del))return del;
@@ -598,9 +598,9 @@
return quant(s,( (1.-del)*s->label_vals[base] + del*s->label_vals[base+1] ));
}
-void slider_vals_bound(Slider *s,int slicenum){
+void _sv_slider_vals_bound(_sv_slider_t *s,int slicenum){
int i,flag=-1;
- Slice *center = SLICE(s->slices[slicenum]);
+ _sv_slice_t *center = SLICE(s->slices[slicenum]);
double min = (s->neg ? s->label_vals[s->labels-1] : s->label_vals[0]);
double max = (s->neg ? s->label_vals[0] : s->label_vals[s->labels-1]);
int flip = (s->neg? 1: 0);
@@ -612,7 +612,7 @@
center->thumb_val = max;
// now make sure other sliders have valid spacing
- if( (s->flags & SLIDER_FLAG_INDEPENDENT_MIDDLE) &&
+ if( (s->flags & _SV_SLIDER_FLAG_INDEPENDENT_MIDDLE) &&
s->num_slices == 3)
flag=1;
@@ -622,10 +622,10 @@
if(i2 == flag)i2++;
if(i2>=s->num_slices)continue;
- Slice *sl = SLICE(s->slices[i]);
- Slice *sl2 = SLICE(s->slices[i2]);
+ _sv_slice_t *sl = SLICE(s->slices[i]);
+ _sv_slice_t *sl2 = SLICE(s->slices[i2]);
if((sl->thumb_val>sl2->thumb_val)^flip)
- slice_thumb_set(sl,sl2->thumb_val);
+ _sv_slice_thumb_set(sl,sl2->thumb_val);
}
for(i=slicenum+1; i<s->num_slices;i++){
@@ -634,22 +634,22 @@
if(i2 == flag)i2--;
if(i2<0)continue;
- Slice *sl = SLICE(s->slices[i]);
- Slice *sl2 = SLICE(s->slices[i2]);
+ _sv_slice_t *sl = SLICE(s->slices[i]);
+ _sv_slice_t *sl2 = SLICE(s->slices[i2]);
if((sl->thumb_val<sl2->thumb_val)^flip)
- slice_thumb_set(sl,sl2->thumb_val);
+ _sv_slice_thumb_set(sl,sl2->thumb_val);
}
}
-static int determine_thumb(Slider *s,int slicenum,int x,int y){
+static int determine_thumb(_sv_slider_t *s,int slicenum,int x,int y){
int i;
int best=-1;
float bestdist=s->w+1;
int n = s->num_slices;
if(s->flip){
- Slice *sl = SLICE(s->slices[slicenum]);
+ _sv_slice_t *sl = SLICE(s->slices[slicenum]);
int temp = x;
x = sl->widget.allocation.height - y -1;
y = temp;
@@ -657,7 +657,7 @@
x=slice_adjust_pixel(s,slicenum,x);
for(i=0;i<n;i++){
- Slice *sl = SLICE(s->slices[i]);
+ _sv_slice_t *sl = SLICE(s->slices[i]);
if(sl->thumb_active){
float tx = val_to_pixel(s,sl->thumb_val) + i - s->num_slices/2;
float ty = ((n==3 && i==1) ? 0:s->h);
@@ -671,31 +671,31 @@
return best;
}
-static int lit_thumb(Slider *s){
+static int lit_thumb(_sv_slider_t *s){
int i;
for(i=0;i<s->num_slices;i++){
- Slice *sl = SLICE(s->slices[i]);
+ _sv_slice_t *sl = SLICE(s->slices[i]);
if(sl->thumb_state)return i;
}
return -1;
}
-void slider_unlight(Slider *s){
+void _sv_slider_unlight(_sv_slider_t *s){
int i;
for(i=0;i<s->num_slices;i++){
- Slice *sl = SLICE(s->slices[i]);
+ _sv_slice_t *sl = SLICE(s->slices[i]);
if(!sl->thumb_grab)
sl->thumb_state = 0;
}
}
-int slider_lightme(Slider *s,int slicenum,int x,int y){
+int _sv_slider_lightme(_sv_slider_t *s,int slicenum,int x,int y){
int last = lit_thumb(s);
int best = determine_thumb(s,slicenum,x,y);
if(last != best){
- slider_unlight(s);
+ _sv_slider_unlight(s);
if(best>-1){
- Slice *sl = SLICE(s->slices[best]);
+ _sv_slice_t *sl = SLICE(s->slices[best]);
sl->thumb_state=1;
}
return 1;
@@ -703,30 +703,30 @@
return 0;
}
-void slider_button_press(Slider *s,int slicenum,int x,int y){
+void _sv_slider_button_press(_sv_slider_t *s,int slicenum,int x,int y){
int i;
for(i=0;i<s->num_slices;i++){
- Slice *sl = SLICE(s->slices[i]);
+ _sv_slice_t *sl = SLICE(s->slices[i]);
if(sl->thumb_state){
sl->thumb_grab=1;
sl->thumb_focus=1;
gtk_widget_grab_focus(GTK_WIDGET(sl));
if(sl->callback)sl->callback(sl->callback_data,0);
- slider_motion(s,slicenum,x,y);
+ _sv_slider_motion(s,slicenum,x,y);
}else{
sl->thumb_grab=0;
sl->thumb_focus=0;
}
}
- slider_draw(s);
- slider_expose(s);
+ _sv_slider_draw(s);
+ _sv_slider_expose(s);
}
-void slider_button_release(Slider *s,int slicenum,int x,int y){
+void _sv_slider_button_release(_sv_slider_t *s,int slicenum,int x,int y){
int i;
for(i=0;i<s->num_slices;i++){
- Slice *sl = SLICE(s->slices[i]);
+ _sv_slice_t *sl = SLICE(s->slices[i]);
if(sl->thumb_grab){
sl->thumb_grab=0;
@@ -735,29 +735,29 @@
}
}
-static void update_gradient(Slider *s){
+static void update_gradient(_sv_slider_t *s){
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);
- double hdel = slider_val_to_del(s,sh->thumb_val);
+ _sv_slice_t *sl = SLICE(s->slices[0]);
+ _sv_slice_t *sh = SLICE(s->slices[s->num_slices-1]);
+ double ldel = _sv_slider_val_to_del(s,sl->thumb_val);
+ double hdel = _sv_slider_val_to_del(s,sh->thumb_val);
if(s->gradient->low != ldel ||
s->gradient->high != hdel){
- mapping_set_lo(s->gradient,ldel);
- mapping_set_hi(s->gradient,hdel);
- slider_draw_background(s);
- slider_draw(s);
+ _sv_mapping_set_lo(s->gradient,ldel);
+ _sv_mapping_set_hi(s->gradient,hdel);
+ _sv_slider_draw_background(s);
+ _sv_slider_draw(s);
}
- slider_expose(s);
+ _sv_slider_expose(s);
}
}
-void slider_motion(Slider *s,int slicenum,int x,int y){
+void _sv_slider_motion(_sv_slider_t *s,int slicenum,int x,int y){
double altered[s->num_slices];
int i, grabflag=0;
- Slice *sl = SLICE(s->slices[slicenum]);
+ _sv_slice_t *sl = SLICE(s->slices[slicenum]);
int px = (s->flip?sl->widget.allocation.height-y-1 : x);
for(i=0;i<s->num_slices;i++){
@@ -770,8 +770,8 @@
sl = SLICE(s->slices[i]);
if(sl->thumb_grab){
sl->thumb_val=
- slider_pixel_to_val(s,slice_adjust_pixel(s,slicenum,px));
- slider_vals_bound(s,i);
+ _sv_slider_pixel_to_val(s,slice_adjust_pixel(s,slicenum,px));
+ _sv_slider_vals_bound(s,i);
grabflag = 1;
}
}
@@ -780,14 +780,14 @@
update_gradient(s);
if(grabflag){
- slider_draw(s);
- slider_expose(s);
+ _sv_slider_draw(s);
+ _sv_slider_expose(s);
// call slice callbacks on all slices that were altered; value
// bounding might have affected slices other than the grabbed one.
for(i=0;i<s->num_slices;i++){
- Slice *sl = SLICE(s->slices[i]);
+ _sv_slice_t *sl = SLICE(s->slices[i]);
if(sl->thumb_val != altered[i])
if(sl->callback)sl->callback(sl->callback_data,1);
@@ -795,15 +795,15 @@
}else{
/* nothing grabbed right now; determine if we're in a thumb's area */
- if(slider_lightme(s,slicenum,x,y)){
- slider_draw(s);
- slider_expose(s);
+ if(_sv_slider_lightme(s,slicenum,x,y)){
+ _sv_slider_draw(s);
+ _sv_slider_expose(s);
}
}
}
-gboolean slider_key_press(Slider *s,GdkEventKey *event,int slicenum){
- Slice *sl = (Slice *)(s->slices[slicenum]);
+gboolean _sv_slider_key_press(_sv_slider_t *s,GdkEventKey *event,int slicenum){
+ _sv_slice_t *sl = (_sv_slice_t *)(s->slices[slicenum]);
int shift = (event->state&GDK_SHIFT_MASK);
if(event->state&GDK_MOD1_MASK) return FALSE;
if(event->state&GDK_CONTROL_MASK)return FALSE;
@@ -814,11 +814,11 @@
{
double x = val_to_pixel(s,sl->thumb_val);
while(sl->thumb_val > s->label_vals[0] &&
- sl->thumb_val == slider_pixel_to_val(s,x))x--;
+ sl->thumb_val == _sv_slider_pixel_to_val(s,x))x--;
if(shift)
x-=9;
- sl->thumb_val=slider_pixel_to_val(s,x);
- slider_vals_bound(s,slicenum);
+ sl->thumb_val=_sv_slider_pixel_to_val(s,x);
+ _sv_slider_vals_bound(s,slicenum);
// did a gradient get altered?
update_gradient(s);
@@ -827,8 +827,8 @@
sl->callback(sl->callback_data,1);
sl->callback(sl->callback_data,2);
}
- slider_draw(s);
- slider_expose(s);
+ _sv_slider_draw(s);
+ _sv_slider_expose(s);
}
return TRUE;
@@ -837,11 +837,11 @@
{
double x = val_to_pixel(s,sl->thumb_val);
while(sl->thumb_val < s->label_vals[s->labels-1] &&
- sl->thumb_val == slider_pixel_to_val(s,x))x++;
+ sl->thumb_val == _sv_slider_pixel_to_val(s,x))x++;
if(shift)
x+=9;
- sl->thumb_val=slider_pixel_to_val(s,x);
- slider_vals_bound(s,slicenum);
+ sl->thumb_val=_sv_slider_pixel_to_val(s,x);
+ _sv_slider_vals_bound(s,slicenum);
// did a gradient get altered?
update_gradient(s);
@@ -850,8 +850,8 @@
sl->callback(sl->callback_data,1);
sl->callback(sl->callback_data,2);
}
- slider_draw(s);
- slider_expose(s);
+ _sv_slider_draw(s);
+ _sv_slider_expose(s);
}
return TRUE;
}
@@ -859,10 +859,10 @@
return FALSE; // keep processing
}
-Slider *slider_new(Slice **slices, int num_slices, char **labels, double *label_vals, int num_labels,
- unsigned flags){
+_sv_slider_t *_sv_slider_new(_sv_slice_t **slices, int num_slices, char **labels, double *label_vals, int num_labels,
+ unsigned flags){
int i;
- Slider *ret = calloc(1,sizeof(*ret));
+ _sv_slider_t *ret = calloc(1,sizeof(*ret));
ret->slices = (GtkWidget **)slices;
ret->num_slices = num_slices;
@@ -891,24 +891,24 @@
ret->neg = 1;
ret->flags=flags;
- if(flags & SLIDER_FLAG_VERTICAL) ret->flip = 1;
+ if(flags & _SV_SLIDER_FLAG_VERTICAL) ret->flip = 1;
return ret;
}
-void slider_set_gradient(Slider *s, mapping *m){
+void _sv_slider_set_gradient(_sv_slider_t *s, _sv_mapping_t *m){
s->gradient = m;
if(s->realized){
- slider_draw_background(s);
- slider_draw(s);
- slider_expose(s);
+ _sv_slider_draw_background(s);
+ _sv_slider_draw(s);
+ _sv_slider_expose(s);
}
}
-void slider_set_thumb_active(Slider *s, int thumbnum, int activep){
- slice_set_active(SLICE(s->slices[thumbnum]),activep);
+void _sv_slider_set_thumb_active(_sv_slider_t *s, int thumbnum, int activep){
+ _sv_slice_set_active(SLICE(s->slices[thumbnum]),activep);
}
-double slider_get_value(Slider *s, int thumbnum){
+double _sv_slider_get_value(_sv_slider_t *s, int thumbnum){
GtkWidget *w;
if(thumbnum >= s->num_slices)return 0;
if(thumbnum < 0)return 0;
@@ -916,25 +916,25 @@
return SLICE(w)->thumb_val;
}
-void slider_set_value(Slider *s, int thumbnum, double v){
+void _sv_slider_set_value(_sv_slider_t *s, int thumbnum, double v){
GtkWidget *w;
if(thumbnum >= s->num_slices)return;
if(thumbnum < 0)return;
w = s->slices[thumbnum];
- slice_thumb_set(SLICE(w),v);
+ _sv_slice_thumb_set(SLICE(w),v);
update_gradient(s);
}
-void slider_set_quant(Slider *s,double num, double denom){
+void _sv_slider_set_quant(_sv_slider_t *s,double num, double denom){
s->quant_num=num;
s->quant_denom=denom;
}
-double slider_print_height(Slider *s){
+double _sv_slider_print_height(_sv_slider_t *s){
return (s->slices[0]->allocation.height - s->ypad*2)*1.2;
}
-void slider_print(Slider *s, cairo_t *c, int w, int h){
+void _sv_slider_print(_sv_slider_t *s, cairo_t *c, int w, int h){
cairo_save(c);
double ypad = h*.1;
double neg = (s->neg? -1.: 1.);
@@ -978,7 +978,7 @@
double lodel = 1. / (s->labels-1) * firstlabel;
double hidel = 1. / (s->labels-1) * lastlabel;
double alphadel = (slices==3 ?
- slider_val_to_del(s,SLICE(s->slices[1])->thumb_val):0.);
+ _sv_slider_val_to_del(s,SLICE(s->slices[1])->thumb_val):0.);
// create background image
{
@@ -1003,11 +1003,11 @@
}
for(y=0;y<h;y++){
- ucolor *line = (ucolor *)cairo_image_surface_get_data(image) + w*y;
+ _sv_ucolor_t *line = (_sv_ucolor_t *)cairo_image_surface_get_data(image) + w*y;
for(x=0;x<w;x++){
double del = (hidel - lodel) / (w-1) * x + lodel;
if(del>=alphadel)
- line[x].u = mapping_calc(s->gradient, del, line[x].u);
+ line[x].u = _sv_mapping_calc(s->gradient, del, line[x].u);
}
}
Modified: trunk/sushivision/slider.h
===================================================================
--- trunk/sushivision/slider.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/slider.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -21,7 +21,7 @@
#include <sys/types.h>
-struct _Slider {
+struct _sv_slider {
GtkWidget **slices;
int num_slices;
int realized;
@@ -32,7 +32,7 @@
cairo_surface_t *foreground;
int w;
int h;
- mapping *gradient;
+ _sv_mapping_t *gradient;
int xpad;
int ypad;
@@ -46,34 +46,33 @@
double quant_denom;
};
-#define SLIDER_FLAG_INDEPENDENT_MIDDLE 0x1
-#define SLIDER_FLAG_VERTICAL 0x80
+#define _SV_SLIDER_FLAG_INDEPENDENT_MIDDLE 0x1
+#define _SV_SLIDER_FLAG_VERTICAL 0x80
-extern void slider_draw_background(Slider *s);
-extern void slider_realize(Slider *s);
-extern void slider_draw(Slider *);
-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,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);
-extern void slider_unlight(Slider *slider);
-extern void slider_button_press(Slider *slider,int slicenum,int x,int y);
-extern void slider_button_release(Slider *s,int slicenum,int x,int y);
-extern void slider_motion(Slider *s,int slicenum,int x,int y);
-extern gboolean slider_key_press(Slider *slider,GdkEventKey *event,int slicenum);
-extern Slider *slider_new(Slice **slices, int num_slices,
+extern void _sv_slider_realize(_sv_slider_t *s);
+extern void _sv_slider_draw(_sv_slider_t *s);
+extern void _sv_slider_expose_slice(_sv_slider_t *s, int slicenum);
+extern void _sv_slider_expose(_sv_slider_t *s);
+extern void _sv_slider_size_request_slice(_sv_slider_t *s,GtkRequisition *requisition);
+extern double _sv_slider_pixel_to_val(_sv_slider_t *slider,double x);
+extern double _sv_slider_pixel_to_del(_sv_slider_t *slider,double x);
+extern double _sv_slider_val_to_del(_sv_slider_t *slider,double v);
+extern void _sv_slider_vals_bound(_sv_slider_t *slider,int slicenum);
+extern int _sv_slider_lightme(_sv_slider_t *slider,int slicenum,int x,int y);
+extern void _sv_slider_unlight(_sv_slider_t *slider);
+extern void _sv_slider_button_press(_sv_slider_t *slider,int slicenum,int x,int y);
+extern void _sv_slider_button_release(_sv_slider_t *s,int slicenum,int x,int y);
+extern void _sv_slider_motion(_sv_slider_t *s,int slicenum,int x,int y);
+extern gboolean _sv_slider_key_press(_sv_slider_t *slider,GdkEventKey *event,int slicenum);
+extern _sv_slider_t *_sv_slider_new(_sv_slice_t **slices, int num_slices,
char **labels, double *label_vals, int num_labels,
unsigned flags);
-extern void slider_set_thumb_active(Slider *s, int thumbnum, int activep);
-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);
-extern void slider_set_quant(Slider *s, double n, double d);
+extern void _sv_slider_set_thumb_active(_sv_slider_t *s, int thumbnum, int activep);
+extern void _sv_slider_set_gradient(_sv_slider_t *s, _sv_mapping_t *m);
+extern double _sv_slider_get_value(_sv_slider_t *s, int thumbnum);
+extern void _sv_slider_set_value(_sv_slider_t *s, int thumbnum, double v);
+extern double _sv_slider_del_to_val(_sv_slider_t *s, double del);
+extern void _sv_slider_set_quant(_sv_slider_t *s, double n, double d);
-extern void slider_print(Slider *s, cairo_t *c, int w, int h);
-extern double slider_print_height(Slider *s);
+extern void _sv_slider_print(_sv_slider_t *s, cairo_t *c, int w, int h);
+extern double _sv_slider_print_height(_sv_slider_t *s);
Modified: trunk/sushivision/spinner.c
===================================================================
--- trunk/sushivision/spinner.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/spinner.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -34,7 +34,7 @@
#define DIA 4
#define SPA 6
-static void spinner_draw(GtkWidget *wg, cairo_surface_t *s,int n){
+static void _sv_spinner_draw(GtkWidget *wg, cairo_surface_t *s,int n){
cairo_t *c = cairo_create(s);
int w = cairo_image_surface_get_width(s);
int h = cairo_image_surface_get_height(s);
@@ -68,17 +68,17 @@
}while(i!=n);
}
-static void spinner_init (Spinner *p){
+static void _sv_spinner_init (_sv_spinner_t *p){
// instance initialization
}
-static void spinner_destroy (GtkObject *object){
+static void _sv_spinner_destroy (GtkObject *object){
int i;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
GtkWidget *widget = GTK_WIDGET(object);
- Spinner *p = SPINNER (widget);
+ _sv_spinner_t *p = SPINNER (widget);
// free local resources
if(p->wc){
cairo_destroy(p->wc);
@@ -93,10 +93,10 @@
}
}
-static gint spinner_expose (GtkWidget *widget,
+static gint _sv_spinner_expose (GtkWidget *widget,
GdkEventExpose *event){
if (GTK_WIDGET_REALIZED (widget)){
- Spinner *sp = SPINNER (widget);
+ _sv_spinner_t *sp = SPINNER (widget);
int frame = (sp->busy?sp->busy_count+1:0);
// blit to window
@@ -110,13 +110,13 @@
return FALSE;
}
-static void spinner_size_request (GtkWidget *widget,
+static void _sv_spinner_size_request (GtkWidget *widget,
GtkRequisition *requisition){
requisition->width = SPA*7 + DIA + 2;
requisition->height = DIA + 2;
}
-static void spinner_realize (GtkWidget *widget){
+static void _sv_spinner_realize (GtkWidget *widget){
GdkWindowAttr attributes;
gint attributes_mask;
@@ -144,9 +144,9 @@
gtk_widget_set_double_buffered (widget, FALSE);
}
-static void spinner_size_allocate (GtkWidget *widget,
+static void _sv_spinner_size_allocate (GtkWidget *widget,
GtkAllocation *allocation){
- Spinner *p = SPINNER (widget);
+ _sv_spinner_t *p = SPINNER (widget);
int i;
if (GTK_WIDGET_REALIZED (widget)){
@@ -171,44 +171,44 @@
p->b[i] = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
allocation->width,
allocation->height);
- spinner_draw(widget, p->b[i],i-1);
+ _sv_spinner_draw(widget, p->b[i],i-1);
}
}
widget->allocation = *allocation;
}
-static void spinner_class_init (SpinnerClass * class) {
+static void _sv_spinner_class_init (_sv_spinner_class_t * class) {
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (GTK_TYPE_WIDGET);
- object_class->destroy = spinner_destroy;
- widget_class->realize = spinner_realize;
- widget_class->expose_event = spinner_expose;
- widget_class->size_request = spinner_size_request;
- widget_class->size_allocate = spinner_size_allocate;
+ object_class->destroy = _sv_spinner_destroy;
+ widget_class->realize = _sv_spinner_realize;
+ widget_class->expose_event = _sv_spinner_expose;
+ widget_class->size_request = _sv_spinner_size_request;
+ widget_class->size_allocate = _sv_spinner_size_allocate;
}
-GType spinner_get_type (void){
+GType _sv_spinner_get_type (void){
static GType spinner_type = 0;
if (!spinner_type)
{
static const GTypeInfo spinner_info = {
- sizeof (SpinnerClass),
+ sizeof (_sv_spinner_class_t),
NULL,
NULL,
- (GClassInitFunc) spinner_class_init,
+ (GClassInitFunc) _sv_spinner_class_init,
NULL,
NULL,
- sizeof (Spinner),
+ sizeof (_sv_spinner_t),
0,
- (GInstanceInitFunc) spinner_init,
+ (GInstanceInitFunc) _sv_spinner_init,
0
};
@@ -219,13 +219,13 @@
return spinner_type;
}
-Spinner *spinner_new (){
+_sv_spinner_t *_sv_spinner_new (){
GtkWidget *g = GTK_WIDGET (g_object_new (SPINNER_TYPE, NULL));
- Spinner *p = SPINNER (g);
+ _sv_spinner_t *p = SPINNER (g);
return p;
}
-void spinner_set_busy(Spinner *p){
+void _sv_spinner_set_busy(_sv_spinner_t *p){
struct timeval now;
int test;
@@ -236,7 +236,7 @@
if(!p->busy){
p->busy=1;
p->last = now;
- spinner_expose(GTK_WIDGET(p),NULL); // do it now
+ _sv_spinner_expose(GTK_WIDGET(p),NULL); // do it now
}else{
test = (now.tv_sec - p->last.tv_sec)*1000 + (now.tv_usec - p->last.tv_usec)/1000;
@@ -247,14 +247,14 @@
if(p->busy_count>7)
p->busy_count=0;
p->last = now;
- spinner_expose(GTK_WIDGET(p),NULL); // do it now
+ _sv_spinner_expose(GTK_WIDGET(p),NULL); // do it now
}
}
}
-void spinner_set_idle(Spinner *p){
+void _sv_spinner_set_idle(_sv_spinner_t *p){
if(!p)return;
p->busy=0;
- spinner_expose(GTK_WIDGET(p),NULL); // do it now
+ _sv_spinner_expose(GTK_WIDGET(p),NULL); // do it now
}
Modified: trunk/sushivision/spinner.h
===================================================================
--- trunk/sushivision/spinner.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/spinner.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -28,16 +28,16 @@
G_BEGIN_DECLS
-#define SPINNER_TYPE (spinner_get_type ())
-#define SPINNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPINNER_TYPE, Spinner))
-#define SPINNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SPINNER_TYPE, SpinnerClass))
+#define SPINNER_TYPE (_sv_spinner_get_type ())
+#define SPINNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPINNER_TYPE, _sv_spinner_t))
+#define SPINNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SPINNER_TYPE, _sv_spinner_class_t))
#define IS_SPINNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPINNER_TYPE))
#define IS_SPINNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPINNER_TYPE))
-typedef struct _Spinner Spinner;
-typedef struct _SpinnerClass SpinnerClass;
+typedef struct _sv_spinner _sv_spinner_t;
+typedef struct _sv_spinner_class _sv_spinner_class_t;
-struct _Spinner{
+struct _sv_spinner{
GtkWidget w;
cairo_t *wc;
cairo_surface_t *b[9];
@@ -47,16 +47,16 @@
struct timeval last;
};
-struct _SpinnerClass{
+struct _sv_spinner_class{
GtkWidgetClass parent_class;
- void (*spinner) (Spinner *m);
+ void (*spinner) (_sv_spinner_t *m);
};
-GType spinner_get_type (void);
-Spinner *spinner_new (void);
+GType _sv_spinner_get_type (void);
+_sv_spinner_t *_sv_spinner_new (void);
G_END_DECLS
// the widget subclass half
-void spinner_set_busy(Spinner *p);
-void spinner_set_idle(Spinner *p);
+void _sv_spinner_set_busy(_sv_spinner_t *p);
+void _sv_spinner_set_idle(_sv_spinner_t *p);
Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/sushivision.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -22,246 +22,288 @@
#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;
-typedef struct sushiv_function sushiv_function_t;
+typedef struct sv_scale sv_scale_t;
+typedef struct sv_panel sv_panel_t;
+typedef struct sv_dim sv_dim_t;
+typedef struct sv_obj sv_obj_t;
+typedef struct sv_func sv_func_t;
+typedef struct _sv_instance_internal sv_instance_internal_t;
+typedef struct _sv_scale_internal sv_scale_internal_t;
+typedef struct _sv_dim_internal sv_dim_internal_t;
+typedef union _sv_dim_subtype sv_dim_subtype_t;
+typedef struct _sv_func_internal sv_func_internal_t;
+typedef union _sv_func_subtype sv_func_subtype_t;
+typedef struct _sv_obj_internal sv_obj_internal_t;
+typedef union _sv_obj_subtype sv_obj_subtype_t;
+typedef struct _sv_panel_internal sv_panel_internal_t;
+typedef union _sv_panel_subtype sv_panel_subtype_t;
-typedef struct sushiv_instance_internal sushiv_instance_internal_t;
+int sv_submain(int argc, char *argv[]);
+int sv_atexit(void);
+int sv_save(char *filename);
+int sv_load(char *filename);
-typedef struct sushiv_instance {
+/* toplevel instances ********************************************/
+
+typedef struct sv_instance {
int number;
char *name;
int functions;
- sushiv_function_t **function_list;
+ sv_func_t **function_list;
int dimensions;
- sushiv_dimension_t **dimension_list;
+ sv_dim_t **dimension_list;
int objectives;
- sushiv_objective_t **objective_list;
+ sv_obj_t **objective_list;
int panels;
- struct sushiv_panel **panel_list;
+ sv_panel_t **panel_list;
- sushiv_instance_internal_t *private;
-} sushiv_instance_t;
+ sv_instance_internal_t *private;
+} sv_instance_t;
-struct sushiv_scale{
+sv_instance_t *sv_new (int number,
+ char *name);
+
+/* scales ********************************************************/
+
+struct sv_scale{
int vals;
double *val_list;
char **label_list;
char *legend;
+
+ sv_scale_internal_t *private;
+ unsigned flags;
};
-#define SUSHIV_DIM_NO_X 0x100
-#define SUSHIV_DIM_NO_Y 0x200
-#define SUSHIV_DIM_ZEROINDEX 0x1
-#define SUSHIV_DIM_MONOTONIC 0x2
+sv_scale_t *sv_scale_new (char *legend,
+ unsigned scalevals,
+ double *scaleval_list,
+ char **scalelabel_list,
+ unsigned flags);
-typedef struct sushiv_dimension_internal sushiv_dimension_internal_t;
-enum sushiv_dimension_type { SUSHIV_DIM_CONTINUOUS,
- SUSHIV_DIM_DISCRETE,
- SUSHIV_DIM_PICKLIST};
-typedef union sushiv_dimension_subtype sushiv_dimension_subtype_t;
+sv_scale_t *sv_scale_copy (sv_scale_t *s);
-struct sushiv_dimension{
+void sv_scale_free (sv_scale_t *s);
+
+/* dimensions ****************************************************/
+
+#define SV_DIM_NO_X 0x100
+#define SV_DIM_NO_Y 0x200
+#define SV_DIM_ZEROINDEX 0x1
+#define SV_DIM_MONOTONIC 0x2
+
+enum sv_dim_type { SV_DIM_CONTINUOUS,
+ SV_DIM_DISCRETE,
+ SV_DIM_PICKLIST};
+
+struct sv_dim{
int number;
char *name;
- enum sushiv_dimension_type type;
+ enum sv_dim_type type;
double bracket[2];
double val;
- sushiv_scale_t *scale;
+ sv_scale_t *scale;
unsigned flags;
- int (*callback)(sushiv_dimension_t *);
- sushiv_instance_t *sushi;
- sushiv_dimension_subtype_t *subtype;
- sushiv_dimension_internal_t *private;
+ int (*callback)(sv_dim_t *);
+ sv_instance_t *sushi;
+ sv_dim_subtype_t *subtype;
+ sv_dim_internal_t *private;
};
-typedef struct sushiv_function_internal sushiv_function_internal_t;
-enum sushiv_function_type { SUSHIV_FUNC_BASIC };
-typedef union sushiv_function_subtype sushiv_function_subtype_t;
+sv_dim_t *sv_dim_new (sv_instance_t *s,
+ int number,
+ char *name,
+ unsigned flags);
-struct sushiv_function {
+int sv_dim_set_scale (sv_dim_t *d,
+ sv_scale_t *scale);
+
+int sv_dim_make_scale (sv_dim_t *d,
+ unsigned scalevals,
+ double *scaleval_list,
+ char **scalelabel_list,
+ unsigned flags);
+
+int sv_dim_set_discrete (sv_dim_t *d,
+ long quant_numerator,
+ long quant_denominator);
+
+int sv_dim_set_picklist (sv_dim_t *d);
+
+int sv_dim_set_value (sv_dim_t *d,
+ int thumb,
+ double val);
+
+int sv_dim_callback_value (sv_dim_t *d,
+ int (*callback)(sv_dim_t *));
+
+/* functions *****************************************************/
+
+enum sv_func_type { SV_FUNC_BASIC };
+
+struct sv_func {
int number;
- enum sushiv_function_type type;
+ enum sv_func_type type;
int inputs;
int outputs;
void (*callback)(double *,double *);
unsigned flags;
- sushiv_instance_t *sushi;
- sushiv_function_subtype_t *subtype;
- sushiv_function_internal_t *private;
+ sv_instance_t *sushi;
+ sv_func_subtype_t *subtype;
+ sv_func_internal_t *private;
};
-typedef struct sushiv_objective_internal sushiv_objective_internal_t;
-enum sushiv_objective_type { SUSHIV_OBJ_BASIC };
-typedef union sushiv_objective_subtype sushiv_objective_subtype_t;
+sv_func_t *sv_func_new (sv_instance_t *s,
+ int number,
+ int out_vals,
+ void (*function)(double *,double *),
+ unsigned flags);
-struct sushiv_objective {
+/* objectives ****************************************************/
+
+enum sv_obj_type { SV_OBJ_BASIC };
+
+struct sv_obj {
int number;
char *name;
- enum sushiv_objective_type type;
+ enum sv_obj_type type;
- sushiv_scale_t *scale;
+ sv_scale_t *scale;
int outputs;
int *function_map;
int *output_map;
char *output_types;
unsigned flags;
- sushiv_instance_t *sushi;
- sushiv_objective_subtype_t *subtype;
- sushiv_objective_internal_t *private;
+ sv_instance_t *sushi;
+ sv_obj_subtype_t *subtype;
+ sv_obj_internal_t *private;
};
-#define SUSHIV_PANEL_LINK_X 0x1
-#define SUSHIV_PANEL_LINK_Y 0x2
-#define SUSHIV_PANEL_FLIP 0x4
+sv_obj_t *sv_obj_new (sv_instance_t *s,
+ int number,
+ char *name,
+ sv_func_t **function_map,
+ int *function_output_map,
+ char *output_type_map,
+ unsigned flags);
-typedef struct sushiv_panel_internal sushiv_panel_internal_t;
-enum sushiv_panel_type { SUSHIV_PANEL_1D,
- SUSHIV_PANEL_2D,
- SUSHIV_PANEL_XY };
-enum sushiv_background { SUSHIV_BG_WHITE,
- SUSHIV_BG_BLACK,
- SUSHIV_BG_CHECKS };
-typedef union sushiv_panel_subtype sushiv_panel_subtype_t;
+sv_obj_t *sv_obj_new_defaults (sv_instance_t *s,
+ int number,
+ char *name,
+ sv_func_t *function,
+ unsigned flags);
+int sv_obj_set_scale (sv_obj_t *d,
+ sv_scale_t *scale);
+
+int sv_obj_make_scale (sv_obj_t *d,
+ unsigned scalevals,
+ double *scaleval_list,
+ char **scalelabel_list,
+ unsigned flags);
+
+/* panels ********************************************************/
+
+enum sv_panel_type { SV_PANEL_1D,
+ SV_PANEL_2D,
+ SV_PANEL_XY };
+enum sv_background { SV_BG_WHITE,
+ SV_BG_BLACK,
+ SV_BG_CHECKS };
+
+#define SV_PANEL_LINK_X 0x1
+#define SV_PANEL_LINK_Y 0x2
+#define SV_PANEL_FLIP 0x4
+
typedef struct {
- sushiv_dimension_t *d;
- sushiv_panel_t *p;
-} sushiv_dimension_list_t;
+ sv_dim_t *d;
+ sv_panel_t *p;
+} sv_dim_list_t;
typedef struct {
- sushiv_objective_t *o;
- sushiv_panel_t *p;
-} sushiv_objective_list_t;
+ sv_obj_t *o;
+ sv_panel_t *p;
+} sv_obj_list_t;
-struct sushiv_panel {
+struct sv_panel {
int number;
char *name;
- enum sushiv_panel_type type;
+ enum sv_panel_type type;
int dimensions;
- sushiv_dimension_list_t *dimension_list;
+ sv_dim_list_t *dimension_list;
int objectives;
- sushiv_objective_list_t *objective_list;
+ sv_obj_list_t *objective_list;
- sushiv_instance_t *sushi;
+ sv_instance_t *sushi;
unsigned flags;
- sushiv_panel_subtype_t *subtype;
- sushiv_panel_internal_t *private;
+ sv_panel_subtype_t *subtype;
+ sv_panel_internal_t *private;
};
-extern sushiv_instance_t *sushiv_new_instance(int number, char *name);
+sv_panel_t *sv_panel_new_1d (sv_instance_t *s,
+ int number,
+ char *name,
+ sv_scale_t *y_scale,
+ sv_obj_t **objectives,
+ sv_dim_t **dimensions,
+ unsigned flags);
-extern void scale_free(sushiv_scale_t *s);
-extern sushiv_scale_t *scale_new(unsigned scalevals,
- double *scaleval_list,
- const char *legend);
-extern int scale_set_scalelabels(sushiv_scale_t *s,
- char **scalelabel_list);
+sv_panel_t *sv_panel_new_xy (sv_instance_t *s,
+ int number,
+ char *name,
+ sv_scale_t *x_scale,
+ sv_scale_t *y_scale,
+ sv_obj_t **objectives,
+ sv_dim_t **dimensions,
+ unsigned flags);
-extern int sushiv_new_dimension(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned scalevals,
- double *scaleval_list,
- int (*callback)(sushiv_dimension_t *),
- unsigned flags);
+sv_panel_t *sv_panel_new_2d (sv_instance_t *s,
+ int number,
+ char *name,
+ sv_obj_t **objectives,
+ sv_dim_t **dimensions,
+ unsigned flags);
-extern int sushiv_new_dimension_discrete(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned scalevals,
- double *scaleval_list,
- int (*callback)(sushiv_dimension_t *),
- long quant_numerator,
- long quant_denominator,
- unsigned flags);
+int sv_panel_link_1d (sv_panel_t *p,
+ sv_panel_t *panel_2d,
+ unsigned flags);
-extern int sushiv_new_dimension_picklist(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned pickvals,
- double *pickval_list,
- char **pickval_labels,
- int (*callback)(sushiv_dimension_t *),
- unsigned flags);
+int sv_panel_callback_recompute (sv_panel_t *p,
+ int (*callback)(sv_panel_t *p));
-extern void sushiv_dimension_set_value(sushiv_instance_t *s,
- int dim_number,
- int thumb,
- double val);
+int sv_panel_set_resample (sv_panel_t *p,
+ int numerator,
+ int denominator);
-extern int sushiv_new_function(sushiv_instance_t *s,
- int number,
- int out_vals,
- void(*callback)(double *,double *),
- unsigned flags);
-
-extern int sushiv_new_objective(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned scalevals,
- double *scaleval_list,
- int *function_map,
- int *function_output_map,
- char *output_type_map,
- unsigned flags);
+int sv_panel_set_background (sv_panel_t *p,
+ enum sv_background bg);
-extern int sushiv_new_panel_2d(sushiv_instance_t *s,
- int number,
- const char *name,
- int *objectives,
- int *dimensions,
- unsigned flags);
+int sv_panel_set_axis (sv_panel_t *p,
+ char axis,
+ sv_dim_t *d);
-extern int sushiv_new_panel_1d(sushiv_instance_t *s,
- int number,
- const char *name,
- sushiv_scale_t *scale,
- int *objectives,
- int *dimensions,
- unsigned flags);
+int sv_panel_get_resample (sv_panel_t *p,
+ int *numerator,
+ int *denominator);
-extern int sushiv_new_panel_1d_linked(sushiv_instance_t *s,
- int number,
- const char *name,
- sushiv_scale_t *scale,
- int *objectives,
- int linkee,
- unsigned flags);
+int sv_panel_get_background (sv_panel_t *p,
+ enum sv_background *bg);
-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);
+int sv_panel_get_axis (sv_panel_t *p,
+ char axis,
+ sv_dim_t **d);
+
-extern int sushiv_panel_oversample(sushiv_instance_t *s,
- int number,
- int numer,
- int denom);
-
-extern int sushiv_panel_background(sushiv_instance_t *s,
- int number,
- enum sushiv_background bg);
-
-extern int sushiv_submain(int argc, char *argv[]);
-extern int sushiv_atexit(void);
-
#endif
Modified: trunk/sushivision/undo.c
===================================================================
--- trunk/sushivision/undo.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/undo.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -28,20 +28,20 @@
/* encapsulates some amount of common undo/redo infrastructure */
-static void update_all_menus(sushiv_instance_t *s){
+static void update_all_menus(sv_instance_t *s){
int i;
if(s->panel_list){
for(i=0;i<s->panels;i++)
if(s->panel_list[i])
- _sushiv_panel_update_menus(s->panel_list[i]);
+ _sv_panel_update_menus(s->panel_list[i]);
}
}
-void _sushiv_undo_suspend(sushiv_instance_t *s){
+void _sv_undo_suspend(sv_instance_t *s){
s->private->undo_suspend++;
}
-void _sushiv_undo_resume(sushiv_instance_t *s){
+void _sv_undo_resume(sv_instance_t *s){
s->private->undo_suspend--;
if(s->private->undo_suspend<0){
fprintf(stderr,"Internal error: undo suspend refcount count < 0\n");
@@ -49,8 +49,8 @@
}
}
-void _sushiv_undo_pop(sushiv_instance_t *s){
- sushiv_instance_undo_t *u;
+void _sv_undo_pop(sv_instance_t *s){
+ _sv_instance_undo_t *u;
int i,j;
if(!s->private->undo_stack)
s->private->undo_stack = calloc(2,sizeof(*s->private->undo_stack));
@@ -66,7 +66,7 @@
if(u->panels){
for(j=0;j<s->panels;j++){
- sushiv_panel_undo_t *pu = u->panels+j;
+ _sv_panel_undo_t *pu = u->panels+j;
if(pu->mappings) free(pu->mappings);
if(pu->scale_vals[0]) free(pu->scale_vals[0]);
if(pu->scale_vals[1]) free(pu->scale_vals[1]);
@@ -88,17 +88,17 @@
u->dim_vals[2] = calloc(s->dimensions,sizeof(**u->dim_vals));
}
-void _sushiv_undo_log(sushiv_instance_t *s){
- sushiv_instance_undo_t *u;
+void _sv_undo_log(sv_instance_t *s){
+ _sv_instance_undo_t *u;
int i,j;
// log into a fresh entry; pop this level and all above it
- _sushiv_undo_pop(s);
+ _sv_undo_pop(s);
u = s->private->undo_stack[s->private->undo_level];
// save dim values
for(i=0;i<s->dimensions;i++){
- sushiv_dimension_t *d = s->dimension_list[i];
+ sv_dim_t *d = s->dimension_list[i];
if(d){
u->dim_vals[0][i] = d->bracket[0];
u->dim_vals[1][i] = d->val;
@@ -109,37 +109,37 @@
// pass off panel population to panels
for(j=0;j<s->panels;j++)
if(s->panel_list[j])
- _sushiv_panel_undo_log(s->panel_list[j], u->panels+j);
+ _sv_panel_undo_log(s->panel_list[j], u->panels+j);
}
-void _sushiv_undo_restore(sushiv_instance_t *s){
+void _sv_undo_restore(sv_instance_t *s){
int i;
- sushiv_instance_undo_t *u = s->private->undo_stack[s->private->undo_level];
+ _sv_instance_undo_t *u = s->private->undo_stack[s->private->undo_level];
// dims
// need to happen first as setting dims can have side effect (like activating crosshairs)
for(i=0;i<s->dimensions;i++){
- sushiv_dimension_t *d = s->dimension_list[i];
+ sv_dim_t *d = s->dimension_list[i];
if(d){
- sushiv_dimension_set_value(s, d->number, 0, u->dim_vals[0][i]);
- sushiv_dimension_set_value(s, d->number, 1, u->dim_vals[1][i]);
- sushiv_dimension_set_value(s, d->number, 2, u->dim_vals[2][i]);
+ sv_dim_set_value(d, 0, u->dim_vals[0][i]);
+ sv_dim_set_value(d, 1, u->dim_vals[1][i]);
+ sv_dim_set_value(d, 2, u->dim_vals[2][i]);
}
}
// panels
for(i=0;i<s->panels;i++){
- sushiv_panel_t *p = s->panel_list[i];
+ sv_panel_t *p = s->panel_list[i];
if(p)
- _sushiv_panel_undo_restore(s->panel_list[i],u->panels+i);
+ _sv_panel_undo_restore(s->panel_list[i],u->panels+i);
}
}
-void _sushiv_undo_push(sushiv_instance_t *s){
+void _sv_undo_push(sv_instance_t *s){
if(s->private->undo_suspend)return;
- _sushiv_undo_log(s);
+ _sv_undo_log(s);
// realloc stack
s->private->undo_stack =
@@ -151,29 +151,29 @@
update_all_menus(s);
}
-void _sushiv_undo_up(sushiv_instance_t *s){
+void _sv_undo_up(sv_instance_t *s){
if(!s->private->undo_stack)return;
if(!s->private->undo_stack[s->private->undo_level])return;
if(!s->private->undo_stack[s->private->undo_level+1])return;
s->private->undo_level++;
- _sushiv_undo_suspend(s);
- _sushiv_undo_restore(s);
- _sushiv_undo_resume(s);
+ _sv_undo_suspend(s);
+ _sv_undo_restore(s);
+ _sv_undo_resume(s);
update_all_menus(s);
}
-void _sushiv_undo_down(sushiv_instance_t *s){
+void _sv_undo_down(sv_instance_t *s){
if(!s->private->undo_stack)return;
if(!s->private->undo_level)return;
if(!s->private->undo_stack[s->private->undo_level+1])
- _sushiv_undo_log(s);
+ _sv_undo_log(s);
s->private->undo_level--;
- _sushiv_undo_suspend(s);
- _sushiv_undo_restore(s);
- _sushiv_undo_resume(s);
+ _sv_undo_suspend(s);
+ _sv_undo_restore(s);
+ _sv_undo_resume(s);
update_all_menus(s);
}
Modified: trunk/sushivision/xml.c
===================================================================
--- trunk/sushivision/xml.c 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/xml.c 2007-03-21 17:33:32 UTC (rev 12786)
@@ -28,7 +28,7 @@
/* a few helpers to make specific libxml2 call patterns more concise */
-xmlNodePtr xmlGetChildSPreserve(xmlNodePtr n, char *name,char *prop, char *val){
+xmlNodePtr _xmlGetChildSPreserve(xmlNodePtr n, char *name,char *prop, char *val){
xmlNodePtr child = (n?n->xmlChildrenNode:NULL);
while(child){
// is this the child we want?
@@ -52,8 +52,8 @@
return NULL;
}
-xmlNodePtr xmlGetChildS(xmlNodePtr n, char *name,char *prop, char *val){
- xmlNodePtr child = (n?xmlGetChildSPreserve(n,name,prop,val):NULL);
+xmlNodePtr _xmlGetChildS(xmlNodePtr n, char *name,char *prop, char *val){
+ xmlNodePtr child = (n?_xmlGetChildSPreserve(n,name,prop,val):NULL);
if(child){
// this is what we want
// remove it from the tree
@@ -63,20 +63,20 @@
return child;
}
-xmlNodePtr xmlGetChildI(xmlNodePtr n, char *name,char *prop, int val){
+xmlNodePtr _xmlGetChildI(xmlNodePtr n, char *name,char *prop, int val){
char buffer[80];
snprintf(buffer,sizeof(buffer),"%d",val);
- return xmlGetChildS(n, name, prop, buffer);
+ return _xmlGetChildS(n, name, prop, buffer);
}
-xmlNodePtr xmlGetChildIPreserve(xmlNodePtr n, char *name,char *prop, int val){
+xmlNodePtr _xmlGetChildIPreserve(xmlNodePtr n, char *name,char *prop, int val){
char buffer[80];
snprintf(buffer,sizeof(buffer),"%d",val);
- return xmlGetChildSPreserve(n, name, prop, buffer);
+ return _xmlGetChildSPreserve(n, name, prop, buffer);
}
-void xmlNewMapProp(xmlNodePtr n, char *name, propmap **map, int val){
- propmap *m = *map++;
+void _xmlNewMapProp(xmlNodePtr n, char *name, _sv_propmap_t **map, int val){
+ _sv_propmap_t *m = *map++;
while(m){
if(m->value == val){
xmlNewProp(n, (xmlChar *)name, (xmlChar *)m->left);
@@ -86,29 +86,29 @@
}
}
-void xmlNewPropF(xmlNodePtr n, char *name, double val){
+void _xmlNewPropF(xmlNodePtr n, char *name, double val){
char buffer[80];
snprintf(buffer,sizeof(buffer),"%.20g",val);
xmlNewProp(n, (xmlChar *) name, (xmlChar *)buffer);
}
-void xmlNewPropI(xmlNodePtr n, char *name, int val){
+void _xmlNewPropI(xmlNodePtr n, char *name, int val){
char buffer[80];
snprintf(buffer,sizeof(buffer),"%d",val);
xmlNewProp(n, (xmlChar *) name, (xmlChar *)buffer);
}
-void xmlNewPropS(xmlNodePtr n, char *name, char *val){
+void _xmlNewPropS(xmlNodePtr n, char *name, char *val){
if(val)
xmlNewProp(n, (xmlChar *) name, (xmlChar *)val);
}
-void xmlGetPropS(xmlNodePtr n, char *name, char **value){
+void _xmlGetPropS(xmlNodePtr n, char *name, char **value){
char *ret = (char *)(n?xmlGetProp(n, (xmlChar *)name):NULL);
if(ret) *value=ret;
}
-void xmlGetPropF(xmlNodePtr n, char *name, double *val){
+void _xmlGetPropF(xmlNodePtr n, char *name, double *val){
xmlChar *v = (n?xmlGetProp(n, (xmlChar *)name):NULL);
if(v){
*val = atof((char *)v);
@@ -116,30 +116,30 @@
}
}
-void xmlCheckPropS(xmlNodePtr n, char *prop, char *val, char *msg, int num, int *warn){
+void _xmlCheckPropS(xmlNodePtr n, char *prop, char *val, char *msg, int num, int *warn){
char *testval = NULL;
- xmlGetPropS(n, prop, &testval);
+ _xmlGetPropS(n, prop, &testval);
if(testval){
if(strcmp(val,testval)){
- first_load_warning(warn);
+ _sv_first_load_warning(warn);
fprintf(stderr,msg, num);
fprintf(stderr,"\n\t(found %s, should be %s).\n", testval, val);
}
xmlFree(testval);
}else{
- first_load_warning(warn);
+ _sv_first_load_warning(warn);
fprintf(stderr,msg, num);
fprintf(stderr,"\n\t(null found, should be %s).\n", val);
}
}
-void xmlCheckMap(xmlNodePtr n, char *prop, propmap **map, int val, char *msg, int num, int *warn){
+void _xmlCheckMap(xmlNodePtr n, char *prop, _sv_propmap_t **map, int val, char *msg, int num, int *warn){
char *name = NULL;
char *testname = NULL;
- xmlGetPropS(n, prop, &testname);
+ _xmlGetPropS(n, prop, &testname);
// look up our desired value
- propmap *m = *map++;
+ _sv_propmap_t *m = *map++;
while(m){
if(m->value == val){
name = m->left;
@@ -151,30 +151,30 @@
if(testname){
if(name){
if(strcmp(name,testname)){
- first_load_warning(warn);
+ _sv_first_load_warning(warn);
fprintf(stderr,msg, num);
fprintf(stderr,"\n\t(found %s, should be %s).\n", testname, name);
}
}else{
- first_load_warning(warn);
+ _sv_first_load_warning(warn);
fprintf(stderr,msg, num);
fprintf(stderr,"\n\t(found %s, should be null).\n", testname);
}
xmlFree(testname);
}else{
if(name){
- first_load_warning(warn);
+ _sv_first_load_warning(warn);
fprintf(stderr,msg, num);
fprintf(stderr,"\n\t(null found, should be %s).\n", name);
}
}
}
-static void xmlGetMapVal(xmlNodePtr n, char *key, propmap **map, int *out){
+static void _xmlGetMapVal(xmlNodePtr n, char *key, _sv_propmap_t **map, int *out){
char *valname = (char *)(n?xmlGetProp(n, (xmlChar *)key):NULL);
if(!valname) return;
- propmap *m = *map++;
+ _sv_propmap_t *m = *map++;
while(m){
if(!strcmp(m->left,valname)){
xmlFree(valname);
@@ -186,11 +186,11 @@
xmlFree(valname);
}
-static void xmlGetChildMap_i(xmlNodePtr in, char *prop, char *key, propmap **map, int *out,
+static void _xmlGetChildMap_i(xmlNodePtr in, char *prop, char *key, _sv_propmap_t **map, int *out,
char *msg, int num, int *warn, int pres){
xmlNodePtr n = (pres ?
- (in?xmlGetChildSPreserve(in, prop, NULL, NULL):NULL):
- (in?xmlGetChildS(in, prop, NULL, NULL):NULL));
+ (in?_xmlGetChildSPreserve(in, prop, NULL, NULL):NULL):
+ (in?_xmlGetChildS(in, prop, NULL, NULL):NULL));
if(!n)return;
char *val = (char *)xmlGetProp(n, (xmlChar *)key);
@@ -200,10 +200,10 @@
}
int ret = -1;
- xmlGetMapVal(n,key,map,&ret);
+ _xmlGetMapVal(n,key,map,&ret);
if(ret == -1){
if(msg){
- first_load_warning(warn);
+ _sv_first_load_warning(warn);
fprintf(stderr,msg,num);
fprintf(stderr," (%s).\n", val);
}
@@ -214,33 +214,33 @@
if(!pres) xmlFreeNode(n);
}
-void xmlGetChildMap(xmlNodePtr in, char *prop, char *key, propmap **map, int *out,
+void _xmlGetChildMap(xmlNodePtr in, char *prop, char *key, _sv_propmap_t **map, int *out,
char *msg, int num, int *warn){
- xmlGetChildMap_i(in, prop, key, map, out, msg, num, warn, 0);
+ _xmlGetChildMap_i(in, prop, key, map, out, msg, num, warn, 0);
}
-void xmlGetChildMapPreserve(xmlNodePtr in, char *prop, char *key, propmap **map, int *out,
+void _xmlGetChildMapPreserve(xmlNodePtr in, char *prop, char *key, _sv_propmap_t **map, int *out,
char *msg, int num, int *warn){
- xmlGetChildMap_i(in, prop, key, map, out, msg, num, warn, 1);
+ _xmlGetChildMap_i(in, prop, key, map, out, msg, num, warn, 1);
}
-void xmlGetChildPropS(xmlNodePtr in, char *prop, char *key, char **out){
- xmlNodePtr n = (in?xmlGetChildS(in, prop, NULL, NULL):NULL);
+void _xmlGetChildPropS(xmlNodePtr in, char *prop, char *key, char **out){
+ xmlNodePtr n = (in?_xmlGetChildS(in, prop, NULL, NULL):NULL);
if(!n)return;
char *val = (char *)xmlGetProp(n, (xmlChar *)key);
xmlFreeNode(n);
if(val) *out = val;
}
-void xmlGetChildPropSPreserve(xmlNodePtr in, char *prop, char *key, char **out){
- xmlNodePtr n = (in?xmlGetChildSPreserve(in, prop, NULL, NULL):NULL);
+void _xmlGetChildPropSPreserve(xmlNodePtr in, char *prop, char *key, char **out){
+ xmlNodePtr n = (in?_xmlGetChildSPreserve(in, prop, NULL, NULL):NULL);
if(!n)return;
char *val = (char *)xmlGetProp(n, (xmlChar *)key);
if(val) *out = val;
}
-void xmlGetChildPropF(xmlNodePtr in, char *prop, char *key, double *out){
- xmlNodePtr n = (in?xmlGetChildS(in, prop, NULL, NULL):NULL);
+void _xmlGetChildPropF(xmlNodePtr in, char *prop, char *key, double *out){
+ xmlNodePtr n = (in?_xmlGetChildS(in, prop, NULL, NULL):NULL);
if(!n)return;
char *val = (char *)xmlGetProp(n, (xmlChar *)key);
xmlFreeNode(n);
@@ -248,16 +248,16 @@
xmlFree(val);
}
-void xmlGetChildPropFPreserve(xmlNodePtr in, char *prop, char *key, double *out){
- xmlNodePtr n = (in?xmlGetChildSPreserve(in, prop, NULL, NULL):NULL);
+void _xmlGetChildPropFPreserve(xmlNodePtr in, char *prop, char *key, double *out){
+ xmlNodePtr n = (in?_xmlGetChildSPreserve(in, prop, NULL, NULL):NULL);
if(!n)return;
char *val = (char *)xmlGetProp(n, (xmlChar *)key);
if(val) *out = atof(val);
xmlFree(val);
}
-void xmlGetChildPropI(xmlNodePtr in, char *prop, char *key, int *out){
- xmlNodePtr n = (in?xmlGetChildS(in, prop, NULL, NULL):NULL);
+void _xmlGetChildPropI(xmlNodePtr in, char *prop, char *key, int *out){
+ xmlNodePtr n = (in?_xmlGetChildS(in, prop, NULL, NULL):NULL);
if(!n)return;
char *val = (char *)xmlGetProp(n, (xmlChar *)key);
xmlFreeNode(n);
@@ -265,8 +265,8 @@
xmlFree(val);
}
-void xmlGetChildPropIPreserve(xmlNodePtr in, char *prop, char *key, int *out){
- xmlNodePtr n = (in?xmlGetChildSPreserve(in, prop, NULL, NULL):NULL);
+void _xmlGetChildPropIPreserve(xmlNodePtr in, char *prop, char *key, int *out){
+ xmlNodePtr n = (in?_xmlGetChildSPreserve(in, prop, NULL, NULL):NULL);
if(!n)return;
char *val = (char *)xmlGetProp(n, (xmlChar *)key);
if(val) *out = atoi(val);
@@ -274,9 +274,9 @@
}
/* convenience helpers for wielding property maps */
-int propmap_pos(propmap **map, int val){
+int _sv_propmap_pos(_sv_propmap_t **map, int val){
int i=0;
- propmap *m = *map++;
+ _sv_propmap_t *m = *map++;
while(m){
if(m->value == val)
return i;
@@ -286,9 +286,9 @@
return 0;
}
-int propmap_last(propmap **map){
+int _sv_propmap_last(_sv_propmap_t **map){
int i=0;
- propmap *m = *map++;
+ _sv_propmap_t *m = *map++;
while(m){
i++;
m = *map++;
@@ -296,9 +296,9 @@
return i-1;
}
-int propmap_label_pos(propmap **map, char *label){
+int _sv_propmap_label_pos(_sv_propmap_t **map, char *label){
int i=0;
- propmap *m = *map++;
+ _sv_propmap_t *m = *map++;
while(m){
if(!strcmp(m->left,label))
return i;
Modified: trunk/sushivision/xml.h
===================================================================
--- trunk/sushivision/xml.h 2007-03-20 23:42:20 UTC (rev 12785)
+++ trunk/sushivision/xml.h 2007-03-21 17:33:32 UTC (rev 12786)
@@ -19,29 +19,29 @@
*
*/
-extern xmlNodePtr xmlGetChildS(xmlNodePtr n, char *name,char *prop, char *val);
-extern xmlNodePtr xmlGetChildI(xmlNodePtr n, char *name,char *prop, int val);
-extern void xmlNewMapProp(xmlNodePtr n, char *name, propmap **map, int val);
-extern void xmlNewPropF(xmlNodePtr n, char *name, double val);
-extern void xmlNewPropI(xmlNodePtr n, char *name, int val);
-extern void xmlNewPropS(xmlNodePtr n, char *name, char *val);
+extern xmlNodePtr _xmlGetChildS(xmlNodePtr n, char *name,char *prop, char *val);
+extern xmlNodePtr _xmlGetChildI(xmlNodePtr n, char *name,char *prop, int val);
+extern void _xmlNewMapProp(xmlNodePtr n, char *name, _sv_propmap_t **map, int val);
+extern void _xmlNewPropF(xmlNodePtr n, char *name, double val);
+extern void _xmlNewPropI(xmlNodePtr n, char *name, int val);
+extern void _xmlNewPropS(xmlNodePtr n, char *name, char *val);
-extern void xmlCheckPropS(xmlNodePtr n, char *prop, char *val, char *msg, int num, int *warn);
-extern void xmlCheckMap(xmlNodePtr n, char *prop, propmap **map, int val, char *msg, int num, int *warn);
+extern void _xmlCheckPropS(xmlNodePtr n, char *prop, char *val, char *msg, int num, int *warn);
+extern void _xmlCheckMap(xmlNodePtr n, char *prop, _sv_propmap_t **map, int val, char *msg, int num, int *warn);
-extern void xmlGetPropS(xmlNodePtr n, char *name, char **out);
-extern void xmlGetPropF(xmlNodePtr n, char *name, double *out);
-extern void xmlGetChildMap(xmlNodePtr in, char *prop, char *key, propmap **map, int *out,
+extern void _xmlGetPropS(xmlNodePtr n, char *name, char **out);
+extern void _xmlGetPropF(xmlNodePtr n, char *name, double *out);
+extern void _xmlGetChildMap(xmlNodePtr in, char *prop, char *key, _sv_propmap_t **map, int *out,
char *msg, int num, int *warn);
-extern void xmlGetChildMapPreserve(xmlNodePtr in, char *prop, char *key, propmap **map, int *out,
+extern void _xmlGetChildMapPreserve(xmlNodePtr in, char *prop, char *key, _sv_propmap_t **map, int *out,
char *msg, int num, int *warn);
-extern void xmlGetChildPropS(xmlNodePtr in, char *prop, char *key, char **out);
-extern void xmlGetChildPropSPreserve(xmlNodePtr in, char *prop, char *key, char **out);
-extern void xmlGetChildPropF(xmlNodePtr in, char *prop, char *key, double *out);
-extern void xmlGetChildPropFPreserve(xmlNodePtr in, char *prop, char *key, double *out);
-extern void xmlGetChildPropI(xmlNodePtr in, char *prop, char *key, int *out);
-extern void xmlGetChildPropIPreserve(xmlNodePtr in, char *prop, char *key, int *out);
+extern void _xmlGetChildPropS(xmlNodePtr in, char *prop, char *key, char **out);
+extern void _xmlGetChildPropSPreserve(xmlNodePtr in, char *prop, char *key, char **out);
+extern void _xmlGetChildPropF(xmlNodePtr in, char *prop, char *key, double *out);
+extern void _xmlGetChildPropFPreserve(xmlNodePtr in, char *prop, char *key, double *out);
+extern void _xmlGetChildPropI(xmlNodePtr in, char *prop, char *key, int *out);
+extern void _xmlGetChildPropIPreserve(xmlNodePtr in, char *prop, char *key, int *out);
-extern int propmap_pos(propmap **map, int val);
-extern int propmap_last(propmap **map);
-extern int propmap_label_pos(propmap **map, char *label);
+extern int _sv_propmap_pos(_sv_propmap_t **map, int val);
+extern int _sv_propmap_last(_sv_propmap_t **map);
+extern int _sv_propmap_label_pos(_sv_propmap_t **map, char *label);
More information about the commits
mailing list