[xiph-commits] r12276 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Sun Dec 31 14:59:38 PST 2006
Author: xiphmont
Date: 2006-12-31 14:59:36 -0800 (Sun, 31 Dec 2006)
New Revision: 12276
Modified:
trunk/sushivision/internal.h
trunk/sushivision/panel-1d.c
trunk/sushivision/panel-2d.c
trunk/sushivision/undo.c
Log:
Several udo fixes for bugs introduced by having multiple panel states,
but only logging one at a time.
Alter the undo to take a snapshot of all panels; this makes a somewhat
wasteful system even more wasteful, but it is very
straightforward/robust.
Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h 2006-12-31 21:19:24 UTC (rev 12275)
+++ trunk/sushivision/internal.h 2006-12-31 22:59:36 UTC (rev 12276)
@@ -41,12 +41,10 @@
// for now we use a master undo type which leaves one or two fields
// unused for a given panel.
typedef struct sushiv_panel_undo {
- sushiv_panel_t *p;
int *mappings;
int *submappings;
double *scale_vals[3];
- double *obj_vals[3];
double *dim_vals[3];
int x_d;
@@ -73,8 +71,8 @@
void (*request_compute)(sushiv_panel_t *p);
void (*crosshair_action)(sushiv_panel_t *p);
- void (*undo_log)(sushiv_panel_undo_t *u);
- void (*undo_restore)(sushiv_panel_undo_t *u, int *mapflag, int *compflag);
+ void (*undo_log)(sushiv_panel_undo_t *u, sushiv_panel_t *p);
+ void (*undo_restore)(sushiv_panel_undo_t *u, sushiv_panel_t *p);
void (*update_menus)(sushiv_panel_t *p);
};
Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c 2006-12-31 21:19:24 UTC (rev 12275)
+++ trunk/sushivision/panel-1d.c 2006-12-31 22:59:36 UTC (rev 12276)
@@ -50,16 +50,6 @@
static void update_context_menus(sushiv_panel_t *p);
-static int ilog10(int x){
- int count=0;
- if(x<0)x=-x;
- while(x){
- count++;
- x/=10;
- }
- return count;
-}
-
// called internally, assumes we hold lock
// redraws the data, does not compute the data
static void _sushiv_panel1d_remap(sushiv_panel_t *p){
@@ -145,9 +135,6 @@
Plot *plot = PLOT(p->private->graph);
gdk_threads_enter ();
- int w = p1->panel_w;
- int h = p1->panel_h;
- int offset = ilog10(w>h?w:h);
if(plot){
int i,depth=0;
@@ -513,13 +500,13 @@
for(i=0;i<link->dimensions;i++){
sushiv_dimension_t *d = link->dimension_list[i].d;
if(d == p1->x_d)
- x = link->private->dim_scales[i]->dl->d->val;
+ x = link->dimension_list[i].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 = p->private->dim_scales[i]->dl->d->val;
+ x = p->dimension_list[i].d->val;
}
}
@@ -769,13 +756,11 @@
return 1;
}
-static void panel1d_undo_log(sushiv_panel_undo_t *u){
- sushiv_panel_t *p = u->p;
+static void panel1d_undo_log(sushiv_panel_undo_t *u, sushiv_panel_t *p){
sushiv_panel1d_t *p1 = p->subtype->p1;
int i;
// alloc fields as necessary
-
if(!u->mappings)
u->mappings = calloc(p->objectives,sizeof(*u->mappings));
if(!u->submappings)
@@ -787,11 +772,11 @@
if(!u->scale_vals[2])
u->scale_vals[2] = calloc(1,sizeof(**u->scale_vals));
if(!u->dim_vals[0])
- u->dim_vals[0] = calloc(p->dimensions,sizeof(**u->dim_vals));
+ u->dim_vals[0] = calloc(p->dimensions+1,sizeof(**u->dim_vals)); // +1 for possible linked dim
if(!u->dim_vals[1])
- u->dim_vals[1] = calloc(p->dimensions,sizeof(**u->dim_vals));
+ u->dim_vals[1] = calloc(p->dimensions+1,sizeof(**u->dim_vals)); // +1 for possible linked dim
if(!u->dim_vals[2])
- u->dim_vals[2] = calloc(p->dimensions,sizeof(**u->dim_vals));
+ u->dim_vals[2] = calloc(p->dimensions+1,sizeof(**u->dim_vals)); // +1 for possible linked dim
// populate undo
u->scale_vals[0][0] = slider_get_value(p1->range_slider,0);
@@ -803,11 +788,15 @@
}
for(i=0;i<p->dimensions;i++){
- 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->dim_vals[0][i] = p->dimension_list[i].d->bracket[0];
+ u->dim_vals[1][i] = p->dimension_list[i].d->val;
+ u->dim_vals[2][i] = p->dimension_list[i].d->bracket[1];
}
-
+
+ u->dim_vals[0][i] = p1->x_d->bracket[0];
+ u->dim_vals[1][i] = p1->x_d->val;
+ u->dim_vals[2][i] = p1->x_d->bracket[1];
+
u->x_d = p1->x_dnum;
u->box[0] = p1->oldbox[0];
u->box[1] = p1->oldbox[1];
@@ -815,30 +804,19 @@
}
-static void panel1d_undo_restore(sushiv_panel_undo_t *u, int *remap_flag, int *recomp_flag){
- sushiv_panel_t *p = u->p;
+static void panel1d_undo_restore(sushiv_panel_undo_t *u, sushiv_panel_t *p){
sushiv_panel1d_t *p1 = p->subtype->p1;
Plot *plot = PLOT(p->private->graph);
+ sushiv_panel_t *link = (p1->link_x?p1->link_x:p1->link_y);
+
int i;
- *remap_flag=0;
- *recomp_flag=0;
-
// go in through widgets
- if(slider_get_value(p1->range_slider,0)!=u->scale_vals[0][0] ||
- slider_get_value(p1->range_slider,1)!=u->scale_vals[1][0]){
- *remap_flag = 1;
- }
slider_set_value(p1->range_slider,0,u->scale_vals[0][0]);
slider_set_value(p1->range_slider,1,u->scale_vals[1][0]);
for(i=0;i<p->objectives;i++){
- if(gtk_combo_box_get_active(GTK_COMBO_BOX(p1->map_pulldowns[i])) != u->mappings[i] ||
- gtk_combo_box_get_active(GTK_COMBO_BOX(p1->line_pulldowns[i])) != u->submappings[i]){
- *remap_flag = 1;
- }
-
gtk_combo_box_set_active(GTK_COMBO_BOX(p1->map_pulldowns[i]),u->mappings[i]);
gtk_combo_box_set_active(GTK_COMBO_BOX(p1->line_pulldowns[i]),u->submappings[i]);
}
@@ -849,15 +827,19 @@
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]){
- if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p1->dim_xb[u->x_d]))){
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p1->dim_xb[u->x_d]),TRUE);
- *recomp_flag=1;
- }
- }
+ if(p1->dim_xb && u->x_d<p->dimensions && p1->dim_xb[u->x_d])
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p1->dim_xb[u->x_d]),TRUE);
+ /* make sure x_d is set before updating the x_d sliders! */
update_x_sel(p);
+ if(link){
+ /* doesn't matter which widget belonging to the dimension is the one that gets set */
+ sushiv_dimension_set_value(p1->x_d->private->widget_list[0],0,u->dim_vals[0][p->dimensions]);
+ sushiv_dimension_set_value(p1->x_d->private->widget_list[0],1,u->dim_vals[1][p->dimensions]);
+ sushiv_dimension_set_value(p1->x_d->private->widget_list[0],2,u->dim_vals[2][p->dimensions]);
+ }
+
if(u->box_active){
plot_box_set(plot,u->box);
p1->oldbox_active = 1;
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2006-12-31 21:19:24 UTC (rev 12275)
+++ trunk/sushivision/panel-2d.c 2006-12-31 22:59:36 UTC (rev 12276)
@@ -123,7 +123,6 @@
int h = p2->data_h;
int x = plot_get_crosshair_xpixel(plot);
int y = plot_get_crosshair_ypixel(plot);
- int offset = ilog10(w>h?w:h);
if(plot){
int i;
@@ -849,8 +848,7 @@
return 1;
}
-static void panel2d_undo_log(sushiv_panel_undo_t *u){
- sushiv_panel_t *p = u->p;
+static void panel2d_undo_log(sushiv_panel_undo_t *u, sushiv_panel_t *p){
sushiv_panel2d_t *p2 = p->subtype->p2;
int i;
@@ -858,12 +856,12 @@
if(!u->mappings)
u->mappings = calloc(p->objectives,sizeof(*u->mappings));
- if(!u->obj_vals[0])
- u->obj_vals[0] = calloc(p->objectives,sizeof(**u->obj_vals));
- if(!u->obj_vals[1])
- u->obj_vals[1] = calloc(p->objectives,sizeof(**u->obj_vals));
- if(!u->obj_vals[2])
- u->obj_vals[2] = calloc(p->objectives,sizeof(**u->obj_vals));
+ if(!u->scale_vals[0])
+ u->scale_vals[0] = calloc(p->objectives,sizeof(**u->scale_vals));
+ if(!u->scale_vals[1])
+ u->scale_vals[1] = calloc(p->objectives,sizeof(**u->scale_vals));
+ if(!u->scale_vals[2])
+ u->scale_vals[2] = calloc(p->objectives,sizeof(**u->scale_vals));
if(!u->dim_vals[0])
u->dim_vals[0] = calloc(p->dimensions,sizeof(**u->dim_vals));
if(!u->dim_vals[1])
@@ -874,9 +872,9 @@
// populate undo
for(i=0;i<p->objectives;i++){
u->mappings[i] = p2->mappings[i].mapnum;
- u->obj_vals[0][i] = slider_get_value(p2->range_scales[i],0);
- u->obj_vals[1][i] = slider_get_value(p2->range_scales[i],1);
- u->obj_vals[2][i] = slider_get_value(p2->range_scales[i],2);
+ u->scale_vals[0][i] = slider_get_value(p2->range_scales[i],0);
+ u->scale_vals[1][i] = slider_get_value(p2->range_scales[i],1);
+ u->scale_vals[2][i] = slider_get_value(p2->range_scales[i],2);
}
for(i=0;i<p->dimensions;i++){
@@ -894,28 +892,17 @@
u->box_active = p2->oldbox_active;
}
-static void panel2d_undo_restore(sushiv_panel_undo_t *u, int *remap_flag, int *recomp_flag){
- sushiv_panel_t *p = u->p;
+static void panel2d_undo_restore(sushiv_panel_undo_t *u, sushiv_panel_t *p){
sushiv_panel2d_t *p2 = p->subtype->p2;
Plot *plot = PLOT(p->private->graph);
int i;
- *remap_flag=0;
- *recomp_flag=0;
-
// go in through widgets
for(i=0;i<p->objectives;i++){
- if(gtk_combo_box_get_active(GTK_COMBO_BOX(p2->range_pulldowns[i])) != u->mappings[i] ||
- slider_get_value(p2->range_scales[i],0)!=u->obj_vals[0][i] ||
- slider_get_value(p2->range_scales[i],1)!=u->obj_vals[1][i] ||
- slider_get_value(p2->range_scales[i],2)!=u->obj_vals[2][i]){
- *remap_flag = 1;
- }
-
gtk_combo_box_set_active(GTK_COMBO_BOX(p2->range_pulldowns[i]),u->mappings[i]);
- slider_set_value(p2->range_scales[i],0,u->obj_vals[0][i]);
- slider_set_value(p2->range_scales[i],1,u->obj_vals[1][i]);
- slider_set_value(p2->range_scales[i],2,u->obj_vals[2][i]);
+ slider_set_value(p2->range_scales[i],0,u->scale_vals[0][i]);
+ slider_set_value(p2->range_scales[i],1,u->scale_vals[1][i]);
+ slider_set_value(p2->range_scales[i],2,u->scale_vals[2][i]);
}
for(i=0;i<p->dimensions;i++){
@@ -924,14 +911,8 @@
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]))){
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_xb[u->x_d]),TRUE);
- *recomp_flag=1;
- }
- if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p2->dim_yb[u->y_d]))){
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_yb[u->y_d]),TRUE);
- *recomp_flag=1;
- }
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_xb[u->x_d]),TRUE);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_yb[u->y_d]),TRUE);
update_xy_availability(p);
Modified: trunk/sushivision/undo.c
===================================================================
--- trunk/sushivision/undo.c 2006-12-31 21:19:24 UTC (rev 12275)
+++ trunk/sushivision/undo.c 2006-12-31 22:59:36 UTC (rev 12276)
@@ -50,98 +50,96 @@
}
void _sushiv_panel_undo_log(sushiv_panel_t *p){
+ sushiv_instance_t *s = p->sushi;
sushiv_panel_undo_t *u;
- int i;
+ int i,j;
if(!p->sushi->private->undo_stack)
- p->sushi->private->undo_stack = calloc(2,sizeof(*p->sushi->private->undo_stack));
+ s->private->undo_stack = calloc(2,s->panels*sizeof(*s->private->undo_stack));
// log into a fresh entry; pop this level and all above it
- if(p->sushi->private->undo_stack[p->sushi->private->undo_level]){
- i=p->sushi->private->undo_level;
- while(p->sushi->private->undo_stack[i]){
- u = p->sushi->private->undo_stack[i];
- if(u->mappings) free(u->mappings);
- if(u->scale_vals[0]) free(u->scale_vals[0]);
- if(u->scale_vals[1]) free(u->scale_vals[1]);
- if(u->scale_vals[2]) free(u->scale_vals[2]);
- if(u->obj_vals[0]) free(u->obj_vals[0]);
- if(u->obj_vals[1]) free(u->obj_vals[1]);
- if(u->obj_vals[2]) free(u->obj_vals[2]);
- if(u->dim_vals[0]) free(u->dim_vals[0]);
- if(u->dim_vals[1]) free(u->dim_vals[1]);
- if(u->dim_vals[2]) free(u->dim_vals[2]);
- free(u);
- p->sushi->private->undo_stack[i]= NULL;
+ if(s->private->undo_stack[s->private->undo_level]){
+ i=s->private->undo_level;
+ while(s->private->undo_stack[i]){
+ for(j=0;j<s->panels;j++){
+ u = s->private->undo_stack[i]+j;
+ if(u->mappings) free(u->mappings);
+ if(u->scale_vals[0]) free(u->scale_vals[0]);
+ if(u->scale_vals[1]) free(u->scale_vals[1]);
+ if(u->scale_vals[2]) free(u->scale_vals[2]);
+ if(u->dim_vals[0]) free(u->dim_vals[0]);
+ if(u->dim_vals[1]) free(u->dim_vals[1]);
+ if(u->dim_vals[2]) free(u->dim_vals[2]);
+ }
+ free(s->private->undo_stack[i]);
+ s->private->undo_stack[i]= NULL;
i++;
}
}
- // alloc new undo
- u = p->sushi->private->undo_stack[p->sushi->private->undo_level]= calloc(1,sizeof(*u));
+ // alloc new undos
+ u = s->private->undo_stack[s->private->undo_level]= calloc(s->panels,sizeof(*u));
- // pass off actual population to panel subtype
- u->p = p;
- p->private->undo_log(u);
+ // 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]);
}
void _sushiv_panel_undo_restore(sushiv_panel_t *p){
- sushiv_panel_undo_t *u = p->sushi->private->undo_stack[p->sushi->private->undo_level];
- int remap_flag=0;
- int recomp_flag=0;
-
- u->p->private->undo_restore(u, &remap_flag, &recomp_flag);
-
- if(recomp_flag)
- u->p->private->request_compute(u->p);
- else if(remap_flag){
- u->p->private->map_redraw(u->p);
- u->p->private->legend_redraw(u->p);
- }else
- plot_expose_request(PLOT(u->p->private->graph));
+ sushiv_instance_t *s = p->sushi;
+ int i;
+
+ for(i=0;i<s->panels;i++){
+ sushiv_panel_undo_t *u = &s->private->undo_stack[s->private->undo_level][i];
+
+ s->panel_list[i]->private->undo_restore(u,s->panel_list[i]);
+ plot_expose_request(PLOT(s->panel_list[i]->private->graph));
+ }
}
void _sushiv_panel_undo_push(sushiv_panel_t *p){
+ sushiv_instance_t *s = p->sushi;
- if(p->sushi->private->undo_suspend)return;
+ if(s->private->undo_suspend)return;
_sushiv_panel_undo_log(p);
// realloc stack
- p->sushi->private->undo_stack =
- realloc(p->sushi->private->undo_stack,
- (p->sushi->private->undo_level+3)*sizeof(*p->sushi->private->undo_stack));
- p->sushi->private->undo_level++;
- p->sushi->private->undo_stack[p->sushi->private->undo_level]=NULL;
- p->sushi->private->undo_stack[p->sushi->private->undo_level+1]=NULL;
- update_all_menus(p->sushi);
-
+ s->private->undo_stack =
+ realloc(s->private->undo_stack,
+ (s->private->undo_level+3)*sizeof(*s->private->undo_stack));
+ s->private->undo_level++;
+ s->private->undo_stack[s->private->undo_level]=NULL;
+ s->private->undo_stack[s->private->undo_level+1]=NULL;
+ update_all_menus(s);
}
void _sushiv_panel_undo_up(sushiv_panel_t *p){
+ sushiv_instance_t *s = p->sushi;
- if(!p->sushi->private->undo_stack)return;
- if(!p->sushi->private->undo_stack[p->sushi->private->undo_level])return;
- if(!p->sushi->private->undo_stack[p->sushi->private->undo_level+1])return;
+ if(!s->private->undo_stack)return;
+ if(!s->private->undo_stack[s->private->undo_level])return;
+ if(!s->private->undo_stack[s->private->undo_level+1])return;
- p->sushi->private->undo_level++;
+ s->private->undo_level++;
_sushiv_panel_undo_suspend(p);
_sushiv_panel_undo_restore(p);
_sushiv_panel_undo_resume(p);
- update_all_menus(p->sushi);
+ update_all_menus(s);
}
void _sushiv_panel_undo_down(sushiv_panel_t *p){
+ sushiv_instance_t *s = p->sushi;
- if(!p->sushi->private->undo_stack)return;
- if(!p->sushi->private->undo_level)return;
+ if(!s->private->undo_stack)return;
+ if(!s->private->undo_level)return;
- if(!p->sushi->private->undo_stack[p->sushi->private->undo_level+1])
+ if(!s->private->undo_stack[s->private->undo_level+1])
_sushiv_panel_undo_log(p);
- p->sushi->private->undo_level--;
+ s->private->undo_level--;
_sushiv_panel_undo_suspend(p);
_sushiv_panel_undo_restore(p);
_sushiv_panel_undo_resume(p);
- update_all_menus(p->sushi);
+ update_all_menus(s);
}
More information about the commits
mailing list