From ae1dac973d07eccb94acd434e625deb94b66e8e6 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 13 Jan 2004 12:39:46 +0000
Subject: [PATCH] New post-processing range mode to adapt the scale for each
 time step (i.e., min/max is time step dependent)

---
 Common/CommandLine.cpp   |  6 ++--
 Common/DefaultOptions.h  |  6 ++--
 Common/Options.cpp       | 19 +++++++---
 Common/Views.cpp         | 76 ++++++++++++++++++++++++++++++++++------
 Common/Views.h           |  9 ++---
 Fltk/Callbacks.cpp       | 55 +++++++++++++++++++----------
 Fltk/GUI.cpp             | 36 +++++++++++--------
 Fltk/Message.cpp         |  4 +--
 Graphics/Graph2D.cpp     | 12 ++++---
 Graphics/Post.cpp        | 20 ++++++-----
 Graphics/PostElement.cpp |  5 ++-
 Graphics/Scale.cpp       | 17 ++++++---
 Makefile                 |  8 ++---
 TODO                     |  7 +---
 doc/VERSIONS             |  5 +--
 15 files changed, 194 insertions(+), 91 deletions(-)

diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index 443459bdd0..dd5f2e9954 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -1,6 +1,6 @@
-// $Id: CommandLine.cpp,v 1.23 2003-11-27 02:33:31 geuzaine Exp $
+// $Id: CommandLine.cpp,v 1.24 2004-01-13 12:39:44 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ char *TheBgmFileName = NULL, *TheOptString = NULL;
 // *INDENT-OFF*
 
 char gmsh_progname[]  = "This is Gmsh" ;
-char gmsh_copyright[] = "Copyright (C) 1997-2003 Jean-Francois Remacle and Christophe Geuzaine";
+char gmsh_copyright[] = "Copyright (C) 1997-2004 Jean-Francois Remacle and Christophe Geuzaine";
 char gmsh_version[]   = "Version        : " ;
 char gmsh_license[]   = "License        : " GMSH_SHORT_LICENSE;
 char gmsh_gui[]       = "GUI toolkit    : " ;
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index ae9392784d..3e1602e697 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -1,7 +1,7 @@
 #ifndef _DEFAULT_OPTIONS_H_
 #define _DEFAULT_OPTIONS_H_
 
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -978,8 +978,8 @@ StringXNumber ViewOptions_Number[] = {
     "Elevation of the view along Y-axis (in model coordinates)" },
   { F,   "RaiseZ" , opt_view_raise2 , 0. , 
     "Elevation of the view along Z-axis (in model coordinates)" },
-  { F|O, "RangeType" , opt_view_range_type , DRAW_POST_DEFAULT ,
-    "Value scale range type (1=default, 2=custom)" },
+  { F|O, "RangeType" , opt_view_range_type , DRAW_POST_RANGE_DEFAULT ,
+    "Value scale range type (1=default, 2=custom, 3=per time step)" },
 
   { F|O, "SaturateValues" , opt_view_saturate_values , 0. ,
     "Saturate the view values to custom min and max (1=true, 0=false)" },
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 528a3e1b8f..33f889743a 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,6 +1,6 @@
-// $Id: Options.cpp,v 1.129 2003-12-08 19:18:13 geuzaine Exp $
+// $Id: Options.cpp,v 1.130 2004-01-13 12:39:44 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -4425,8 +4425,19 @@ double opt_view_range_type(OPT_ARGS_NUM)
     v->Changed = 1;
   }
 #if defined(HAVE_FLTK)
-  if(WID && (action & GMSH_GUI) && (num == WID->view_number))
-    WID->view_butt[34]->value(v->RangeType == DRAW_POST_CUSTOM);
+  if(WID && (action & GMSH_GUI) && (num == WID->view_number)){
+    switch(v->RangeType){
+    case DRAW_POST_RANGE_DEFAULT:
+      WID->view_choice[7]->value(0);
+      break;
+    case DRAW_POST_RANGE_PER_STEP:
+      WID->view_choice[7]->value(1);
+      break;
+    case DRAW_POST_RANGE_CUSTOM:
+      WID->view_choice[7]->value(2);
+      break;
+    }
+  }
 #endif
   return v->RangeType;
 }
diff --git a/Common/Views.cpp b/Common/Views.cpp
index 65ba45c524..de0f4812fd 100644
--- a/Common/Views.cpp
+++ b/Common/Views.cpp
@@ -1,6 +1,6 @@
-// $Id: Views.cpp,v 1.106 2003-11-29 03:15:04 geuzaine Exp $
+// $Id: Views.cpp,v 1.107 2004-01-13 12:39:44 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -77,6 +77,8 @@ Post_View *BeginView(int allocate)
   v->Dirty = 1;
   v->DisplayListNum = -1;
   v->NbTimeStep = 0;
+  v->TimeStepMin = NULL;
+  v->TimeStepMax = NULL;
   v->NbSP = v->NbVP = v->NbTP = 0;
   v->NbSL = v->NbVL = v->NbTL = 0;
   v->NbST = v->NbVT = v->NbTT = 0;
@@ -193,15 +195,31 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N,
       v->Min = V[0];
       v->Max = V[0];
       v->NbTimeStep = N / nbnod;
+      v->TimeStepMin = (double*)Malloc(v->NbTimeStep * sizeof(double));
+      v->TimeStepMax = (double*)Malloc(v->NbTimeStep * sizeof(double));
+      for(i = 0; i < v->NbTimeStep; i++){
+	v->TimeStepMin[i] = V[0];
+	v->TimeStepMax[i] = V[0];
+      }
     }
-    else if(N / nbnod < v->NbTimeStep)
+    else if(N / nbnod < v->NbTimeStep){
+      // if some elts have less steps, reduce the total number!
       v->NbTimeStep = N / nbnod;
+    }
 
     for(i = 0; i < N; i++) {
-      if(V[i] < v->Min)
-        v->Min = V[i];
-      if(V[i] > v->Max)
-        v->Max = V[i];
+      l0 = V[i];
+      if(l0 < v->Min)
+        v->Min = l0;
+      if(l0 > v->Max)
+        v->Max = l0;
+      int ts = i / nbnod;
+      if(ts < v->NbTimeStep){ // security
+	if(l0 < v->TimeStepMin[ts])
+	  v->TimeStepMin[ts] = l0;
+	if(l0 > v->TimeStepMax[ts])
+	  v->TimeStepMax[ts] = l0;
+      }
     }
     break;
 
@@ -211,9 +229,16 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N,
       v->Min = l0;
       v->Max = l0;
       v->NbTimeStep = N / (3 * nbnod);
+      v->TimeStepMin = (double*)Malloc(v->NbTimeStep * sizeof(double));
+      v->TimeStepMax = (double*)Malloc(v->NbTimeStep * sizeof(double));
+      for(i = 0; i < v->NbTimeStep; i++){
+	v->TimeStepMin[i] = l0;
+	v->TimeStepMax[i] = l0;
+      }
     }
-    else if(N / (3 * nbnod) < v->NbTimeStep)
+    else if(N / (3 * nbnod) < v->NbTimeStep){
       v->NbTimeStep = N / (3 * nbnod);
+    }
 
     for(i = 0; i < N; i += 3) {
       l0 = sqrt(DSQR(V[i]) + DSQR(V[i + 1]) + DSQR(V[i + 2]));
@@ -221,6 +246,13 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N,
         v->Min = l0;
       if(l0 > v->Max)
         v->Max = l0;
+      int ts = i / (3 * nbnod);
+      if(ts < v->NbTimeStep){ // security
+	if(l0 < v->TimeStepMin[ts])
+	  v->TimeStepMin[ts] = l0;
+	if(l0 > v->TimeStepMax[ts])
+	  v->TimeStepMax[ts] = l0;
+      }
     }
     v->ScalarOnly = 0;
     break;
@@ -234,9 +266,16 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N,
       v->Min = l0;
       v->Max = l0;
       v->NbTimeStep = N / (9 * nbnod);
+      v->TimeStepMin = (double*)Malloc(v->NbTimeStep * sizeof(double));
+      v->TimeStepMax = (double*)Malloc(v->NbTimeStep * sizeof(double));
+      for(i = 0; i < v->NbTimeStep; i++){
+	v->TimeStepMin[i] = l0;
+	v->TimeStepMax[i] = l0;
+      }
     }
-    else if(N / (9 * nbnod) < v->NbTimeStep)
+    else if(N / (9 * nbnod) < v->NbTimeStep){
       v->NbTimeStep = N / (9 * nbnod);
+    }
 
     for(i = 0; i < N; i += 9) {
       l0 = ComputeVonMises(V+i);
@@ -244,6 +283,13 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N,
         v->Min = l0;
       if(l0 > v->Max)
         v->Max = l0;
+      int ts = i / (9 * nbnod);
+      if(ts < v->NbTimeStep){ // security
+	if(l0 < v->TimeStepMin[ts])
+	  v->TimeStepMin[ts] = l0;
+	if(l0 > v->TimeStepMax[ts])
+	  v->TimeStepMax[ts] = l0;
+      }
     }
     v->ScalarOnly = 0;
     break;
@@ -336,6 +382,10 @@ void EndView(Post_View * v, int add_in_gui, char *file_name, char *name)
     }
   }
 
+  //for(i = 0; i < v->NbTimeStep; i++) {
+  //  printf("step %d, min %g, max %g\n", i, v->TimeStepMin[i], v->TimeStepMax[i]);
+  //}
+
   opt_view_name(v->Index, GMSH_SET | GMSH_GUI, name);
   opt_view_filename(v->Index, GMSH_SET | GMSH_GUI, file_name);
   opt_view_nb_timestep(v->Index, GMSH_GUI, 0);
@@ -399,6 +449,8 @@ void DuplicateView(Post_View * v1, int withoptions)
   // *INDENT-OFF*
 
   v2->Time = v1->Time;
+  v2->TimeStepMin = v1->TimeStepMin;
+  v2->TimeStepMax = v1->TimeStepMax;
 
   v2->NbSP = v1->NbSP; v2->SP = v1->SP; 
   v2->NbVP = v1->NbVP; v2->VP = v1->VP; 
@@ -522,6 +574,8 @@ void FreeView(Post_View * v)
   if(free && !v->Links) {
     Msg(DEBUG, "Freeing View!");
     List_Delete(v->Time);
+    Free(v->TimeStepMin);
+    Free(v->TimeStepMax);
     // *INDENT-OFF*
     List_Delete(v->SP); List_Delete(v->VP); List_Delete(v->TP);
     List_Delete(v->SL); List_Delete(v->VL); List_Delete(v->TL);
@@ -538,6 +592,8 @@ void FreeView(Post_View * v)
     //+ the reload does not work (e.g. the file is gone). This way,
     //the next Free stuff will still work gracefully.
     v->Time = NULL;
+    v->TimeStepMin = NULL;
+    v->TimeStepMax = NULL;
     v->SP = v->VP = v->TP = NULL;
     v->SL = v->VL = v->TL = NULL;
     v->ST = v->VT = v->TT = NULL;
@@ -676,7 +732,7 @@ Post_View *Create2DGraph(char *xname, char *yname,
   return v;
 }
 
-// INput/output
+// Input/output
 
 void ReadView(FILE *file, char *filename)
 {
diff --git a/Common/Views.h b/Common/Views.h
index 2c23cc4c0e..3471dd26f5 100644
--- a/Common/Views.h
+++ b/Common/Views.h
@@ -1,7 +1,7 @@
 #ifndef _VIEWS_H_
 #define _VIEWS_H_
 
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@ class Post_View{
   // the data
   int DataSize; // size(double) or sizeof(float)
   int NbTimeStep, ScalarOnly, TextOnly;
-  double Min, Max, BBox[6];
+  double Min, Max, BBox[6], *TimeStepMin, *TimeStepMax;
   List_T *Time;
   int NbSP, NbVP, NbTP;
   List_T *SP, *VP, *TP; // points
@@ -128,8 +128,9 @@ class Post_View{
 #define DRAW_POST_EIGENVECTORS  1
 
 // RangeType
-#define DRAW_POST_DEFAULT 1
-#define DRAW_POST_CUSTOM  2
+#define DRAW_POST_RANGE_DEFAULT  1
+#define DRAW_POST_RANGE_CUSTOM   2
+#define DRAW_POST_RANGE_PER_STEP 3
 
 // ScaleType
 #define DRAW_POST_LINEAR             1
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 1b8895cc1c..467bde6236 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,6 +1,6 @@
-// $Id: Callbacks.cpp,v 1.198 2003-12-07 15:30:59 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.199 2004-01-13 12:39:45 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -3008,7 +3008,9 @@ void view_options_plugin_cb(CALLBACK_ARGS)
 
 void view_options_custom_cb(CALLBACK_ARGS)
 {
-  if(WID->view_butt[34]->value()) {
+  int custom = (int)data;
+    
+  if(custom){
     WID->view_value[31]->activate();
     WID->view_value[32]->activate();
   }
@@ -3016,6 +3018,8 @@ void view_options_custom_cb(CALLBACK_ARGS)
     WID->view_value[31]->deactivate();
     WID->view_value[32]->deactivate();
   }
+
+  if(w) w->set_changed();
 }
 
 void view_options_timestep_cb(CALLBACK_ARGS)
@@ -3076,19 +3080,7 @@ void view_options_ok_cb(CALLBACK_ARGS)
       if(links == 3 || links == 4)
         force = 1;
 
-      // view_butts
-
-      //not this one. if(WID->view_butt[34]->changed())
-      opt_view_range_type(i, GMSH_SET,
-                          WID->view_butt[34]->value()? DRAW_POST_CUSTOM :
-                          DRAW_POST_DEFAULT);
-
-      if(force || WID->view_butt[1]->changed() ||
-         WID->view_butt[2]->changed() || WID->view_butt[3]->changed())
-        opt_view_type(i, GMSH_SET,
-                      WID->view_butt[1]->value()? DRAW_POST_3D :
-                      WID->view_butt[2]->value()? DRAW_POST_2D_SPACE :
-                      DRAW_POST_2D_TIME);
+      // view_choice
 
       if(force || WID->view_choice[1]->changed()) {
         int val;
@@ -3106,9 +3098,6 @@ void view_options_ok_cb(CALLBACK_ARGS)
         opt_view_scale_type(i, GMSH_SET, val);
       }
 
-      if(force || WID->view_butt[38]->changed())
-        opt_view_saturate_values(i, GMSH_SET, WID->view_butt[38]->value());
-
       if(force || WID->view_choice[0]->changed()) {
         int val;
         switch (WID->view_choice[0]->value()) {
@@ -3202,6 +3191,34 @@ void view_options_ok_cb(CALLBACK_ARGS)
         opt_view_tensor_type(i, GMSH_SET, val);
       }
 
+      if(force || WID->view_choice[7]->changed()) {
+        int val;
+        switch (WID->view_choice[7]->value()) {
+        case 0:
+          val = DRAW_POST_RANGE_DEFAULT;
+          break;
+        case 1:
+          val = DRAW_POST_RANGE_PER_STEP;
+          break;
+        default:
+          val = DRAW_POST_RANGE_CUSTOM;
+          break;
+        }
+        opt_view_range_type(i, GMSH_SET, val);
+      }
+
+      // view_butts
+
+      if(force || WID->view_butt[1]->changed() ||
+         WID->view_butt[2]->changed() || WID->view_butt[3]->changed())
+        opt_view_type(i, GMSH_SET,
+                      WID->view_butt[1]->value()? DRAW_POST_3D :
+                      WID->view_butt[2]->value()? DRAW_POST_2D_SPACE :
+                      DRAW_POST_2D_TIME);
+
+      if(force || WID->view_butt[38]->changed())
+        opt_view_saturate_values(i, GMSH_SET, WID->view_butt[38]->value());
+
       if(force || WID->view_butt[10]->changed())
         opt_view_show_element(i, GMSH_SET, WID->view_butt[10]->value());
 
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index b99b63ccb7..b6020e455c 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,6 +1,6 @@
-// $Id: GUI.cpp,v 1.265 2003-12-07 00:23:07 geuzaine Exp $
+// $Id: GUI.cpp,v 1.266 2004-01-13 12:39:45 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -2100,14 +2100,21 @@ void GUI::create_option_window()
       view_choice[0]->align(FL_ALIGN_RIGHT);
       view_choice[0]->callback(set_changed_cb, 0);
 
-      view_butt[34] = new Fl_Check_Button(2 * WB, 2 * WB + 3 * BH, IW, BH, "Custom range");
-      view_butt[34]->type(FL_TOGGLE_BUTTON);
-      view_butt[34]->down_box(TOGGLE_BOX);
-      view_butt[34]->selection_color(TOGGLE_COLOR);
-      //no set_changed since customrange has its own callback
-
-      view_value[31] = new Fl_Value_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Minimum");
-      view_value[32] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "Maximum");
+      static Fl_Menu_Item menu_range[] = {
+        {"Default", 0, (Fl_Callback *)view_options_custom_cb, (void*)0},
+        {"Per time step", 0, (Fl_Callback *)view_options_custom_cb, (void*)0},
+        {"Custom", 0, (Fl_Callback *)view_options_custom_cb, (void*)1},
+        {0}
+      };
+      view_choice[7] = new Fl_Choice(2 * WB, 2 * WB + 3 * BH, IW, BH, "Range type");
+      view_choice[7]->menu(menu_range);
+      view_choice[7]->align(FL_ALIGN_RIGHT);
+      // won't work, since the items have their own callbaks; the
+      // changed flag has to be set in view_options_custom_cb!
+      //view_choice[7]->callback(set_changed_cb, 0);
+
+      view_value[31] = new Fl_Value_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Custom minimum");
+      view_value[32] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "Custom maximum");
       for(i = 31; i <= 32; i++) {
         view_value[i]->align(FL_ALIGN_RIGHT);
         view_value[i]->callback(set_changed_cb, 0);
@@ -2318,15 +2325,16 @@ void GUI::update_view_window(int num)
   // range
   opt_view_nb_iso(num, GMSH_GUI, 0);
   opt_view_intervals_type(num, GMSH_GUI, 0);
-  opt_view_range_type(num, GMSH_GUI, 0);
-  view_butt[34]->callback(view_options_custom_cb, (void *)num);
-  view_options_custom_cb(0, 0);
-  view_butt[34]->clear_changed();
+  int range_type = (int)opt_view_range_type(num, GMSH_GUI, 0);
   opt_view_custom_min(num, GMSH_GUI, 0);
   opt_view_custom_max(num, GMSH_GUI, 0);
   for(i = 31; i <= 32; i++) {
     view_value[i]->minimum(v->CustomMin);
     view_value[i]->maximum(v->CustomMax);
+    if(range_type == DRAW_POST_RANGE_CUSTOM)
+      view_options_custom_cb(NULL, (void*)1);
+    else
+      view_options_custom_cb(NULL, (void*)0);
   }
   opt_view_scale_type(num, GMSH_GUI, 0);
   opt_view_saturate_values(num, GMSH_GUI, 0);
diff --git a/Fltk/Message.cpp b/Fltk/Message.cpp
index 44d3cc0e46..5df656bc35 100644
--- a/Fltk/Message.cpp
+++ b/Fltk/Message.cpp
@@ -1,6 +1,6 @@
-// $Id: Message.cpp,v 1.43 2003-11-27 02:33:31 geuzaine Exp $
+// $Id: Message.cpp,v 1.44 2004-01-13 12:39:45 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
diff --git a/Graphics/Graph2D.cpp b/Graphics/Graph2D.cpp
index 90c80ef431..d66a39152a 100644
--- a/Graphics/Graph2D.cpp
+++ b/Graphics/Graph2D.cpp
@@ -1,6 +1,6 @@
-// $Id: Graph2D.cpp,v 1.29 2003-11-28 19:15:29 geuzaine Exp $
+// $Id: Graph2D.cpp,v 1.30 2004-01-13 12:39:45 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -121,14 +121,18 @@ static void Draw_Graph2D(Post_View * v,
   font_a = gl_height() - gl_descent();  // height above ref pt
 
   switch (v->RangeType) {
-  case DRAW_POST_DEFAULT:
+  case DRAW_POST_RANGE_DEFAULT:
     ValMin = v->Min;
     ValMax = v->Max;
     break;
-  case DRAW_POST_CUSTOM:
+  case DRAW_POST_RANGE_CUSTOM:
     ValMin = v->CustomMin;
     ValMax = v->CustomMax;
     break;
+  case DRAW_POST_RANGE_PER_STEP:
+    ValMin = v->TimeStepMin[v->TimeStep];
+    ValMax = v->TimeStepMax[v->TimeStep];
+    break;
   }
 
   glPointSize(CTX.point_size);
diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp
index 5273830088..c7597d0b72 100644
--- a/Graphics/Post.cpp
+++ b/Graphics/Post.cpp
@@ -1,6 +1,6 @@
-// $Id: Post.cpp,v 1.49 2003-11-29 01:38:50 geuzaine Exp $
+// $Id: Post.cpp,v 1.50 2004-01-13 12:39:45 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -259,10 +259,10 @@ void Draw_ScalarList(Post_View * v, double ValMin, double ValMax,
     nb = List_Nbr(list) / nbelm;
     if(smoothnormals && v->Light && v->SmoothNormals && v->Changed &&
        v->IntervalsType != DRAW_POST_ISO) {
-      v->reset_normals();       // we might save some normal stuff by
-      // checking if the change actually changed
-      // the "geometry"... Should put
-      // e.g. Change=2 if timestep chnaged, etc.
+      v->reset_normals(); 
+      // we might save some normal stuff by checking if the change
+      // actually changed the "geometry"... Should put e.g. Change=2
+      // if timestep changed, etc.
       Msg(DEBUG, "Preprocessing of normals in view %d", v->Num);
       for(i = 0; i < List_Nbr(list); i += nb) {
         Get_Coords(v->Explode, v->Offset, nbnod,
@@ -486,14 +486,18 @@ void Draw_Post(void)
         }
 
         switch (v->RangeType) {
-        case DRAW_POST_DEFAULT:
+        case DRAW_POST_RANGE_DEFAULT:
           ValMin = v->Min;
           ValMax = v->Max;
           break;
-        case DRAW_POST_CUSTOM:
+        case DRAW_POST_RANGE_CUSTOM:
           ValMin = v->CustomMin;
           ValMax = v->CustomMax;
           break;
+        case DRAW_POST_RANGE_PER_STEP:
+          ValMin = v->TimeStepMin[v->TimeStep];
+          ValMax = v->TimeStepMax[v->TimeStep];
+          break;
         }
 
         switch (v->ScaleType) {
diff --git a/Graphics/PostElement.cpp b/Graphics/PostElement.cpp
index f4ff030f0e..f14ed96f75 100644
--- a/Graphics/PostElement.cpp
+++ b/Graphics/PostElement.cpp
@@ -1,6 +1,6 @@
-// $Id: PostElement.cpp,v 1.19 2003-11-22 01:43:18 geuzaine Exp $
+// $Id: PostElement.cpp,v 1.20 2004-01-13 12:39:45 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -23,7 +23,6 @@
 //   Laurent Stainier
 //
 
-
 // OK, I understand why the Cut2D stuff does not work correctly with a
 // TWO_FACE light: the normal has too be coherent with the vertex
 // ordering of the polygon. Doing i=nb-1; i>=0; i-- works when the
diff --git a/Graphics/Scale.cpp b/Graphics/Scale.cpp
index 159da8ded2..affa0a810e 100644
--- a/Graphics/Scale.cpp
+++ b/Graphics/Scale.cpp
@@ -1,6 +1,6 @@
-// $Id: Scale.cpp,v 1.36 2003-11-28 19:15:29 geuzaine Exp $
+// $Id: Scale.cpp,v 1.37 2004-01-13 12:39:46 geuzaine Exp $
 //
-// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -82,13 +82,20 @@ void draw_scale(Post_View * v,
   else
     glShadeModel(GL_FLAT);
 
-  if(v->RangeType == DRAW_POST_CUSTOM) {
+  switch(v->RangeType){
+  case DRAW_POST_RANGE_CUSTOM:
     ValMin = v->CustomMin;
     ValMax = v->CustomMax;
-  }
-  else {
+    break;
+  case DRAW_POST_RANGE_PER_STEP:
+    ValMin = v->TimeStepMin[v->TimeStep];
+    ValMax = v->TimeStepMax[v->TimeStep];
+    break;
+  case DRAW_POST_RANGE_DEFAULT:
+  default:
     ValMin = v->Min;
     ValMax = v->Max;
+    break;
   }
 
   switch (v->ScaleType) {
diff --git a/Makefile b/Makefile
index 13ca28ac4f..3c7341bd88 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
-# $Id: Makefile,v 1.318 2003-12-08 19:18:13 geuzaine Exp $
+# $Id: Makefile,v 1.319 2004-01-13 12:39:44 geuzaine Exp $
 #
-# Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
+# Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@ include variables
 
 GMSH_MAJOR_VERSION = 1
 GMSH_MINOR_VERSION = 50
-GMSH_PATCH_VERSION = 1
+GMSH_PATCH_VERSION = 2
 
 GMSH_SHORT_LICENSE = "GNU General Public License"
 
@@ -232,7 +232,7 @@ package-mac:
         "    <key>CFBundleIconFile</key><string>gmsh.icns</string>\n"\
         "    <key>CFBundleSignature</key><string>GMSH</string>\n"\
         "    <key>CFBundleGetInfoString</key><string>Gmsh version ${GMSH_RELEASE}, "\
-              "Copyright (C) 1997-2003 C. Geuzaine and J.-F. Remacle</string>\n"\
+              "Copyright (C) 1997-2004 C. Geuzaine and J.-F. Remacle</string>\n"\
         "    <key>CFBundleIdentifier</key><string>org.geuz.Gmsh</string>\n"\
         "  </dict>\n"\
         "</plist>" > gmsh-${GMSH_RELEASE}/Gmsh.app/Contents/Info.plist
diff --git a/TODO b/TODO
index f772cdac8b..bfac398fe6 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,4 @@
-$Id: TODO,v 1.28 2003-12-30 22:08:04 geuzaine Exp $
-
-compute min/max for each time step and allow to use that instead of
-the global min/max
-
-********************************************************************
+$Id: TODO,v 1.29 2004-01-13 12:39:44 geuzaine Exp $
 
 add nicer 3d drawing code for arrows (cylinder+cone, with lights)
 
diff --git a/doc/VERSIONS b/doc/VERSIONS
index 2ce7270d71..c692e18c07 100644
--- a/doc/VERSIONS
+++ b/doc/VERSIONS
@@ -1,7 +1,8 @@
-$Id: VERSIONS,v 1.179 2004-01-08 20:32:41 geuzaine Exp $
+$Id: VERSIONS,v 1.180 2004-01-13 12:39:46 geuzaine Exp $
 
 New since 1.50: initial support for visualizing mesh partitions;
-integrated version 2.0 of the MSH mesh file format;
+integrated version 2.0 of the MSH mesh file format; post-processing
+range (min/max) can now be computed per time step;
 
 New in 1.50: small changes to the visibility browser + made visibility
 scriptable (new Show/Hide commands); fixed (rare) crash when deleting
-- 
GitLab