From 8eaa91cf9544e35e54e45b93417e273dfcc66820 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sun, 27 Jan 2002 20:24:54 +0000 Subject: [PATCH] New 'Rewind' button + new 'Cycle through views' animation option --- Common/Bitmaps.h | 8 +++++ Common/Context.h | 2 +- Common/DefaultOptions.h | 2 ++ Common/Options.cpp | 17 +++++++++-- Common/Options.h | 1 + Fltk/Callbacks.cpp | 59 ++++++++++++++++++++++++++---------- Fltk/Callbacks.h | 1 + Fltk/GUI.cpp | 66 ++++++++++++++++++++++++++++------------- Fltk/GUI.h | 5 ++-- 9 files changed, 120 insertions(+), 41 deletions(-) diff --git a/Common/Bitmaps.h b/Common/Bitmaps.h index fd78a65d29..459e765082 100644 --- a/Common/Bitmaps.h +++ b/Common/Bitmaps.h @@ -132,4 +132,12 @@ static char stop_bits[] = { 0x00,0xfe,0xee,0xfe,0xaa,0xfe,0xaa,0xfe,0xaa,0xfe,0xaa,0xfe,0xaa,0xfe,0xaa, 0xfe,0xaa,0xfe,0xaa,0xfe,0xaa,0xfe,0xee,0xfe,0x00,0xfe}; +// 'Rewind button' bitmap +#define rewind_width 12 +#define rewind_height 13 +static char rewind_bits[] = { + 0x00,0xf0,0x0e,0xf6,0x0a,0xf5,0x8a,0xf4,0x4a,0xf4,0x2a,0xf4,0x1a,0xf4,0x2a, + 0xf4,0x4a,0xf4,0x8a,0xf4,0x0a,0xf5,0x0e,0xf6,0x00,0xf0}; + + #endif diff --git a/Common/Context.h b/Common/Context.h index 98eaa52d6e..cb658e7f5e 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -149,7 +149,7 @@ public : List_T *list ; int force_num, compute_bb; int draw, scales, link ; - int smooth ; + int smooth, anim_cycle ; double anim_delay ; }post; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 8325e35438..60b079b2ed 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -761,6 +761,8 @@ StringXNumber SolverOptions_Number[] = { StringXNumber PostProcessingOptions_Number[] = { { F|O, "AnimationDelay" , opt_post_anim_delay , 0.25 , "Delay (in seconds) between to animation frames" }, + { F|O, "AnimationCycle" , opt_post_anim_cycle , 0. , + "Cycle through views instead of time steps for the animation" }, { F|O, "Link" , opt_post_link , 0. , "Link post-processing views (0=none, 1,2=changes in visible/all, 3,4=everything in visible/all)" }, diff --git a/Common/Options.cpp b/Common/Options.cpp index 315fd761a2..ea5bc223e8 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.68 2002-01-03 10:25:06 geuzaine Exp $ +// $Id: Options.cpp,v 1.69 2002-01-27 20:24:54 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -2045,7 +2045,7 @@ double opt_post_smooth(OPT_ARGS_NUM){ CTX.post.smooth = (int)val; #ifdef _FLTK if(WID && (action & GMSH_GUI)) - WID->post_butt[3]->value(CTX.post.smooth); + WID->post_butt[5]->value(CTX.post.smooth); #endif return CTX.post.smooth; } @@ -2058,6 +2058,15 @@ double opt_post_anim_delay(OPT_ARGS_NUM){ #endif return CTX.post.anim_delay; } +double opt_post_anim_cycle(OPT_ARGS_NUM){ + if(action & GMSH_SET) + CTX.post.anim_cycle = (int)val; +#ifdef _FLTK + if(WID && (action & GMSH_GUI)) + WID->post_butt[6]->value(CTX.post.anim_cycle); +#endif + return CTX.post.anim_cycle; +} double opt_post_nb_views(OPT_ARGS_NUM){ return List_Nbr(CTX.post.list); } @@ -2071,8 +2080,10 @@ double opt_view_nb_timestep(OPT_ARGS_NUM){ #ifdef _FLTK if(WID && (action & GMSH_GUI) && (num == WID->view_number)) WID->view_value[50]->maximum(v->NbTimeStep-1); - if(WID && (action & GMSH_GUI) && v->NbTimeStep > 1) + if(WID && (action & GMSH_GUI) && v->NbTimeStep > 1){ WID->g_status_butt[5]->activate(); + WID->g_status_butt[6]->activate(); + } #endif return v->NbTimeStep; } diff --git a/Common/Options.h b/Common/Options.h index f6854ebf9b..0e11dd1c59 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -360,6 +360,7 @@ double opt_post_scales(OPT_ARGS_NUM); double opt_post_link(OPT_ARGS_NUM); double opt_post_smooth(OPT_ARGS_NUM); double opt_post_anim_delay(OPT_ARGS_NUM); +double opt_post_anim_cycle(OPT_ARGS_NUM); double opt_post_nb_views(OPT_ARGS_NUM); double opt_post_color_scheme(OPT_ARGS_NUM); double opt_view_nb_timestep(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 1a471b8633..0b1b1f5ac8 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.102 2002-01-26 01:25:20 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.103 2002-01-27 20:24:54 geuzaine Exp $ #include <sys/types.h> #include <signal.h> @@ -146,19 +146,30 @@ void status_xyz1p_cb(CALLBACK_ARGS){ } } -static int stop_anim ; +static int stop_anim, view_in_cycle=0 ; void status_play_cb(CALLBACK_ARGS){ static long anim_time ; int i; - WID->set_anim(0); + WID->set_anim_buttons(0); stop_anim = 0 ; anim_time = GetTime(); while(1){ if(stop_anim) break ; if(GetTime() - anim_time > 1.e6*CTX.post.anim_delay){ anim_time = GetTime(); - for(i=0 ; i<List_Nbr(CTX.post.list) ; i++) - opt_view_timestep(i, GMSH_SET|GMSH_GUI, opt_view_timestep(i, GMSH_GET, 0)+1); + if(!CTX.post.anim_cycle){ + for(i=0 ; i<List_Nbr(CTX.post.list) ; i++) + opt_view_timestep(i, GMSH_SET|GMSH_GUI, opt_view_timestep(i, GMSH_GET, 0)+1); + } + else{//hide all views except view_in_cycle + for(i=0 ; i<List_Nbr(CTX.post.list) ; i++){ + if(i == view_in_cycle) + opt_view_visible(i, GMSH_SET|GMSH_GUI, 1); + else + opt_view_visible(i, GMSH_SET|GMSH_GUI, 0); + } + if(++view_in_cycle>=List_Nbr(CTX.post.list)) view_in_cycle=0; + } Draw(); } WID->check(); @@ -167,7 +178,25 @@ void status_play_cb(CALLBACK_ARGS){ void status_pause_cb(CALLBACK_ARGS){ stop_anim = 1; - WID->set_anim(1); + WID->set_anim_buttons(1); +} + +void status_rewind_cb(CALLBACK_ARGS){ + int i; + if(!CTX.post.anim_cycle){ + for(i=0 ; i<List_Nbr(CTX.post.list) ; i++) + opt_view_timestep(i, GMSH_SET|GMSH_GUI, 0); + } + else{ + view_in_cycle = 0; + for(i=0 ; i<List_Nbr(CTX.post.list) ; i++){ + if(!i) + opt_view_visible(i, GMSH_SET|GMSH_GUI, 1); + else + opt_view_visible(i, GMSH_SET|GMSH_GUI, 0); + } + } + Draw(); } void status_cancel_cb(CALLBACK_ARGS){ @@ -481,7 +510,14 @@ void opt_post_ok_cb(CALLBACK_ARGS) { WID->post_butt[2]->value()?2: WID->post_butt[3]->value()?3: 4); - opt_post_smooth(0, GMSH_SET, WID->post_butt[3]->value()); + opt_post_smooth(0, GMSH_SET, WID->post_butt[5]->value()); + opt_post_anim_cycle(0, GMSH_SET, WID->post_butt[6]->value()); + if(WID->post_butt[6]->value()){ + WID->g_status_butt[5]->activate(); + WID->g_status_butt[6]->activate(); + } + else + WID->check_anim_buttons(); opt_post_anim_delay(0, GMSH_SET, WID->post_value[0]->value()); Draw(); @@ -1787,16 +1823,9 @@ void view_remove_invisible_cb(CALLBACK_ARGS) { } void view_remove_cb(CALLBACK_ARGS){ - int i, play=0; - FreeView((long int)data); - for(i=0 ; i<List_Nbr(CTX.post.list) ; i++) - if(((Post_View*)List_Pointer(CTX.post.list,i))->NbTimeStep > 1){ - play = 1 ; - break ; - } - if(!play) WID->g_status_butt[5]->deactivate(); + WID->check_anim_buttons(); if(WID->get_context() == 3) WID->set_context(menu_post, 0); diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h index 9580932b88..2cac29d31a 100644 --- a/Fltk/Callbacks.h +++ b/Fltk/Callbacks.h @@ -16,6 +16,7 @@ void set_changed_cb(CALLBACK_ARGS); void status_xyz1p_cb(CALLBACK_ARGS) ; void status_play_cb(CALLBACK_ARGS) ; void status_pause_cb(CALLBACK_ARGS) ; +void status_rewind_cb(CALLBACK_ARGS) ; void status_cancel_cb(CALLBACK_ARGS) ; // File Menu diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index e25cbcc6ad..8b59f97c23 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.144 2002-01-26 01:25:20 geuzaine Exp $ +// $Id: GUI.cpp,v 1.145 2002-01-27 20:24:54 geuzaine Exp $ // To make the interface as visually consistent as possible, please: // - use the IW, BB, BH, BW and WB values @@ -865,20 +865,27 @@ void GUI::create_graphic_window(int argc, char **argv){ g_status_butt[4]->callback(status_xyz1p_cb, (void*)4); //g_status_butt[4]->tooltip("Show current options"); g_status_butt[5] = new Fl_Button(x,glheight+2,sw,sh-4); x+=sw; - g_status_butt[5]->callback(status_play_cb); - start_bmp = new Fl_Bitmap(start_bits,start_width,start_height); - start_bmp->label(g_status_butt[5]); - stop_bmp = new Fl_Bitmap(stop_bits,stop_width,stop_height); + g_status_butt[5]->callback(status_rewind_cb); + rewind_bmp = new Fl_Bitmap(rewind_bits,rewind_width,rewind_height); + rewind_bmp->label(g_status_butt[5]); g_status_butt[5]->deactivate(); //g_status_butt[5]->tooltip("Play/pause animation"); - /* g_status_butt[6] = new Fl_Button(x,glheight+2,sw,sh-4); x+=sw; - g_status_butt[6]->callback(status_cancel_cb); - abort_bmp = new Fl_Bitmap(abort_bits,abort_width,abort_height); - abort_bmp->label(g_status_butt[6]); + g_status_butt[6]->callback(status_play_cb); + start_bmp = new Fl_Bitmap(start_bits,start_width,start_height); + start_bmp->label(g_status_butt[6]); + stop_bmp = new Fl_Bitmap(stop_bits,stop_width,stop_height); g_status_butt[6]->deactivate(); + //g_status_butt[6]->tooltip("Play/pause animation"); + + /* + g_status_butt[7] = new Fl_Button(x,glheight+2,sw,sh-4); x+=sw; + g_status_butt[7]->callback(status_cancel_cb); + abort_bmp = new Fl_Bitmap(abort_bits,abort_width,abort_height); + abort_bmp->label(g_status_butt[7]); + g_status_butt[7]->deactivate(); */ - for(i = 0 ; i<6/*7*/ ; i++){ + for(i = 0 ; i<7 ; i++){ g_status_butt[i]->box(FL_FLAT_BOX); g_status_butt[i]->selection_color(FL_WHITE); g_status_butt[i]->labelsize(CTX.fontsize); @@ -914,14 +921,27 @@ void GUI::set_title(char *str){ // Set animation button -void GUI::set_anim(int mode){ +void GUI::set_anim_buttons(int mode){ if(mode){ - g_status_butt[5]->callback(status_play_cb); - start_bmp->label(g_status_butt[5]); + g_status_butt[6]->callback(status_play_cb); + start_bmp->label(g_status_butt[6]); } else{ - g_status_butt[5]->callback(status_pause_cb); - stop_bmp->label(g_status_butt[5]); + g_status_butt[6]->callback(status_pause_cb); + stop_bmp->label(g_status_butt[6]); + } +} + +void GUI::check_anim_buttons(){ + int i, play=0; + for(i=0 ; i<List_Nbr(CTX.post.list) ; i++) + if(((Post_View*)List_Pointer(CTX.post.list,i))->NbTimeStep > 1){ + play = 1 ; + break ; + } + if(!play){ + g_status_butt[5]->deactivate(); + g_status_butt[6]->deactivate(); } } @@ -1572,11 +1592,11 @@ void GUI::create_post_options_window(){ { Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Smoothing"); o->labelsize(CTX.fontsize); - post_butt[3] = new Fl_Check_Button(2*WB, 2*WB+1*BH, BW, BH, "Smooth views during merge"); - post_butt[3]->type(FL_TOGGLE_BUTTON); - post_butt[3]->down_box(TOGGLE_BOX); - post_butt[3]->labelsize(CTX.fontsize); - post_butt[3]->selection_color(TOGGLE_COLOR); + post_butt[5] = new Fl_Check_Button(2*WB, 2*WB+1*BH, BW, BH, "Smooth views during merge"); + post_butt[5]->type(FL_TOGGLE_BUTTON); + post_butt[5]->down_box(TOGGLE_BOX); + post_butt[5]->labelsize(CTX.fontsize); + post_butt[5]->selection_color(TOGGLE_COLOR); o->end(); } { @@ -1591,6 +1611,12 @@ void GUI::create_post_options_window(){ post_value[0]->textsize(CTX.fontsize); post_value[0]->type(FL_HORIZONTAL); post_value[0]->align(FL_ALIGN_RIGHT); + + post_butt[6] = new Fl_Check_Button(2*WB, 2*WB+2*BH, BW, BH, "Cycle through views instead of time steps"); + post_butt[6]->type(FL_TOGGLE_BUTTON); + post_butt[6]->down_box(TOGGLE_BOX); + post_butt[6]->labelsize(CTX.fontsize); + post_butt[6]->selection_color(TOGGLE_COLOR); o->end(); } o->end(); diff --git a/Fltk/GUI.h b/Fltk/GUI.h index 07d2a1f782..ccfa3b4af6 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -95,7 +95,7 @@ class GUI{ int MH ; // Bitmaps - Fl_Bitmap *abort_bmp, *start_bmp, *stop_bmp, *about_bmp ; + Fl_Bitmap *abort_bmp, *start_bmp, *stop_bmp, *rewind_bmp, *about_bmp ; void add_post_plugins ( Fl_Menu_Button *button , int iView); void add_multiline_in_browser(Fl_Browser *o, char* prefix, char *str); @@ -220,7 +220,8 @@ public: void set_menu_size(int nb_butt); void set_context(Context_Item menu[], int flag); int get_context(); - void set_anim(int mode); + void set_anim_buttons(int mode); + void check_anim_buttons(); void set_status(char *msg, int num); void add_message(char *msg); void save_message(char *filename); -- GitLab