[xiph-commits] r12518 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Sat Feb 24 01:33:47 PST 2007
Author: xiphmont
Date: 2007-02-24 01:33:45 -0800 (Sat, 24 Feb 2007)
New Revision: 12518
Added:
trunk/sushivision/example_chirp.c
Modified:
trunk/sushivision/Makefile
trunk/sushivision/main.c
trunk/sushivision/panel-1d.c
trunk/sushivision/panel.c
trunk/sushivision/sushi-gtkrc.in
trunk/sushivision/undo.c
Log:
Implement straight-up 1d panels
Add a small example (sushivision_chirp) to play with 1 panel
Numerous 1d bugfixes, more yet to come (eg, still need to fix resize/expander behavior)
Modified: trunk/sushivision/Makefile
===================================================================
--- trunk/sushivision/Makefile 2007-02-24 06:13:38 UTC (rev 12517)
+++ trunk/sushivision/Makefile 2007-02-24 09:33:45 UTC (rev 12518)
@@ -26,11 +26,11 @@
SRC = main.c scale.c plot.c slider.c slice.c spinner.c panel.c panel-1d.c panel-2d.c \
mapping.c dimension.c function.c objective.c undo.c gtksucks.c \
- example_fractal.c example_discrete.c
+ example_fractal.c example_discrete.c example_chirp.c
INC = sushivision.h
MAN =
-EXAMPLES = sushivision_fractal sushivision_discrete
-EX_OBJ = example_fractal.o example_discrete.o
+EXAMPLES = sushivision_fractal sushivision_discrete sushivision_chirp
+EX_OBJ = example_fractal.o example_discrete.o example_chirp.o
OBJ = main.o scale.o plot.o slider.o slice.o spinner.c panel.o panel-1d.o panel-2d.o \
mapping.o dimension.o function.o objective.o undo.o gtksucks.o
LIBS = -lpthread -ldl
@@ -98,7 +98,7 @@
examples: $(OBJ) $(EX_OBJ)
$(LD) $(OBJ) example_fractal.o $(CFLAGS) -o sushivision_fractal $(LIBS) $(LDF)
$(LD) $(OBJ) example_discrete.o $(CFLAGS) -o sushivision_discrete $(LIBS) $(LDF)
-# $(LD) $(OBJ) example_chirpfit.o $(CFLAGS) -o sushivision_chirpfit $(LIBS) $(LDF)
+ $(LD) $(OBJ) example_chirp.o $(CFLAGS) -o sushivision_chirp $(LIBS) $(LDF)
install: target
$(INSTALL) -d -m 0755 $(INCDIR)
Added: trunk/sushivision/example_chirp.c
===================================================================
--- trunk/sushivision/example_chirp.c 2007-02-24 06:13:38 UTC (rev 12517)
+++ trunk/sushivision/example_chirp.c 2007-02-24 09:33:45 UTC (rev 12518)
@@ -0,0 +1,107 @@
+/*
+ *
+ * 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.
+ *
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#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];
+ double phas = d[2];
+ double damp = d[3];
+ double dpha = d[4];
+ double t = d[5];
+
+ /* 0: sin
+ 2: ph
+ 3: a */
+ double phase_t = (phas + freq*t*M_PI*2 + dpha*t*t);
+ double cycles = floor(phase_t/(M_PI*2));
+ double norm_phase = phase_t - cycles*M_PI*2;
+ if(norm_phase > M_PI) norm_phase -= M_PI*2;
+
+ ret[2] = (ampl + damp*t);
+ ret[1] = norm_phase / M_PI;
+ ret[0] = sin(phase_t) * (ampl + damp*t);
+}
+
+int sushiv_submain(int argc, char *argv[]){
+
+ s=sushiv_new_instance();
+
+ 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);
+
+ sushiv_dimension_set_value(s,1,1,1.0);
+
+ sushiv_new_function(s, 0, 6, 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/main.c
===================================================================
--- trunk/sushivision/main.c 2007-02-24 06:13:38 UTC (rev 12517)
+++ trunk/sushivision/main.c 2007-02-24 09:33:45 UTC (rev 12518)
@@ -114,7 +114,7 @@
// pending remap work?
gdk_threads_enter();
- if(p->private->realized && p->private->graph){
+ if(p && p->private && p->private->realized && p->private->graph){
// pending computation work?
if(p->private->plot_active){
@@ -171,7 +171,8 @@
for(i=0;i<s->panels;i++)
_sushiv_realize_panel(s->panel_list[i]);
for(i=0;i<s->panels;i++)
- s->panel_list[i]->private->request_compute(s->panel_list[i]);
+ if(s->panel_list[i])
+ s->panel_list[i]->private->request_compute(s->panel_list[i]);
}
static void sushiv_realize_all(void){
Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c 2007-02-24 06:13:38 UTC (rev 12517)
+++ trunk/sushivision/panel-1d.c 2007-02-24 09:33:45 UTC (rev 12518)
@@ -126,7 +126,7 @@
/* by objective */
for(j=0;j<p->objectives;j++){
- if(p1->data_vec[j]){
+ if(p1->data_vec[j] && !mapping_inactive_p(p1->mappings+j)){
double alpha = slider_get_value(p1->alpha_scale[j],0);
int linetype = p1->linetype[j];
@@ -338,6 +338,9 @@
cairo_surface_destroy(plot->back);
plot->back = cs;
cairo_destroy(c);
+
+ _sushiv_panel_clean_map(p);
+ plot_expose_request(plot);
return;
abort:
@@ -397,26 +400,27 @@
{
double val = (p1->flip?plot->sely:plot->selx);
int bin = rint(scalespace_pixel(&p1->x_v, val));
- u_int32_t color = mapping_calc(p1->mappings+i,1.,0);
for(i=0;i<p->objectives;i++){
-
- snprintf(buffer,320,"%s",
- p->objective_list[i].o->name);
-
- if(bin>=0 && bin<p1->data_size){
+ if(!mapping_inactive_p(p1->mappings+i)){
+ u_int32_t color = mapping_calc(p1->mappings+i,1.,0);
- float val = p1->data_vec[i][bin];
+ snprintf(buffer,320,"%s",
+ p->objective_list[i].o->name);
- if(!isnan(val)){
- snprintf(buffer,320,"%s = %f",
- p->objective_list[i].o->name,
- val);
+ if(bin>=0 && bin<p1->data_size){
+
+ float val = p1->data_vec[i][bin];
+
+ if(!isnan(val)){
+ snprintf(buffer,320,"%s = %f",
+ p->objective_list[i].o->name,
+ val);
+ }
}
+
+ plot_legend_add_with_color(plot,buffer,color | 0xff000000);
}
-
- plot_legend_add_with_color(plot,buffer,color | 0xff000000);
-
}
}
gdk_threads_leave ();
@@ -959,13 +963,9 @@
// subtype entry point for plot remaps; lock held
int _sushiv_panel1d_map_redraw(sushiv_panel_t *p, _sushiv_bythread_cache *c){
- Plot *plot = PLOT(p->private->graph);
-
if(p->private->map_progress_count)return 0;
p->private->map_progress_count++;
_sushiv_panel1d_remap(p);
- _sushiv_panel_clean_map(p);
- plot_expose_request(plot);
return 1;
}
@@ -1052,11 +1052,12 @@
compute_1d(p, serialno, x_d, x_min, x_max, dw, dim_vals, &c->p1);
gdk_threads_enter ();
-
- _sushiv_panel_dirty_map(p);
- _sushiv_panel_dirty_legend(p);
- _sushiv_panel_clean_plot(p);
-
+
+ if(serialno == p->private->plot_serialno){
+ _sushiv_panel_dirty_map(p);
+ _sushiv_panel_dirty_legend(p);
+ _sushiv_panel_clean_plot(p);
+ }
return 1;
}
@@ -1417,6 +1418,44 @@
_sushiv_panel_undo_resume(p);
}
+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 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];
+ 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;
+
+ if(p->flags && SUSHIV_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->undo_log = panel1d_undo_log;
+ p->private->undo_restore = panel1d_undo_restore;
+
+ return 0;
+}
+
int sushiv_new_panel_1d_linked(sushiv_instance_t *s,
int number,
const char *name,
@@ -1433,39 +1472,21 @@
return -EINVAL;
}
- int ret = _sushiv_new_panel(s,number,name,objectives,(int []){-1},flags);
+ int ret = sushiv_new_panel_1d(s,number,name,scale,objectives,(int []){-1},flags);
+
sushiv_panel_t *p;
sushiv_panel1d_t *p1;
sushiv_panel_t *p2 = s->panel_list[link];
if(ret<0)return ret;
p = s->panel_list[number];
- p1 = calloc(1, sizeof(*p1));
- p->subtype = calloc(1, sizeof(*p->subtype));
+ p1 = p->subtype->p1;
- p->subtype->p1 = p1;
- p->type = SUSHIV_PANEL_1D;
- p1->range_scale = scale;
- p->private->bg_type = SUSHIV_BG_WHITE;
-
if(flags && SUSHIV_PANEL_LINK_Y)
p1->link_y = p2;
else
p1->link_x = p2;
- if(p->flags && SUSHIV_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->undo_log = panel1d_undo_log;
- p->private->undo_restore = panel1d_undo_restore;
-
return 0;
}
Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c 2007-02-24 06:13:38 UTC (rev 12517)
+++ trunk/sushivision/panel.c 2007-02-24 09:33:45 UTC (rev 12518)
@@ -229,7 +229,7 @@
}
void _sushiv_realize_panel(sushiv_panel_t *p){
- if(!p->private->realized){
+ if(p && !p->private->realized){
p->private->realize(p);
p->private->realized=1;
Modified: trunk/sushivision/sushi-gtkrc.in
===================================================================
--- trunk/sushivision/sushi-gtkrc.in 2007-02-24 06:13:38 UTC (rev 12517)
+++ trunk/sushivision/sushi-gtkrc.in 2007-02-24 09:33:45 UTC (rev 12518)
@@ -19,12 +19,12 @@
base[PRELIGHT] = "#80a0ff"
base[INSENSITIVE] = "#808080"
- font_name = "sans 8"
-
GtkWidget::focus_line_width = 1
GtkWidget::focus_padding = 0
GtkWidget::interior_focus = 0
GtkWidget::internal_padding = 0
+
+ font_name = "sans"
}
style "exp-poppy" {
@@ -48,13 +48,13 @@
base[PRELIGHT] = "#c0f0ff"
base[INSENSITIVE] = "#808080"
- font_name = "sans 8"
-
GtkWidget::focus_line_width = 1
GtkWidget::focus_padding = 0
GtkWidget::interior_focus = 0
GtkWidget::internal_padding = 0
GtkExpander::expander_size = 14
+
+ font_name = "sans"
}
style "slider-poppy" {
@@ -70,13 +70,12 @@
text[ACTIVE]="#000000"
text[PRELIGHT]="#000000"
- font_name = "sans 8"
-
GtkWidget::focus_line_width = 1
GtkWidget::focus_padding = 0
GtkWidget::interior_focus = 0
GtkWidget::internal_padding = 0
+ font_name = "sans"
}
style "entry-poppy" {
@@ -89,8 +88,7 @@
text[ACTIVE]="#000000"
text[PRELIGHT]="#000000"
- font_name = "sans 7"
-
+ font_name = "sans"
}
style "panel" {
@@ -102,30 +100,16 @@
text[NORMAL]="#000000"
text[ACTIVE]="#000000"
text[PRELIGHT]="#000000"
+
+ font_name = "sans"
}
style "panel-text" {
- font_name = "sans 9"
+ font_name = "sans"
}
-style "frame-label" {
- font_name = "sans bold 10"
-}
-
-style "readout" {
- base[NORMAL]="#ffffff"
- base[ACTIVE]="#ffffff"
- bg[NORMAL]="#ffffff"
- bg[ACTIVE]="#ffffff"
-
- font_name = "Fixed, Nimbus Mono L, Courier, Monospace 10"
-}
-
widget "*" style "panel"
widget "*.GtkLabel" style "panel-text"
-widget "*.GtkFrame.GtkLabel" style "frame-label"
-widget "*.GtkFrame.GtkHBox.GtkLabel" style "frame-label"
-widget "*.GtkEntry" style "readout"
widget "*.GtkMenu*" style "button-poppy"
widget "*.GtkComboBox*" style "button-poppy"
widget "*.GtkToggleButton*" style "button-poppy"
Modified: trunk/sushivision/undo.c
===================================================================
--- trunk/sushivision/undo.c 2007-02-24 06:13:38 UTC (rev 12517)
+++ trunk/sushivision/undo.c 2007-02-24 09:33:45 UTC (rev 12518)
@@ -82,7 +82,8 @@
// pass off actual population to panels
for(j=0;j<s->panels;j++)
- s->panel_list[j]->private->undo_log(u+j,s->panel_list[j]);
+ if(s->panel_list[j])
+ s->panel_list[j]->private->undo_log(u+j,s->panel_list[j]);
}
void _sushiv_panel_undo_restore(sushiv_panel_t *p){
More information about the commits
mailing list