[xiph-commits] r12292 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Tue Jan 2 18:59:23 PST 2007
Author: xiphmont
Date: 2007-01-02 18:59:15 -0800 (Tue, 02 Jan 2007)
New Revision: 12292
Added:
trunk/sushivision/function.c
Removed:
trunk/sushivision/sushi.h
Modified:
trunk/sushivision/Makefile
trunk/sushivision/dimension.c
trunk/sushivision/dimension.h
trunk/sushivision/example_fractal.c
trunk/sushivision/example_submain.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/panel-1d.c
trunk/sushivision/panel-1d.h
trunk/sushivision/panel-2d.c
trunk/sushivision/panel-2d.h
trunk/sushivision/panel.c
trunk/sushivision/plot.c
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/sushivision.h
trunk/sushivision/undo.c
Log:
First cut of sereated objective/function interface that splits
functional side of computation into 'sushiv_function_t' and the UI
representation side to 'sushiv_objective_t). Functions have a full
indirection mapping to objectives now.
Objectives may conceptually command more than a single return value
now; there are four conceptul types at the moment, Y, XY, YZ and XYZ.
Right now, the various panels only use the Y value, but 1d 'bubble'
graphs could easily use the Z, and xy panels will use X...
Objectives may be a composite of multiple functions.
Functions may contribute to multiple objectives.
Some debugging left to do (no doubt), have an illustration planned for
the fractal demo...
Also, update copyright.
Modified: trunk/sushivision/Makefile
===================================================================
--- trunk/sushivision/Makefile 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/Makefile 2007-01-03 02:59:15 UTC (rev 12292)
@@ -14,10 +14,10 @@
SOCFLAGS = -fPIC
SOLDFLAGS = -shared -nostdlib
-SRC = main.c scale.c plot.c slider.c slice.c panel.c panel-1d.c panel-2d.c mapping.c dimension.c objective.c undo.c gtksucks.c example_submain.c example_fractal.c
-OBJ = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o objective.o undo.o gtksucks.o
-OBJ_EX1 = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o objective.o undo.o gtksucks.o example_submain.o
-OBJ_EX2 = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o objective.o undo.o gtksucks.o example_fractal.o
+SRC = main.c scale.c plot.c slider.c slice.c panel.c panel-1d.c panel-2d.c mapping.c dimension.c function.c objective.c undo.c gtksucks.c example_submain.c example_fractal.c
+OBJ = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o function.o objective.o undo.o gtksucks.o
+#OBJ_EX1 = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o function.o objective.o undo.o gtksucks.o example_submain.o
+OBJ_EX2 = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o function.o objective.o undo.o gtksucks.o example_fractal.o
INC = sushivision.h
LIBS = -lpthread -ldl
CAIROVER = >= 1.0.0
@@ -60,8 +60,8 @@
$(LD) $(OBJ) $(CFLAGS) $(SOLDFLAGS) -o $(TARGET) $(LIBS) $(LDF)
examples: $(OBJ_EX1) $(OBJ_EX2)
- $(LD) $(OBJ_EX1) $(CFLAGS) -o sushivision_example $(LIBS) $(LDF)
$(LD) $(OBJ_EX2) $(CFLAGS) -o sushivision_fractal $(LIBS) $(LDF)
+# $(LD) $(OBJ_EX1) $(CFLAGS) -o sushivision_example $(LIBS) $(LDF)
install: target
$(INSTALL) -d -m 0755 $(BINDIR)
Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/dimension.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/dimension.h
===================================================================
--- trunk/sushivision/dimension.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/dimension.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/example_fractal.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
@@ -73,10 +73,12 @@
NULL,0);
sushiv_dimension_set_value(s,4,1,10000);
- sushiv_new_objective(s,0,"fractal",
- 5,(double []){0, .001, .01, .1, 1.0},
- fractal_objective,0);
+ sushiv_new_function(s, 0, 5, 1, fractal_objective, 0);
+ sushiv_new_objective_Y(s,0,"fractal",
+ 5,(double []){0, .001, .01, .1, 1.0},
+ 0,0,0);
+
sushiv_new_panel_2d(s,0,"Mandel/Julia Fractal",
(int []){0,-1},
(int []){0,1,2,3,4,-1},
Modified: trunk/sushivision/example_submain.c
===================================================================
--- trunk/sushivision/example_submain.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/example_submain.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Added: trunk/sushivision/function.c
===================================================================
--- trunk/sushivision/function.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/function.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -0,0 +1,66 @@
+/*
+ *
+ * sushivision copyright (C) 2006-2007 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.
+ *
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "internal.h"
+
+int sushiv_new_function(sushiv_instance_t *s,
+ int number,
+ int in_vals,
+ int out_vals,
+ void(*callback)(double *,double *),
+ unsigned flags){
+ sushiv_function_t *f;
+
+ if(number<0){
+ fprintf(stderr,"Function number must be >= 0\n");
+ return -EINVAL;
+ }
+
+ if(number<s->functions){
+ if(s->function_list[number]!=NULL){
+ fprintf(stderr,"Function number %d already exists\n",number);
+ return -EINVAL;
+ }
+ }else{
+ if(s->functions == 0){
+ s->function_list = calloc (number+1,sizeof(*s->function_list));
+ }else{
+ s->function_list = realloc (s->function_list,(number+1) * sizeof(*s->function_list));
+ memset(s->function_list + s->functions, 0, sizeof(*s->function_list)*(number +1 - s->functions));
+ }
+ s->functions=number+1;
+ }
+
+ f = s->function_list[number] = calloc(1, sizeof(**s->function_list));
+ f->number = number;
+ f->flags = flags;
+ f->sushi = s;
+ f->callback = callback;
+ f->inputs = in_vals;
+ f->outputs = out_vals;
+ f->type = SUSHIV_FUNC_BASIC;
+
+ return 0;
+}
Modified: trunk/sushivision/gtksucks.c
===================================================================
--- trunk/sushivision/gtksucks.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/gtksucks.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/gtksucks.h
===================================================================
--- trunk/sushivision/gtksucks.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/gtksucks.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/internal.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
@@ -53,6 +53,13 @@
int box_active;
} sushiv_panel_undo_t;
+typedef struct {
+ void (**call)(double *, double *);
+ double **fout; // [function number][outval_number*x]
+ int storage_width;
+
+} _sushiv_compute_cache;
+
struct sushiv_panel_internal {
GtkWidget *toplevel;
GtkWidget *graph;
@@ -68,7 +75,7 @@
void (*realize)(sushiv_panel_t *p);
void (*map_redraw)(sushiv_panel_t *p);
void (*legend_redraw)(sushiv_panel_t *p);
- int (*compute_action)(sushiv_panel_t *p);
+ int (*compute_action)(sushiv_panel_t *p, _sushiv_compute_cache *c);
void (*request_compute)(sushiv_panel_t *p);
void (*crosshair_action)(sushiv_panel_t *p);
@@ -96,7 +103,9 @@
extern void _sushiv_panel_dirty_legend(sushiv_panel_t *p);
extern void _sushiv_wake_workers(void);
-extern int _sushiv_panel_cooperative_compute(sushiv_panel_t *p);
+extern void _maintain_cache(sushiv_panel_t *p, _sushiv_compute_cache *c, int w);
+extern int _sushiv_panel_cooperative_compute(sushiv_panel_t *p,
+ _sushiv_compute_cache *c);
extern void _sushiv_panel_undo_log(sushiv_panel_t *p);
extern void _sushiv_panel_undo_push(sushiv_panel_t *p);
@@ -109,4 +118,6 @@
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 int obj_y(sushiv_objective_t *o);
+
extern sig_atomic_t _sushiv_exiting;
Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/main.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
@@ -85,13 +85,56 @@
}
}
+void _maintain_cache(sushiv_panel_t *p, _sushiv_compute_cache *c, int w){
+
+ /* toplevel initialization */
+ if(c->fout == 0){
+ int i,j;
+
+ /* determine which functions are actually needed */
+ 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;
+ for(j=0;j<o->outputs;j++)
+ c->call[o->function_map[j]]=
+ p->sushi->function_list[o->function_map[j]]->callback;
+ }
+ }
+
+ /* once to begin, as well as anytime the data width changes */
+ if(c->storage_width < w){
+ int i;
+ c->storage_width = w;
+
+ for(i=0;i<p->sushi->functions;i++){
+ if(c->call[i]){
+ if(c->fout[i])free(c->fout[i]);
+ c->fout[i] = malloc(w * p->sushi->function_list[i]->outputs *
+ sizeof(**c->fout));
+ }
+ }
+ }
+}
+
static void *worker_thread(void *dummy){
+ /* set up temporary working space for function rendering; this saves
+ continuously recreating it in the loop below */
+ _sushiv_compute_cache **c; // [instance][panel]
+ int i,j;
+
+ c = calloc(instances,sizeof(*c));
+ for(j=0;j<instances;j++){
+ sushiv_instance_t *s = instance_list[j];
+ c[j] = calloc(s->panels,sizeof(**c));
+ }
+
while(1){
if(_sushiv_exiting)break;
// look for work
{
- int i,j,flag=0;
+ int flag=0;
// by instance
for(j=0;j<instances;j++){
sushiv_instance_t *s = instance_list[j];
@@ -130,7 +173,8 @@
gdk_threads_leave ();
// pending computation work?
- flag |= _sushiv_panel_cooperative_compute(s->panel_list[i]);
+ flag |= _sushiv_panel_cooperative_compute(s->panel_list[i],
+ &c[j][i]);
}
}
if(flag==1)continue;
Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/mapping.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/mapping.h
===================================================================
--- trunk/sushivision/mapping.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/mapping.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/objective.c
===================================================================
--- trunk/sushivision/objective.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/objective.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
@@ -25,20 +25,34 @@
#include <errno.h>
#include "internal.h"
-int sushiv_new_objective(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned scalevals,
- double *scaleval_list,
- void(*callback)(double *,double *),
- unsigned flags){
+int obj_y(sushiv_objective_t *o){
+ switch(o->type){
+ case SUSHIV_OBJ_XY:
+ case SUSHIV_OBJ_XYZ:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static int _sushiv_new_objective(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int type,
+ int outputs,
+ int *function_map,
+ int *output_map,
+ unsigned flags){
sushiv_objective_t *o;
-
+ int i;
+
if(number<0){
fprintf(stderr,"Objective number must be >= 0\n");
return -EINVAL;
}
-
+
if(number<s->objectives){
if(s->objective_list[number]!=NULL){
fprintf(stderr,"Objective number %d already exists\n",number);
@@ -54,15 +68,107 @@
s->objectives=number+1;
}
+ /* 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(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;
+ }
+ }
+
o = s->objective_list[number] = calloc(1, sizeof(**s->objective_list));
o->number = number;
o->name = strdup(name);
+ o->type = type;
+ o->outputs = outputs;
o->flags = flags;
o->sushi = s;
- o->callback = callback;
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));
+
return 0;
}
+
+int sushiv_new_objective_Y(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int function_number,
+ int function_output,
+ unsigned flags){
+ return _sushiv_new_objective(s,number,name,
+ scalevals,scaleval_list,
+ SUSHIV_OBJ_Y,
+ 1,
+ (int []){function_number},
+ (int []){function_output},
+ flags);
+}
+
+int sushiv_new_objective_XY(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int function_number[2],
+ int function_output[2],
+ unsigned flags){
+ return _sushiv_new_objective(s,number,name,
+ scalevals,scaleval_list,
+ SUSHIV_OBJ_XY,
+ 2,
+ function_number,
+ function_output,
+ flags);
+}
+
+int sushiv_new_objective_YZ(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int function_number[2],
+ int function_output[2],
+ unsigned flags){
+ return _sushiv_new_objective(s,number,name,
+ scalevals,scaleval_list,
+ SUSHIV_OBJ_YZ,
+ 2,
+ function_number,
+ function_output,
+ flags);
+}
+
+int sushiv_new_objective_XYZ(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int function_number[3],
+ int function_output[3],
+ unsigned flags){
+ return _sushiv_new_objective(s,number,name,
+ scalevals,scaleval_list,
+ SUSHIV_OBJ_XYZ,
+ 3,
+ function_number,
+ function_output,
+ flags);
+}
Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/panel-1d.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
@@ -542,25 +542,46 @@
double x_min,
double x_max,
int w,
- double *dim_vals){
+ double *dim_vals,
+ _sushiv_compute_cache *c){
sushiv_panel1d_t *p1 = p->subtype->p1;
double work[w];
- double inv_w = 1./w;
- int i,j;
+ int i,j,fn=p->sushi->functions;
- /* by objective */
+ /* by function */
+ for(i=0;i<fn;i++){
+ if(c->call[i]){
+ sushiv_function_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] = (x_max-x_min) * j / w + x_min;
+ c->call[i](dim_vals,fout);
+ fout+=step;
+ }
+ }
+ }
+
+ /* process function output by objective */
+ /* 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;
-
- /* by x */
+ int funcnum = o->function_map[obj_y(o)];
+ int offset = o->output_map[obj_y(o)];
+ sushiv_function_t *f = p->sushi->function_list[funcnum];
+ int step = f->outputs;
+ double *fout = c->fout[funcnum]+offset;
+
+ /* map result from function output to objective output */
for(j=0;j<w;j++){
-
- /* compute value for this objective for this pixel */
- dim_vals[x_d] = (x_max-x_min) * inv_w * j + x_min;
- o->callback(dim_vals,work+j);
-
+ work[j] = *fout;
+ fout+=step;
}
-
+
gdk_threads_enter (); // misuse me as a global mutex
if(p1->serialno == serialno){
/* store result in panel */
@@ -868,7 +889,8 @@
update_context_menus(p);
}
-int _sushiv_panel_cooperative_compute_1d(sushiv_panel_t *p){
+int _sushiv_panel_cooperative_compute_1d(sushiv_panel_t *p,
+ _sushiv_compute_cache *c){
sushiv_panel1d_t *p1 = p->subtype->p1;
Plot *plot;
@@ -930,8 +952,12 @@
dim_vals[i]=dim->val;
}
+ _maintain_cache(p,c,dw);
+
// update scales if we're just starting
- if(p1->last_line==0) render_scale_flag = 1;
+ if(p1->last_line==0){
+ render_scale_flag = 1;
+ }
if(plot->w.allocation.height == h &&
serialno == p1->serialno){
@@ -946,7 +972,7 @@
}
/* compute */
- compute_1d(p, serialno, x_d, x_min, x_max, dw, dim_vals);
+ compute_1d(p, serialno, x_d, x_min, x_max, dw, dim_vals, c);
gdk_threads_enter ();
_sushiv_panel_dirty_map(p);
_sushiv_panel_dirty_legend(p);
@@ -1504,7 +1530,6 @@
structure must be hidden */
p->subtype->p1 = p1;
p->type = SUSHIV_PANEL_1D;
-
p1->range_scale = scale;
if(flags && SUSHIV_PANEL_LINK_Y)
Modified: trunk/sushivision/panel-1d.h
===================================================================
--- trunk/sushivision/panel-1d.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/panel-1d.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/panel-2d.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
@@ -273,50 +273,70 @@
double x_max,
int w,
double *dim_vals,
- u_int32_t *render){
+ u_int32_t *render,
+ _sushiv_compute_cache *c){
+
sushiv_panel2d_t *p2 = p->subtype->p2;
+ int i,j,fn=p->sushi->functions;
double work[w];
- double inv_w = 1./w;
- int i,j;
render_checks(w,y,render);
- gdk_threads_enter (); // misuse me as a global mutex
-
- /* by objective */
+
+ /* by function */
+ for(i=0;i<fn;i++){
+ if(c->call[i]){
+ sushiv_function_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] = (x_max-x_min) * j / w + x_min;
+ c->call[i](dim_vals,fout);
+ fout+=step;
+ }
+ }
+ }
+
+ /* process function output by objective */
+ /* 2d panels only care about the Y output value */
for(i=0;i<p->objectives;i++){
sushiv_objective_t *o = p->objective_list[i].o;
- double alpha = p2->alphadel[i];
-
- gdk_threads_leave (); // misuse me as a global mutex
-
- /* by x */
+ int funcnum = o->function_map[obj_y(o)];
+ int offset = o->output_map[obj_y(o)];
+ sushiv_function_t *f = p->sushi->function_list[funcnum];
+ int step = f->outputs;
+ double *fout = c->fout[funcnum]+offset;
+ mapping m;
+ double alpha;
+
+ /* map result */
+ /* range scales are static so no need to lock; if that ever
+ changes, locking should happen in the scales... */
for(j=0;j<w;j++){
+ work[j] = slider_val_to_del(p2->range_scales[i],*fout);
+ fout+=step;
+ }
- /* compute value for this objective for this pixel */
- dim_vals[x_d] = (x_max-x_min) * inv_w * j + x_min;
- o->callback(dim_vals,work+j);
-
- }
-
gdk_threads_enter (); // misuse me as a global mutex
if(p2->serialno == serialno){
-
- /* map/render result */
- for(j=0;j<w;j++){
- double val = slider_val_to_del(p2->range_scales[i],work[j]);
- work[j] = val;
-
- if(!isnan(val) && val>=alpha)
- render[j] = mapping_calc(p2->mappings+i,val,render[j]);
-
- }
-
- /* store result in panel */
memcpy(p2->data_rect[i]+y*w,work,w*sizeof(*work));
- }else
+ memcpy(&m,p2->mappings+i,sizeof(m));
+ alpha = p2->alphadel[i];
+ gdk_threads_leave (); // misuse me as a global mutex
+ }else{
+ gdk_threads_leave (); // misuse me as a global mutex
break;
+ }
+
+ for(j=0;j<w;j++){
+ double val = work[j];
+ if(!isnan(val) && val>=alpha)
+ render[j] = mapping_calc(&m,val,render[j]);
+
+ }
}
- gdk_threads_leave (); // misuse me as a global mutex
}
static int v_swizzle(int y, int height){
@@ -717,7 +737,9 @@
// called from one/all of the worker threads; the idea is that several
// of the threads will all call this and they collectively interleave
// ongoing computation of the pane
-static int _sushiv_panel_cooperative_compute_2d(sushiv_panel_t *p){
+static int _sushiv_panel_cooperative_compute_2d(sushiv_panel_t *p,
+ _sushiv_compute_cache *c){
+
sushiv_panel2d_t *p2 = p->subtype->p2;
Plot *plot;
@@ -798,8 +820,12 @@
dim_vals[i]=dim->val;
}
+ _maintain_cache(p,c,w);
+
// update scales if we're just starting
- if(p2->last_line==0) render_scale_flag = 1;
+ if(p2->last_line==0){
+ render_scale_flag = 1;
+ }
/* iterate */
/* by line */
@@ -821,7 +847,7 @@
dim_vals[y_d]= (y_max - y_min) / h * y + y_min;
/* compute line */
- compute_one_line_2d(p, serialno, y, x_d, x_min, x_max, w, dim_vals, render);
+ compute_one_line_2d(p, serialno, y, x_d, x_min, x_max, w, dim_vals, render, c);
/* move rendered line back into widget */
gdk_threads_enter ();
Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/panel-2d.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/panel.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
@@ -40,9 +40,10 @@
}
}
-int _sushiv_panel_cooperative_compute(sushiv_panel_t *p){
+int _sushiv_panel_cooperative_compute(sushiv_panel_t *p,
+ _sushiv_compute_cache *c){
if(p->private->realized)
- return p->private->compute_action(p);
+ return p->private->compute_action(p,c);
return 0;
}
Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/plot.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/scale.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/scale.h
===================================================================
--- trunk/sushivision/scale.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/scale.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/slice.c
===================================================================
--- trunk/sushivision/slice.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/slice.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/slice.h
===================================================================
--- trunk/sushivision/slice.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/slice.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/slider.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Modified: trunk/sushivision/slider.h
===================================================================
--- trunk/sushivision/slider.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/slider.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
Deleted: trunk/sushivision/sushi.h
===================================================================
--- trunk/sushivision/sushi.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/sushi.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,29 +0,0 @@
-/*
- *
- * 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.
- *
- *
- */
-
-
-extern void sushi_submain();
-extern void sushi_new_2d(int axes, double (*objective)(double *),
- char **labels, double *vals,
- double small_step, double large_step);
-extern void sushi_axis_2d(double range_low, double range_hi,
- double small_step, double large_step);
-
Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/sushivision.h 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
@@ -26,10 +26,14 @@
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 sushiv_instance_internal sushiv_instance_internal_t;
typedef struct sushiv_instance {
+ int functions;
+ sushiv_function_t **function_list;
+
int dimensions;
sushiv_dimension_t **dimension_list;
@@ -53,7 +57,9 @@
#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 };
+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{
@@ -73,8 +79,29 @@
sushiv_dimension_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;
+
+struct sushiv_function {
+ int number;
+ enum sushiv_function_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;
+};
+
typedef struct sushiv_objective_internal sushiv_objective_internal_t;
-enum sushiv_objective_type { SUSHIV_OBJ_CONTINUOUS };
+enum sushiv_objective_type { SUSHIV_OBJ_Y,
+ SUSHIV_OBJ_XY,
+ SUSHIV_OBJ_YZ,
+ SUSHIV_OBJ_XYZ };
typedef union sushiv_objective_subtype sushiv_objective_subtype_t;
struct sushiv_objective {
@@ -83,9 +110,11 @@
enum sushiv_objective_type type;
sushiv_scale_t *scale;
+ int outputs;
+ int *function_map;
+ int *output_map;
unsigned flags;
- void (*callback)(double *,double *);
sushiv_instance_t *sushi;
sushiv_objective_subtype_t *subtype;
sushiv_objective_internal_t *private;
@@ -96,7 +125,9 @@
#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 };
+enum sushiv_panel_type { SUSHIV_PANEL_1D,
+ SUSHIV_PANEL_2D,
+ SUSHIV_PANEL_XY };
typedef union sushiv_panel_subtype sushiv_panel_subtype_t;
typedef struct {
@@ -129,8 +160,11 @@
extern sushiv_instance_t *sushiv_new_instance(void);
extern void scale_free(sushiv_scale_t *s);
-extern sushiv_scale_t *scale_new(unsigned scalevals, double *scaleval_list, const char *legend);
-extern int scale_set_scalelabels(sushiv_scale_t *s, char **scalelabel_list);
+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);
extern int sushiv_new_dimension(sushiv_instance_t *s,
int number,
@@ -159,16 +193,54 @@
int (*callback)(sushiv_dimension_t *),
unsigned flags);
-extern void sushiv_dimension_set_value(sushiv_instance_t *s, int dim_number, int thumb, double val);
+extern void sushiv_dimension_set_value(sushiv_instance_t *s,
+ int dim_number,
+ int thumb,
+ double val);
-extern int sushiv_new_objective(sushiv_instance_t *s,
- int number,
- const char *name,
- unsigned scalevals,
- double *scaleval_list,
- void (*callback)(double *, double *),
- unsigned flags);
+extern int sushiv_new_function(sushiv_instance_t *s,
+ int number,
+ int in_vals,
+ int out_vals,
+ void(*callback)(double *,double *),
+ unsigned flags);
+
+extern int sushiv_new_objective_Y(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int function_number,
+ int function_output,
+ unsigned flags);
+extern int sushiv_new_objective_XY(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int function_number[2],
+ int function_output[2],
+ unsigned flags);
+
+extern int sushiv_new_objective_YZ(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int function_number[2],
+ int function_output[2],
+ unsigned flags);
+
+extern int sushiv_new_objective_XYZ(sushiv_instance_t *s,
+ int number,
+ const char *name,
+ unsigned scalevals,
+ double *scaleval_list,
+ int function_number[3],
+ int function_output[3],
+ unsigned flags);
+
extern int sushiv_new_panel_2d(sushiv_instance_t *s,
int number,
const char *name,
Modified: trunk/sushivision/undo.c
===================================================================
--- trunk/sushivision/undo.c 2007-01-02 13:49:38 UTC (rev 12291)
+++ trunk/sushivision/undo.c 2007-01-03 02:59:15 UTC (rev 12292)
@@ -1,6 +1,6 @@
/*
*
- * sushivision copyright (C) 2006 Monty <monty at xiph.org>
+ * sushivision copyright (C) 2006-2007 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
More information about the commits
mailing list