From c478235bdd5506228187843e6aee6f9ed8192f1e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 29 Jan 2001 08:43:45 +0000
Subject: [PATCH] Opengl clean up

---
 Box/Box.cpp              |   3 +-
 Common/Context.cpp       |   5 +-
 Common/Context.h         |   2 +
 Common/GetOptions.cpp    |   5 +-
 Fltk/Callbacks.cpp       |  96 ++---
 Fltk/Colorbar_Window.cpp | 875 ++++++++++++++++++++-------------------
 Fltk/Colorbar_Window.h   |  44 +-
 Fltk/GUI.cpp             |  58 ++-
 Fltk/GUI.h               |  11 +-
 Fltk/Main.cpp            |   7 +-
 Fltk/Opengl.cpp          |  34 +-
 Fltk/Opengl_Window.cpp   | 205 ++++-----
 Graphics/CreateFile.cpp  |  12 +-
 Graphics/Draw.cpp        |   4 +-
 Graphics/Draw.h          |   4 +-
 Graphics/Geom.cpp        |  16 +-
 Graphics/Mesh.cpp        |   4 +-
 Graphics/Scale.cpp       |  22 +-
 Makefile                 |   4 +-
 Motif/CbContext.cpp      |   9 +-
 Motif/CbFile.cpp         |   6 +-
 Motif/CbGeom.cpp         |   3 +-
 Motif/CbInput.cpp        |  53 +--
 Motif/CbMesh.cpp         |   5 +-
 Motif/CbOptions.cpp      |  16 +-
 Motif/CbPost.cpp         |  11 +-
 Motif/Main.cpp           |   7 +-
 Motif/Opengl.cpp         |  18 +-
 Parser/Gmsh.tab.cpp      | 307 +++++++-------
 Parser/Gmsh.y            |   3 +-
 Parser/Gmsh.yy.cpp       |   4 +-
 31 files changed, 900 insertions(+), 953 deletions(-)

diff --git a/Box/Box.cpp b/Box/Box.cpp
index 04f2563e0e..be97d75948 100644
--- a/Box/Box.cpp
+++ b/Box/Box.cpp
@@ -1,4 +1,4 @@
-// $Id: Box.cpp,v 1.20 2001-01-13 15:41:35 geuzaine Exp $
+// $Id: Box.cpp,v 1.21 2001-01-29 08:43:44 geuzaine Exp $
 
 #include <signal.h>
 
@@ -20,7 +20,6 @@
 void AddViewInUI(int, char *, int){}
 void draw_polygon_2d (double, double, double, int, double *, double *, double *){}
 void set_r(int, double){}
-void Init(void){}
 void Draw(void){}
 void DrawUI(void){}
 void Replot(void){}
diff --git a/Common/Context.cpp b/Common/Context.cpp
index 81ba42abf4..ab9ffbe964 100644
--- a/Common/Context.cpp
+++ b/Common/Context.cpp
@@ -1,4 +1,4 @@
-// $Id: Context.cpp,v 1.34 2001-01-24 09:28:03 geuzaine Exp $
+// $Id: Context.cpp,v 1.35 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Const.h"
@@ -198,6 +198,9 @@ void Init_Context(void){
   CTX.threads      = 1 ; // effective on Unix only with -D_USETHREADS
   CTX.threads_lock = 0 ;
 
+  CTX.gl_fontheight = 12;
+  CTX.gl_fontascent = 8;
+
   // only used for motif
   CTX.font = "-*-helvetica-medium-r-*-*-*-*-*-*-*-*-*-*" ;
   CTX.fixed_font = "fixed" ;
diff --git a/Common/Context.h b/Common/Context.h
index 0620f42c25..4ae4be3dd6 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -103,6 +103,8 @@ public :
 
   int fontsize;               // font size for fltk UI
   int gl_fontsize;            // font size for opengl graphics
+  int gl_fontheight;          // font height
+  int gl_fontascent;          // height of the font above the reference point
 
   // OpenGL stuff 
   int viewport[4];            // current viewport 
diff --git a/Common/GetOptions.cpp b/Common/GetOptions.cpp
index b38b10254c..71a8ac17f6 100644
--- a/Common/GetOptions.cpp
+++ b/Common/GetOptions.cpp
@@ -1,4 +1,4 @@
-// $Id: GetOptions.cpp,v 1.5 2001-01-24 09:28:03 geuzaine Exp $
+// $Id: GetOptions.cpp,v 1.6 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshVersion.h"
@@ -335,6 +335,9 @@ void Get_Options (int argc, char *argv[], int *nbfiles) {
               !strcmp(argv[i]+1, "noov")){ 
         CTX.overlay = CTX.geom.highlight = 0; i++;
       }
+      else if(!strcmp(argv[i]+1, "hh")){ 
+        CTX.overlay = 0 ; CTX.geom.highlight = 1; i++;
+      }
       else if(!strcmp(argv[i]+1, "perspective") ||
               !strcmp(argv[i]+1, "p")){ 
         CTX.ortho = 0; i++;
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index e6874b42ab..c7f8ce5bc1 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.21 2001-01-24 09:28:03 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.22 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -15,20 +15,8 @@
 #include "GUI.h"
 #include "Callbacks.h"
 
-#include <FL/Fl.H>
-#include <FL/Fl_Button.H>
-#include <FL/Fl_Window.H>
-#include <FL/Fl_Input.H>
 #include <FL/fl_file_chooser.H>
-#include <stdio.h>
-#include <string.h>
 #include <errno.h>
-#include <stdlib.h>
-#include <FL/fl_file_chooser.H>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
 
 extern GUI       *WID;
 extern Mesh       M;
@@ -90,7 +78,6 @@ void* StartMeshThread(void * data){
   CTX.mesh.draw = 1;
   CTX.threads_lock = 0;
   XtSetSensitive(WID.G.Butt[6], 0);
-  Init();
   Draw();
   pthread_exit(NULL);
   return NULL ;
@@ -105,7 +92,6 @@ void CancelMeshThread(void){
     Msg(STATUS2,"Mesh Aborted");
     mesh_event_handler(MESH_DELETE);
     Msg(STATUS3N,"Ready");
-    Init();
     Draw();
   }
 }
@@ -167,7 +153,6 @@ void cancel_cb(CALLBACK_ARGS){
 }
 
 void ok_cb(CALLBACK_ARGS){
-  Init();
   Draw();
 }
 
@@ -184,24 +169,24 @@ void status_xyz1p_cb(CALLBACK_ARGS){
     if(CTX.useTrackball)
       CTX.setQuaternion(0.,-1./sqrt(2.),0.,1./sqrt(2.));
     set_r(0,0.);  set_r(1,90.);set_r(2,0.); 
-    Init(); Draw(); 
+    Draw(); 
     break;
   case 1 : 
     if(CTX.useTrackball)
       CTX.setQuaternion(1./sqrt(2.),0.,0.,1./sqrt(2.));
     set_r(0,-90.);set_r(1,0.); set_r(2,0.); 
-    Init(); Draw(); 
+    Draw(); 
     break;
   case 2 :
     if(CTX.useTrackball)
       CTX.setQuaternion(0.,0.,0.,1.);
     set_r(0,0.);  set_r(1,0.); set_r(2,0.); 
-    Init(); Draw(); 
+    Draw(); 
     break;
   case 3 : 
     set_t(0,0.);  set_t(1,0.); set_t(2,0.); 
     set_s(0,1.);  set_s(1,1.); set_s(2,1.); 
-    Init(); Draw(); 
+    Draw(); 
     break;
   case 4 :
     Print_Context(NULL);
@@ -217,12 +202,12 @@ void status_play_cb(CALLBACK_ARGS){
   anim_time = GetTime();
   while(1){
     if(stop_anim) break ;
-    WID->check();
     if(GetTime() - anim_time > CTX.post.anim_delay){
       anim_time = GetTime();
       MarkAllViewsChanged(2);
-      Init(); Draw();
+      Draw();
     }
+    WID->check();
   }
 }
 
@@ -242,7 +227,6 @@ void file_open_cb(CALLBACK_ARGS) {
   newfile = fl_file_chooser("Open File", "*.geo", NULL);
   if (newfile != NULL) {
     OpenProblem(newfile); 
-    Init();
     Draw(); 
   }
 }
@@ -252,7 +236,6 @@ void file_merge_cb(CALLBACK_ARGS) {
   newfile = fl_file_chooser("Merge File", "*", NULL);
   if (newfile != NULL) {
     MergeProblem(newfile); 
-    Init();
     Draw(); 
   }
 }
@@ -358,7 +341,6 @@ void file_reload_all_views_cb(CALLBACK_ARGS) {
   for(int i = 0 ; i<List_Nbr(Post_ViewList) ; i++)
     view_reload_cb(NULL, (void *)i);
   RELOAD_ALL_VIEWS = 0;
-  Init();
   Draw();
 }
 
@@ -370,7 +352,6 @@ void file_remove_all_views_cb(CALLBACK_ARGS) {
   while(List_Nbr(Post_ViewList))
     view_remove_cb(NULL, (void*)0);
   REMOVE_ALL_VIEWS = 0;
-  Init();
   Draw();
 }
 
@@ -407,7 +388,6 @@ void opt_general_orthographic_cb(CALLBACK_ARGS){
 }
 void opt_general_color_cb(CALLBACK_ARGS){
   Init_Colors((int)((Fl_Value_Input*)w)->value()-1);
-  Init();
   Draw();
 }
 void opt_general_shininess_cb(CALLBACK_ARGS){
@@ -582,7 +562,6 @@ void geometry_physical_cb(CALLBACK_ARGS){
 }
 void geometry_reload_cb(CALLBACK_ARGS){
   OpenProblem(CTX.filename);
-  Init();
   Draw();
 } 
 void geometry_elementary_add_cb(CALLBACK_ARGS){
@@ -621,12 +600,12 @@ static void _new_line_spline(int dim){
       }
       n=0;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       break;
     }
   }
@@ -658,13 +637,13 @@ void geometry_elementary_add_new_circle_cb(CALLBACK_ARGS){
     if(ib == 0) { /* 'q' */
       n=0 ;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       break;
     }
     if(n == 3){
       add_circ(p[1],p[0],p[2],CTX.filename); /* begin, center, end */
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       n=0;
     }
   }
@@ -690,13 +669,13 @@ void geometry_elementary_add_new_ellipsis_cb(CALLBACK_ARGS){
     if(ib == 0){ /* 'q' */
       n=0 ;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       break;
     }
     if(n == 4){
       add_ell(p[3],p[2],p[0],p[1],CTX.filename);
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       n=0;
     }
   }
@@ -727,7 +706,7 @@ static void _new_surface_volume(int mode){
       ib = SelectEntity(type, &v,&c,&s);
       if(ib <= 0){
 	ZeroHighlight(&M);
-	DrawUpdate();
+	Draw();
 	goto stopall;
       }       
       if(SelectContour (type, (type==ENT_LINE)?c->Num:s->Num, Liste1)){
@@ -742,7 +721,7 @@ static void _new_surface_volume(int mode){
 	  ib = SelectEntity(type, &v,&c,&s); 
 	  if(ib <= 0){
 	    ZeroHighlight(&M);
-	    DrawUpdate();
+	    Draw();
 	    break;
 	  }
 	  if(SelectContour (type, (type==ENT_LINE)?c->Num:s->Num, Liste1)){
@@ -761,7 +740,7 @@ static void _new_surface_volume(int mode){
 	  case 2 : add_multvol(Liste2,CTX.filename); break;
 	  }
 	  ZeroHighlight(&M);
-	  DrawUpdate();
+	  Draw();
 	  break;
 	}
       }
@@ -800,7 +779,7 @@ static void _transform_point_curve_surface(int transfo, int mode, char *what){
     Msg(STATUS3N,"Select %s ('q'=quit)", what);
     if(!SelectEntity(type, &v,&c,&s)){
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       break;
     }
     switch(type){
@@ -818,7 +797,7 @@ static void _transform_point_curve_surface(int transfo, int mode, char *what){
     case 6: delet(num,CTX.filename,what); break;
     }
     ZeroHighlight(&M);
-    DrawUpdate();
+    Draw();
   }
   Msg(STATUS3N,"Ready");
 }
@@ -1029,12 +1008,12 @@ static void _add_physical(char *what){
 	add_physical(Liste1,CTX.filename,type,&zone);
 	List_Reset(Liste1);
 	ZeroHighlight(&M);
-	DrawUpdate();
+	Draw();
       }
     }
     if(ib == 0){
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       break;
     }
   }
@@ -1072,7 +1051,6 @@ void mesh_1d_cb(CALLBACK_ARGS){
   else
 #endif
     mai3d(&M, 1); 
-  Init(); 
   Draw();
   Msg(STATUS3N,"Ready");
 }
@@ -1086,7 +1064,6 @@ void mesh_2d_cb(CALLBACK_ARGS){
   else
 #endif
     mai3d(&M, 2);
-  Init(); 
   Draw();
   Msg(STATUS3N,"Ready");
 } 
@@ -1100,7 +1077,6 @@ void mesh_3d_cb(CALLBACK_ARGS){
   else
 #endif
     mai3d(&M, 3); 
-  Init(); 
   Draw();
   Msg(STATUS3N,"Ready");
 } 
@@ -1124,14 +1100,14 @@ void mesh_define_length_cb (CALLBACK_ARGS){
 	add_charlength(n,p,CTX.filename); 
 	n=0;
 	ZeroHighlight(&M);
-	DrawUpdate();
+	Draw();
 	break;
       }
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       break;
     }
   }
@@ -1157,12 +1133,12 @@ void mesh_define_recombine_cb (CALLBACK_ARGS){
       }
       n=0;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       break;
     }
   }
@@ -1222,13 +1198,13 @@ static void _add_transfinite(int dim){
 	    }
 	    n=0;
 	    ZeroHighlight(&M);
-	    DrawUpdate();
+	    Draw();
 	    break;
 	  }
 	  if(ib == 0){ /* 'q' */
 	    n=0 ;
 	    ZeroHighlight(&M);
-	    DrawUpdate();
+	    Draw();
 	    break;
 	  }
 	}
@@ -1241,12 +1217,12 @@ static void _add_transfinite(int dim){
       }
       n=0;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
       ZeroHighlight(&M);
-      DrawUpdate();
+      Draw();
       break;
     }
   }
@@ -1279,8 +1255,7 @@ void view_toggle_cb(CALLBACK_ARGS){
   Msg(DEBUG3, "  -> Links %d", v->Links);
 
   v->Visible = !v->Visible;
-
-  Init();
+  
   Draw();
 }
 
@@ -1303,10 +1278,8 @@ void view_reload_cb(CALLBACK_ARGS){
   v = (Post_View*)List_Pointer(Post_ViewList,(int)data);
   CopyViewOptions(&tmp, v);
 
-  if(!RELOAD_ALL_VIEWS){
-    Init();
+  if(!RELOAD_ALL_VIEWS)
     Draw();
-  }
 }
 
 void view_remove_cb(CALLBACK_ARGS){
@@ -1321,10 +1294,8 @@ void view_remove_cb(CALLBACK_ARGS){
   if(WID->get_context() == 2)
     WID->set_context(menu_post, 0);  
 
-  if(!REMOVE_ALL_VIEWS){
-    Init();
+  if(!REMOVE_ALL_VIEWS)
     Draw();
-  }
 }
 
 void view_duplicate_cb(CALLBACK_ARGS){
@@ -1374,9 +1345,7 @@ void view_duplicate_cb(CALLBACK_ARGS){
   v2->NbTimeStep  = v1->NbTimeStep;
 
   CopyViewOptions(v1, v2);
-
   AddViewInUI(List_Nbr(Post_ViewList), v2->Name, v2->Num);
-  Init();
   Draw();
 }
 
@@ -1384,14 +1353,12 @@ void view_lighting_cb(CALLBACK_ARGS){
   Post_View *v = (Post_View*)List_Pointer(Post_ViewList,(int)data);
   v->Light = !v->Light;
   v->Changed = 1;
-  Init() ;
   Draw() ;
 }
 void view_elements_cb(CALLBACK_ARGS){
   Post_View *v = (Post_View*)List_Pointer(Post_ViewList,(int)data);
   v->ShowElement = !v->ShowElement;
   v->Changed = 1;
-  Init() ;
   Draw() ;
 }
 void view_applybgmesh_cb(CALLBACK_ARGS){
@@ -1566,7 +1533,6 @@ void view_options_timestep_cb(CALLBACK_ARGS){
     v->TimeStep = (int)((Fl_Value_Input*)w)->value() ;
     v->Changed = 1;
   ENDVIEWMOD
-  Init();
   Draw();
 }
 void view_options_vector_line_cb(CALLBACK_ARGS){
diff --git a/Fltk/Colorbar_Window.cpp b/Fltk/Colorbar_Window.cpp
index 6849711301..a160c4650d 100644
--- a/Fltk/Colorbar_Window.cpp
+++ b/Fltk/Colorbar_Window.cpp
@@ -1,32 +1,43 @@
-// $Id: Colorbar_Window.cpp,v 1.2 2001-01-10 10:06:16 geuzaine Exp $
-
-#if 0
+// $Id: Colorbar_Window.cpp,v 1.3 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
 #include "GUI.h"
 #include "ColorTable.h"
-#include "Colorbar.h"
+#include "Colorbar_Window.h"
+#include "Context.h"
+
+extern GUI *WID;
+extern Context_T  CTX;
+
+#define UNDEFINED   0
+#define EPS         1.e-10
 
 // This file defines the Colorbar_Window class (subclass of Fl_Window)
 
-extern XContext_T  XCTX ;
-extern Widgets_T   WID;
+// The constructor
 
-#define FONT_HEIGHT 10 ;
+Colorbar_Window::Colorbar_Window(int x,int y,int w,int h,const char *l)
+  : Fl_Window(x,y,w,h,l){
 
-/* RGB/HSV transformation */
+  ct = NULL;
+  label = NULL;
+  help_flag = 1;  
+  font_height = CTX.fontsize ;
+  marker_height = font_height ;
+  wedge_height = marker_height ;
+  marker_pos = 0 ;
+  minval = maxval = 0.0 ;
+}
 
-#define RETURN_HSV(h,s,v) {*H=h; *S=s; *V=v; return;} 
-#define RETURN_RGB(r,g,b) {*R=r; *G=g; *B=b; return;} 
-#define UNDEFINED 0
-#define EPS       1.e-10
 
-/* rgb on [0, 1], sv returned on [0, 1] and h on [0, 6]. 
-   Exception: h is returned UNDEFINED if S==0. */
+// rgb on [0, 1], sv returned on [0, 1] and h on [0, 6]. 
+// Exception: h is returned UNDEFINED if S==0.
+
+#define RETURN_HSV(h,s,v) {*H=h; *S=s; *V=v; return;} 
                                                                              
-void RGB_to_HSV(double  R, double  G, double  B,
-                double *H, double *S, double *V) { 
+static void RGB_to_HSV(double  R, double  G, double  B,
+		       double *H, double *S, double *V) { 
   double v, x, f;   
   int i; 
    
@@ -38,18 +49,20 @@ void RGB_to_HSV(double  R, double  G, double  B,
   RETURN_HSV(i - f /(v - x), (v - x)/v, v);   
 } 
 
-/* h given on [0, 6] or UNDEFINED. s and v given on [0, 1].      
-   rgb each returned on [0, 1]. */
+// h given on [0, 6] or UNDEFINED. s and v given on [0, 1].      
+// rgb each returned on [0, 1].
 
-void HSV_to_RGB(double  H, double  S, double  V,
-                double *R, double *G, double *B) {     
+#define RETURN_RGB(r,g,b) {*R=r; *G=g; *B=b; return;} 
+
+static void HSV_to_RGB(double  H, double  S, double  V,
+		       double *R, double *G, double *B) {     
   double m, n, f;   
   int i; 
       
   if (H == UNDEFINED) RETURN_RGB(V, V, V);
   i = (int)floor(H);
   f = H - i;   
-  if ( !(i&1) ) f = 1 - f; /* if i is even */
+  if ( !(i&1) ) f = 1 - f; // if i is even
   m = V * (1 - S);   
   n = V * (1 - S * f); 
   
@@ -65,530 +78,518 @@ void HSV_to_RGB(double  H, double  S, double  V,
 } 
 
 
-/* Convert window X coordinate to color table index */
+// Convert window X coordinate to color table index
 
-static int x_to_index(ColorBar *cb, int x){
+int Colorbar_Window::x_to_index(int x){
   int index;
-  index = (int) (x * (float) cb->ct->size / (float) cb->width );
+  index = (int) (x * (float) ct->size / (float)w());
   if (index<0) 
     index = 0;
-  else if (index>=cb->ct->size)
-    index = cb->ct->size-1;
+  else if (index >= ct->size)
+    index = ct->size-1;
   return index;
 }
 
-/* Convert color table index to window X coordinate */
+// Convert color table index to window X coordinate
 
-static int index_to_x(ColorBar *cb, int index){
+int Colorbar_Window::index_to_x(int index){
   int x;
-  x = (int) (index * (float) cb->width / (float)(cb->ct->size-1) );
-  if (x>=cb->width)
-    x = cb->width - 1;
+  x = (int) (index * (float)w() / (float)(ct->size-1));
+  if (x >= w())
+    x = w() - 1;
   return x;
 }
 
-/* Convert a color intensity to a window Y coordinate */
+// Convert a color intensity to a window Y coordinate
 
-static int intensity_to_y(ColorBar *cb, int intensity){
+int Colorbar_Window::intensity_to_y(int intensity){
   int y;
-  y = (int) (cb->wedge_y - intensity * (float) cb->wedge_y / 255.0 );
-  if (y<0)
+  y = (int) (wedge_y - intensity * (float)wedge_y/255.);
+  if (y < 0)
     y = 0;
-  else if (y>=cb->wedge_y)
-    y = cb->wedge_y - 1;
+  else if (y >= wedge_y)
+    y = wedge_y - 1;
   return y;
 }
 
-/* Convert a window Y coordinate to a color intensity */
+// Convert a window Y coordinate to a color intensity
 
-static int y_to_intensity(ColorBar *cb, int y){
+int Colorbar_Window::y_to_intensity(int y){
   int intensity;
-  intensity = (int) ((cb->wedge_y - y ) * 255.0 / (float) cb->wedge_y );
-  if (intensity<0)
+  intensity = (int) ((wedge_y - y) * 255. / (float)wedge_y);
+  if (intensity < 0)
     intensity = 0;
-  else if (intensity>255)
+  else if (intensity > 255)
     intensity = 255;
   return intensity;
 }
 
+// Redraw part of the Colorbar_Window (between a and b)
 
-/* Redraw part of a Color Widget (between a and b) */
-
-#define HELP_LINES 9
-
-static void redraw_range(ColorBar *cb, int a, int b){
+void Colorbar_Window::redraw_range(int a, int b){
    int i;
    int x,y, px,py;
    int x1, y1, x2, y2;
    int intensity;
    double H,S,V;
-   char rgb_str[] = "RGB", hsv_str[] = "HSV" ;
-   char help_str[HELP_LINES][100] = {
-     "h           show this message",
-     "1 -> 6      choose predefined colormap",
-     "m           switch color mode",
-     "c/p/r       copy/paste/reset",
-     "mouse       draw color or alpha",
-     "left/right  move or rotate",
-     "up/down     color or alpha curvature",
-     "i           invert x or y range",
-     "b           increase or decrease gamma"
-   };
-
-   if (a<0)  a = 0;
-   if (b>=cb->ct->size)  b = cb->ct->size-1;
-
-   /* calc region to update */
-   x1 = index_to_x( cb, a );
-   x2 = index_to_x( cb, b);
-
-   y1 = intensity_to_y( cb, 255 );
-   y2 = intensity_to_y( cb, 0 ); 
-
-   /* erase region */
-   fl_color(Fl_BLACK);
-   fl_rectf(x1,y1, x2-x1+1, y2-y1+1);
-
-   /* redraw region of entries in interval [a,b] */
-   if (a>0) a--;
-   if (b<cb->ct->size-1)  b++;
-
-   /* draw red or hue levels */
-   for (i=a;i<=b;i++) {
-      x = index_to_x( cb, i );
-
-      if(cb->ct->ipar[COLORTABLE_MODE]==COLORTABLE_RGB){
-        intensity = UNPACK_RED(cb->ct->table[i]);
-      }
-      else if(cb->ct->ipar[COLORTABLE_MODE]==COLORTABLE_HSV){
-        RGB_to_HSV(UNPACK_RED  (cb->ct->table[i])/255., 
-                   UNPACK_GREEN(cb->ct->table[i])/255.,
-                   UNPACK_BLUE (cb->ct->table[i])/255.,
+
+   WID->make_colorbar_current();
+
+   if(a < 0)  a = 0;
+   if(b >= ct->size)  b = ct->size-1;
+
+   // calculate region to update
+   x1 = index_to_x(a);
+   x2 = index_to_x(b);
+   y1 = intensity_to_y(255);
+   y2 = intensity_to_y(0); 
+
+   // erase region
+   fl_color(FL_BLACK);
+   fl_rectf(x1, y1, x2-x1+1, y2-y1+1);
+
+   // redraw region of entries in interval [a,b]
+   if (a > 0) a--;
+   if (b < ct->size-1) b++;
+
+   // draw red or hue levels
+   for (i=a ; i<=b ; i++) {
+      x = index_to_x(i);
+      if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
+        intensity = UNPACK_RED(ct->table[i]);
+      else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV){
+        RGB_to_HSV(UNPACK_RED  (ct->table[i])/255., 
+                   UNPACK_GREEN(ct->table[i])/255.,
+                   UNPACK_BLUE (ct->table[i])/255.,
                    &H,&S,&V);
-        intensity = (int) (H/6.*255.+EPS);
+        intensity = (int)(H/6.*255.+EPS);
       }
-
-      y = intensity_to_y( cb, intensity );
+      y = intensity_to_y(intensity);
       if (i!=a){
-	fl_color(Fl_RED);
-	fl_line(px, py, x, y);
+	fl_color(FL_RED);
+	fl_line(px,py,x,y);
       }
       px = x;  py = y;
    }
 
-   /* draw green or saturation levels */
-   for (i=a;i<=b;i++) {
-      x = index_to_x( cb, i );
-
-      if(cb->ct->ipar[COLORTABLE_MODE]==COLORTABLE_RGB){
-        intensity = UNPACK_GREEN(cb->ct->table[i]);
-      }
-      else if(cb->ct->ipar[COLORTABLE_MODE]==COLORTABLE_HSV){
-        RGB_to_HSV(UNPACK_RED  (cb->ct->table[i])/255., 
-                   UNPACK_GREEN(cb->ct->table[i])/255.,
-                   UNPACK_BLUE (cb->ct->table[i])/255.,
+   // draw green or saturation levels
+   for (i=a ; i<=b ; i++) {
+      x = index_to_x(i);
+      if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
+        intensity = UNPACK_GREEN(ct->table[i]);
+      else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV){
+        RGB_to_HSV(UNPACK_RED  (ct->table[i])/255., 
+                   UNPACK_GREEN(ct->table[i])/255.,
+                   UNPACK_BLUE (ct->table[i])/255.,
                    &H,&S,&V);
-        intensity = (int) (S*255.);
+        intensity = (int)(S*255.);
       }
-
-      y = intensity_to_y(cb, intensity);
+      y = intensity_to_y(intensity);
       if (i!=a){
-	fl_color(Fl_GREEN);
-	fl_line(px,py, x,y);
+	fl_color(FL_GREEN);
+	fl_line(px,py,x,y);
       }
       px = x;  py = y;
    }
 
-   /* draw blue or value levels */
-   for (i=a;i<=b;i++) {
-      x = index_to_x( cb, i );
-
-      if(cb->ct->ipar[COLORTABLE_MODE]==COLORTABLE_RGB){
-        intensity = UNPACK_BLUE(cb->ct->table[i]);
-      }
-      else if(cb->ct->ipar[COLORTABLE_MODE]==COLORTABLE_HSV){
-        RGB_to_HSV(UNPACK_RED  (cb->ct->table[i])/255., 
-                   UNPACK_GREEN(cb->ct->table[i])/255.,
-                   UNPACK_BLUE (cb->ct->table[i])/255.,
+   // draw blue or value levels
+   for (i=a ; i<=b ; i++) {
+      x = index_to_x(i);
+      if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
+        intensity = UNPACK_BLUE(ct->table[i]);
+      else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV){
+        RGB_to_HSV(UNPACK_RED  (ct->table[i])/255., 
+                   UNPACK_GREEN(ct->table[i])/255.,
+                   UNPACK_BLUE (ct->table[i])/255.,
                    &H,&S,&V);
-        intensity = (int) (V*255.);
+        intensity = (int)(V*255.);
       }
-
-      y = intensity_to_y( cb, intensity );
+      y = intensity_to_y(intensity);
       if (i!=a){
 	fl_color(FL_BLUE);
-	fl_line(px,py, x,y);
+	fl_line(px,py,x,y);
       }
       px = x;  py = y;
    }
 
-   /* draw alpha levels */   
-   for (i=a;i<=b;i++) {
-     x = index_to_x( cb, i );
-     y = intensity_to_y( cb, UNPACK_ALPHA(cb->ct->table[i]) );
+   // draw alpha levels
+   for (i=a ; i<=b ; i++) {
+     x = index_to_x(i);
+     y = intensity_to_y(UNPACK_ALPHA(ct->table[i]));
      if (i!=a){
        fl_color(FL_WHITE);
-       fl_line(px,py, x,y);
+       fl_line(px,py,x,y);
      }
      px = x;  py = y;
    }
 
-   /* draw the color bar */
-   for (x=x1;x<=x2;x++) {
-      int r, g, b;
-      unsigned int color;
-      i = x_to_index( cb, x );
-      color = cb->ct->table[i];
-      r = UNPACK_RED( color );
-      g = UNPACK_GREEN( color );
-      b = UNPACK_BLUE( color );
-      fl_color(r,g,b);
-      fl_line(x, cb->wedge_y, x, cb->wedge_y + WEDGE_HEIGHT-1); 
+   // draw the color bar
+   for (x=x1 ; x<=x2 ; x++) {
+     int r, g, b;
+     unsigned int color;
+     i = x_to_index(x);
+     color = ct->table[i];
+     r = UNPACK_RED(color);
+     g = UNPACK_GREEN(color);
+     b = UNPACK_BLUE(color);
+     fl_color(r,g,b);
+     fl_line(x, wedge_y, x, wedge_y + wedge_height-1); 
    }
 
-   /* print colortable mode and help */
-   fl_font(FL_HELVETICA, FONT_HEIGHT);
+   // print colortable mode and help
+   fl_font(FL_HELVETICA, font_height);
    fl_color(FL_WHITE);
-   if (cb->helpflag) {
-     for (i=0;i<HELP_LINES;i++) {
-       fl_draw(help_str[i], 10,10+(i+1)*FONT_HEIGHT);
-     }
-   }
-   else{
-     if(cb->ct->ipar[COLORTABLE_MODE]==COLORTABLE_RGB)
-       fl_draw(rgb_str, 10, 10+FONT_HEIGHT);
-     else if(cb->ct->ipar[COLORTABLE_MODE]==COLORTABLE_HSV)
-       fl_draw(hsv_str, 10, 10+FONT_HEIGHT);
+   if (help_flag){
+     int i=0, xx=11*font_height;
+     fl_draw("1, 2, ..., 6", 10,10+(i+1)*font_height); 
+     fl_draw("select predefined colormap", xx,10+(i+1)*font_height); i++;
+     fl_draw("mouse1", 10,10+(i+1)*font_height); 
+     fl_draw("draw red or hue channel", xx,10+(i+1)*font_height); i++;
+     fl_draw("mouse2", 10,10+(i+1)*font_height); 
+     fl_draw("draw green or saturation channel", xx,10+(i+1)*font_height); i++;
+     fl_draw("mouse3", 10,10+(i+1)*font_height); 
+     fl_draw("draw blue or value channel", xx,10+(i+1)*font_height); i++;
+     fl_draw("Ctrl+mouse1", 10,10+(i+1)*font_height); 
+     fl_draw("draw alpha channel", xx,10+(i+1)*font_height); i++;
+     fl_draw("c, p, r", 10,10+(i+1)*font_height); 
+     fl_draw("copy, paste or reset current colormap", xx,10+(i+1)*font_height); i++;
+     fl_draw("m", 10,10+(i+1)*font_height); 
+     fl_draw("toggle RGB/HSV mode", xx,10+(i+1)*font_height); i++;
+     fl_draw("left, right", 10,10+(i+1)*font_height); 
+     fl_draw("move or rotate colormap", xx,10+(i+1)*font_height); i++;
+     fl_draw("up, down", 10,10+(i+1)*font_height); 
+     fl_draw("modify color curvature", xx,10+(i+1)*font_height); i++;
+     fl_draw("Ctrl+up, Ctrl+down", 10,10+(i+1)*font_height); 
+     fl_draw("modify alpha curvature", xx,10+(i+1)*font_height); i++;
+     fl_draw("i, Ctrl+i", 10,10+(i+1)*font_height); 
+     fl_draw("invert x or y range", xx,10+(i+1)*font_height); i++;
+     fl_draw("b, Ctrl+b", 10,10+(i+1)*font_height); 
+     fl_draw("increase or decrease gamma", xx,10+(i+1)*font_height); i++;
+     fl_draw("h", 10,10+(i+1)*font_height); 
+     fl_draw("show this help message", xx,10+(i+1)*font_height); i++;
    }
+   else
+     if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
+       fl_draw("RGB", 10, 10+font_height);
+     else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV)
+       fl_draw("HSV", 10, 10+font_height);
 }
 
 
-/* Redraw the marker and the text */
-
-static void redraw_marker(ColorBar *cb){
-   int x, y0, y1;
-   char str[50];
-   int dir,ascent, descent;
-   int xpos;
-   float val;
+// Redraw the marker and the text
 
-   y0 = cb->marker_y;
-   y1 = cb->height - 1;
-   
-   fl_color(FL_BLACK);
-   fl_rectf(0, y0, cb->width, y1-y0+1);
-
-   /* draw marker below color wedge */
-   x = index_to_x(cb, cb->markerpos);
-   fl_color(FL_WHITE);   
-   fl_line(x, cb->marker_y, x, cb->marker_y+MARKER_HEIGHT);
-   fl_line(x, cb->marker_y, x-3, cb->marker_y+6);
-   fl_line(x, cb->marker_y, x+3, cb->marker_y+6);
-
-   /* draw min value */
-   sprintf(str, "%.2g", cb->minval);
-   fl_draw(str, 2, cb->label_y);
-
-   /* draw marker value */
-   val = cb->minval + (cb->maxval-cb->minval)
-                  * ( (float) cb->markerpos / (float) (cb->ct->size-1));
-   sprintf(str, "(%.2g)", val);
-   int width = 30 ;
-   xpos = (cb->width - width) / 2;
-   fl_draw(str, xpos, cb->label_y);
-
-   /* draw max value */
-   sprintf(str, "%.2g", cb->maxval);
-   width = 30 ;
-   xpos = cb->width - width - 2;
-   fl_draw(str, xpos, cb->label_y);
+void Colorbar_Window::redraw_marker(){
+  int x, y0, y1;
+  char str[50];
+  float val;
 
-}
+  WID->make_colorbar_current();
 
-static void set_size(ColorBar *cb, int width, int height){
-   cb->width = width;
-   cb->height = height;
-   cb->label_y = cb->height - 5; 
-   cb->marker_y = cb->label_y + 1 - MARKER_HEIGHT - FONT_HEIGHT;
-   cb->wedge_y = cb->marker_y - WEDGE_HEIGHT;
+  y0 = marker_y;
+  y1 = h() - 1;
+  
+  fl_color(FL_BLACK);
+  fl_rectf(0, y0, w(), y1-y0+1);
+  
+  // draw marker below color wedge
+  x = index_to_x(marker_pos);
+  fl_color(FL_WHITE);   
+  fl_line(x, marker_y, x, marker_y+marker_height);
+  fl_line(x, marker_y, x-3, marker_y+6);
+  fl_line(x, marker_y, x+3, marker_y+6);
+  
+  // draw marker value
+  fl_font(FL_HELVETICA, font_height);
+  val = minval + (maxval-minval) * ((float)marker_pos/(float)(ct->size-1));
+  sprintf(str, "%g", val);
+  fl_draw(str, 10, label_y);
 }
 
+// Draw everything
 
-
-
-/* creation, manipulation and callbacks functions */
-
-static ColorBar *TheCB=NULL ;
-
-void ColorBarCreate(int width, int height){
-  static int first=1 ;
-
-  if(!TheCB) TheCB = (ColorBar *) calloc(1, sizeof(ColorBar));
-  set_size(TheCB, width, height);
-  if(first){
-    TheCB->helpflag = 1;
-    first=0;
+void Colorbar_Window::draw(){
+  Fl_Window::draw();
+  if(ct){
+    label_y = h() - 5; 
+    marker_y = label_y - marker_height - font_height;
+    wedge_y = marker_y - wedge_height;
+    redraw_range(0, ct->size-1);
+    redraw_marker();
   }
 }
 
-void ColorBarRedraw(void){
-  if(!TheCB) return;
-  redraw_range(TheCB, 0, TheCB->ct->size-1);
-  redraw_marker(TheCB);
-}
+// Update
 
-void ColorBarChange(char *label, float min, float max, ColorTable *ct, int rgb){
-  strncpy(TheCB->label, label, LABEL_STR_L);
-  TheCB->ct     = ct;
-  TheCB->minval = min;
-  TheCB->maxval = max;
-  if (rgb) redraw_range(TheCB, 0, TheCB->ct->size-1);
-  redraw_marker(TheCB);
+void Colorbar_Window::update(char *name, float min, float max, ColorTable *table){
+  label  = name;
+  ct     = table;
+  minval = min;
+  maxval = max;
+  redraw();
 }
 
-void ColorBarInput(){
-  static int      p1=0, p2=0, p3=0, p4=0; /* red, green, blue, alpha */
+// Handle
+
+int Colorbar_Window::handle(int event){
+  static int      p1=0, p2=0, p3=0, p4=0;
   static int      pentry, move_marker;
-  int             i, modify, entry, compute;
-  char            keybuf[50];
+  int             i, ibut, xpos, ypos, modify, entry, compute;
 
-  event  = call_data->event;   
   modify = 0;
   compute = 0;
 
-  /* shortcut */
-  
-  if (event->type==KeyPress) {
-
-    switch(key){
-    case XK_1 : ColorTable_InitParam(1, TheCB->ct, 1, 1); compute=1; break;
-    case XK_2 : ColorTable_InitParam(2, TheCB->ct, 1, 1); compute=1; break;
-    case XK_3 : ColorTable_InitParam(3, TheCB->ct, 1, 1); compute=1; break;
-    case XK_4 : ColorTable_InitParam(4, TheCB->ct, 1, 1); compute=1; break;
-    case XK_5 : ColorTable_InitParam(5, TheCB->ct, 1, 1); compute=1; break;
-    case XK_6 : ColorTable_InitParam(6, TheCB->ct, 1, 1); compute=1; break;
-    case XK_7 : ColorTable_InitParam(7, TheCB->ct, 1, 1); compute=1; break;
-    case XK_8 : ColorTable_InitParam(8, TheCB->ct, 1, 1); compute=1; break;
-    case XK_9 : ColorTable_InitParam(9, TheCB->ct, 1, 1); compute=1; break;
-    case XK_0 : ColorTable_InitParam(0, TheCB->ct, 1, 1); compute=1; break;
-
-    case XK_c : case XK_C : ColorTable_Copy(TheCB->ct); break;
-    case XK_p : case XK_P : ColorTable_Paste(TheCB->ct); ColorBarRedraw(); break;
-    case XK_h : case XK_H : TheCB->helpflag = !TheCB->helpflag; ColorBarRedraw(); break;
-
-    case XK_r : 
-    case XK_R : 
-      ColorTable_InitParam(TheCB->ct->ipar[COLORTABLE_NUMBER], 
-                           TheCB->ct, 1, 1); 
-      compute=1; 
-      break;
-
-    case XK_m : 
-    case XK_M : 
-      if(TheCB->ct->ipar[COLORTABLE_MODE]==COLORTABLE_RGB)
-        TheCB->ct->ipar[COLORTABLE_MODE] = COLORTABLE_HSV;
-      else
-        TheCB->ct->ipar[COLORTABLE_MODE] = COLORTABLE_RGB;
-      ColorBarRedraw(); 
-      break;
-
-    case XK_i : 
-    case XK_I : 
-      if (event->xkey.state&ANY_MODIFIER)
-        TheCB->ct->ipar[COLORTABLE_INVERT] = !TheCB->ct->ipar[COLORTABLE_INVERT]; 
+  switch(event){
+
+  case FL_SHORTCUT :
+
+    if(Fl::test_shortcut('0')){
+      ColorTable_InitParam(0, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('1')){
+      ColorTable_InitParam(1, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('2')){
+      ColorTable_InitParam(2, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('3')){
+      ColorTable_InitParam(3, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('4')){
+      ColorTable_InitParam(4, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('5')){
+      ColorTable_InitParam(5, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('6')){
+      ColorTable_InitParam(6, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('7')){
+      ColorTable_InitParam(7, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('8')){
+      ColorTable_InitParam(8, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('9')){
+      ColorTable_InitParam(9, ct, 1, 1); compute=1;
+    }
+    else if(Fl::test_shortcut('c')){
+      ColorTable_Copy(ct);
+    }
+    else if(Fl::test_shortcut('p')){
+      ColorTable_Paste(ct); 
+      draw();
+    }
+    else if(Fl::test_shortcut('h')){
+      help_flag = !help_flag;
+      draw();
+    }
+    else if(Fl::test_shortcut('r')){
+      ColorTable_InitParam(ct->ipar[COLORTABLE_NUMBER], 
+                           ct, 1, 1); 
+      compute=1;
+    }
+    else if(Fl::test_shortcut('m')){
+      if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
+        ct->ipar[COLORTABLE_MODE] = COLORTABLE_HSV;
       else
-        TheCB->ct->ipar[COLORTABLE_SWAP] = !TheCB->ct->ipar[COLORTABLE_SWAP];   
+        ct->ipar[COLORTABLE_MODE] = COLORTABLE_RGB;
+      draw(); 
+    }
+    else if(Fl::test_shortcut('i')){
+      ct->ipar[COLORTABLE_SWAP] = !ct->ipar[COLORTABLE_SWAP];   
       compute=1;
-      break;
-
-    case XK_b :
-    case XK_B :
-      if (event->xkey.state&ANY_MODIFIER) {
-        TheCB->ct->fpar[COLORTABLE_BETA] -= 0.05;
-        if(TheCB->ct->fpar[COLORTABLE_BETA]<-1.0) 
-          TheCB->ct->fpar[COLORTABLE_BETA] = -1.0;
-      }
-      else{
-        TheCB->ct->fpar[COLORTABLE_BETA] += 0.05;
-        if(TheCB->ct->fpar[COLORTABLE_BETA]>1.0) 
-          TheCB->ct->fpar[COLORTABLE_BETA] = 1.0;
-      }
+    }
+    else if(Fl::test_shortcut(FL_CTRL + 'i')){
+      ct->ipar[COLORTABLE_INVERT] = !ct->ipar[COLORTABLE_INVERT]; 
+      compute=1;
+    }
+    else if(Fl::test_shortcut('b')){
+      ct->fpar[COLORTABLE_BETA] += 0.05;
+      if(ct->fpar[COLORTABLE_BETA]>1.0) 
+	ct->fpar[COLORTABLE_BETA] = 1.0;
       compute = 1;
-      break;
-
-    case XK_Left  : 
-      if (event->xkey.state&ANY_MODIFIER) {
-        TheCB->ct->ipar[COLORTABLE_ROTATE] += 5;
-        if(TheCB->ct->ipar[COLORTABLE_ROTATE] > TheCB->ct->size-1) 
-          TheCB->ct->ipar[COLORTABLE_ROTATE] -= TheCB->ct->size-1;
-      }
-      else
-        TheCB->ct->fpar[COLORTABLE_BIAS] -= 0.05; 
+    }
+    else if(Fl::test_shortcut(FL_CTRL + 'b')){
+      ct->fpar[COLORTABLE_BETA] -= 0.05;
+      if(ct->fpar[COLORTABLE_BETA]<-1.0) 
+	ct->fpar[COLORTABLE_BETA] = -1.0;
+      compute = 1;
+    }
+    else if(Fl::test_shortcut(FL_Left)){
+      ct->fpar[COLORTABLE_BIAS] -= 0.05; 
       compute = 1; 
-      break;
-
-    case XK_Right : 
-      if (event->xkey.state&ANY_MODIFIER) {
-        TheCB->ct->ipar[COLORTABLE_ROTATE] -= 5;
-        if(TheCB->ct->ipar[COLORTABLE_ROTATE]<-(TheCB->ct->size-1)) 
-          TheCB->ct->ipar[COLORTABLE_ROTATE] += TheCB->ct->size-1;
-      }
-      else{
-        TheCB->ct->fpar[COLORTABLE_BIAS] += 0.05; 
-      }
+    }
+    else if(Fl::test_shortcut(FL_CTRL + FL_Left)){
+      ct->ipar[COLORTABLE_ROTATE] += 5;
+      if(ct->ipar[COLORTABLE_ROTATE] > ct->size-1) 
+	ct->ipar[COLORTABLE_ROTATE] -= ct->size-1;
+      compute = 1; 
+    }
+    else if(Fl::test_shortcut(FL_Right)){
+      ct->fpar[COLORTABLE_BIAS] += 0.05; 
       compute = 1;
-      break;
-
-    case XK_Up :
-      if (event->xkey.state&ANY_MODIFIER) {
-        TheCB->ct->fpar[COLORTABLE_ALPHAPOW] -= 0.05;
-        if (TheCB->ct->fpar[COLORTABLE_ALPHAPOW]<0.0)
-          TheCB->ct->fpar[COLORTABLE_ALPHAPOW] = 0.0;
-      }
-      else
-        TheCB->ct->fpar[COLORTABLE_CURVE] -= 0.05;
+    }
+    else if(Fl::test_shortcut(FL_CTRL + FL_Right)){
+      ct->ipar[COLORTABLE_ROTATE] -= 5;
+      if(ct->ipar[COLORTABLE_ROTATE] < -(ct->size-1)) 
+	ct->ipar[COLORTABLE_ROTATE] += ct->size-1;
+      compute = 1;
+    }
+    else if(Fl::test_shortcut(FL_Up)){
+      ct->fpar[COLORTABLE_CURVE] -= 0.05;
       compute = 1; 
-      break;
-
-    case XK_Down :
-      if (event->xkey.state&ANY_MODIFIER)
-        TheCB->ct->fpar[COLORTABLE_ALPHAPOW] += 0.05;
-      else
-        TheCB->ct->fpar[COLORTABLE_CURVE] += 0.05;
+    }
+    else if(Fl::test_shortcut(FL_CTRL + FL_Up)){
+      ct->fpar[COLORTABLE_ALPHAPOW] -= 0.05;
+      if (ct->fpar[COLORTABLE_ALPHAPOW] < 0.0)
+	ct->fpar[COLORTABLE_ALPHAPOW] = 0.0;
+      compute = 1; 
+    }
+    else if(Fl::test_shortcut(FL_Down)){
+      ct->fpar[COLORTABLE_CURVE] += 0.05;
       compute = 1; 
-      break;
-
+    }
+    else if(Fl::test_shortcut(FL_CTRL + FL_Down)){
+      ct->fpar[COLORTABLE_ALPHAPOW] += 0.05;
+      compute = 1; 
+    }
+    else{
+      return Fl_Window::handle(event); 
     }
 
     if(compute){
-      ColorTable_Recompute(TheCB->ct, 1, 1);
-      ColorBarRedraw();
+      ColorTable_Recompute(ct, 1, 1);
+      draw();
     }
-
-  }
-
-  /* button press */
-
-  else if (event->type==ButtonPress) {
-
-    if(TheCB->helpflag){
-      TheCB->helpflag = 0;
-      ColorBarRedraw();
+    // discard the event for other uses
+    return 1;
+
+  case FL_PUSH :
+    ibut = Fl::event_button();
+    xpos = Fl::event_x();
+    ypos = Fl::event_y();
+    if(help_flag){
+      help_flag = 0;
+      draw();
     }
-
-    if (event->xbutton.y<TheCB->wedge_y) {
-      /* change color function */
+    // change color function or marker position
+    if (ypos < wedge_y)
       move_marker = 0;
-    }
-    else {
-      /* change marker position */
+    else
       move_marker = 1;
-    }
-    /* determine which curve to modify */
-    if (event->xbutton.state&ANY_MODIFIER) {
+
+    // determine which curve to modify
+    if (0) {
       p4 = 1;
     }
     else {
-      if (event->xbutton.button==Button1)  p1 = 1;
-      if (event->xbutton.button==Button2)  p2 = 1;
-      if (event->xbutton.button==Button3)  p3 = 1;
+      switch(ibut){
+      case 1 : p1 = 1 ; break ;
+      case 2 : p2 = 1 ; break ;
+      case 3 : p3 = 1 ; break ;
+      }
     }
-    pentry = x_to_index(TheCB, event->xbutton.x);
+    pentry = x_to_index(xpos);
     modify = 1;
-  }
-
-  /* souris relachee */
-
-  else if (event->type==ButtonRelease) {
-    if (event->xbutton.button==Button1)  p1 = 0;
-    if (event->xbutton.button==Button2)  p2 = 0;
-    if (event->xbutton.button==Button3)  p3 = 0;
+    break;
+
+  case FL_RELEASE :
+    ibut = Fl::event_button();
+    xpos = Fl::event_x();
+    ypos = Fl::event_y();
+    switch(ibut){
+    case 1 : p1 = 0 ; break ;
+    case 2 : p2 = 0 ; break ;
+    case 3 : p3 = 0 ; break ;
+    }
     p4 = 0;
-  }
+    break;
 
-  /* bouger */
-
-  else if (event->type==MotionNotify) {
-    /* Flush extra MotionNotify events */
-    while (QLength(XCTX.display)>0) {
-      XEvent next;
-      XPeekEvent(XCTX.display, &next);
-      if (next.type!=MotionNotify)
-        break;
-      XNextEvent(XCTX.display, event);
-    }
+  case FL_DRAG :
+    ibut = Fl::event_button();
+    xpos = Fl::event_x();
+    ypos = Fl::event_y();
     modify = 1;
+    break;
+
+  default:
+    // don't know what to do with the event: passing it to parent
+    return Fl_Window::handle(event);
+    
   }
 
-  /* Modify one or more of the color curves */
+  // Modify one or more of the color curves
   
-   if (modify && (p1 || p2 || p3 || p4)) {
-     /* calculate which entry in color table to change */
-     entry = x_to_index(TheCB, event->xbutton.x);
-     /* update */
-     if (move_marker) {
-       /* changing marker position */
-       TheCB->markerpos = entry;
-       redraw_marker(TheCB);
-     }
-     else {
-       /* changing color graph */
-       int a, b, value;
-       
-       value = y_to_intensity(TheCB, event->xbutton.y);
-
-       if (pentry<=entry) {
-         a = pentry;
-         b = entry;
-       }
-       else {
-         a = entry;
-         b = pentry;
-       }
-       
-       /* update entries from 'pentry' to 'entry' */
-       for (i=a; i<=b; i++) {
-         int red, green, blue, alpha;
-         double R,G,B,H,S,V;
-         
-         red   = UNPACK_RED  (TheCB->ct->table[i]);
-         green = UNPACK_GREEN(TheCB->ct->table[i]);
-         blue  = UNPACK_BLUE (TheCB->ct->table[i]);
-         alpha = UNPACK_ALPHA(TheCB->ct->table[i]);
-         
-         if(TheCB->ct->ipar[COLORTABLE_MODE]==COLORTABLE_RGB){
-           if (p1) { red = value; }
-           if (p2) { green = value; }
-           if (p3) { blue = value; }
-           if (p4) { alpha = value; }
-         }         
-         else if(TheCB->ct->ipar[COLORTABLE_MODE]==COLORTABLE_HSV){
-           RGB_to_HSV((double)red/255.,(double)green/255.,(double)blue/255.,
-                      &H,&S,&V);
-           if (p1) { H = 6.*(double)value/255.+EPS ; }
-           if (p2) { S = (double)value/255.; }
-           if (p3) { V = (double)value/255.; }
-           if (p4) { alpha = value; }         
-           HSV_to_RGB(H, S, V, &R,&G,&B);
-           red   = (int)(255 * R);
-           green = (int)(255 * G);
-           blue  = (int)(255 * B);
-         }
-         
-         TheCB->ct->table[i] = PACK_COLOR(red,green,blue,alpha);
-       } 
-       
-       /* redraw the color curves */
-       if (pentry<entry)
-         redraw_range(TheCB, pentry-1, entry+1);
-       else
-         redraw_range(TheCB, entry-1, pentry+1);
-       
-       pentry = entry;
+  if (modify && (p1 || p2 || p3 || p4)) {
+    // calculate which entry in color table to change
+    entry = x_to_index(xpos);
+    // update
+    if (move_marker) {
+      // changing marker position
+      marker_pos = entry;
+      redraw_marker();
+    }
+    else {
+      // changing color graph
+      int a, b, value;
+      
+      value = y_to_intensity(ypos);
+      
+      if (pentry<=entry) {
+	a = pentry;
+	b = entry;
+      }
+      else {
+	a = entry;
+	b = pentry;
+      }
+      
+      // update entries from 'pentry' to 'entry'
+      for (i=a; i<=b; i++) {
+	int red, green, blue, alpha;
+	double R,G,B,H,S,V;
+	
+	red   = UNPACK_RED  (ct->table[i]);
+	green = UNPACK_GREEN(ct->table[i]);
+	blue  = UNPACK_BLUE (ct->table[i]);
+	alpha = UNPACK_ALPHA(ct->table[i]);
+	
+	if(ct->ipar[COLORTABLE_MODE]==COLORTABLE_RGB){
+	  if (p1) { red = value; }
+	  if (p2) { green = value; }
+	  if (p3) { blue = value; }
+	  if (p4) { alpha = value; }
+	}         
+	else if(ct->ipar[COLORTABLE_MODE]==COLORTABLE_HSV){
+	  RGB_to_HSV((double)red/255.,(double)green/255.,(double)blue/255.,
+		     &H,&S,&V);
+	  if (p1) { H = 6.*(double)value/255.+EPS ; }
+	  if (p2) { S = (double)value/255.; }
+	  if (p3) { V = (double)value/255.; }
+	  if (p4) { alpha = value; }         
+	  HSV_to_RGB(H, S, V, &R,&G,&B);
+	  red   = (int)(255 * R);
+	  green = (int)(255 * G);
+	  blue  = (int)(255 * B);
+	}
+	
+	ct->table[i] = PACK_COLOR(red,green,blue,alpha);
+      } 
        
-     }
-   }
-   
+      // redraw the color curves
+      if (pentry<entry)
+	redraw_range(pentry-1, entry+1);
+      else
+	redraw_range(entry-1, pentry+1);
+      
+      pentry = entry;
+      
+    }
+    return 1;
+  }
+  
+  return 1;
+
 }
 
-#endif
+
diff --git a/Fltk/Colorbar_Window.h b/Fltk/Colorbar_Window.h
index 9bdc872a2e..434b0a90e3 100644
--- a/Fltk/Colorbar_Window.h
+++ b/Fltk/Colorbar_Window.h
@@ -3,19 +3,35 @@
 
 #include "ColorTable.h"
 
-typedef struct _colorbar {
-  int width, height;           /* size */
-  int wedge_y;                 /* top coord of color wedge */
-  int marker_y;                /* top coord of marker arrow */
-  int label_y;                 /* y coord of text labels */
-  char label[LABEL_STR_L];     /* text label at bottom */
-  float minval, maxval;        /* min and max data values */
-  int markerpos;               /* position of marker as index into table */
-  int helpflag;                /* if nonzero, print help messages */  
-  ColorTable *ct;              /* pointer to color table (allocated in Post_View) */
-} ColorBar;
-
-#define WEDGE_HEIGHT    12  /* epaisseur de la colorbar */
-#define MARKER_HEIGHT   10  /* hauteur de la fleche */
+class Colorbar_Window : public Fl_Window {
+  void draw();
+  int  handle(int);
+
+  // new
+  int  x_to_index(int x);
+  int  index_to_x(int index);
+  int  intensity_to_y(int intensity);
+  int  y_to_intensity(int y);
+  void redraw_range(int a, int b);
+  void redraw_marker();
+
+  int font_height, marker_height, wedge_height;
+  char *label;
+
+  float minval, maxval;  // min and max data values
+  int wedge_y;     // top coord of color wedge
+  int marker_y;    // top coord of marker arrow
+  int label_y;     // y coord of text labels
+  int help_flag;   // if nonzero, print help message
+  int marker_pos;  // position of marker as index into table
+  
+  ColorTable *ct; // pointer to the color table (allocated in Post_View)
+
+public:
+
+  Colorbar_Window(int x,int y,int w,int h,const char *l=0);
+  void update(char *name, float min, float max, ColorTable *ct);
+
+};
 
 #endif
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index e82b9d9578..990b25aaf6 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,3 +1,4 @@
+// $Id: GUI.cpp,v 1.30 2001-01-29 08:43:44 geuzaine Exp $
 
 // To make the interface as visually consistent as possible, please:
 // - use the BH, BW, WB, IW values for button heights/widths, window borders, etc.
@@ -322,7 +323,7 @@ GUI::GUI(int argc, char **argv) {
   create_help_window();
   create_about_window();
 
-  // Draw the actual scene
+  // Draw the scene
 
   g_opengl_window->redraw();
 
@@ -423,6 +424,7 @@ void GUI::create_menu_window(int argc, char **argv){
       m_window->show(1, argv);
     
   }
+
 }
 
 // Dynamically set the height of the menu window
@@ -549,7 +551,8 @@ void GUI::create_graphic_window(int argc, char **argv){
 
     g_window = new Fl_Window(width, height);
     g_opengl_window = new Opengl_Window(0,0,width,glheight);
-    
+    g_opengl_window->end();
+
     {
       Fl_Group *o = new Fl_Group(0,glheight,width,sh);
       o->box(FL_THIN_UP_BOX);
@@ -653,33 +656,29 @@ void GUI::set_status(char *msg, int num){
   g_status_label[num]->redraw();
 }
 
-// set the current drawing context to the main opengl window
+// set the current drawing context 
 
-void GUI::make_current(){
+void GUI::make_opengl_current(){
   g_opengl_window->make_current();
 }
 
-// set the current drawing context to the overlay opengl window
-
 void GUI::make_overlay_current(){
   g_opengl_window->make_overlay_current();
 }
 
-// swap buffer
-
-void GUI::swap_buffers(){
-  g_opengl_window->swap_buffers();
+void GUI::make_colorbar_current(){
+  view_colorbar_window->make_current();
 }
 
 // Draw the opengl window
 
-void GUI::draw(){
+void GUI::redraw_opengl(){
   g_opengl_window->redraw();
 }
 
 // Draw the opengl overlay window
 
-void GUI::draw_overlay(){
+void GUI::redraw_overlay(){
   g_opengl_window->redraw_overlay();
 }
 
@@ -1048,8 +1047,8 @@ void GUI::create_mesh_options_window(){
 	}
         mesh_value[4] = new Fl_Value_Input(2*WB, 2*WB+4*BH, IW, BH, "Explode elements");
 	mesh_value[4]->minimum(0);
-	mesh_value[4]->maximum(100);
-	mesh_value[4]->step(1);
+	mesh_value[4]->maximum(1);
+	mesh_value[4]->step(0.01);
 	mesh_value[4]->callback(opt_mesh_explode_cb);
 	mesh_value[4]->value(CTX.mesh.explode);
 	mesh_value[4]->labelsize(CTX.fontsize);
@@ -1494,12 +1493,23 @@ void GUI::create_view_window(int num){
     init_view_window = 1 ;
 
     int width = 32*CTX.fontsize;
-    int height = 5*WB+7*BH ;
+    int height = 5*WB+7*BH + 7*CTX.fontsize;
     
     view_window = new Fl_Window(width,height);
     view_window->box(FL_THIN_UP_BOX);
+
     { 
       Fl_Tabs* o = new Fl_Tabs(WB, WB, width-2*WB, height-3*WB-BH);
+      // Colors
+      { 
+	view_colors = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Colors");
+	view_colors->labelsize(CTX.fontsize);
+        //view_colorbar->hide();
+	view_colorbar_window = new Colorbar_Window(2*WB, 2*WB+1*BH,
+						   width-4*WB, height-5*WB-2*BH);
+	view_colorbar_window->end();
+        view_colors->end();
+      }
       // Color bar
       { 
 	view_colorbar = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Color bar");
@@ -1514,8 +1524,8 @@ void GUI::create_view_window(int num){
 	  view_butt[i]->labelsize(CTX.fontsize);
 	  view_butt[i]->selection_color(FL_YELLOW);
 	}
-	view_input[0] = new Fl_Input (2*WB, 2*WB+4*BH, IW, BH, "Title");
-	view_input[1] = new Fl_Input (2*WB, 2*WB+5*BH, IW, BH, "Format");
+	view_input[0] = new Fl_Input(2*WB, 2*WB+4*BH, IW, BH, "Title");
+	view_input[1] = new Fl_Input(2*WB, 2*WB+5*BH, IW, BH, "Format");
 	for(i=0 ; i<2 ; i++){
 	  view_input[i]->labelsize(CTX.fontsize);
 	  view_input[i]->align(FL_ALIGN_RIGHT);
@@ -1553,6 +1563,7 @@ void GUI::create_view_window(int num){
       {
 	view_intervals = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Intervals");
 	view_intervals->labelsize(CTX.fontsize);
+	view_intervals->hide();
 	view_value[2] = new Fl_Value_Input(2*WB, 2*WB+1*BH, IW, BH, "Number of intervals");
 	view_value[2]->labelsize(CTX.fontsize);
 	view_value[2]->type(FL_HORIZONTAL);
@@ -1574,7 +1585,7 @@ void GUI::create_view_window(int num){
       }
       // Offset and Raise
       { 
-	view_offsetraise = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Offset/Raise");
+	view_offsetraise = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Offset");
 	view_offsetraise->labelsize(CTX.fontsize);
         view_offsetraise->hide();
 	view_value[3] = new Fl_Value_Input(2*WB, 2*WB+1*BH, IW, BH, "X offset");
@@ -1663,15 +1674,18 @@ void GUI::create_view_window(int num){
     if(CTX.center_windows)
       view_window->position(m_window->x()+m_window->w()/2-width/2,
 			    m_window->y()+2*MH);
+
+    view_window->resizable(view_colorbar_window);
     view_window->end();
   }
-  
-  update_view_window(num);
 
+  update_view_window(num);
+  
   if(view_window->shown())
     view_window->redraw();
   else
     view_window->show();
+
 }
 
 void GUI::update_view_window(int num){
@@ -1683,7 +1697,7 @@ void GUI::update_view_window(int num){
   sprintf(buffer, "Options for \"%s\" (\"%s\")", v->Name, v->FileName);
   view_window->label(buffer);
 
-  // colorbar
+  // colobar
   view_butt[0]->callback(view_options_show_scale_cb, (void*)num);
   view_butt[0]->value(v->ShowScale);
   view_butt[1]->callback(view_options_show_time_cb, (void*)num);
@@ -1694,6 +1708,7 @@ void GUI::update_view_window(int num){
   view_input[0]->value(v->Name);
   view_input[1]->callback(view_options_format_cb, (void*)num);
   view_input[1]->value(v->Format);
+  view_colorbar_window->update(v->Name, v->Min, v->Max, &v->CT);
 
   // range
   if(v->RangeType==DRAW_POST_CUSTOM) activate_custom(1);
@@ -1771,6 +1786,7 @@ void GUI::update_view_window(int num){
   view_butt[14]->value(v->ArrowLocation==DRAW_POST_LOCATE_COG);
   view_butt[15]->callback(view_options_vector_vertex_cb, (void*)num);
   view_butt[15]->value(v->ArrowLocation==DRAW_POST_LOCATE_VERTEX);
+
 }
 
 // Handle activation of cutom min/max
diff --git a/Fltk/GUI.h b/Fltk/GUI.h
index 098b9db34b..d193a2f566 100644
--- a/Fltk/GUI.h
+++ b/Fltk/GUI.h
@@ -133,11 +133,12 @@ class GUI{
 
   // view options window
   Fl_Window        *view_window ;
-  Fl_Group         *view_colorbar, *view_range, *view_intervals ;
+  Fl_Group         *view_colors, *view_colorbar, *view_range, *view_intervals ;
   Fl_Group         *view_offsetraise, *view_timestep, *view_vector ;
   Fl_Check_Button  *view_butt[20] ;
   Fl_Value_Input   *view_value[20] ;
   Fl_Input         *view_input[20] ;
+  Colorbar_Window  *view_colorbar_window ;
   
   // geometry context window
   Fl_Window        *context_geometry_window ;
@@ -170,11 +171,11 @@ public:
   // general purpose interaction
   void run();
   void check();
-  void make_current();
+  void make_opengl_current();
+  void make_colorbar_current();
   void make_overlay_current();
-  void swap_buffers();
-  void draw();
-  void draw_overlay();
+  void redraw_opengl();
+  void redraw_overlay();
   void set_size(int w, int h);
   void set_menu_size(int nb_butt);
   void get_position(int m[2], int g[2]);
diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp
index 171d956ed9..d2a83b3173 100644
--- a/Fltk/Main.cpp
+++ b/Fltk/Main.cpp
@@ -1,4 +1,4 @@
-// $Id: Main.cpp,v 1.12 2001-01-24 09:28:03 geuzaine Exp $
+// $Id: Main.cpp,v 1.13 2001-01-29 08:43:44 geuzaine Exp $
 
 #include <signal.h>
 
@@ -27,6 +27,10 @@ int main(int argc, char *argv[]){
   
   Init_Context();
 
+  // This does not work with FLTK right now...
+  CTX.overlay = 0 ;
+  CTX.geom.highlight = 0 ;
+
   // Configuration file and command line options
 
   Get_Options(argc, argv, &nbf);
@@ -132,7 +136,6 @@ int main(int argc, char *argv[]){
   }
 
   // Draw the actual scene
-  Init();
   Draw();
   CTX.expose = 1 ;
 
diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp
index 11be21a18a..ce3498919a 100644
--- a/Fltk/Opengl.cpp
+++ b/Fltk/Opengl.cpp
@@ -1,4 +1,4 @@
-// $Id: Opengl.cpp,v 1.13 2001-01-13 15:41:35 geuzaine Exp $
+// $Id: Opengl.cpp,v 1.14 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -21,45 +21,27 @@ void myZoom(GLdouble X1, GLdouble X2, GLdouble Y1, GLdouble Y2,
             GLdouble Xc1, GLdouble Xc2, GLdouble Yc1, GLdouble Yc2);
 
 /* ------------------------------------------------------------------------ */
-/*  Init/Draw                                                               */
+/*  Draw                                                               */
 /* ------------------------------------------------------------------------ */
 
-void Init(void){
+void InitOpengl(void){
+  WID->make_opengl_current();
+  Orthogonalize(0,0);
 }
 
 void InitOverlay(void){
   WID->make_overlay_current();
+  Orthogonalize(0,0);
 }
 
 void Draw(void){
-  WID->draw();
-}
-
-void DrawOverlay(void){
-  WID->draw_overlay();
+  WID->redraw_opengl();
 }
 
 void DrawUI(void){
   WID->check();
 }
 
-// Opengl_Window::draw() from the handle(), but
-// rather the following:
-
-void DrawUpdate(){
-  if(!CTX.expose) return ;
-  WID->make_current();
-  Orthogonalize(0,0);
-  glClearColor(UNPACK_RED(CTX.color.bg)/255.,
-               UNPACK_GREEN(CTX.color.bg)/255.,
-               UNPACK_BLUE(CTX.color.bg)/255.,
-               0.);
-  glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
-  Draw3d();
-  Draw2d();
-  WID->swap_buffers();
-}
-
 void Draw_String(char *s){
 
   if(CTX.stream == TO_FILE){
@@ -70,6 +52,8 @@ void Draw_String(char *s){
   }
 
   gl_font(FL_HELVETICA, CTX.gl_fontsize);
+  CTX.gl_fontheight = gl_height() ;
+  CTX.gl_fontascent = gl_height()-gl_descent() ;
   gl_draw(s);
 
 }
diff --git a/Fltk/Opengl_Window.cpp b/Fltk/Opengl_Window.cpp
index e57f3fabe5..77376a2245 100644
--- a/Fltk/Opengl_Window.cpp
+++ b/Fltk/Opengl_Window.cpp
@@ -1,4 +1,4 @@
-// $Id: Opengl_Window.cpp,v 1.7 2001-01-11 12:25:23 geuzaine Exp $
+// $Id: Opengl_Window.cpp,v 1.8 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -23,25 +23,19 @@ void myZoom(GLdouble X1, GLdouble X2, GLdouble Y1, GLdouble Y2,
             GLdouble Xc1, GLdouble Xc2, GLdouble Yc1, GLdouble Yc2);
 
 void Opengl_Window::draw() {
-  if (!valid()) {
+  if(!valid()){
     valid(1);
-    CTX.viewport[0] = 0 ;
-    CTX.viewport[1] = 0 ;
-    CTX.viewport[2] = w() ;
-    CTX.viewport[3] = h() ;
-    glViewport(CTX.viewport[0],
-	       CTX.viewport[1],
-	       CTX.viewport[2],
-	       CTX.viewport[3]);
+    CTX.viewport[0] = 0 ; CTX.viewport[1] = 0 ;
+    CTX.viewport[2] = w() ; CTX.viewport[3] = h() ;
+    glViewport(CTX.viewport[0], CTX.viewport[1],
+	       CTX.viewport[2], CTX.viewport[3]);
   }
   if((w() != CTX.viewport[2]-CTX.viewport[0]) ||
      (h() != CTX.viewport[3]-CTX.viewport[1])){
     WID->set_size(CTX.viewport[2]-CTX.viewport[0],
 		  CTX.viewport[3]-CTX.viewport[1]);
-    glViewport(CTX.viewport[0],
-	       CTX.viewport[1],
-	       CTX.viewport[2],
-	       CTX.viewport[3]);
+    glViewport(CTX.viewport[0], CTX.viewport[1],
+	       CTX.viewport[2], CTX.viewport[3]);
   }
   Orthogonalize(0,0);
   glClearColor(UNPACK_RED(CTX.color.bg)/255.,
@@ -105,7 +99,6 @@ void Opengl_Window::draw_overlay_highlight(){
   else{
     if(ov != v || oc != c || os != s) { 
       if(CTX.geom.highlight){
-	Init();
 	Draw();
       }
       BeginHighlight();
@@ -129,48 +122,41 @@ static int Modifier=0;
 // parent.
 
 int Opengl_Window::handle(int event) {
-  GLuint          ii[SELECTION_BUFFER_SIZE], jj[SELECTION_BUFFER_SIZE];
-  int             previous_mesh_draw, previous_post_draw ;
-  int             width, height ;
-
-  static int      ibut, hits;
-  static int      ButtonPressed=0, ZoomClick=0, FirstClick=0;
-  static int      x, y, movx, movy;
+  static int      xpos, ypos, xmov, ymov, ibut, hits;
+  static int      ZoomClick=0, FirstClick=0;
   static GLdouble xc1, yc1, xc2, yc2, xt1, yt1, xscale1, yscale1;
   static GLdouble xb, yb, xc, yc, xe, ye, xz, yz;
   static GLdouble movzx, movzy;
   static Vertex   *v=NULL, *ov;
   static Curve    *c=NULL, *oc;
   static Surface  *s=NULL, *os;
-  
-  width  = w() ;
-  height = h() ;
+
+  GLuint  ii[SELECTION_BUFFER_SIZE], jj[SELECTION_BUFFER_SIZE];
 
   switch (event) {
 
   case FL_PUSH:
-    ButtonPressed++;
-    FirstClick=1;
+    FirstClick = 1;
     ibut = Fl::event_button();
-    x    = Fl::event_x();
-    y    = Fl::event_y();
+    xpos = Fl::event_x();
+    ypos = Fl::event_y();
 
     switch(ibut){
     case 1:
       if(!ZoomClick && Modifier){
-        xb = CTX.vxmin + ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin);
-        yb = CTX.vymax - ((GLdouble) y / height) * (CTX.vymax - CTX.vymin);
+        xb = CTX.vxmin + ((double)xpos/(double)w()) * (CTX.vxmax - CTX.vxmin);
+        yb = CTX.vymax - ((double)ypos/(double)h()) * (CTX.vymax - CTX.vymin);
         xc1 = xb/CTX.s[0] - CTX.t[0];
         yc1 = yb/CTX.s[1] - CTX.t[1];
-        ZoomClick=1;
+        ZoomClick = 1;
         Modifier = 0;
       }
       else if(ZoomClick){
-        xe = CTX.vxmin + ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin);
-        ye = CTX.vymax - ((GLdouble) y / height) * (CTX.vymax - CTX.vymin);
+        xe = CTX.vxmin + ((double)xpos/(double)w()) * (CTX.vxmax - CTX.vxmin);
+        ye = CTX.vymax - ((double)ypos/(double)h()) * (CTX.vymax - CTX.vymin);
         xc2 = xe/CTX.s[0] - CTX.t[0];
         yc2 = ye/CTX.s[1] - CTX.t[1];     
-        ZoomClick=0;
+        ZoomClick = 0;
         clear_overlay();
         if(xb!=xe && yb!=ye) myZoom(xb,xe,yb,ye,xc1,xc2,yc1,yc2);
       }
@@ -183,77 +169,105 @@ int Opengl_Window::handle(int event) {
         Modifier = 0;
         set_s(1, CTX.s[0]);
         set_s(2, CTX.s[0]);
-        DrawUpdate();
+        redraw();
       }
       else{
-        ZoomClick=0;
+        ZoomClick = 0;
         clear_overlay();
       }
       break;      
     case 3:
       if(Modifier && !ZoomClick){
         Modifier = 0;
-	if(CTX.useTrackball){
+	if(CTX.useTrackball)
 	  CTX.setQuaternion(0.,0.,0.,1.);
-	}
 	else{
 	  set_r(0,0.); set_r(1,0.); set_r(2,0.); 
 	}
         set_t(0,0.); set_t(1,0.); set_t(2,0.);
         set_s(0,1.); set_s(1,1.); set_s(2,1.);
-        DrawUpdate();
+        redraw();
       }
       else{
-        ZoomClick=0;
+        ZoomClick = 0;
         clear_overlay();
       }
       break;
     }
-
     return 1;
 
   case FL_RELEASE:
-    if(ButtonPressed>0){
-      ButtonPressed--;
-      ibut = Fl::event_button();
-      x    = Fl::event_x();
-      y    = Fl::event_y();
-    }
+    ibut = Fl::event_button();
+    xpos = Fl::event_x();
+    ypos = Fl::event_y();
     if(!ZoomClick){
-      previous_mesh_draw = CTX.mesh.draw ;
-      previous_post_draw = CTX.post.draw ;
-      if(ButtonPressed>0){
-        if(CTX.fast) CTX.mesh.draw = CTX.post.draw = 0;
-      }
-      DrawUpdate();
-      CTX.mesh.draw = previous_mesh_draw ;
-      CTX.post.draw = previous_post_draw ;
+      CTX.mesh.draw = 1 ;
+      CTX.post.draw = 1 ;
+      redraw();
     }
     return 1;
 
       
   case FL_DRAG:
-    movx = Fl::event_x()-x;
-    movy = Fl::event_y()-y;
+    xmov = Fl::event_x() - xpos;
+    ymov = Fl::event_y() - ypos;
 
     if(ZoomClick) {
-      printf("should draw the zoom... %d %d %d %d\n", x, y, movx, movy);
+      printf("should draw the zoom... %d %d %d %d\n", xpos, ypos, xmov, ymov);
 
-      xz = CTX.vxmin + ((GLdouble) Fl::event_x() / width) *
-	(CTX.vxmax - CTX.vxmin);
-      yz = CTX.vymax - ((GLdouble) Fl::event_y() / height) * 
-	(CTX.vymax - CTX.vymin) ;
+      xz = CTX.vxmin + ((double)Fl::event_x()/(double)w()) * (CTX.vxmax - CTX.vxmin);
+      yz = CTX.vymax - ((double)Fl::event_y()/(double)h()) * (CTX.vymax - CTX.vymin);
+      movzx = xz - xb; movzy = yz - yb;
 
+      WID->make_opengl_current();
+      glPopMatrix();
+      glDisable(GL_DEPTH_TEST);
+      glDisable(GL_LIGHTING);
+      glMatrixMode(GL_PROJECTION);
+      glPushMatrix();
+      glLoadIdentity();
+      gluOrtho2D(CTX.vxmin, CTX.vxmax, CTX.vymin, CTX.vymax);
+      glMatrixMode(GL_MODELVIEW);
+      glPushMatrix();
+      glLoadIdentity();
+      if(CTX.db) glDrawBuffer(GL_BACK);
+      glDisable(GL_DEPTH_TEST);
+      glColor3f(1.,1.,1.);
+      glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
+      glEnable(GL_BLEND);
+      glBegin(GL_LINE_STRIP);
+      glVertex2d(xb,yb);
+      glVertex2d(xb+movzx,yb);
+      glVertex2d(xb+movzx,yb+movzy);
+      glVertex2d(xb,yb+movzy);
+      glVertex2d(xb,yb);
+      glEnd();
       movzx = xz - xb; movzy = yz - yb;
+      glBegin(GL_LINE_STRIP);
+      glVertex2d(xb,yb);
+      glVertex2d(xb+movzx,yb);
+      glVertex2d(xb+movzx,yb+movzy);
+      glVertex2d(xb,yb+movzy);
+      glVertex2d(xb,yb);
+      glEnd();
+      glDisable(GL_BLEND);
+      glEnable(GL_DEPTH_TEST);
+      glPopMatrix();
+      glMatrixMode(GL_PROJECTION);
+      glPopMatrix();
+      glMatrixMode(GL_MODELVIEW);
+      if(CTX.db) swap_buffers();
+      else glFlush();
+
     }
     else {
       clear_overlay();
 
       if(FirstClick){
-	xc1 = ( ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin) 
-		+ CTX.vxmin )/CTX.s[0] - CTX.t[0];
-	yc1 = ( CTX.vymax - ((GLdouble) y / height) * 
-		(CTX.vymax - CTX.vymin))/CTX.s[1] - CTX.t[1];
+	xc1 = (((double)xpos/(double)w()) * (CTX.vxmax-CTX.vxmin) + CTX.vxmin)
+	  / CTX.s[0] - CTX.t[0];
+	yc1 = (CTX.vymax - ((double)ypos/(double)h()) * (CTX.vymax-CTX.vymin))
+	  / CTX.s[1] - CTX.t[1];
 	xt1 = CTX.t[0];
 	yt1 = CTX.t[1];
 	xscale1 = CTX.s[0];
@@ -263,60 +277,57 @@ int Opengl_Window::handle(int event) {
 
       switch(ibut){
       case 1:
-	if(CTX.useTrackball){
-	  CTX.addQuaternion ((2.0*x - width) / width,
-			     (height - 2.0*y) / height,
-			     (2.0*Fl::event_x() - width) / width,
-			     (height - 2.0*Fl::event_y()) / height);
-	}
+	if(CTX.useTrackball)
+	  CTX.addQuaternion((2.0*xpos - w()) / w(),
+			    (h() - 2.0*ypos) / h(),
+			    (2.0*Fl::event_x() - w()) / w(),
+			    (h() - 2.0*Fl::event_y()) / h());
 	else{
-	  set_r(1, CTX.r[1] + ((abs(movx) > abs(movy))?180*(float)movx/(float)width:0));
-	  set_r(0, CTX.r[0] + ((abs(movx) > abs(movy))?0:180*(float)movy/(float)height));
+	  set_r(1, CTX.r[1] + ((abs(xmov) > abs(ymov))?180*(float)xmov/(float)w():0));
+	  set_r(0, CTX.r[0] + ((abs(xmov) > abs(ymov))?0:180*(float)ymov/(float)h()));
 	}
 	break;
       case 2:
 	if(!CTX.useTrackball)
-	  set_r(2, CTX.r[2] + ((abs(movy) > abs(movx))?0:-180*(float)movx/(float)width));         
-	set_s(0, CTX.s[0] * ( (abs(movy) > abs(movx)) ?
-			      ( (movy>0) ? (float)(1.04*(abs(movy)+height))/(float)height
-				: (float)(height)/(float)(1.04*(abs(movy)+height)) )
+	  set_r(2, CTX.r[2] + ((abs(ymov) > abs(xmov))?0:-180*(float)xmov/(float)w()));         
+	set_s(0, CTX.s[0] * ( (abs(ymov) > abs(xmov)) ?
+			      ( (ymov>0) ? (float)(1.04*(abs(ymov)+h()))/(float)h()
+				: (float)(h())/(float)(1.04*(abs(ymov)+h())) )
 			      : 1.) );                    
 	set_s(1, CTX.s[0]);
 	set_s(2, CTX.s[0]);
-	if(abs(movy) > abs(movx)){
+	if(abs(ymov) > abs(xmov)){
 	  set_t(0, xt1*(xscale1/CTX.s[0])-xc1*(1.-(xscale1/CTX.s[0])));
 	  set_t(1, yt1*(yscale1/CTX.s[1])-yc1*(1.-(yscale1/CTX.s[1])));
 	}
 	break;
       case 3:
-	xc = ( ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin) + 
-	       CTX.vxmin ) / CTX.s[0];
-	yc = ( CTX.vymax - ((GLdouble) y / height) *
-	       (CTX.vymax - CTX.vymin)) / CTX.s[1];
+	xc = ( ((double)xpos/(double)w()) * (CTX.vxmax - CTX.vxmin) + CTX.vxmin )
+	  / CTX.s[0];
+	yc = ( CTX.vymax - ((double)ypos/(double)h()) * (CTX.vymax - CTX.vymin))
+	  / CTX.s[1];
 	set_t(0, xc-xc1);
 	set_t(1, yc-yc1);
 	set_t(2, 0.);
 	break;
       }
-      previous_mesh_draw = CTX.mesh.draw ;
-      previous_post_draw = CTX.post.draw ;
+
       if(CTX.fast){
 	CTX.mesh.draw = 0 ;
 	CTX.post.draw = 0;
       }
-      DrawUpdate();
-      CTX.mesh.draw = previous_mesh_draw ;
-      CTX.post.draw = previous_post_draw ;
+      redraw();
+
     }
-    x += movx; 
-    y += movy; 
+    xpos += xmov; 
+    ypos += ymov; 
     return 1;
     
 
   case FL_MOVE:
-    movx = Fl::event_x()-x;
-    movy = Fl::event_y()-y;
-    WID->make_current();
+    xmov = Fl::event_x()-xpos;
+    ymov = Fl::event_y()-ypos;
+    WID->make_opengl_current();
     Process_SelectionBuffer(Fl::event_x(), Fl::event_y(), &hits, ii, jj);
     ov = v; oc = c; os = s; v = NULL; c = NULL; s = NULL;
     Filter_SelectionBuffer(hits,ii,jj,&v,&c,&s,&M);
@@ -340,11 +351,11 @@ int Opengl_Window::handle(int event) {
 	HighlightEntity(v,c,s,0);
 	EndHighlight(0);
       }
-      WID->make_current();
+      WID->make_opengl_current();
     }
 #endif
-    x += movx; 
-    y += movy; 
+    xpos += xmov; 
+    ypos += ymov; 
     return 1;
 
   default:
diff --git a/Graphics/CreateFile.cpp b/Graphics/CreateFile.cpp
index aec37631a8..0ef52ca556 100644
--- a/Graphics/CreateFile.cpp
+++ b/Graphics/CreateFile.cpp
@@ -1,4 +1,4 @@
-// $Id: CreateFile.cpp,v 1.11 2001-01-24 09:28:03 geuzaine Exp $
+// $Id: CreateFile.cpp,v 1.12 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -112,7 +112,7 @@ void CreateFile (char *name, int format) {
       Msg(WARNING, "Unable to Open File '%s'", name); 
       return;
     }
-    DrawUpdate();
+    Draw();
     create_jpeg(fp, CTX.viewport[2]-CTX.viewport[0],
 		CTX.viewport[3]-CTX.viewport[1],
 		CTX.print.jpeg_quality);
@@ -127,7 +127,7 @@ void CreateFile (char *name, int format) {
       Msg(WARNING, "Unable to Open File '%s'", name); 
       return;
     }
-    DrawUpdate();
+    Draw();
     create_gif(fp, CTX.viewport[2]-CTX.viewport[0],
                CTX.viewport[3]-CTX.viewport[1], 
 	       CTX.print.gif_dither,
@@ -147,7 +147,7 @@ void CreateFile (char *name, int format) {
       Msg(WARNING, "Unable to Open File '%s'", name); 
       return;
     }
-    DrawUpdate();
+    Draw();
     create_ppm(fp, CTX.viewport[2]-CTX.viewport[0],
 	       CTX.viewport[3]-CTX.viewport[1]);
     Msg(INFO, "PPM Creation Complete '%s'", name);
@@ -160,7 +160,7 @@ void CreateFile (char *name, int format) {
       Msg(WARNING, "Unable to Open File '%s'", name); 
       return;
     }
-    DrawUpdate();
+    Draw();
     create_yuv(fp, CTX.viewport[2]-CTX.viewport[0],
 	       CTX.viewport[3]-CTX.viewport[1]);
     Msg(INFO, "YUV Creation Complete '%s'", name);
@@ -209,7 +209,7 @@ void CreateFile (char *name, int format) {
 		       GL2PS_SIMPLE_LINE_OFFSET | GL2PS_DRAW_BACKGROUND,
 		       GL_RGBA, 0, NULL, size3d, fp);
 	CTX.stream = TO_FILE ;
-	DrawUpdate();
+	Draw();
 	CTX.stream = TO_SCREEN ;
 	res = gl2psEndPage();
       }
diff --git a/Graphics/Draw.cpp b/Graphics/Draw.cpp
index b459a971b5..923cf1dd78 100644
--- a/Graphics/Draw.cpp
+++ b/Graphics/Draw.cpp
@@ -1,4 +1,4 @@
-// $Id: Draw.cpp,v 1.18 2001-01-25 21:36:59 remacle Exp $
+// $Id: Draw.cpp,v 1.19 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -185,7 +185,6 @@ void InitPosition(void){
    ajoutes dans la base de donnee -> dans cb_geom */
 void Replot(void){
   CalculateMinMax(M.Points);
-  Init();
   Draw();
 }
 
@@ -284,7 +283,6 @@ void myZoom(GLdouble X1, GLdouble X2, GLdouble Y1, GLdouble Y2,
   set_s(2, 0.5*(CTX.s[0]+CTX.s[1]));
   set_t(0, CTX.t[0] * (xscale1/CTX.s[0]) - ((Xc1+Xc2)/2.)*(1.-(xscale1/CTX.s[0])));
   set_t(1, CTX.t[1] * (yscale1/CTX.s[1]) - ((Yc1+Yc2)/2.)*(1.-(yscale1/CTX.s[1])));
-  Init();
   Draw();
 }
 
diff --git a/Graphics/Draw.h b/Graphics/Draw.h
index 9cb970376c..d7f12c2661 100644
--- a/Graphics/Draw.h
+++ b/Graphics/Draw.h
@@ -10,7 +10,7 @@
 #define TO_SCREEN  1
 #define TO_FILE    2
 
-void Init(void);
+void InitOpengl(void);
 void InitOverlay(void);
 void InitShading(void);
 void InitNoShading(void);
@@ -38,9 +38,7 @@ void HighlightEntityNum(int v, int c, int s, int permanant);
 void Draw3d(void);
 void Draw2d(void);
 void DrawUI(void);
-void DrawOverlay(void);
 void Draw(void);
-void DrawUpdate(void);
 
 void Draw_String(char *s);
 void Draw_Geom (Mesh *m);
diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp
index 4bec8461e3..d12e08d59c 100644
--- a/Graphics/Geom.cpp
+++ b/Graphics/Geom.cpp
@@ -1,4 +1,4 @@
-// $Id: Geom.cpp,v 1.14 2001-01-24 16:15:30 geuzaine Exp $
+// $Id: Geom.cpp,v 1.15 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -787,14 +787,10 @@ void ZeroHighlight(Mesh *m){
 
 void BeginHighlight(void){
   if(CTX.geom.highlight){
-#ifdef _XMOTIF
-    if(CTX.overlay){ 
+    if(CTX.overlay)
       InitOverlay();
-    }
-    else{ 
-      Init();
-    }
-#endif
+    else
+      InitOpengl();
     Highlighted = 1;
     glPushMatrix();
     InitPosition();    
@@ -807,10 +803,8 @@ void BeginHighlight(void){
 
 void EndHighlight(int permanent){
   Highlighted = 0;
-  if(permanent){
-    Init();
+  if(permanent) 
     Draw();
-  }
   else{
     if(CTX.geom.highlight) {
       glPopMatrix();
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 2e2830bf0c..84e7c9af2b 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.17 2001-01-17 21:26:24 remacle Exp $
+// $Id: Mesh.cpp,v 1.18 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -27,7 +27,7 @@ void draw_polygon_2d (double r, double g, double b, int n,
   int i ;
 
   CalculateMinMax(THEM->Points);
-  Init();
+  InitOpengl();
   InitPosition();
 
   glDisable(GL_DEPTH_TEST);
diff --git a/Graphics/Scale.cpp b/Graphics/Scale.cpp
index 28a6595285..fbe652161c 100644
--- a/Graphics/Scale.cpp
+++ b/Graphics/Scale.cpp
@@ -1,4 +1,4 @@
-// $Id: Scale.cpp,v 1.15 2001-01-10 21:20:39 geuzaine Exp $
+// $Id: Scale.cpp,v 1.16 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -19,20 +19,14 @@ static XCharStruct  overall;
 #define CHECK_W                                                                         \
   XTextExtents(XCTX.xfont.helve, label, strlen(label), &dir,&ascent,&descent,&overall); \
   if(overall.width > cv_w) cv_w=overall.width
-#define FONTHEIGHT XCTX.xfont.helve_h
-#define FONTASCENT XCTX.xfont.helve_a
 
 #elif _FLTK
 
-#define CHECK_W     cv_w=gl_width(label)
-#define FONTHEIGHT  gl_height()
-#define FONTASCENT (gl_height()-gl_descent())
+#define CHECK_W  cv_w=gl_width(label)
 
 #else
 
 #define CHECK_W  cv_w=200
-#define FONTHEIGHT 21
-#define FONTASCENT 21
 
 #endif
 
@@ -56,16 +50,8 @@ void draw_scale(Post_View *v, double xmin, double ymin, double *width, double he
   char      label[128] ;
   double    Val, ValMin, ValMax;
 
-#ifdef _XMOTIF
-  font_h  = FONTHEIGHT ;      /* hauteur totale de la fonte */
-  font_a  = FONTASCENT ;      /* hauteur de la fonte au dessus de pt de ref */
-#else
-  font_h  = 21 ;
-  font_a  = 21 ;
-#endif
-
-  font_h  = FONTHEIGHT ;              /* hauteur totale de la fonte */
-  font_a  = FONTASCENT ;              /* hauteur de la fonte au dessus de pt de ref */
+  font_h  = CTX.gl_fontheight ;       /* hauteur totale de la fonte */
+  font_a  = CTX.gl_fontascent ;       /* hauteur de la fonte au dessus de pt de ref */
   label_h = 1.8*font_h ;              /* hauteur du label */
 
   cs_xmin = xmin ;                    /* colorscale xmin */
diff --git a/Makefile b/Makefile
index a05d66fbe3..bc4f2e52ba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.43 2001-01-24 11:24:03 geuzaine Exp $
+# $Id: Makefile,v 1.44 2001-01-29 08:43:44 geuzaine Exp $
 # ----------------------------------------------------------------------
 #  Makefile for Gmsh  
 # ----------------------------------------------------------------------
@@ -7,7 +7,7 @@
 
             MAKE = make
               CC = g++
-           FLAGS = -O
+           FLAGS = -g -Wall
               RM = rm
          RMFLAGS = -f 
 
diff --git a/Motif/CbContext.cpp b/Motif/CbContext.cpp
index 50b100aed1..6a38c257dc 100644
--- a/Motif/CbContext.cpp
+++ b/Motif/CbContext.cpp
@@ -1,4 +1,4 @@
-// $Id: CbContext.cpp,v 1.4 2001-01-12 13:29:02 geuzaine Exp $
+// $Id: CbContext.cpp,v 1.5 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -637,10 +637,8 @@ void RemoveViewCb(Widget w, XtPointer client_data, XtPointer call_data){
   if(actual_global_context == CONTEXT_POST)
     ActualizeContextCb(NULL,(XtPointer)actual_global_context,NULL);  
 
-  if(!All){
-    Init();
-    Draw();
-  }
+  if(!All) Draw();
+
 }
 
 void RemoveAllViewsCb(Widget w, XtPointer client_data, XtPointer call_data){
@@ -650,7 +648,6 @@ void RemoveAllViewsCb(Widget w, XtPointer client_data, XtPointer call_data){
   while(List_Nbr(Post_ViewList))
     RemoveViewCb(NULL, (XtPointer)i, NULL);
   All = 0;
-  Init();
   Draw();
 }
 
diff --git a/Motif/CbFile.cpp b/Motif/CbFile.cpp
index 9826e6c2d9..a87ea32f5a 100644
--- a/Motif/CbFile.cpp
+++ b/Motif/CbFile.cpp
@@ -1,4 +1,4 @@
-// $Id: CbFile.cpp,v 1.2 2001-01-09 13:28:47 geuzaine Exp $
+// $Id: CbFile.cpp,v 1.3 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -59,8 +59,8 @@ void FileCb(Widget w, XtPointer client_data, XtPointer call_data){
   XmStringFree(xms);
   
   switch ((long int)client_data) {
-  case FILE_LOAD_GEOM       : OpenProblem(c); Init(); Draw(); break;
-  case FILE_LOAD_POST       : MergeProblem(c); ColorBarRedraw(); Init(); Draw(); break;
+  case FILE_LOAD_GEOM       : OpenProblem(c); Draw(); break;
+  case FILE_LOAD_POST       : MergeProblem(c); ColorBarRedraw(); Draw(); break;
   case FILE_SAVE_AS         : SaveToDisk(c, WID.ED.saveAsDialog, CreateFile); break;
   case FILE_SAVE_OPTIONS_AS : Print_Context(c); break;
   default :
diff --git a/Motif/CbGeom.cpp b/Motif/CbGeom.cpp
index e7ef0c67d4..5e6928b49c 100644
--- a/Motif/CbGeom.cpp
+++ b/Motif/CbGeom.cpp
@@ -1,4 +1,4 @@
-// $Id: CbGeom.cpp,v 1.4 2001-01-12 13:29:02 geuzaine Exp $
+// $Id: CbGeom.cpp,v 1.5 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -73,7 +73,6 @@ void geom_event_handler (int event) {
 
   case GEOM_PARSE :
     OpenProblem(CTX.filename);
-    Init();
     Draw();
     break;
 
diff --git a/Motif/CbInput.cpp b/Motif/CbInput.cpp
index a471a9fd34..c22a0088e1 100644
--- a/Motif/CbInput.cpp
+++ b/Motif/CbInput.cpp
@@ -1,4 +1,4 @@
-// $Id: CbInput.cpp,v 1.3 2001-01-12 13:29:02 geuzaine Exp $
+// $Id: CbInput.cpp,v 1.4 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -53,12 +53,12 @@ void KeyboardAccel(XEvent *event){
     case XK_Up :
       CTX.clip_plane0[2] = 1. ;
       if(fabs(CTX.clip_plane0[3]-CTX.lc/20. <1.)) CTX.clip_plane0[3] -= CTX.lc/20. ;
-      Init(); Draw();
+      Draw();
       break;
     case XK_Down :
       CTX.clip_plane0[2] = 1. ;
       if(fabs(CTX.clip_plane0[3]+CTX.lc/20 <1.)) CTX.clip_plane0[3] += CTX.lc/20. ;
-      Init(); Draw();
+      Draw();
       break;
       */
 
@@ -192,14 +192,14 @@ void KeyboardAccel(XEvent *event){
       break;
     case XK_b : case XK_B :
       CTX.post.scales = !CTX.post.scales;
-      Init(); Draw();
+      Draw();
       break;
     case XK_o : case XK_O :
       CTX.ortho = !CTX.ortho; 
       XtVaSetValues(WID.OD.miscProjButt[0], XmNset, CTX.ortho, NULL);
       XtVaSetValues(WID.OD.miscProjButt[1], XmNset, !CTX.ortho, NULL);
       XmUpdateDisplay(WID.OD.miscProjCheck);
-      Init(); Draw();
+      Draw();
       break;
     case XK_h : case XK_H :
       CTX.geom.highlight = !CTX.geom.highlight;
@@ -212,7 +212,7 @@ void KeyboardAccel(XEvent *event){
       else Init_Colors(0);
       XtVaSetValues(WID.OD.miscColorSchemeScale,XmNvalue, CTX.color.id, NULL);
       XmUpdateDisplay(WID.OD.miscColorSchemeScale);  
-      Init(); Draw();
+      Draw();
       break;
     case XK_d : case XK_D :
       if(!CTX.mesh.hidden && !CTX.mesh.shade)
@@ -226,34 +226,34 @@ void KeyboardAccel(XEvent *event){
       XtVaSetValues(WID.OD.meshAspectButt[1],XmNset,CTX.mesh.hidden&&!CTX.mesh.shade, NULL);
       XtVaSetValues(WID.OD.meshAspectButt[0],XmNset,!CTX.mesh.hidden&&!CTX.mesh.shade, NULL);
       XmUpdateDisplay(WID.OD.meshAspectCheck);  
-      Init(); Draw();
+      Draw();
       break;
     case XK_x : case XK_X :
       if(CTX.useTrackball)
 	CTX.setQuaternion(0.,-1./sqrt(2.),0.,1./sqrt(2.));
-      set_r(0,0.);  set_r(1,90.);set_r(2,0.); Init(); Draw(); 
+      set_r(0,0.);  set_r(1,90.);set_r(2,0.); Draw(); 
       break;
     case XK_y : case XK_Y : 
       if(CTX.useTrackball)
 	CTX.setQuaternion(1./sqrt(2.),0.,0.,1./sqrt(2.));
-      set_r(0,-90.);set_r(1,0.); set_r(2,0.); Init(); Draw(); 
+      set_r(0,-90.);set_r(1,0.); set_r(2,0.); Draw(); 
       break;
     case XK_z : case XK_Z : 
       if(CTX.useTrackball)
 	CTX.setQuaternion(0.,0.,0.,1.);
-      set_r(0,0.);  set_r(1,0.); set_r(2,0.); Init(); Draw(); 
+      set_r(0,0.);  set_r(1,0.); set_r(2,0.); Draw(); 
       break;
     case XK_a :
       CTX.small_axes = !CTX.small_axes;
       XtVaSetValues(WID.OD.miscMiscButt[1], XmNset, CTX.small_axes, NULL);
       XmUpdateDisplay(WID.OD.miscMiscCheck);
-      Init(); Draw();
+      Draw();
       break;
     case XK_A :
       CTX.axes = !CTX.axes;
       XtVaSetValues(WID.OD.miscMiscButt[0], XmNset, CTX.axes, NULL);
       XmUpdateDisplay(WID.OD.miscMiscCheck);
-      Init(); Draw();
+      Draw();
       break;
     case XK_p :
       CTX.geom.points = !CTX.geom.points;
@@ -261,7 +261,7 @@ void KeyboardAccel(XEvent *event){
         XtVaSetValues(WID.OD.geomVisibleButt[0], XmNset, CTX.geom.points, NULL);
         XmUpdateDisplay(WID.OD.geomVisibleButt[0]); 
       }
-      Init(); Draw();
+      Draw();
       break;
     case XK_P :
       CTX.mesh.points = !CTX.mesh.points;
@@ -269,7 +269,7 @@ void KeyboardAccel(XEvent *event){
         XtVaSetValues(WID.OD.meshVisibleButt[0], XmNset, CTX.mesh.points, NULL);
         XmUpdateDisplay(WID.OD.meshVisibleButt[0]); 
       }
-      Init(); Draw();
+      Draw();
       break;
     case XK_l :
       CTX.geom.lines = !CTX.geom.lines;
@@ -277,7 +277,7 @@ void KeyboardAccel(XEvent *event){
         XtVaSetValues(WID.OD.geomVisibleButt[1], XmNset, CTX.geom.lines, NULL);
         XmUpdateDisplay(WID.OD.geomVisibleButt[1]); 
       }
-      Init(); Draw();
+      Draw();
       break;
     case XK_L :
       CTX.mesh.lines = !CTX.mesh.lines;
@@ -285,7 +285,7 @@ void KeyboardAccel(XEvent *event){
         XtVaSetValues(WID.OD.meshVisibleButt[1], XmNset, CTX.mesh.lines, NULL);
         XmUpdateDisplay(WID.OD.meshVisibleButt[1]); 
       }
-      Init(); Draw();
+      Draw();
       break;
     case XK_s :
       CTX.geom.surfaces = !CTX.geom.surfaces;
@@ -293,7 +293,7 @@ void KeyboardAccel(XEvent *event){
         XtVaSetValues(WID.OD.geomVisibleButt[2], XmNset, CTX.geom.surfaces, NULL);
         XmUpdateDisplay(WID.OD.geomVisibleButt[2]); 
       }
-      Init(); Draw();
+      Draw();
       break;
     case XK_S :
       CTX.mesh.surfaces = !CTX.mesh.surfaces;
@@ -301,7 +301,7 @@ void KeyboardAccel(XEvent *event){
         XtVaSetValues(WID.OD.meshVisibleButt[2], XmNset, CTX.mesh.surfaces, NULL);
         XmUpdateDisplay(WID.OD.meshVisibleButt[2]); 
       }
-      Init(); Draw();
+      Draw();
       break;
     case XK_v :
       CTX.geom.volumes = !CTX.geom.volumes;
@@ -309,7 +309,7 @@ void KeyboardAccel(XEvent *event){
         XtVaSetValues(WID.OD.geomVisibleButt[3], XmNset, CTX.geom.volumes, NULL);
         XmUpdateDisplay(WID.OD.geomVisibleButt[3]); 
       }
-      Init(); Draw();
+      Draw();
       break;
     case XK_V :
       CTX.mesh.volumes = !CTX.mesh.volumes;
@@ -317,7 +317,7 @@ void KeyboardAccel(XEvent *event){
         XtVaSetValues(WID.OD.meshVisibleButt[3], XmNset, CTX.mesh.volumes, NULL);
         XmUpdateDisplay(WID.OD.meshVisibleButt[3]); 
       }
-      Init(); Draw();
+      Draw();
       break;
     case XK_m : case XK_M :
       CTX.mesh.points   = !CTX.mesh.points;
@@ -329,11 +329,11 @@ void KeyboardAccel(XEvent *event){
       XtVaSetValues(WID.OD.meshVisibleButt[2], XmNset, CTX.mesh.surfaces, NULL);
       XtVaSetValues(WID.OD.meshVisibleButt[3], XmNset, CTX.mesh.volumes, NULL);
       XmUpdateDisplay(WID.OD.meshVisibleCheck); 
-      Init(); Draw();
+      Draw();
       break;
     case XK_t : case XK_T :
       MarkAllViewsChanged(1);
-      Init(); Draw();
+      Draw();
       break;
     }
     break ;
@@ -441,7 +441,6 @@ void InputCb (Widget w, XtPointer client_data, GLwDrawingAreaCallbackStruct *cb)
         Modifier = 0;
         set_s(1, CTX.s[0]);
         set_s(2, CTX.s[0]);
-        Init();
         Draw();
       }
       else{
@@ -465,7 +464,6 @@ void InputCb (Widget w, XtPointer client_data, GLwDrawingAreaCallbackStruct *cb)
 	}
         set_t(0,0.); set_t(1,0.); set_t(2,0.);
         set_s(0,1.); set_s(1,1.); set_s(2,1.);
-        Init();
         Draw();
       }
       else{
@@ -493,7 +491,6 @@ void InputCb (Widget w, XtPointer client_data, GLwDrawingAreaCallbackStruct *cb)
       y    = event->xbutton.y;
     }
     if(!ZoomClick){
-      Init();
       previous_mesh_draw = CTX.mesh.draw ;
       previous_post_draw = CTX.post.draw ;
       if(ButtonPressed>0){
@@ -681,7 +678,6 @@ void InputCb (Widget w, XtPointer client_data, GLwDrawingAreaCallbackStruct *cb)
           set_t(2, 0.);
           break;
         }
-        Init();
         previous_mesh_draw = CTX.mesh.draw ;
         previous_post_draw = CTX.post.draw ;
         if(CTX.fast) CTX.mesh.draw = CTX.post.draw = 0;
@@ -709,10 +705,7 @@ void InputCb (Widget w, XtPointer client_data, GLwDrawingAreaCallbackStruct *cb)
         }
         else{
           if(ov != v || oc != c || os != s) { 
-            if(CTX.geom.highlight){
-              Init();
-              Draw();
-            }
+            if(CTX.geom.highlight) Draw();
             BeginHighlight();
             HighlightEntity(v,c,s,0);
             EndHighlight(0);
diff --git a/Motif/CbMesh.cpp b/Motif/CbMesh.cpp
index db35b37a7e..351be097a3 100644
--- a/Motif/CbMesh.cpp
+++ b/Motif/CbMesh.cpp
@@ -1,4 +1,4 @@
-// $Id: CbMesh.cpp,v 1.3 2001-01-12 13:29:02 geuzaine Exp $
+// $Id: CbMesh.cpp,v 1.4 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -35,7 +35,6 @@ void* StartMeshThread(void * data){
   CTX.mesh.draw = 1;
   CTX.threads_lock = 0;
   XtSetSensitive(WID.G.Butt[6], 0);
-  Init();
   Draw();
   pthread_exit(NULL);
   return NULL ;
@@ -54,7 +53,6 @@ void CancelMeshThread(void){
     Msg(STATUS2,"Mesh Aborted");
     mesh_event_handler(MESH_DELETE);
     Msg(STATUS3,"Ready");
-    Init();
     Draw();
   }
 }
@@ -266,7 +264,6 @@ void mesh_event_handler (int event) {
 
   if(!CTX.threads){
     Msg(STATUS3,"Ready");
-    Init();
     Draw();
   }
 }
diff --git a/Motif/CbOptions.cpp b/Motif/CbOptions.cpp
index eee29453d2..d591c92669 100644
--- a/Motif/CbOptions.cpp
+++ b/Motif/CbOptions.cpp
@@ -1,4 +1,4 @@
-// $Id: CbOptions.cpp,v 1.3 2001-01-10 10:06:18 geuzaine Exp $
+// $Id: CbOptions.cpp,v 1.4 2001-01-29 08:43:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -43,7 +43,7 @@ void OptionsCb (Widget w, XtPointer client_data, XtPointer call_data){
 
     /* globales */
     
-  case OPTIONS_REPLOT        : Init(); Draw(); break;
+  case OPTIONS_REPLOT        : Draw(); break;
   case OPTIONS_AXES          : CTX.axes = !CTX.axes; break;
   case OPTIONS_LITTLE_AXES   : CTX.small_axes = !CTX.small_axes; break;
   case OPTIONS_FAST_REDRAW   : CTX.fast = !CTX.fast ; break ;
@@ -52,7 +52,7 @@ void OptionsCb (Widget w, XtPointer client_data, XtPointer call_data){
   case OPTIONS_TRACKBALL     : CTX.useTrackball = !CTX.useTrackball; break;
   case OPTIONS_COLOR_SCHEME_SCALE: 
     XmScaleGetValue(WID.OD.miscColorSchemeScale, &e); Init_Colors(e);
-    Init(); Draw();
+    Draw();
     break ;
   case OPTIONS_ORTHOGRAPHIC  : CTX.ortho = 1; break;
   case OPTIONS_PERSPECTIVE   : CTX.ortho = 0; break;
@@ -90,24 +90,24 @@ void OptionsCb (Widget w, XtPointer client_data, XtPointer call_data){
     if(CTX.useTrackball)
       CTX.setQuaternion(0.,-1./sqrt(2.),0.,1./sqrt(2.));
     set_r(0,0.);  set_r(1,90.);set_r(2,0.); 
-    Init(); Draw(); 
+    Draw(); 
     break;
   case OPTIONS_YVIEW : 
     if(CTX.useTrackball)
       CTX.setQuaternion(1./sqrt(2.),0.,0.,1./sqrt(2.));
     set_r(0,-90.);set_r(1,0.); set_r(2,0.); 
-    Init(); Draw(); 
+    Draw(); 
     break;
   case OPTIONS_ZVIEW :
     if(CTX.useTrackball)
       CTX.setQuaternion(0.,0.,0.,1.);
     set_r(0,0.);  set_r(1,0.); set_r(2,0.); 
-    Init(); Draw(); 
+    Draw(); 
     break;
   case OPTIONS_CVIEW : 
     set_t(0,0.);  set_t(1,0.); set_t(2,0.); 
     set_s(0,1.);  set_s(1,1.); set_s(2,1.); 
-    Init(); Draw(); 
+    Draw(); 
     break;
   case OPTIONS_PVIEW :
     XGetWindowAttributes(XtDisplay(WID.G.shell),XtWindow(WID.G.shell),&xattrib);
@@ -326,7 +326,7 @@ void OptionsCb (Widget w, XtPointer client_data, XtPointer call_data){
         if(GetTime() - anim_time > CTX.post.anim_delay){
           anim_time = GetTime();
           MarkAllViewsChanged(2);
-          Init(); Draw();
+          Draw();
         }
       }
     }
diff --git a/Motif/CbPost.cpp b/Motif/CbPost.cpp
index 2674cfe1c9..aa28ed636e 100644
--- a/Motif/CbPost.cpp
+++ b/Motif/CbPost.cpp
@@ -1,4 +1,4 @@
-// $Id: CbPost.cpp,v 1.3 2001-01-11 22:27:55 geuzaine Exp $
+// $Id: CbPost.cpp,v 1.4 2001-01-29 08:43:45 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -91,7 +91,6 @@ void SwapViewCb (Widget w, XtPointer client_data, XtPointer call_data){
 
   v->Visible = !v->Visible;
 
-  Init();
   Draw();
 }
 
@@ -147,7 +146,6 @@ void DuplicateViewCb (Widget w, XtPointer client_data, XtPointer call_data){
   CopyViewOptions(v1, v2);
 
   AddViewInUI(List_Nbr(Post_ViewList), v2->Name, v2->Num);
-  Init();
   Draw();
 }
 
@@ -172,7 +170,6 @@ void ReloadViewCb (Widget w, XtPointer client_data, XtPointer call_data){
   CopyViewOptions(&tmp, v);
 
   if(!All){
-    Init();
     Draw();
   }
 }
@@ -184,7 +181,6 @@ void ReloadAllViewsCb(Widget w, XtPointer client_data, XtPointer call_data){
   for(i = 1 ; i<=List_Nbr(Post_ViewList) ; i++)
     ReloadViewCb(NULL, (XtPointer)i, NULL);
   All = 0;
-  Init();
   Draw();
 }
 
@@ -216,7 +212,6 @@ void PostDialogCb (Widget w, XtPointer client_data, XtPointer call_data){
   case POST_LIGHT:     
     v->Light = !v->Light;
     v->Changed = 1;
-    Init() ;
     Draw() ;
     break;
 
@@ -224,7 +219,6 @@ void PostDialogCb (Widget w, XtPointer client_data, XtPointer call_data){
   case POST_ELEMENT:     
     v->ShowElement = !v->ShowElement;
     v->Changed = 1;
-    Init() ;
     Draw() ;
     break;
 
@@ -387,7 +381,6 @@ void PostCb (Widget w, XtPointer client_data, XtPointer call_data){
     XmStringFree(xms);
     CreateBGM(v, ADAPTATION_METHOD, 1.0, ADAPTATION_ERROR, &d, c); 
     MergeProblem(c);     
-    Init(); 
     Draw();
     return;
   case POST_COLOR_REPLOT : 
@@ -410,7 +403,6 @@ void PostCb (Widget w, XtPointer client_data, XtPointer call_data){
         }
       }
     }
-    Init();
     Draw();
     return;
   }
@@ -477,7 +469,6 @@ void PostCb (Widget w, XtPointer client_data, XtPointer call_data){
   if((long int)client_data == POST_TIME_STEP_SCALE){
     if(LastTimeStep != v->TimeStep){
       LastTimeStep = v->TimeStep;
-      Init();
       Draw();
     }
   }
diff --git a/Motif/Main.cpp b/Motif/Main.cpp
index 7a567c446e..6188270242 100644
--- a/Motif/Main.cpp
+++ b/Motif/Main.cpp
@@ -1,4 +1,4 @@
-// $Id: Main.cpp,v 1.6 2001-01-13 15:41:35 geuzaine Exp $
+// $Id: Main.cpp,v 1.7 2001-01-29 08:43:45 geuzaine Exp $
 
 #include <signal.h>
 
@@ -324,6 +324,10 @@ int main(int argc, char *argv[]){
   XCTX.xfont.fixed_a = XCTX.xfont.fixed->max_bounds.ascent;
   XCTX.xfont.fixed_w = XCTX.xfont.fixed->max_bounds.width;
 
+  CTX.gl_fontheight = XCTX.xfont.helve_h ;
+  CTX.gl_fontascent = XCTX.xfont.helve_a ;
+
+
   /* X color initialisation (set the pixel format and allocate some colors in XCTX) */
 
   XColorInitialize();
@@ -401,7 +405,6 @@ int main(int argc, char *argv[]){
   }
   
   /* Draw the actual scene */
-  Init();
   Draw();
 
   /* Loop until were done */
diff --git a/Motif/Opengl.cpp b/Motif/Opengl.cpp
index afe3a88c08..e10ce94f2a 100644
--- a/Motif/Opengl.cpp
+++ b/Motif/Opengl.cpp
@@ -1,4 +1,4 @@
-// $Id: Opengl.cpp,v 1.3 2001-01-10 20:23:38 geuzaine Exp $
+// $Id: Opengl.cpp,v 1.4 2001-01-29 08:43:45 geuzaine Exp $
 
 #include <X11/IntrinsicP.h>
 
@@ -28,8 +28,7 @@ void myZoom(GLdouble X1, GLdouble X2, GLdouble Y1, GLdouble Y2,
 /*  Init/Draw                                                               */
 /* ------------------------------------------------------------------------ */
 
-void Init(void){
-
+void InitOpengl(void){
   /* Resize Graphical Window if told to do it */
   XWindowAttributes  xattrib;
   XGetWindowAttributes(XtDisplay(WID.G.bottomForm),XtWindow(WID.G.bottomForm),&xattrib);
@@ -37,12 +36,10 @@ void Init(void){
 		 CTX.viewport[2]-CTX.viewport[0],
 		 xattrib.height+CTX.viewport[3]-CTX.viewport[1],
 		 0);
-
   /* X11 forbids to change the context (GLX) in GL_FEEDBACK or GL_SELECT mode,
      which would happen for postscript output */
   if(CTX.stream == TO_SCREEN)
     glXMakeCurrent(XtDisplay(WID.G.glw), XtWindow(WID.G.glw), XCTX.glw.context);
-
   Orthogonalize(0,0);
 }
 
@@ -52,6 +49,7 @@ void InitOverlay(void){
 }
 
 void Draw(void){
+  InitOpengl();
   glClearColor(UNPACK_RED(CTX.color.bg)/255.,
                UNPACK_GREEN(CTX.color.bg)/255.,
                UNPACK_BLUE(CTX.color.bg)/255.,
@@ -64,14 +62,6 @@ void Draw(void){
   if(CTX.db) glXSwapBuffers(XCTX.display,XtWindow(WID.G.glw));
 }
 
-void DrawUpdate(void){
-  Init();
-  Draw();
-}
-
-void DrawOverlay(void){
-}
-
 void DrawUI(void){
 }
 
@@ -158,7 +148,6 @@ void ResizeCb(Widget w,XtPointer client_data, GLwDrawingAreaCallbackStruct *cb){
              CTX.viewport[1],
              CTX.viewport[2],
              CTX.viewport[3]);
-  Init();
   Draw();
   if(CTX.overlay) InitOverlay();
 }
@@ -171,7 +160,6 @@ void ExposeCb(Widget w,XtPointer client_data, GLwDrawingAreaCallbackStruct *cb){
   }
 
   if(!CTX.expose) return;
-  Init();
   Draw(); 
 
 }
diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp
index 5a49f613b2..691109dd16 100644
--- a/Parser/Gmsh.tab.cpp
+++ b/Parser/Gmsh.tab.cpp
@@ -169,7 +169,7 @@
 #line 1 "Gmsh.y"
  
 
-// $Id: Gmsh.tab.cpp,v 1.64 2001-01-17 21:26:24 remacle Exp $
+// $Id: Gmsh.tab.cpp,v 1.65 2001-01-29 08:43:45 geuzaine Exp $
 
 #include <stdarg.h>
 
@@ -598,21 +598,21 @@ static const short yyrline[] = { 0,
   1333,  1349,  1356,  1362,  1368,  1374,  1380,  1399,  1411,  1417,
   1436,  1457,  1465,  1471,  1477,  1483,  1495,  1501,  1507,  1519,
   1525,  1530,  1535,  1542,  1544,  1545,  1548,  1553,  1564,  1582,
-  1590,  1594,  1605,  1657,  1676,  1680,  1701,  1717,  1731,  1756,
-  1781,  1807,  1813,  1818,  1823,  1827,  1837,  1843,  1849,  1853,
-  1857,  1861,  1865,  1870,  1877,  1881,  1886,  1904,  1914,  1932,
-  1949,  1966,  1987,  2007,  2027,  2044,  2068,  2073,  2084,  2086,
-  2089,  2091,  2092,  2093,  2094,  2097,  2099,  2100,  2101,  2102,
-  2103,  2104,  2105,  2106,  2113,  2114,  2115,  2116,  2117,  2118,
-  2119,  2120,  2121,  2122,  2123,  2124,  2125,  2126,  2127,  2128,
-  2129,  2130,  2131,  2132,  2133,  2134,  2135,  2136,  2137,  2138,
-  2139,  2140,  2141,  2142,  2143,  2144,  2149,  2154,  2158,  2170,
-  2188,  2200,  2218,  2230,  2250,  2271,  2295,  2316,  2340,  2361,
-  2386,  2393,  2406,  2413,  2417,  2421,  2425,  2430,  2435,  2439,
-  2443,  2449,  2453,  2458,  2462,  2467,  2471,  2475,  2481,  2487,
-  2493,  2497,  2503,  2518,  2525,  2531,  2540,  2552,  2556,  2564,
-  2577,  2582,  2586,  2591,  2596,  2614,  2619,  2640,  2649,  2655,
-  2660,  2664
+  1590,  1594,  1605,  1657,  1676,  1680,  1700,  1716,  1730,  1755,
+  1780,  1806,  1812,  1817,  1822,  1826,  1836,  1842,  1848,  1852,
+  1856,  1860,  1864,  1869,  1876,  1880,  1885,  1903,  1913,  1931,
+  1948,  1965,  1986,  2006,  2026,  2043,  2067,  2072,  2083,  2085,
+  2088,  2090,  2091,  2092,  2093,  2096,  2098,  2099,  2100,  2101,
+  2102,  2103,  2104,  2105,  2112,  2113,  2114,  2115,  2116,  2117,
+  2118,  2119,  2120,  2121,  2122,  2123,  2124,  2125,  2126,  2127,
+  2128,  2129,  2130,  2131,  2132,  2133,  2134,  2135,  2136,  2137,
+  2138,  2139,  2140,  2141,  2142,  2143,  2148,  2153,  2157,  2169,
+  2187,  2199,  2217,  2229,  2249,  2270,  2294,  2315,  2339,  2360,
+  2385,  2392,  2405,  2412,  2416,  2420,  2424,  2429,  2434,  2438,
+  2442,  2448,  2452,  2457,  2461,  2466,  2470,  2474,  2480,  2486,
+  2492,  2496,  2502,  2517,  2524,  2530,  2539,  2551,  2555,  2563,
+  2576,  2581,  2585,  2590,  2595,  2613,  2618,  2639,  2648,  2654,
+  2659,  2663
 };
 #endif
 
@@ -4701,7 +4701,6 @@ case 206:
 	  DrawUI();
 	}
 	else{
-	  Init();
 	  Draw();
 	  DrawUI();
 	}
@@ -4709,7 +4708,7 @@ case 206:
     ;
     break;}
 case 207:
-#line 1704 "Gmsh.y"
+#line 1703 "Gmsh.y"
 {
       FILE* ff;
       if(RecursionLevel)
@@ -4725,7 +4724,7 @@ case 207:
     ;
     break;}
 case 208:
-#line 1718 "Gmsh.y"
+#line 1717 "Gmsh.y"
 {
       FILE* ff;
       if(RecursionLevel)
@@ -4741,7 +4740,7 @@ case 208:
     ;
     break;}
 case 209:
-#line 1732 "Gmsh.y"
+#line 1731 "Gmsh.y"
 {
       FILE* ff;
       if(RecursionLevel)
@@ -4768,7 +4767,7 @@ case 209:
     ;
     break;}
 case 210:
-#line 1757 "Gmsh.y"
+#line 1756 "Gmsh.y"
 {
       FILE* ff;
       if(RecursionLevel)
@@ -4795,7 +4794,7 @@ case 210:
     ;
     break;}
 case 211:
-#line 1782 "Gmsh.y"
+#line 1781 "Gmsh.y"
 {
       if(LoopControlVariablesTab[ImbricatedLoop-1][1] >  
 	 LoopControlVariablesTab[ImbricatedLoop-1][0]){
@@ -4823,7 +4822,7 @@ case 211:
     ;
     break;}
 case 212:
-#line 1808 "Gmsh.y"
+#line 1807 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->createFunction(yyvsp[0].c,yyin,yylineno))
 	vyyerror("Redefinition of function %s",yyvsp[0].c);
@@ -4831,39 +4830,39 @@ case 212:
     ;
     break;}
 case 213:
-#line 1814 "Gmsh.y"
+#line 1813 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->leaveFunction(&yyin,yylineno))
 	vyyerror("Error while exiting function");
     ;
     break;}
 case 214:
-#line 1819 "Gmsh.y"
+#line 1818 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->enterFunction(yyvsp[-1].c,&yyin,yylineno))
 	vyyerror("Unknown Function %s",yyvsp[-1].c);
     ;
     break;}
 case 215:
-#line 1824 "Gmsh.y"
+#line 1823 "Gmsh.y"
 {
       if(!yyvsp[-1].d) skip_until("If", "EndIf");
     ;
     break;}
 case 216:
-#line 1828 "Gmsh.y"
+#line 1827 "Gmsh.y"
 {
     ;
     break;}
 case 217:
-#line 1839 "Gmsh.y"
+#line 1838 "Gmsh.y"
 {
       Curve *pc, *prc;
       Extrude_ProtudePoint(1,(int)yyvsp[-4].d,yyvsp[-2].v[0],yyvsp[-2].v[1],yyvsp[-2].v[2],0.,0.,0.,0.,&pc,&prc,NULL);
     ;
     break;}
 case 218:
-#line 1844 "Gmsh.y"
+#line 1843 "Gmsh.y"
 {
       Curve *pc, *prc;
       Extrude_ProtudePoint(0,(int)yyvsp[-8].d,yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].v[0],yyvsp[-4].v[1],yyvsp[-4].v[2],yyvsp[-2].d,
@@ -4871,55 +4870,55 @@ case 218:
     ;
     break;}
 case 219:
-#line 1850 "Gmsh.y"
+#line 1849 "Gmsh.y"
 {
       Extrude_ProtudeCurve(1,(int)yyvsp[-4].d,yyvsp[-2].v[0],yyvsp[-2].v[1],yyvsp[-2].v[2],0.,0.,0.,0.,NULL);
     ;
     break;}
 case 220:
-#line 1854 "Gmsh.y"
+#line 1853 "Gmsh.y"
 {
       Extrude_ProtudeCurve(0,(int)yyvsp[-8].d,yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].v[0],yyvsp[-4].v[1],yyvsp[-4].v[2],yyvsp[-2].d,NULL);
     ;
     break;}
 case 221:
-#line 1858 "Gmsh.y"
+#line 1857 "Gmsh.y"
 {
       Extrude_ProtudeSurface(1,(int)yyvsp[-4].d,yyvsp[-2].v[0],yyvsp[-2].v[1],yyvsp[-2].v[2],0.,0.,0.,0.,0,NULL);
     ;
     break;}
 case 222:
-#line 1862 "Gmsh.y"
+#line 1861 "Gmsh.y"
 {
       Extrude_ProtudeSurface(0,(int)yyvsp[-8].d,yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].v[0],yyvsp[-4].v[1],yyvsp[-4].v[2],yyvsp[-2].d,0,NULL);
     ;
     break;}
 case 223:
-#line 1866 "Gmsh.y"
+#line 1865 "Gmsh.y"
 {
     int vol = NEWREG();
     Extrude_ProtudeSurface(1,(int)yyvsp[-7].d,yyvsp[-5].v[0],yyvsp[-5].v[1],yyvsp[-5].v[2],0.,0.,0.,0.,vol,&extr);
   ;
     break;}
 case 224:
-#line 1871 "Gmsh.y"
+#line 1870 "Gmsh.y"
 {
     int vol = NEWREG();
     Extrude_ProtudeSurface(0,(int)yyvsp[-11].d,yyvsp[-9].v[0],yyvsp[-9].v[1],yyvsp[-9].v[2],yyvsp[-7].v[0],yyvsp[-7].v[1],yyvsp[-7].v[2],yyvsp[-5].d,vol,&extr);
   ;
     break;}
 case 225:
-#line 1879 "Gmsh.y"
+#line 1878 "Gmsh.y"
 {
     ;
     break;}
 case 226:
-#line 1882 "Gmsh.y"
+#line 1881 "Gmsh.y"
 {
     ;
     break;}
 case 227:
-#line 1888 "Gmsh.y"
+#line 1887 "Gmsh.y"
 {
       double d;
       int j;
@@ -4938,13 +4937,13 @@ case 227:
     ;
     break;}
 case 228:
-#line 1905 "Gmsh.y"
+#line 1904 "Gmsh.y"
 {
       extr.mesh.Recombine = true;
     ;
     break;}
 case 229:
-#line 1916 "Gmsh.y"
+#line 1915 "Gmsh.y"
 {
       Curve *c;
       for(i=0;i<List_Nbr(yyvsp[-3].l);i++){
@@ -4963,7 +4962,7 @@ case 229:
     ;
     break;}
 case 230:
-#line 1933 "Gmsh.y"
+#line 1932 "Gmsh.y"
 {
       Curve *c;
       for(i=0;i<List_Nbr(yyvsp[-6].l);i++){
@@ -4982,7 +4981,7 @@ case 230:
     ;
     break;}
 case 231:
-#line 1950 "Gmsh.y"
+#line 1949 "Gmsh.y"
 {
       Curve *c;
       for(i=0;i<List_Nbr(yyvsp[-6].l);i++){
@@ -5001,7 +5000,7 @@ case 231:
     ;
     break;}
 case 232:
-#line 1967 "Gmsh.y"
+#line 1966 "Gmsh.y"
 {
       Surface *s = FindSurface((int)yyvsp[-4].d,THEM);
       if(!s)
@@ -5024,7 +5023,7 @@ case 232:
     ;
     break;}
 case 233:
-#line 1988 "Gmsh.y"
+#line 1987 "Gmsh.y"
 {
       Surface *s = FindSurface((int)yyvsp[-4].d,THEM);
       if(!s)
@@ -5046,7 +5045,7 @@ case 233:
     ;
     break;}
 case 234:
-#line 2008 "Gmsh.y"
+#line 2007 "Gmsh.y"
 {
       Volume *v = FindVolume((int)yyvsp[-4].d,THEM);
       if(!v)
@@ -5068,7 +5067,7 @@ case 234:
     ;
     break;}
 case 235:
-#line 2028 "Gmsh.y"
+#line 2027 "Gmsh.y"
 {
       Surface *s;
       for(i=0;i<List_Nbr(yyvsp[-3].l);i++){
@@ -5087,7 +5086,7 @@ case 235:
     ;
     break;}
 case 236:
-#line 2045 "Gmsh.y"
+#line 2044 "Gmsh.y"
 {
       Surface *s;
       for(i=0;i<List_Nbr(yyvsp[-1].l);i++){
@@ -5106,79 +5105,79 @@ case 236:
     ;
     break;}
 case 237:
-#line 2070 "Gmsh.y"
+#line 2069 "Gmsh.y"
 { 
       Coherence_PS();
     ;
     break;}
 case 238:
-#line 2074 "Gmsh.y"
+#line 2073 "Gmsh.y"
 { 
       IntersectAllSegmentsTogether();
     ;
     break;}
 case 239:
-#line 2085 "Gmsh.y"
+#line 2084 "Gmsh.y"
 { yyval.d = yyvsp[0].d; ;
     break;}
 case 240:
-#line 2086 "Gmsh.y"
+#line 2085 "Gmsh.y"
 { yyval.d = -yyvsp[0].d; ;
     break;}
 case 241:
-#line 2090 "Gmsh.y"
+#line 2089 "Gmsh.y"
 {yyval.i = 1;;
     break;}
 case 242:
-#line 2091 "Gmsh.y"
+#line 2090 "Gmsh.y"
 {yyval.i = 0;;
     break;}
 case 243:
-#line 2092 "Gmsh.y"
+#line 2091 "Gmsh.y"
 {yyval.i = -1;;
     break;}
 case 244:
-#line 2093 "Gmsh.y"
+#line 2092 "Gmsh.y"
 {yyval.i = -1;;
     break;}
 case 245:
-#line 2094 "Gmsh.y"
+#line 2093 "Gmsh.y"
 {yyval.i = -1;;
     break;}
 case 246:
-#line 2098 "Gmsh.y"
+#line 2097 "Gmsh.y"
 { yyval.d = yyvsp[0].d;           ;
     break;}
 case 247:
-#line 2099 "Gmsh.y"
+#line 2098 "Gmsh.y"
 { yyval.d = yyvsp[-1].d ;          ;
     break;}
 case 248:
-#line 2100 "Gmsh.y"
+#line 2099 "Gmsh.y"
 { yyval.d = -yyvsp[0].d ;         ;
     break;}
 case 249:
-#line 2101 "Gmsh.y"
+#line 2100 "Gmsh.y"
 { yyval.d = yyvsp[0].d;           ;
     break;}
 case 250:
-#line 2102 "Gmsh.y"
+#line 2101 "Gmsh.y"
 { yyval.d = !yyvsp[0].d ;         ;
     break;}
 case 251:
-#line 2103 "Gmsh.y"
+#line 2102 "Gmsh.y"
 { yyval.d = yyvsp[-2].d - yyvsp[0].d ;     ;
     break;}
 case 252:
-#line 2104 "Gmsh.y"
+#line 2103 "Gmsh.y"
 { yyval.d = yyvsp[-2].d + yyvsp[0].d ;     ;
     break;}
 case 253:
-#line 2105 "Gmsh.y"
+#line 2104 "Gmsh.y"
 { yyval.d = yyvsp[-2].d * yyvsp[0].d ;     ;
     break;}
 case 254:
-#line 2107 "Gmsh.y"
+#line 2106 "Gmsh.y"
 { 
       if(!yyvsp[0].d)
 	vyyerror("Division by Zero in '%g / %g'", yyvsp[-2].d, yyvsp[0].d);
@@ -5187,143 +5186,143 @@ case 254:
     ;
     break;}
 case 255:
-#line 2113 "Gmsh.y"
+#line 2112 "Gmsh.y"
 { yyval.d = (int)yyvsp[-2].d % (int)yyvsp[0].d ;  ;
     break;}
 case 256:
-#line 2114 "Gmsh.y"
+#line 2113 "Gmsh.y"
 { yyval.d = pow(yyvsp[-2].d,yyvsp[0].d) ;  ;
     break;}
 case 257:
-#line 2115 "Gmsh.y"
+#line 2114 "Gmsh.y"
 { yyval.d = yyvsp[-2].d < yyvsp[0].d ;     ;
     break;}
 case 258:
-#line 2116 "Gmsh.y"
+#line 2115 "Gmsh.y"
 { yyval.d = yyvsp[-2].d > yyvsp[0].d ;     ;
     break;}
 case 259:
-#line 2117 "Gmsh.y"
+#line 2116 "Gmsh.y"
 { yyval.d = yyvsp[-2].d <= yyvsp[0].d ;    ;
     break;}
 case 260:
-#line 2118 "Gmsh.y"
+#line 2117 "Gmsh.y"
 { yyval.d = yyvsp[-2].d >= yyvsp[0].d ;    ;
     break;}
 case 261:
-#line 2119 "Gmsh.y"
+#line 2118 "Gmsh.y"
 { yyval.d = yyvsp[-2].d == yyvsp[0].d ;    ;
     break;}
 case 262:
-#line 2120 "Gmsh.y"
+#line 2119 "Gmsh.y"
 { yyval.d = yyvsp[-2].d != yyvsp[0].d ;    ;
     break;}
 case 263:
-#line 2121 "Gmsh.y"
+#line 2120 "Gmsh.y"
 { yyval.d = yyvsp[-2].d && yyvsp[0].d ;    ;
     break;}
 case 264:
-#line 2122 "Gmsh.y"
+#line 2121 "Gmsh.y"
 { yyval.d = yyvsp[-2].d || yyvsp[0].d ;    ;
     break;}
 case 265:
-#line 2123 "Gmsh.y"
+#line 2122 "Gmsh.y"
 { yyval.d = yyvsp[-4].d? yyvsp[-2].d : yyvsp[0].d ; ;
     break;}
 case 266:
-#line 2124 "Gmsh.y"
+#line 2123 "Gmsh.y"
 { yyval.d = exp(yyvsp[-1].d);      ;
     break;}
 case 267:
-#line 2125 "Gmsh.y"
+#line 2124 "Gmsh.y"
 { yyval.d = log(yyvsp[-1].d);      ;
     break;}
 case 268:
-#line 2126 "Gmsh.y"
+#line 2125 "Gmsh.y"
 { yyval.d = log10(yyvsp[-1].d);    ;
     break;}
 case 269:
-#line 2127 "Gmsh.y"
+#line 2126 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-1].d);     ;
     break;}
 case 270:
-#line 2128 "Gmsh.y"
+#line 2127 "Gmsh.y"
 { yyval.d = sin(yyvsp[-1].d);      ;
     break;}
 case 271:
-#line 2129 "Gmsh.y"
+#line 2128 "Gmsh.y"
 { yyval.d = asin(yyvsp[-1].d);     ;
     break;}
 case 272:
-#line 2130 "Gmsh.y"
+#line 2129 "Gmsh.y"
 { yyval.d = cos(yyvsp[-1].d);      ;
     break;}
 case 273:
-#line 2131 "Gmsh.y"
+#line 2130 "Gmsh.y"
 { yyval.d = acos(yyvsp[-1].d);     ;
     break;}
 case 274:
-#line 2132 "Gmsh.y"
+#line 2131 "Gmsh.y"
 { yyval.d = tan(yyvsp[-1].d);      ;
     break;}
 case 275:
-#line 2133 "Gmsh.y"
+#line 2132 "Gmsh.y"
 { yyval.d = atan(yyvsp[-1].d);     ;
     break;}
 case 276:
-#line 2134 "Gmsh.y"
+#line 2133 "Gmsh.y"
 { yyval.d = atan2(yyvsp[-3].d,yyvsp[-1].d); ;
     break;}
 case 277:
-#line 2135 "Gmsh.y"
+#line 2134 "Gmsh.y"
 { yyval.d = sinh(yyvsp[-1].d);     ;
     break;}
 case 278:
-#line 2136 "Gmsh.y"
+#line 2135 "Gmsh.y"
 { yyval.d = cosh(yyvsp[-1].d);     ;
     break;}
 case 279:
-#line 2137 "Gmsh.y"
+#line 2136 "Gmsh.y"
 { yyval.d = tanh(yyvsp[-1].d);     ;
     break;}
 case 280:
-#line 2138 "Gmsh.y"
+#line 2137 "Gmsh.y"
 { yyval.d = fabs(yyvsp[-1].d);     ;
     break;}
 case 281:
-#line 2139 "Gmsh.y"
+#line 2138 "Gmsh.y"
 { yyval.d = floor(yyvsp[-1].d);    ;
     break;}
 case 282:
-#line 2140 "Gmsh.y"
+#line 2139 "Gmsh.y"
 { yyval.d = ceil(yyvsp[-1].d);     ;
     break;}
 case 283:
-#line 2141 "Gmsh.y"
+#line 2140 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d,yyvsp[-1].d);  ;
     break;}
 case 284:
-#line 2142 "Gmsh.y"
+#line 2141 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d,yyvsp[-1].d);  ;
     break;}
 case 285:
-#line 2143 "Gmsh.y"
+#line 2142 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-3].d*yyvsp[-3].d+yyvsp[-1].d*yyvsp[-1].d); ;
     break;}
 case 286:
-#line 2144 "Gmsh.y"
+#line 2143 "Gmsh.y"
 { yyval.d = yyvsp[-1].d*(double)rand()/(double)RAND_MAX; ;
     break;}
 case 287:
-#line 2153 "Gmsh.y"
+#line 2152 "Gmsh.y"
 { yyval.d = yyvsp[0].d; ;
     break;}
 case 288:
-#line 2154 "Gmsh.y"
+#line 2153 "Gmsh.y"
 { yyval.d = 3.141592653589793; ;
     break;}
 case 289:
-#line 2159 "Gmsh.y"
+#line 2158 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[0].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5337,7 +5336,7 @@ case 289:
     ;
     break;}
 case 290:
-#line 2171 "Gmsh.y"
+#line 2170 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-3].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5356,7 +5355,7 @@ case 290:
     ;
     break;}
 case 291:
-#line 2189 "Gmsh.y"
+#line 2188 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-1].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5370,7 +5369,7 @@ case 291:
     ;
     break;}
 case 292:
-#line 2201 "Gmsh.y"
+#line 2200 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-4].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5389,7 +5388,7 @@ case 292:
     ;
     break;}
 case 293:
-#line 2219 "Gmsh.y"
+#line 2218 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-1].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5403,7 +5402,7 @@ case 293:
     ;
     break;}
 case 294:
-#line 2231 "Gmsh.y"
+#line 2230 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-4].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5422,7 +5421,7 @@ case 294:
     ;
     break;}
 case 295:
-#line 2251 "Gmsh.y"
+#line 2250 "Gmsh.y"
 {
       if(!(pNumCat = Get_NumberOptionCategory(yyvsp[-2].c))){
 	vyyerror("Unknown Numeric Option Class '%s'", yyvsp[-2].c);
@@ -5445,7 +5444,7 @@ case 295:
     ;
     break;}
 case 296:
-#line 2272 "Gmsh.y"
+#line 2271 "Gmsh.y"
 {
       if(strcmp(yyvsp[-7].c, "PostProcessing")){
 	vyyerror("Unknown View Option Class '%s'", yyvsp[-7].c);
@@ -5470,7 +5469,7 @@ case 296:
     ;
     break;}
 case 297:
-#line 2296 "Gmsh.y"
+#line 2295 "Gmsh.y"
 {
       if(!(pNumCat = Get_NumberOptionCategory(yyvsp[-3].c))){
 	vyyerror("Unknown Numeric Option Class '%s'", yyvsp[-3].c);
@@ -5493,7 +5492,7 @@ case 297:
     ;
     break;}
 case 298:
-#line 2317 "Gmsh.y"
+#line 2316 "Gmsh.y"
 {
       if(strcmp(yyvsp[-8].c, "PostProcessing")){
 	vyyerror("Unknown View Option Class '%s'", yyvsp[-8].c);
@@ -5518,7 +5517,7 @@ case 298:
     ;
     break;}
 case 299:
-#line 2341 "Gmsh.y"
+#line 2340 "Gmsh.y"
 {
       if(!(pNumCat = Get_NumberOptionCategory(yyvsp[-3].c))){
 	vyyerror("Unknown Numeric Option Class '%s'", yyvsp[-3].c);
@@ -5541,7 +5540,7 @@ case 299:
     ;
     break;}
 case 300:
-#line 2362 "Gmsh.y"
+#line 2361 "Gmsh.y"
 {
       if(strcmp(yyvsp[-8].c, "PostProcessing")){
 	vyyerror("Unknown View Option Class '%s'", yyvsp[-8].c);
@@ -5566,7 +5565,7 @@ case 300:
     ;
     break;}
 case 301:
-#line 2388 "Gmsh.y"
+#line 2387 "Gmsh.y"
 { 
       ListOfDouble2_L = List_Create(2,1,sizeof(double)) ; 
       for(d=yyvsp[-2].d ; (yyvsp[-2].d<yyvsp[0].d)?(d<=yyvsp[0].d):(d>=yyvsp[0].d) ; (yyvsp[-2].d<yyvsp[0].d)?(d+=1.):(d-=1.)) 
@@ -5574,7 +5573,7 @@ case 301:
     ;
     break;}
 case 302:
-#line 2394 "Gmsh.y"
+#line 2393 "Gmsh.y"
 {
       ListOfDouble2_L = List_Create(2,1,sizeof(double)) ; 
       if(!yyvsp[0].d || (yyvsp[-4].d<yyvsp[-2].d && yyvsp[0].d<0) || (yyvsp[-4].d>yyvsp[-2].d && yyvsp[0].d>0)){
@@ -5587,7 +5586,7 @@ case 302:
    ;
     break;}
 case 303:
-#line 2408 "Gmsh.y"
+#line 2407 "Gmsh.y"
 {
       memcpy(yyval.v, yyvsp[0].v, 5*sizeof(double)) ;
       //??? Avec ce qui suit, bison se plante sur DEC
@@ -5595,110 +5594,110 @@ case 303:
     ;
     break;}
 case 304:
-#line 2414 "Gmsh.y"
+#line 2413 "Gmsh.y"
 {
       for(i=0 ; i<5 ; i++) yyval.v[i] = -yyvsp[0].v[i] ;
     ;
     break;}
 case 305:
-#line 2418 "Gmsh.y"
+#line 2417 "Gmsh.y"
 { 
       for(i=0 ; i<5 ; i++) yyval.v[i] = yyvsp[0].v[i];
     ;
     break;}
 case 306:
-#line 2422 "Gmsh.y"
+#line 2421 "Gmsh.y"
 { 
       for(i=0 ; i<5 ; i++) yyval.v[i] = yyvsp[-2].v[i] - yyvsp[0].v[i] ;
     ;
     break;}
 case 307:
-#line 2426 "Gmsh.y"
+#line 2425 "Gmsh.y"
 {
       for(i=0 ; i<5 ; i++) yyval.v[i] = yyvsp[-2].v[i] + yyvsp[0].v[i] ;
     ;
     break;}
 case 308:
-#line 2432 "Gmsh.y"
+#line 2431 "Gmsh.y"
 { 
       yyval.v[0]=yyvsp[-9].d;  yyval.v[1]=yyvsp[-7].d;  yyval.v[2]=yyvsp[-5].d;  yyval.v[3]=yyvsp[-3].d; yyval.v[4]=yyvsp[-1].d;
     ;
     break;}
 case 309:
-#line 2436 "Gmsh.y"
+#line 2435 "Gmsh.y"
 { 
       yyval.v[0]=yyvsp[-7].d;  yyval.v[1]=yyvsp[-5].d;  yyval.v[2]=yyvsp[-3].d;  yyval.v[3]=yyvsp[-1].d; yyval.v[4]=1.0;
     ;
     break;}
 case 310:
-#line 2440 "Gmsh.y"
+#line 2439 "Gmsh.y"
 {
       yyval.v[0]=yyvsp[-5].d;  yyval.v[1]=yyvsp[-3].d;  yyval.v[2]=yyvsp[-1].d;  yyval.v[3]=0.0; yyval.v[4]=1.0;
     ;
     break;}
 case 311:
-#line 2444 "Gmsh.y"
+#line 2443 "Gmsh.y"
 {
       yyval.v[0]=yyvsp[-5].d;  yyval.v[1]=yyvsp[-3].d;  yyval.v[2]=yyvsp[-1].d;  yyval.v[3]=0.0; yyval.v[4]=1.0;
     ;
     break;}
 case 312:
-#line 2451 "Gmsh.y"
+#line 2450 "Gmsh.y"
 {
     ;
     break;}
 case 313:
-#line 2454 "Gmsh.y"
+#line 2453 "Gmsh.y"
 {
     ;
     break;}
 case 314:
-#line 2460 "Gmsh.y"
+#line 2459 "Gmsh.y"
 {
     ;
     break;}
 case 315:
-#line 2463 "Gmsh.y"
+#line 2462 "Gmsh.y"
 {
     ;
     break;}
 case 316:
-#line 2469 "Gmsh.y"
+#line 2468 "Gmsh.y"
 {
     ;
     break;}
 case 317:
-#line 2472 "Gmsh.y"
+#line 2471 "Gmsh.y"
 {
        yyval.l=ListOfListOfDouble_L;
     ;
     break;}
 case 318:
-#line 2476 "Gmsh.y"
+#line 2475 "Gmsh.y"
 {
        yyval.l=ListOfListOfDouble_L;
     ;
     break;}
 case 319:
-#line 2483 "Gmsh.y"
+#line 2482 "Gmsh.y"
 {
       ListOfListOfDouble_L = List_Create(2,1,sizeof(List_T*)) ;
       List_Add(ListOfListOfDouble_L, &(yyvsp[0].l)) ;
     ;
     break;}
 case 320:
-#line 2488 "Gmsh.y"
+#line 2487 "Gmsh.y"
 {
       List_Add(ListOfListOfDouble_L, &(yyvsp[0].l)) ;
     ;
     break;}
 case 321:
-#line 2495 "Gmsh.y"
+#line 2494 "Gmsh.y"
 {
     ;
     break;}
 case 322:
-#line 2498 "Gmsh.y"
+#line 2497 "Gmsh.y"
 {
       ListOfDouble_L = List_Create(2,1,sizeof(double)) ;
       List_Add(ListOfDouble_L, &(yyvsp[0].d)) ;
@@ -5706,7 +5705,7 @@ case 322:
     ;
     break;}
 case 323:
-#line 2504 "Gmsh.y"
+#line 2503 "Gmsh.y"
 {
       ListOfDouble_L = List_Create(2,1,sizeof(double)) ;
       TheSymbol.Name = yyvsp[-2].c ;
@@ -5723,20 +5722,20 @@ case 323:
     ;
     break;}
 case 324:
-#line 2519 "Gmsh.y"
+#line 2518 "Gmsh.y"
 {
       yyval.l=ListOfDouble_L;
     ;
     break;}
 case 325:
-#line 2527 "Gmsh.y"
+#line 2526 "Gmsh.y"
 {
       ListOfDouble_L = List_Create(2,1,sizeof(double)) ;
       List_Add(ListOfDouble_L, &(yyvsp[0].d)) ;
     ;
     break;}
 case 326:
-#line 2532 "Gmsh.y"
+#line 2531 "Gmsh.y"
 { 
       ListOfDouble_L = List_Create(2,1,sizeof(double)) ;
       for(i=0 ; i<List_Nbr(ListOfDouble2_L) ; i++){
@@ -5747,7 +5746,7 @@ case 326:
     ;
     break;}
 case 327:
-#line 2541 "Gmsh.y"
+#line 2540 "Gmsh.y"
 { 
       ListOfDouble_L = List_Create(2,1,sizeof(double)) ;
       TheSymbol.Name = yyvsp[-2].c ;
@@ -5761,13 +5760,13 @@ case 327:
     ;
     break;}
 case 328:
-#line 2553 "Gmsh.y"
+#line 2552 "Gmsh.y"
 {
       List_Add(ListOfDouble_L, &(yyvsp[0].d)) ;
     ;
     break;}
 case 329:
-#line 2557 "Gmsh.y"
+#line 2556 "Gmsh.y"
 {
       for(i=0 ; i<List_Nbr(ListOfDouble2_L) ; i++){
 	List_Read(ListOfDouble2_L, i, &d) ;
@@ -5777,7 +5776,7 @@ case 329:
     ;
     break;}
 case 330:
-#line 2565 "Gmsh.y"
+#line 2564 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-2].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5790,33 +5789,33 @@ case 330:
     ;
     break;}
 case 331:
-#line 2579 "Gmsh.y"
+#line 2578 "Gmsh.y"
 {
       yyval.u = PACK_COLOR((int)yyvsp[-7].d, (int)yyvsp[-5].d, (int)yyvsp[-3].d, (int)yyvsp[-1].d);
     ;
     break;}
 case 332:
-#line 2583 "Gmsh.y"
+#line 2582 "Gmsh.y"
 {
       yyval.u = PACK_COLOR((int)yyvsp[-5].d, (int)yyvsp[-3].d, (int)yyvsp[-1].d, 255);
     ;
     break;}
 case 333:
-#line 2587 "Gmsh.y"
+#line 2586 "Gmsh.y"
 {
       yyval.u = Get_ColorForString(ColorString, (int)yyvsp[-1].d, yyvsp[-3].c, &flag);
       if(flag) vyyerror("Unknown Color '%s'", yyvsp[-3].c);
     ;
     break;}
 case 334:
-#line 2592 "Gmsh.y"
+#line 2591 "Gmsh.y"
 {
       yyval.u = Get_ColorForString(ColorString, -1, yyvsp[0].c, &flag);
       if(flag) vyyerror("Unknown Color '%s'", yyvsp[0].c);
     ;
     break;}
 case 335:
-#line 2597 "Gmsh.y"
+#line 2596 "Gmsh.y"
 {
       if(!(pColCat = Get_ColorOptionCategory(yyvsp[-4].c))){
 	vyyerror("Unknown Color Option Class '%s'", yyvsp[-4].c);
@@ -5834,13 +5833,13 @@ case 335:
     ;
     break;}
 case 336:
-#line 2616 "Gmsh.y"
+#line 2615 "Gmsh.y"
 {
       yyval.l = ListOfColor_L;
     ;
     break;}
 case 337:
-#line 2620 "Gmsh.y"
+#line 2619 "Gmsh.y"
 {
       if(!ListOfColor_L)
 	ListOfColor_L = List_Create(256,10,sizeof(unsigned int)) ;
@@ -5861,7 +5860,7 @@ case 337:
     ;
     break;}
 case 338:
-#line 2642 "Gmsh.y"
+#line 2641 "Gmsh.y"
 {
       if(!ListOfColor_L)
 	ListOfColor_L = List_Create(256,10,sizeof(unsigned int)) ;
@@ -5871,25 +5870,25 @@ case 338:
     ;
     break;}
 case 339:
-#line 2650 "Gmsh.y"
+#line 2649 "Gmsh.y"
 {
       List_Add(ListOfColor_L, &(yyvsp[0].u)) ;
     ;
     break;}
 case 340:
-#line 2657 "Gmsh.y"
+#line 2656 "Gmsh.y"
 {
       yyval.c = yyvsp[0].c;
     ;
     break;}
 case 341:
-#line 2661 "Gmsh.y"
+#line 2660 "Gmsh.y"
 {
       yyval.c = yyvsp[-1].c;
     ;
     break;}
 case 342:
-#line 2665 "Gmsh.y"
+#line 2664 "Gmsh.y"
 {
       for(i = 0 ; i<List_Nbr(ListOfDouble_L) ; i++){
 	if(!i){
@@ -6135,7 +6134,7 @@ yyerrhandle:
     }
   return 1;
 }
-#line 2689 "Gmsh.y"
+#line 2688 "Gmsh.y"
 
 
 void InitSymbols(void){
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index 70596e8037..fc8ee7b606 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -1,6 +1,6 @@
 %{ 
 
-// $Id: Gmsh.y,v 1.56 2001-01-11 22:27:56 geuzaine Exp $
+// $Id: Gmsh.y,v 1.57 2001-01-29 08:43:45 geuzaine Exp $
 
 #include <stdarg.h>
 
@@ -1686,7 +1686,6 @@ Command :
 	  DrawUI();
 	}
 	else{
-	  Init();
 	  Draw();
 	  DrawUI();
 	}
diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp
index 3742be1300..9961a8200a 100644
--- a/Parser/Gmsh.yy.cpp
+++ b/Parser/Gmsh.yy.cpp
@@ -2,7 +2,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.64 2001-01-17 21:26:25 remacle Exp $
+ * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.65 2001-01-29 08:43:45 geuzaine Exp $
  */
 
 #define FLEX_SCANNER
@@ -977,7 +977,7 @@ char *yytext;
 #define INITIAL 0
 #line 2 "Gmsh.l"
 
-// $Id: Gmsh.yy.cpp,v 1.64 2001-01-17 21:26:25 remacle Exp $
+// $Id: Gmsh.yy.cpp,v 1.65 2001-01-29 08:43:45 geuzaine Exp $
 
 #include <stdio.h>
 #include <stdlib.h>
-- 
GitLab