[xiph-commits] r12266 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Sat Dec 30 18:22:12 PST 2006
Author: xiphmont
Date: 2006-12-30 18:22:07 -0800 (Sat, 30 Dec 2006)
New Revision: 12266
Added:
trunk/sushivision/dimension.h
Modified:
trunk/sushivision/dimension.c
trunk/sushivision/example_fractal.c
trunk/sushivision/example_submain.c
trunk/sushivision/internal.h
trunk/sushivision/panel-1d.c
trunk/sushivision/panel-1d.h
trunk/sushivision/panel-2d.c
trunk/sushivision/panel-2d.h
trunk/sushivision/panel.c
trunk/sushivision/slice.c
trunk/sushivision/sushivision.h
Log:
Huge update for somewhat more abstracted dimension handling
Implement new discrete and picklist dimensions
General even path cleanup in several places
Chnaces are, this is as yet *horribly* broken and will be afor at
leats a few hours/days.
Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/dimension.c 2006-12-31 02:22:07 UTC (rev 12266)
@@ -23,8 +23,301 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "internal.h"
+/* modules attempts to encapsulate and hide differences between the
+ different types of dimensions with respect to widgets, iterators,
+ shared dimensions */
+scalespace sushiv_dimension_datascale(sushiv_dimension_t *d, scalespace x){
+ scalespace ret;
+ memset(&ret,0,sizeof(ret));
+
+ switch(d->type){
+ case SUSHIV_DIM_CONTINUOUS:
+ ret = x;
+ break;
+ case SUSHIV_DIM_DISCRETE:
+ {
+ /* return a scale that when iterated will only hit values
+ quantized to the discrete base */
+
+ int lo_i = floor(x.lo * d->private->discrete_denominator /
+ d->private->discrete_numerator);
+ int hi_i = ceil(x.hi * d->private->discrete_denominator /
+ d->private->discrete_numerator);
+
+ double lo = lo_i * d->private->discrete_numerator /
+ d->private->discrete_denominator;
+ double hi = hi_i * d->private->discrete_numerator /
+ d->private->discrete_denominator;
+
+ ret = scalespace_linear(lo, hi, hi_i-lo_i+1, 1, x.legend);
+ }
+ break;
+ case SUSHIV_DIM_PICKLIST:
+ fprintf(stderr,"ERROR: Cannot iterate over picklist dimensions!\n"
+ "\tA picklist dimension may not be a panel axis.\n");
+ break;
+ default:
+ fprintf(stderr,"ERROR: Unsupporrted dimension type in dimension_datascale.\n");
+ break;
+ }
+ return ret;
+}
+
+/* takes the data scale, not the panel plot scale */
+int sushiv_dimension_data_width(sushiv_dimension_t *d, scalespace *datascale){
+ return datascale->pixels;
+}
+
+static void sushiv_dimension_center_callback(void *data, int buttonstate){
+ gdk_threads_enter();
+
+ sushiv_dim_widget_t *dw = (sushiv_dim_widget_t *)data;
+
+ if(!dw->center_updating){
+ sushiv_dimension_t *d = dw->dl->d;
+ sushiv_panel_t *p = dw->dl->p;
+ double val = slider_get_value(dw->scale,1);
+
+ dw->center_updating = 1;
+
+ if(buttonstate == 0){
+ _sushiv_panel_undo_push(p);
+ _sushiv_panel_undo_suspend(p);
+ }
+
+ if(d->val != val){
+ int i;
+
+ d->val = val;
+
+ /* 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];
+ if(w->scale) // all shared widgets had better have scales, but bulletproof in case
+ 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];
+ w->center_callback(dw->dl);
+ }
+ }
+
+ if(buttonstate == 2)
+ _sushiv_panel_undo_resume(p);
+
+ dw->center_updating = 0;
+ }
+ gdk_threads_leave();
+}
+
+static void sushiv_dimension_bracket_callback(void *data, int buttonstate){
+ gdk_threads_enter();
+
+ sushiv_dim_widget_t *dw = (sushiv_dim_widget_t *)data;
+
+ if(!dw->bracket_updating){
+ 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);
+
+ dw->bracket_updating = 1;
+
+ if(buttonstate == 0){
+ _sushiv_panel_undo_push(p);
+ _sushiv_panel_undo_suspend(p);
+ }
+
+ if(d->bracket[0] != lo || d->bracket[1] != hi){
+ int i;
+
+ d->bracket[0] = lo;
+ d->bracket[1] = hi;
+
+ /* 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];
+ 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);
+ }
+ }
+
+ /* 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];
+ w->bracket_callback(dw->dl);
+ }
+ }
+
+ if(buttonstate == 2)
+ _sushiv_panel_undo_resume(p);
+
+ dw->bracket_updating = 0;
+ }
+ gdk_threads_leave();
+}
+
+static void sushiv_dimension_dropdown_callback(void *data){
+ gdk_threads_enter();
+
+ sushiv_dim_widget_t *dw = (sushiv_dim_widget_t *)data;
+
+ if(!dw->center_updating){
+ sushiv_dimension_t *d = dw->dl->d;
+ sushiv_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];
+
+ dw->center_updating = 1;
+
+ _sushiv_panel_undo_push(p);
+ _sushiv_panel_undo_suspend(p);
+
+ if(d->val != val){
+ int i;
+
+ d->val = val;
+ d->bracket[0] = val;
+ d->bracket[1] = val;
+
+ /* 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];
+ 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];
+ w->center_callback(dw->dl);
+ }
+ }
+ _sushiv_panel_undo_resume(p);
+
+ dw->center_updating = 0;
+ }
+ 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;
+
+ switch(d->type){
+ case SUSHIV_DIM_CONTINUOUS:
+ case SUSHIV_DIM_DISCRETE:
+ slider_set_value(dw->scale,thumb,val);
+ break;
+ case SUSHIV_DIM_PICKLIST:
+ /* find the picklist val closest to matching requested val */
+ if(thumb == 1){
+ int best=-1;
+ double besterr=0;
+ int i;
+
+ for(i=0;i<d->scale->vals;i++){
+ double err = fabs(val - d->scale->val_list[i]);
+ if( best == -1 || err < besterr){
+ best = i;
+ besterr = err;
+ }
+ }
+
+ if(best > -1)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dw->menu),best);
+ }
+ break;
+ default:
+ fprintf(stderr,"ERROR: Unsupporrted dimension type in dimension_set_value.\n");
+ break;
+ }
+}
+
+void sushiv_dim_widget_set_thumb_active(sushiv_dim_widget_t *dw, int thumb, int active){
+ if(dw->scale)
+ slider_set_thumb_active(dw->scale,thumb,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 *)){
+
+ sushiv_dim_widget_t *dw = calloc(1, sizeof(*dw));
+ sushiv_dimension_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:
+ /* Continuous and discrete dimensions get sliders */
+ {
+ GtkWidget **sl = calloc(3,sizeof(*sl));
+ dw->t = GTK_TABLE(gtk_table_new(1,3,0));
+
+ 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);
+
+ gtk_table_attach(dw->t,sl[0],0,1,0,1,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+ gtk_table_attach(dw->t,sl[1],1,2,0,1,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+ gtk_table_attach(dw->t,sl[2],2,3,0,1,
+ 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);
+
+ slice_thumb_set((Slice *)sl[0],d->scale->val_list[0]);
+ slice_thumb_set((Slice *)sl[1],0);
+ slice_thumb_set((Slice *)sl[2],d->scale->val_list[d->scale->vals-1]);
+ }
+ break;
+ case SUSHIV_DIM_PICKLIST:
+ /* picklist dimensions get a wide dropdown */
+ dw->t = GTK_TABLE(gtk_table_new(1,1,0));
+
+ {
+ int j;
+ 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]);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dw->menu),0);
+ g_signal_connect (G_OBJECT (dw->menu), "changed",
+ G_CALLBACK (sushiv_dimension_dropdown_callback), dw);
+
+ gtk_table_attach(dw->t,dw->menu,0,1,0,1,
+ GTK_EXPAND|GTK_FILL,GTK_SHRINK,5,0);
+ }
+ break;
+ default:
+ fprintf(stderr,"ERROR: Unsupporrted dimension type in new_dimension_widget.\n");
+ break;
+ }
+
+ /* add widget to dimension */
+ if(!d->private->widget_list){
+ d->private->widget_list = calloc (1, sizeof(*d->private->widget_list));
+ }else{
+ d->private->widget_list = realloc (d->private->widget_list,
+ d->private->widgets+1 * sizeof(*d->private->widget_list));
+ }
+ d->private->widget_list[d->private->widgets] = dw;
+ d->private->widgets++;
+
+ return dw;
+};
+
int sushiv_new_dimension(sushiv_instance_t *s,
int number,
const char *name,
@@ -61,5 +354,59 @@
d->sushi = s;
d->callback = callback;
d->scale = scale_new(scalevals, scaleval_list, name);
+ d->type = SUSHIV_DIM_CONTINUOUS;
+ d->private = calloc(1, sizeof(*d->private));
+
return 0;
}
+
+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){
+
+ /* template is a normal continuous dim */
+ sushiv_dimension_t *d;
+ int ret=sushiv_new_dimension(s,number,name,scalevals,scaleval_list,callback,flags);
+
+ if(ret)return ret;
+
+ d = s->dimension_list[number];
+
+ 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){
+
+ /* template is a normal continuous dim */
+ sushiv_dimension_t *d;
+ int ret=sushiv_new_dimension(s,number,name,pickvals,pickval_list,callback,flags);
+
+ if(ret)return ret;
+
+ d = s->dimension_list[number];
+
+ scale_set_scalelabels(d->scale, pickval_labels);
+ d->flags |= SUSHIV_DIM_NO_X;
+ d->flags |= SUSHIV_DIM_NO_Y;
+ d->type = SUSHIV_DIM_PICKLIST;
+
+ return 0;
+
+}
Added: trunk/sushivision/dimension.h
===================================================================
--- trunk/sushivision/dimension.h 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/dimension.h 2006-12-31 02:22:07 UTC (rev 12266)
@@ -0,0 +1,60 @@
+/*
+ *
+ * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ *
+ * sushivision is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * sushivision is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sushivision; see the file COPYING. If not, write to the
+ * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ */
+
+
+typedef struct {
+ sushiv_dimension_list_t *dl;
+ GtkTable *t;
+
+ /* one or the other */
+ Slider *scale;
+ GtkWidget *menu;
+
+ /* don't rely on intuited state; that could be fragile. If we don't
+ want updates to recurse, be explicit about it! */
+ int center_updating;
+ int bracket_updating;
+
+ /* calls with the callback data and a state flag:
+ 0: begin set
+ 1: continue set
+ 2: end set
+ 3: programmatic modification
+ */
+ void (*center_callback)(sushiv_dimension_list_t *);
+ void (*bracket_callback)(sushiv_dimension_list_t *);
+} sushiv_dim_widget_t;
+
+struct sushiv_dimension_internal {
+ long discrete_numerator;
+ long discrete_denominator;
+
+ int widgets;
+ sushiv_dim_widget_t **widget_list;
+};
+
+extern scalespace sushiv_dimension_datascale(sushiv_dimension_t *d, scalespace x);
+extern int sushiv_dimension_data_width(sushiv_dimension_t *d, scalespace *datascale);
+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 *));
Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/example_fractal.c 2006-12-31 02:22:07 UTC (rev 12266)
@@ -78,7 +78,7 @@
sushiv_new_panel_1d_linked(s,2,"Y Slice",s->objective_list[0]->scale,
(int []){0,-1},
- 0,SUSHIV_LINK_Y | SUSHIV_FLIP);
+ 0,SUSHIV_PANEL_LINK_Y | SUSHIV_PANEL_FLIP);
return 0;
}
Modified: trunk/sushivision/example_submain.c
===================================================================
--- trunk/sushivision/example_submain.c 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/example_submain.c 2006-12-31 02:22:07 UTC (rev 12266)
@@ -88,11 +88,11 @@
sushiv_new_dimension(s,0,"time",
4,(double []){0,1024,2048,4096},
time_callback,
- SUSHIV_NO_X|SUSHIV_NO_Y);
+ SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y);
sushiv_new_dimension(s,1,"blocksize",
8,(double []){64,128,256,512,1024,2048,4096,8192},
blocksize_callback,
- SUSHIV_NO_X|SUSHIV_NO_Y);
+ SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y);
sushiv_new_dimension(s,2,"amplitude",
9,(double []){-96,-84,-72,-60,-48,-36,-24,-12,0},
Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/internal.h 2006-12-31 02:22:07 UTC (rev 12266)
@@ -26,10 +26,11 @@
#include "slice.h"
#include "slider.h"
#include "scale.h"
-#include "panel-1d.h"
-#include "panel-2d.h"
#include "gtksucks.h"
#include "plot.h"
+#include "dimension.h"
+#include "panel-1d.h"
+#include "panel-2d.h"
union sushiv_panel_subtype {
sushiv_panel1d_t *p1;
@@ -58,7 +59,7 @@
struct sushiv_panel_internal {
GtkWidget *toplevel;
GtkWidget *graph;
- Slider **dim_scales;
+ sushiv_dim_widget_t **dim_scales;
int realized;
int maps_dirty;
@@ -106,11 +107,6 @@
extern void _sushiv_panel_undo_up(sushiv_panel_t *p);
extern void _sushiv_panel_undo_down(sushiv_panel_t *p);
-extern void _sushiv_panel_update_shared_bracket(sushiv_dimension_t *d,
- double lo, double hi);
-extern void _sushiv_panel_update_shared_dimension(sushiv_dimension_t *d,
- double val);
-
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);
Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/panel-1d.c 2006-12-31 02:22:07 UTC (rev 12266)
@@ -336,12 +336,12 @@
if(p1->dim_xb[i] &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p1->dim_xb[i]))){
// make all thumbs visible
- slider_set_thumb_active(p->private->dim_scales[i],0,1);
- slider_set_thumb_active(p->private->dim_scales[i],2,1);
+ 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);
}else{
// make bracket thumbs invisible */
- slider_set_thumb_active(p->private->dim_scales[i],0,0);
- slider_set_thumb_active(p->private->dim_scales[i],2,0);
+ 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);
}
}
}
@@ -407,28 +407,32 @@
}
if(plot && GTK_WIDGET_REALIZED(GTK_WIDGET(plot))){
-
p1->x = scalespace_linear(p1->x_d->bracket[0],
- p1->x_d->bracket[1],
- (p1->flip?h:w),
- PLOT(p->private->graph)->scalespacing,
- p1->x_d->name);
+ p1->x_d->bracket[1],
+ (p1->flip?h:w),
+ PLOT(p->private->graph)->scalespacing,
+ p1->x_d->name);
+
p1->y = scalespace_linear(p1->range_bracket[0],
- p1->range_bracket[1],
- (p1->flip?w:h),
- PLOT(p->private->graph)->scalespacing,
- p1->range_scale->legend);
+ p1->range_bracket[1],
+ (p1->flip?w:h),
+ PLOT(p->private->graph)->scalespacing,
+ p1->range_scale->legend);
+
+ // handle the possibility that our data scale is from a link.
// 2d panels do not necessarily update their scales until
// recompute time, and 1d panels may be recomputed first,
// thus duplicate the scale computaiton here
p1->vs = scalespace_linear(p1->x_d->bracket[0],
- p1->x_d->bracket[1],
- dw,
- PLOT(p->private->graph)->scalespacing,
- p1->x_d->name);
+ p1->x_d->bracket[1],
+ dw,
+ PLOT(p->private->graph)->scalespacing,
+ p1->x_d->name);
+
+ // the data iterator may need to be mapped to the dimension type
+ p1->vs = sushiv_dimension_datascale(p1->x_d, p1->vs);
-
if(p1->data_size != dw){
if(p1->data_vec){
@@ -506,13 +510,13 @@
for(i=0;i<link->dimensions;i++){
sushiv_dimension_t *d = link->dimension_list[i].d;
if(d == p1->x_d)
- x = slider_get_value(link->private->dim_scales[i],1);
+ x = link->private->dim_scales[i]->dl->d->val;
}
}else{
for(i=0;i<p->dimensions;i++){
sushiv_dimension_t *d = p->dimension_list[i].d;
if(d == p1->x_d)
- x = slider_get_value(p->private->dim_scales[i],1);
+ x = p->private->dim_scales[i]->dl->d->val;
}
}
@@ -565,24 +569,12 @@
}
}
-static void dim_callback_1d(void *in, int buttonstate){
- sushiv_dimension_list_t *dptr = (sushiv_dimension_list_t *)in;
+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;
- //Plot *plot = PLOT(p->private->graph);
- int dnum = dptr - p->dimension_list;
int axisp = (d == p1->x_d);
- double val = slider_get_value(p->private->dim_scales[dnum],1);
- int recursep = (val != d->val);
- if(buttonstate == 0){
- _sushiv_panel_undo_push(p);
- _sushiv_panel_undo_suspend(p);
- }
-
- d->val = slider_get_value(p->private->dim_scales[dnum],1);
-
if(!axisp){
// mid slider of a non-axis dimension changed, rerender
_mark_recompute_1d(p);
@@ -590,64 +582,19 @@
// mid slider of an axis dimension changed, move crosshairs
update_crosshair(p);
}
-
- /* dims can be shared amongst multiple panels; all must be updated */
- if(recursep)
- _sushiv_panel_update_shared_dimension(d,val);
-
- if(buttonstate == 2)
- _sushiv_panel_undo_resume(p);
}
-static void bracket_callback_1d(void *in, int buttonstate){
- sushiv_dimension_list_t *dptr = (sushiv_dimension_list_t *)in;
+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;
- int dnum = dptr - p->dimension_list;
- double lo = slider_get_value(p->private->dim_scales[dnum],0);
- double hi = slider_get_value(p->private->dim_scales[dnum],2);
int axisp = d == p1->x_d;
-
- if(buttonstate == 0){
- _sushiv_panel_undo_push(p);
- _sushiv_panel_undo_suspend(p);
- }
-
- if(d->bracket[0] != lo || d->bracket[1] != hi){
-
- d->bracket[0] = lo;
- d->bracket[1] = hi;
- if(axisp){
- scalespace s = scalespace_linear(lo,hi,p1->data_size,
- PLOT(p->private->graph)->scalespacing,
- d->name);
-
- if(s.m == 0){
- fprintf(stderr,"X scale underflow; cannot zoom further.\n");
-
- // abort attempt
- if(buttonstate == 2)
- _sushiv_panel_undo_resume(p);
- return;
-
- }
-
- _mark_recompute_1d(p);
+ if(axisp)
+ _mark_recompute_1d(p);
- }
-
- _sushiv_panel_update_shared_bracket(d,lo,hi);
-
- }
-
- if(buttonstate == 2)
- _sushiv_panel_undo_resume(p);
}
-
-
static void dimchange_callback_1d(GtkWidget *button,gpointer in){
sushiv_panel_t *p = (sushiv_panel_t *)in;
@@ -679,14 +626,14 @@
if(p1->link_x){
// make it the master panel's problem.
plot_set_crosshairs_snap(PLOT(link->private->graph),
- x,
- PLOT(link->private->graph)->sely);
+ 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),
- PLOT(link->private->graph)->selx,
- x);
+ PLOT(link->private->graph)->selx,
+ x);
link->private->crosshair_action(link);
}else{
@@ -696,14 +643,9 @@
for(i=0;i<p->dimensions;i++){
sushiv_dimension_t *d = p->dimension_list[i].d;
sushiv_panel1d_t *p1 = p->subtype->p1;
- if(d == p1->x_d){
- slider_set_value(p->private->dim_scales[i],1,x);
-
- // key bindings could move crosshairs out of the window; we
- // stretch in that case, which requires a recompute.
- bracket_callback_1d(p->dimension_list+i,1);
- }
-
+ if(d == p1->x_d)
+ sushiv_dimension_set_value(p->private->dim_scales[i],1,x);
+
p1->oldbox_active = 0;
}
_sushiv_panel_undo_resume(p);
@@ -727,8 +669,8 @@
crosshair_callback(p);
- slider_set_value(p1->x_scale,0,p1->oldbox[0]);
- slider_set_value(p1->x_scale,2,p1->oldbox[1]);
+ sushiv_dimension_set_value(p1->x_scale,0,p1->oldbox[0]);
+ sushiv_dimension_set_value(p1->x_scale,2,p1->oldbox[1]);
p1->oldbox_active = 0;
_sushiv_panel_undo_resume(p);
break;
@@ -860,9 +802,9 @@
}
for(i=0;i<p->dimensions;i++){
- u->dim_vals[0][i] = slider_get_value(p->private->dim_scales[i],0);
- u->dim_vals[1][i] = slider_get_value(p->private->dim_scales[i],1);
- u->dim_vals[2][i] = slider_get_value(p->private->dim_scales[i],2);
+ u->dim_vals[0][i] = p->private->dim_scales[i]->dl->d->bracket[0];
+ u->dim_vals[1][i] = p->private->dim_scales[i]->dl->d->val;
+ u->dim_vals[2][i] = p->private->dim_scales[i]->dl->d->bracket[1];
}
u->x_d = p1->x_dnum;
@@ -901,9 +843,9 @@
}
for(i=0;i<p->dimensions;i++){
- slider_set_value(p->private->dim_scales[i],0,u->dim_vals[0][i]);
- slider_set_value(p->private->dim_scales[i],1,u->dim_vals[1][i]);
- slider_set_value(p->private->dim_scales[i],2,u->dim_vals[2][i]);
+ sushiv_dimension_set_value(p->private->dim_scales[i],0,u->dim_vals[0][i]);
+ sushiv_dimension_set_value(p->private->dim_scales[i],1,u->dim_vals[1][i]);
+ sushiv_dimension_set_value(p->private->dim_scales[i],2,u->dim_vals[2][i]);
}
if(p1->dim_xb && u->x_d<p->dimensions && p1->dim_xb[u->x_d]){
@@ -1145,7 +1087,7 @@
gtk_table_attach(GTK_TABLE(p1->top_table),p1->obj_table,0,4,2,3,
GTK_EXPAND|GTK_FILL,0,0,5);
- p1->dim_table = gtk_table_new(p->dimensions,4,0);
+ p1->dim_table = gtk_table_new(p->dimensions,3,0);
gtk_table_attach(GTK_TABLE(p1->top_table),p1->dim_table,0,4,3,4,
GTK_EXPAND|GTK_FILL,0,0,5);
@@ -1248,7 +1190,6 @@
GtkWidget *first_x = NULL;
for(i=0;i<p->dimensions;i++){
- GtkWidget **sl = calloc(3,sizeof(*sl));
sushiv_dimension_t *d = p->dimension_list[i].d;
/* label */
@@ -1257,7 +1198,7 @@
0,0,10,0);
/* x radio buttons */
- if(!(d->flags & SUSHIV_NO_X) && !p1->link_x && !p1->link_y){
+ if(!(d->flags & SUSHIV_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{
@@ -1267,25 +1208,15 @@
gtk_table_attach(GTK_TABLE(p1->dim_table),p1->dim_xb[i],1,2,i,i+1,
0,0,10,0);
}
-
- /* the dimension slices/slider */
- sl[0] = slice_new(bracket_callback_1d,p->dimension_list+i);
- sl[1] = slice_new(dim_callback_1d,p->dimension_list+i);
- sl[2] = slice_new(bracket_callback_1d,p->dimension_list+i);
- gtk_table_attach(GTK_TABLE(p1->dim_table),sl[0],2,3,i,i+1,
+ p->private->dim_scales[i] =
+ sushiv_new_dimension_widget(p->dimension_list+i,center_callback_1d,bracket_callback_1d);
+
+ gtk_table_attach(GTK_TABLE(p1->dim_table),
+ GTK_WIDGET(p->private->dim_scales[i]->t),
+ 2,3,i,i+1,
GTK_EXPAND|GTK_FILL,0,0,0);
- gtk_table_attach(GTK_TABLE(p1->dim_table),sl[1],3,4,i,i+1,
- GTK_EXPAND|GTK_FILL,0,0,0);
- gtk_table_attach(GTK_TABLE(p1->dim_table),sl[2],4,5,i,i+1,
- GTK_EXPAND|GTK_FILL,0,0,0);
- p->private->dim_scales[i] = slider_new((Slice **)sl,3,d->scale->label_list,d->scale->val_list,
- d->scale->vals,0);
-
- slice_thumb_set((Slice *)sl[0],d->scale->val_list[0]);
- slice_thumb_set((Slice *)sl[1],0);
- slice_thumb_set((Slice *)sl[2],d->scale->val_list[d->scale->vals-1]);
}
for(i=0;i<p->dimensions;i++)
@@ -1353,12 +1284,12 @@
p1->range_scale = scale;
- if(flags && SUSHIV_LINK_Y)
+ if(flags && SUSHIV_PANEL_LINK_Y)
p1->link_y = p2;
else
p1->link_x = p2;
- if(p->flags && SUSHIV_FLIP)
+ if(p->flags && SUSHIV_PANEL_FLIP)
p1->flip=1;
p->private->realize = _sushiv_realize_panel1d;
Modified: trunk/sushivision/panel-1d.h
===================================================================
--- trunk/sushivision/panel-1d.h 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/panel-1d.h 2006-12-31 02:22:07 UTC (rev 12266)
@@ -57,7 +57,7 @@
GtkWidget **dim_xb;
sushiv_dimension_t *x_d;
- Slider *x_scale;
+ sushiv_dim_widget_t *x_scale;
int x_dnum; // number of dimension within panel, not global instance
int last_line;
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/panel-2d.c 2006-12-31 02:22:07 UTC (rev 12266)
@@ -238,12 +238,6 @@
p2->x_d = p->dimension_list[i].d;
p2->x_scale = p->private->dim_scales[i];
p2->x_dnum = i;
- // set panel x scale to this dim
- p2->x = scalespace_linear(p2->x_d->bracket[0],
- p2->x_d->bracket[1],
- p2->data_w,
- PLOT(p->private->graph)->scalespacing,
- p2->x_d->name);
}else{
// if there is a y, make it sensitive
if(p2->dim_yb[i])
@@ -259,12 +253,6 @@
p2->y_d = p->dimension_list[i].d;
p2->y_scale = p->private->dim_scales[i];
p2->y_dnum = i;
- // set panel y scale to this dim
- p2->y = scalespace_linear(p2->y_d->bracket[0],
- p2->y_d->bracket[1],
- p2->data_h,
- PLOT(p->private->graph)->scalespacing,
- p2->y_d->name);
}else{
// if there is a x, make it sensitive
if(p2->dim_xb[i])
@@ -275,12 +263,12 @@
(p2->dim_yb[i] &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p2->dim_yb[i])))){
// make all thumbs visible
- slider_set_thumb_active(p->private->dim_scales[i],0,1);
- slider_set_thumb_active(p->private->dim_scales[i],2,1);
+ 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);
}else{
// make bracket thumbs invisible */
- slider_set_thumb_active(p->private->dim_scales[i],0,0);
- slider_set_thumb_active(p->private->dim_scales[i],2,0);
+ 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);
}
}
}
@@ -557,11 +545,7 @@
p2->data_h = h;
_sushiv_panel2d_map_redraw(p);
}
- }
-
- if(!p2->data_rect){
- int i,j;
- // allocate it
+ }else{
p2->data_w = w;
p2->data_h = h;
p2->x = scalespace_linear(p2->x_d->bracket[0],
@@ -569,11 +553,18 @@
w,
PLOT(p->private->graph)->scalespacing,
p2->x_d->name);
+
p2->y = scalespace_linear(p2->y_d->bracket[0],
p2->y_d->bracket[1],
h,
PLOT(p->private->graph)->scalespacing,
p2->y_d->name);
+ }
+
+ if(!p2->data_rect){
+ int i,j;
+ // allocate it
+
p2->data_rect = calloc(p->objectives,sizeof(*p2->data_rect));
for(i=0;i<p->objectives;i++)
p2->data_rect[i] = malloc(p2->data_w * p2->data_h* sizeof(**p2->data_rect));
@@ -584,7 +575,7 @@
p2->data_rect[i][j]=NAN;
_sushiv_panel2d_map_redraw(p);
}
-
+
p2->serialno++;
p2->last_line = 0;
@@ -606,9 +597,9 @@
for(i=0;i<p->dimensions;i++){
sushiv_dimension_t *d = p->dimension_list[i].d;
if(d == p2->x_d)
- x = slider_get_value(p->private->dim_scales[i],1);
+ x = p->private->dim_scales[i]->dl->d->val;
if(d == p2->y_d)
- y = slider_get_value(p->private->dim_scales[i],1);
+ y = p->private->dim_scales[i]->dl->d->val;
}
@@ -616,24 +607,13 @@
update_legend(p);
}
-static void dim_callback_2d(void *in, int buttonstate){
- sushiv_dimension_list_t *dptr = (sushiv_dimension_list_t *)in;
+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);
- int dnum = dptr - p->dimension_list;
int axisp = (d == p2->x_d || d == p2->y_d);
- double val = slider_get_value(p->private->dim_scales[dnum],1);
- int recursep = (val != d->val);
- if(buttonstate == 0){
- _sushiv_panel_undo_push(p);
- _sushiv_panel_undo_suspend(p);
- }
-
- d->val = slider_get_value(p->private->dim_scales[dnum],1);
-
if(!axisp){
// mid slider of a non-axis dimension changed, rerender
_mark_recompute_2d(p);
@@ -642,65 +622,17 @@
update_crosshairs(p);
_sushiv_panel1d_update_linked_crosshairs(p,d==p2->x_d,d==p2->y_d);
}
-
- /* dims can be shared amongst multiple panels; all must be updated */
- if(recursep)
- _sushiv_panel_update_shared_dimension(d,val);
-
- if(buttonstate == 2)
- _sushiv_panel_undo_resume(p);
}
-static void bracket_callback_2d(void *in, int buttonstate){
- sushiv_dimension_list_t *dptr = (sushiv_dimension_list_t *)in;
+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;
- int dnum = dptr - p->dimension_list;
- double lo = slider_get_value(p->private->dim_scales[dnum],0);
- double hi = slider_get_value(p->private->dim_scales[dnum],2);
int axisp = (d == p2->x_d || d == p2->y_d);
- if(buttonstate == 0){
- _sushiv_panel_undo_push(p);
- _sushiv_panel_undo_suspend(p);
- }
-
- if(d->bracket[0] != lo || d->bracket[1] != hi){
-
- d->bracket[0] = lo;
- d->bracket[1] = hi;
+ if(axisp)
+ _mark_recompute_2d(p);
- if(axisp){
- double xy_p = d == p2->x_d;
- scalespace s = scalespace_linear(lo,hi,(xy_p?p2->data_w:p2->data_h),
- PLOT(p->private->graph)->scalespacing,
- d->name);
-
- if(s.m == 0){
- if(xy_p)
- fprintf(stderr,"X scale underflow; cannot zoom further.\n");
- else
- fprintf(stderr,"Y scale underflow; cannot zoom further.\n");
-
- // abort attempt
- if(buttonstate == 2)
- _sushiv_panel_undo_resume(p);
- return;
-
- }
-
- xy_p?(p2->x=s):(p2->y=s);
- _mark_recompute_2d(p);
-
- }
-
- _sushiv_panel_update_shared_bracket(d,lo,hi);
-
- }
-
- if(buttonstate == 2)
- _sushiv_panel_undo_resume(p);
}
static void dimchange_callback_2d(GtkWidget *button,gpointer in){
@@ -732,25 +664,15 @@
for(i=0;i<p->dimensions;i++){
sushiv_dimension_t *d = p->dimension_list[i].d;
if(d == p2->x_d){
- if(p2->x_d->val != x){
- slider_set_value(p->private->dim_scales[i],1,x);
-
- // key bindings could move crosshairs out of the window; we
- // stretch in that case, which requires a recompute.
- bracket_callback_2d(p->dimension_list+i,1);
- }
+ if(p2->x_d->val != x)
+ sushiv_dimension_set_value(p->private->dim_scales[i],1,x);
}
if(d == p2->y_d){
- if(p2->y_d->val != y){
- slider_set_value(p->private->dim_scales[i],1,y);
-
- // key bindings could move crosshairs out of the window; we
- // stretch in that case, which requires a recompute.
- bracket_callback_2d(p->dimension_list+i,1);
- }
+ if(p2->y_d->val != y)
+ sushiv_dimension_set_value(p->private->dim_scales[i],1,y);
}
-
+
p2->oldbox_active = 0;
}
@@ -774,10 +696,10 @@
_sushiv_panel2d_crosshairs_callback(p);
- slider_set_value(p2->x_scale,0,p2->oldbox[0]);
- slider_set_value(p2->x_scale,2,p2->oldbox[1]);
- slider_set_value(p2->y_scale,0,p2->oldbox[2]);
- slider_set_value(p2->y_scale,2,p2->oldbox[3]);
+ 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]);
p2->oldbox_active = 0;
_sushiv_panel_undo_resume(p);
break;
@@ -942,9 +864,9 @@
}
for(i=0;i<p->dimensions;i++){
- u->dim_vals[0][i] = slider_get_value(p->private->dim_scales[i],0);
- u->dim_vals[1][i] = slider_get_value(p->private->dim_scales[i],1);
- u->dim_vals[2][i] = slider_get_value(p->private->dim_scales[i],2);
+ u->dim_vals[0][i] = p->private->dim_scales[i]->dl->d->bracket[0];
+ u->dim_vals[1][i] = p->private->dim_scales[i]->dl->d->val;
+ u->dim_vals[2][i] = p->private->dim_scales[i]->dl->d->bracket[1];
}
u->x_d = p2->x_dnum;
@@ -981,18 +903,9 @@
}
for(i=0;i<p->dimensions;i++){
- /*if(slider_get_value(p->private->dim_scales[i],0)!=u->dim_vals[0][i] ||
- slider_get_value(p->private->dim_scales[i],2)!=u->dim_vals[2][i]){
- if(i==u->x_d || i==u->y_d)
- recomp_flag=1;
- }
- if(slider_get_value(p->private->dim_scales[i],0)!=u->dim_vals[1][i]){
- if(i!=u->x_d && i!=u->y_d)
- recomp_flag=1;
- }*/
- slider_set_value(p->private->dim_scales[i],0,u->dim_vals[0][i]);
- slider_set_value(p->private->dim_scales[i],1,u->dim_vals[1][i]);
- slider_set_value(p->private->dim_scales[i],2,u->dim_vals[2][i]);
+ sushiv_dimension_set_value(p->private->dim_scales[i],0,u->dim_vals[0][i]);
+ sushiv_dimension_set_value(p->private->dim_scales[i],1,u->dim_vals[1][i]);
+ sushiv_dimension_set_value(p->private->dim_scales[i],2,u->dim_vals[2][i]);
}
if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p2->dim_xb[u->x_d]))){
@@ -1305,7 +1218,6 @@
p2->dim_yb = calloc(p->dimensions,sizeof(*p2->dim_yb));
for(i=0;i<p->dimensions;i++){
- GtkWidget **sl = calloc(3,sizeof(*sl));
sushiv_dimension_t *d = p->dimension_list[i].d;
/* label */
@@ -1314,7 +1226,7 @@
0,0,10,0);
/* x/y radio buttons */
- if(!(d->flags & SUSHIV_NO_X)){
+ if(!(d->flags & SUSHIV_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{
@@ -1325,7 +1237,7 @@
0,0,10,0);
}
- if(!(d->flags & SUSHIV_NO_Y)){
+ if(!(d->flags & SUSHIV_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
@@ -1338,25 +1250,14 @@
0,0,10,0);
}
- /* the dimension slices/slider */
- sl[0] = slice_new(bracket_callback_2d,p->dimension_list+i);
- sl[1] = slice_new(dim_callback_2d,p->dimension_list+i);
- sl[2] = slice_new(bracket_callback_2d,p->dimension_list+i);
-
- gtk_table_attach(GTK_TABLE(p2->dim_table),sl[0],3,4,i,i+1,
+ p->private->dim_scales[i] =
+ sushiv_new_dimension_widget(p->dimension_list+i,center_callback_2d,bracket_callback_2d);
+
+ gtk_table_attach(GTK_TABLE(p2->dim_table),
+ GTK_WIDGET(p->private->dim_scales[i]->t),
+ 2,3,i,i+1,
GTK_EXPAND|GTK_FILL,0,0,0);
- gtk_table_attach(GTK_TABLE(p2->dim_table),sl[1],4,5,i,i+1,
- GTK_EXPAND|GTK_FILL,0,0,0);
- gtk_table_attach(GTK_TABLE(p2->dim_table),sl[2],5,6,i,i+1,
- GTK_EXPAND|GTK_FILL,0,0,0);
- p->private->dim_scales[i] = slider_new((Slice **)sl,3,d->scale->label_list,d->scale->val_list,
- d->scale->vals,0);
-
- slice_thumb_set((Slice *)sl[0],d->scale->val_list[0]);
- slice_thumb_set((Slice *)sl[1],0);
- slice_thumb_set((Slice *)sl[2],d->scale->val_list[d->scale->vals-1]);
-
}
for(i=0;i<p->dimensions;i++){
if(p2->dim_xb[i])
@@ -1427,6 +1328,19 @@
}
}
+ // verify all dimensions that can accept axis selection are continuous
+ for(i=0;i<p->dimensions;i++){
+ if(p->dimension_list[i].d->type != SUSHIV_DIM_CONTINUOUS){
+ if( (p->dimension_list[i].d->flags & (SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y)) !=
+ (SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y)){
+ fprintf(stderr,"Panel %d: x/y selectable dimensions in a 2d panel\n"
+ "must be continuous; removing dimension %d from selectable lists.\n",
+ number,p->dimension_list[i].d->number);
+ p->dimension_list[i].d->flags|=(SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y);
+ }
+ }
+ }
+
p->private->realize = _sushiv_realize_panel2d;
p->private->map_redraw = _sushiv_panel2d_map_redraw;
p->private->legend_redraw = _sushiv_panel2d_legend_redraw;
Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/panel-2d.h 2006-12-31 02:22:07 UTC (rev 12266)
@@ -46,8 +46,8 @@
sushiv_dimension_t *x_d;
sushiv_dimension_t *y_d;
- Slider *x_scale;
- Slider *y_scale;
+ sushiv_dim_widget_t *x_scale;
+ sushiv_dim_widget_t *y_scale;
int x_dnum; // number of dimension within panel, not global instance
int y_dnum; // number of dimension within panel, not global instance
Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/panel.c 2006-12-31 02:22:07 UTC (rev 12266)
@@ -45,42 +45,6 @@
return 0;
}
-void _sushiv_panel_update_shared_dimension(sushiv_dimension_t *d,
- double val){
- int i,j;
- sushiv_instance_t *s = d->sushi;
- for(i=0;i<s->panels;i++){
- sushiv_panel_t *p = s->panel_list[i];
- if(p && p->private && p->private->dim_scales){
- for(j=0;j<p->dimensions;j++){
- sushiv_dimension_list_t *dl = p->dimension_list+j;
- if(dl->d == d && p->private->dim_scales[j])
- slider_set_value(p->private->dim_scales[j],1,val);
- }
- }
- }
-}
-
-void _sushiv_panel_update_shared_bracket(sushiv_dimension_t *d,
- double lo, double hi){
- int i,j;
- sushiv_instance_t *s = d->sushi;
- for(i=0;i<s->panels;i++){
- sushiv_panel_t *p = s->panel_list[i];
- if(p && p->private && p->private->dim_scales){
-
- for(j=0;j<p->dimensions;j++){
- sushiv_dimension_list_t *dl = p->dimension_list+j;
- if(dl->d == d && p->private->dim_scales[j]){
- slider_set_value(p->private->dim_scales[j],0,lo);
- slider_set_value(p->private->dim_scales[j],2,hi);
- }
- }
-
- }
- }
-}
-
/* doesn't take an unbounded period, but shouldn't be
synchronous in the interests of responsiveness. */
static gboolean _map_idle_work(gpointer ptr){
Modified: trunk/sushivision/slice.c
===================================================================
--- trunk/sushivision/slice.c 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/slice.c 2006-12-31 02:22:07 UTC (rev 12266)
@@ -46,20 +46,6 @@
slider_size_request_slice(s->slider,requisition);
}
-static gboolean slice_focus (GtkWidget *widget,
- GtkDirectionType direction){
- Slice *s=SLICE(widget);
-
- if(!s->thumb_active)return FALSE;
- if(s->thumb_focus)return TRUE;
-
- s->thumb_focus=1;
- gtk_widget_grab_focus(widget);
- draw_and_expose(widget);
-
- return TRUE;
-}
-
static gint slice_motion(GtkWidget *widget,
GdkEventMotion *event){
Slice *s=SLICE(widget);
Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h 2006-12-31 01:50:47 UTC (rev 12265)
+++ trunk/sushivision/sushivision.h 2006-12-31 02:22:07 UTC (rev 12266)
@@ -42,12 +42,6 @@
sushiv_instance_internal_t *private;
} sushiv_instance_t;
-#define SUSHIV_NO_X 0x100
-#define SUSHIV_NO_Y 0x200
-#define SUSHIV_LINK_X 0x400
-#define SUSHIV_LINK_Y 0x800
-#define SUSHIV_FLIP 0x1000
-
struct sushiv_scale{
int vals;
double *val_list;
@@ -55,11 +49,18 @@
char *legend;
};
-typedef struct sushiv_panel_internal sushiv_panel_internal_t;
+#define SUSHIV_DIM_NO_X 0x100
+#define SUSHIV_DIM_NO_Y 0x200
+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;
+
struct sushiv_dimension{
int number;
char *name;
+ enum sushiv_dimension_type type;
+
double bracket[2];
double val;
@@ -68,23 +69,33 @@
int (*callback)(sushiv_dimension_t *);
sushiv_instance_t *sushi;
- sushiv_panel_internal_t *private;
+ sushiv_dimension_subtype_t *subtype;
+ sushiv_dimension_internal_t *private;
};
typedef struct sushiv_objective_internal sushiv_objective_internal_t;
+enum sushiv_objective_type { SUSHIV_OBJ_CONTINUOUS };
+typedef union sushiv_objective_subtype sushiv_objective_subtype_t;
struct sushiv_objective {
int number;
char *name;
+ enum sushiv_objective_type type;
sushiv_scale_t *scale;
unsigned flags;
void (*callback)(double *,double *);
sushiv_instance_t *sushi;
+ sushiv_objective_subtype_t *subtype;
sushiv_objective_internal_t *private;
};
+#define SUSHIV_PANEL_LINK_X 0x1
+#define SUSHIV_PANEL_LINK_Y 0x2
+#define SUSHIV_PANEL_FLIP 0x4
+
+typedef struct sushiv_panel_internal sushiv_panel_internal_t;
enum sushiv_panel_type { SUSHIV_PANEL_1D, SUSHIV_PANEL_2D, SUSHIV_PANEL_XY };
typedef union sushiv_panel_subtype sushiv_panel_subtype_t;
@@ -129,6 +140,25 @@
int (*callback)(sushiv_dimension_t *),
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);
+
+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);
+
extern int sushiv_new_objective(sushiv_instance_t *s,
int number,
const char *name,
More information about the commits
mailing list