diff --git a/Common/Context.h b/Common/Context.h
index 602c0075b9b7624dcf94c4c625586b96524000de..a27431828cd863642073e41992637810ac38e0d0 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -77,6 +77,7 @@ public :
   int msg_size[2];            // size of the message window on the screen
   int opt_position[2];        // position of the option window on the screen
   int vis_position[2];        // position of the visibility window on the screen
+  int clip_position[2];       // position of the clipping planes window on the screen
   int stat_position[2];       // position of the statistics window on the screen
   int ctx_position[2];        // position of the geo/mesh context windows on the screen
   int solver_position[2];     // position of the solver windows on the screen
@@ -124,7 +125,7 @@ public :
   double light_position[6][3]; // light sources positions 
   double shine;                // specular value 
   int render_mode;            // GMSH_RENDER, GMSH_SELECT, GMSH_FEEDBACK 
-  int clip[6];                // status of clip planes 
+  int clip[6];                // status of clip planes (bit arrays)
   double clip_plane[6][4];    // clip planes 
   double pixel_equiv_x, pixel_equiv_y ; 
                               // approximative equivalent model length of a pixel 
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index af8e8eedc7d0ec6c42a0c181bec3c6b37d65486c..7439d96ff9c64af124f589ce4997e304fc4b4cfc 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -372,67 +372,71 @@ StringXNumber GeneralOptions_Number[] = {
     "Relative radius of arrow stem" },
   { F|O, "Axes" , opt_general_axes , 0. ,
     "Display the axes linked to the model" },
-
   { F,   "Clip0" , opt_general_clip0 , 0. ,
-    "Enable clip plane 0" },
+    "Enable clipping plane 0 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" },
   { F,   "Clip0A" , opt_general_clip0a , 0.0 ,
-    "First coefficient in equation for clip plane 0 (`A' in `AX+BY+CZ+D=0')" },
+    "First coefficient in equation for clipping plane 0 (`A' in `AX+BY+CZ+D=0')" },
   { F,   "Clip0B" , opt_general_clip0b , 0.0 , 
-    "Second coefficient in equation for clip plane 0 (`B' in `AX+BY+CZ+D=0')" },
+    "Second coefficient in equation for clipping plane 0 (`B' in `AX+BY+CZ+D=0')" },
   { F,   "Clip0C" , opt_general_clip0c , 0.0 , 
-    "Third coefficient in equation for clip plane 0 (`C' in `AX+BY+CZ+D=0')" },
+    "Third coefficient in equation for clipping plane 0 (`C' in `AX+BY+CZ+D=0')" },
   { F,   "Clip0D" , opt_general_clip0d , 0.0 , 
-    "Fourth coefficient in equation for clip plane 0 (`D' in `AX+BY+CZ+D=0')" },
+    "Fourth coefficient in equation for clipping plane 0 (`D' in `AX+BY+CZ+D=0')" },
   { F,   "Clip1" , opt_general_clip1 , 0.,
-    "Enable clip plane 1" },
+    "Enable clipping plane 1 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" },
   { F,   "Clip1A" , opt_general_clip1a , 0.0 , 
-    "First coefficient in equation for clip plane 1" },
+    "First coefficient in equation for clipping plane 1" },
   { F,   "Clip1B" , opt_general_clip1b , 0.0 , 
-    "Second coefficient in equation for clip plane 1" },
+    "Second coefficient in equation for clipping plane 1" },
   { F,   "Clip1C" , opt_general_clip1c , 0.0 , 
-    "Third coefficient in equation for clip plane 1" },
+    "Third coefficient in equation for clipping plane 1" },
   { F,   "Clip1D" , opt_general_clip1d , 0.0 , 
-    "Fourth coefficient in equation for clip plane 1" },
+    "Fourth coefficient in equation for clipping plane 1" },
   { F,   "Clip2" , opt_general_clip2 , 0.,
-    "Enable clip plane 2" },
+    "Enable clipping plane 2 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" },
   { F,   "Clip2A" , opt_general_clip2a , 0.0 , 
-    "First coefficient in equation for clip plane 2" },
+    "First coefficient in equation for clipping plane 2" },
   { F,   "Clip2B" , opt_general_clip2b , 0.0 , 
-    "Second coefficient in equation for clip plane 2" },
+    "Second coefficient in equation for clipping plane 2" },
   { F,   "Clip2C" , opt_general_clip2c , 0.0 , 
-    "Third coefficient in equation for clip plane 2" },
+    "Third coefficient in equation for clipping plane 2" },
   { F,   "Clip2D" , opt_general_clip2d , 0.0 , 
-    "Fourth coefficient in equation for clip plane 2" },
+    "Fourth coefficient in equation for clipping plane 2" },
   { F,   "Clip3" , opt_general_clip3 , 0.,
-    "Enable clip plane 3" },
+    "Enable clipping plane 3 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" },
   { F,   "Clip3A" , opt_general_clip3a , 0.0 , 
-    "First coefficient in equation for clip plane 3" },
+    "First coefficient in equation for clipping plane 3" },
   { F,   "Clip3B" , opt_general_clip3b , 0.0 , 
-    "Second coefficient in equation for clip plane 3" },
+    "Second coefficient in equation for clipping plane 3" },
   { F,   "Clip3C" , opt_general_clip3c , 0.0 , 
-    "Third coefficient in equation for clip plane 3" },
+    "Third coefficient in equation for clipping plane 3" },
   { F,   "Clip3D" , opt_general_clip3d , 0.0 , 
-    "Fourth coefficient in equation for clip plane 3" },
+    "Fourth coefficient in equation for clipping plane 3" },
   { F,   "Clip4" , opt_general_clip4 , 0.,
-    "Enable clip plane 4" },
+    "Enable clipping plane 4 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" },
   { F,   "Clip4A" , opt_general_clip4a , 0.0 , 
-    "First coefficient in equation for clip plane 4" },
+    "First coefficient in equation for clipping plane 4" },
   { F,   "Clip4B" , opt_general_clip4b , 0.0 , 
-    "Second coefficient in equation for clip plane 4" },
+    "Second coefficient in equation for clipping plane 4" },
   { F,   "Clip4C" , opt_general_clip4c , 0.0 , 
-    "Third coefficient in equation for clip plane 4" },
+    "Third coefficient in equation for clipping plane 4" },
   { F,   "Clip4D" , opt_general_clip4d , 0.0 , 
-    "Fourth coefficient in equation for clip plane 4" },
+    "Fourth coefficient in equation for clipping plane 4" },
   { F,   "Clip5" , opt_general_clip5 , 0.,
-    "Enable clip plane 5" },
+    "Enable clipping plane 5 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" },
   { F,   "Clip5A" , opt_general_clip5a , 0.0 , 
-    "First coefficient in equation for clip plane 5" },
+    "First coefficient in equation for clipping plane 5" },
   { F,   "Clip5B" , opt_general_clip5b , 0.0 , 
-    "Second coefficient in equation for clip plane 5" },
+    "Second coefficient in equation for clipping plane 5" },
   { F,   "Clip5C" , opt_general_clip5c , 0.0 , 
-    "Third coefficient in equation for clip plane 5" },
+    "Third coefficient in equation for clipping plane 5" },
   { F,   "Clip5D" , opt_general_clip5d , 0.0 , 
-    "Fourth coefficient in equation for clip plane 5" },
+    "Fourth coefficient in equation for clipping plane 5" },
+  { F|S, "ClipPositionX" , opt_general_clip_position0 , 650. , 
+    "Horizontal position (in pixels) of the upper left corner of the clipping planes window" }, 
+  { F|S, "ClipPositionY" , opt_general_clip_position1 , 150. , 
+    "Vertical position (in pixels) of the upper left corner of the clipping planes window" }, 
+
   { F|O, "ColorScheme", opt_general_color_scheme , 0. ,
     "Default color scheme (0, 1 or 2)" },
   { F|S, "ConfirmOverwrite" , opt_general_confirm_overwrite, 1. , 
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 613ef79990301146c779bf3cfd0d07f04b926c76..051aed8efb19439400acb94d719cafac5675f937 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.171 2004-07-16 18:02:19 geuzaine Exp $
+// $Id: Options.cpp,v 1.172 2004-07-17 22:46:28 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -1975,6 +1975,20 @@ double opt_general_visibility_position1(OPT_ARGS_NUM)
     CTX.vis_position[1] = (int)val;
   return CTX.vis_position[1];
 }
+ 
+double opt_general_clip_position0(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET)
+    CTX.clip_position[0] = (int)val;
+  return CTX.clip_position[0];
+}
+
+double opt_general_clip_position1(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET)
+    CTX.clip_position[1] = (int)val;
+  return CTX.clip_position[1];
+}
 
 double opt_general_visibility_mode(OPT_ARGS_NUM)
 {
@@ -2446,6 +2460,10 @@ double opt_general_clip0(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip[0] = (int)val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip[0];
 }
 
@@ -2453,6 +2471,10 @@ double opt_general_clip0a(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[0][0] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[0][0];
 }
 
@@ -2460,6 +2482,10 @@ double opt_general_clip0b(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[0][1] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[0][1];
 }
 
@@ -2467,6 +2493,10 @@ double opt_general_clip0c(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[0][2] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[0][2];
 }
 
@@ -2474,6 +2504,10 @@ double opt_general_clip0d(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[0][3] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[0][3];
 }
 
@@ -2481,6 +2515,10 @@ double opt_general_clip1(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip[1] = (int)val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip[1];
 }
 
@@ -2488,6 +2526,10 @@ double opt_general_clip1a(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[1][0] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[1][0];
 }
 
@@ -2495,6 +2537,10 @@ double opt_general_clip1b(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[1][1] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[1][1];
 }
 
@@ -2502,6 +2548,10 @@ double opt_general_clip1c(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[1][2] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[1][2];
 }
 
@@ -2509,6 +2559,10 @@ double opt_general_clip1d(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[1][3] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[1][3];
 }
 
@@ -2516,6 +2570,10 @@ double opt_general_clip2(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip[2] = (int)val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip[2];
 }
 
@@ -2523,6 +2581,10 @@ double opt_general_clip2a(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[2][0] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[2][0];
 }
 
@@ -2530,6 +2592,10 @@ double opt_general_clip2b(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[2][1] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[2][1];
 }
 
@@ -2537,6 +2603,10 @@ double opt_general_clip2c(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[2][2] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[2][2];
 }
 
@@ -2544,6 +2614,10 @@ double opt_general_clip2d(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[2][3] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[2][3];
 }
 
@@ -2551,6 +2625,10 @@ double opt_general_clip3(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip[3] = (int)val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip[3];
 }
 
@@ -2558,6 +2636,10 @@ double opt_general_clip3a(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[3][0] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[3][0];
 }
 
@@ -2565,6 +2647,10 @@ double opt_general_clip3b(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[3][1] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[3][1];
 }
 
@@ -2572,6 +2658,10 @@ double opt_general_clip3c(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[3][2] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[3][2];
 }
 
@@ -2579,6 +2669,10 @@ double opt_general_clip3d(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[3][3] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[3][3];
 }
 
@@ -2586,6 +2680,10 @@ double opt_general_clip4(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip[4] = (int)val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip[4];
 }
 
@@ -2593,6 +2691,10 @@ double opt_general_clip4a(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[4][0] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[4][0];
 }
 
@@ -2600,6 +2702,10 @@ double opt_general_clip4b(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[4][1] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[4][1];
 }
 
@@ -2607,6 +2713,10 @@ double opt_general_clip4c(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[4][2] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[4][2];
 }
 
@@ -2614,6 +2724,10 @@ double opt_general_clip4d(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[4][3] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[4][3];
 }
 
@@ -2621,6 +2735,10 @@ double opt_general_clip5(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip[5] = (int)val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip[5];
 }
 
@@ -2628,6 +2746,10 @@ double opt_general_clip5a(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[5][0] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[5][0];
 }
 
@@ -2635,6 +2757,10 @@ double opt_general_clip5b(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[5][1] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[5][1];
 }
 
@@ -2642,6 +2768,10 @@ double opt_general_clip5c(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[5][2] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[5][2];
 }
 
@@ -2649,6 +2779,10 @@ double opt_general_clip5d(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
     CTX.clip_plane[5][3] = val;
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI))
+    WID->reset_clip_browser();
+#endif
   return CTX.clip_plane[5][3];
 }
 
diff --git a/Common/Options.h b/Common/Options.h
index e772ce1221a4dbef4315f5d86270921ab5e37167..f9f9cabf16db72a890915733fa7d933a193d907e 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -211,6 +211,8 @@ double opt_general_statistics_position0(OPT_ARGS_NUM);
 double opt_general_statistics_position1(OPT_ARGS_NUM);
 double opt_general_visibility_position0(OPT_ARGS_NUM);
 double opt_general_visibility_position1(OPT_ARGS_NUM);
+double opt_general_clip_position0(OPT_ARGS_NUM);
+double opt_general_clip_position1(OPT_ARGS_NUM);
 double opt_general_visibility_mode(OPT_ARGS_NUM);
 double opt_general_session_save(OPT_ARGS_NUM);
 double opt_general_options_save(OPT_ARGS_NUM);
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 7ee0b3bd16465bcffc14e7998b44d7df452aa4ca..acc7a0d93b63986df2ca7c53c1a49b9c5e922a09 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.254 2004-07-16 18:02:19 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.255 2004-07-17 22:46:28 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -184,6 +184,7 @@ void UpdateViewsInGUI()
     if(WID->get_context() == 3)
       WID->set_context(menu_post, 0);
     WID->reset_option_browser();
+    WID->reset_clip_browser();
   }
 }
 
@@ -1320,6 +1321,30 @@ void visibility_number_cb(CALLBACK_ARGS)
   Draw();
 }
 
+// Clipping planes menu
+
+void clip_cb(CALLBACK_ARGS)
+{
+  WID->create_clip_window();
+}
+
+void clip_num_cb(CALLBACK_ARGS)
+{
+  WID->reset_clip_browser();
+}
+
+void clip_ok_cb(CALLBACK_ARGS)
+{
+  int idx = WID->clip_choice->value();
+  CTX.clip[idx] = 0;
+  for(int i = 0; i < WID->clip_browser->size(); i++)
+    if(WID->clip_browser->selected(i+1))
+      CTX.clip[idx] += (1<<i);
+  for(int i = 0; i < 4; i++)
+    CTX.clip_plane[idx][i] = WID->clip_value[i]->value();
+  Draw();
+}
+
 // Help Menu
 
 // The fltk guys still have to decide how to map apple keys. Let's
diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h
index aeb2891a51175ef95ab8c1e58c9825a1d678240a..a9a5352175e693af791f316e22963dd1e7199e20 100644
--- a/Fltk/Callbacks.h
+++ b/Fltk/Callbacks.h
@@ -151,6 +151,12 @@ void visibility_sort_cb(CALLBACK_ARGS) ;
 void visibility_number_cb(CALLBACK_ARGS);
 void visibility_ok_cb(CALLBACK_ARGS) ;
 
+// Clipping planes Menu
+
+void clip_cb(CALLBACK_ARGS) ;
+void clip_num_cb(CALLBACK_ARGS) ;
+void clip_ok_cb(CALLBACK_ARGS) ;
+
 // Help Menu
 
 void help_short_cb(CALLBACK_ARGS) ;
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 7534bad7afdc99e953cbfb6ca1cf21db8312ae24..712f9aa9f382645a3ad540d401bbb2081e6bba06 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.323 2004-07-16 18:02:20 geuzaine Exp $
+// $Id: GUI.cpp,v 1.324 2004-07-17 22:46:29 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -84,6 +84,7 @@ Fl_Menu_Item m_menubar_table[] = {
   {"&Tools", 0, 0, 0, FL_SUBMENU},
     {"&Options...",         FL_SHIFT+'o', (Fl_Callback *)options_cb, 0},
     {"&Visibility...",      FL_SHIFT+'v', (Fl_Callback *)visibility_cb, 0},
+    {"&Clipping planes...", FL_SHIFT+'c', (Fl_Callback *)clip_cb, 0},
     {"S&tatistics...",      FL_SHIFT+'i', (Fl_Callback *)statistics_cb, 0, FL_MENU_DIVIDER},
     {"M&essage console...", FL_SHIFT+'l', (Fl_Callback *)message_cb, 0},
     {0},
@@ -115,6 +116,7 @@ Fl_Menu_Item m_sys_menubar_table[] = {
   {"Tools",0,0,0,FL_SUBMENU},
     {"Options...",         FL_SHIFT+'o', (Fl_Callback *)options_cb, 0},
     {"Visibility...",      FL_SHIFT+'v', (Fl_Callback *)visibility_cb, 0},
+    {"Clipping Planes...", FL_SHIFT+'c', (Fl_Callback *)clip_cb, 0},
     {"Statistics...",      FL_SHIFT+'i', (Fl_Callback *)statistics_cb, 0, FL_MENU_DIVIDER},
     {"Message Console...", FL_SHIFT+'l', (Fl_Callback *)message_cb, 0},
     {0},
@@ -689,6 +691,7 @@ GUI::GUI(int argc, char **argv)
   stat_window = NULL;
   msg_window = NULL;
   vis_window = NULL;
+  clip_window = NULL;
   about_window = NULL;
   context_geometry_window = NULL;
   context_mesh_window = NULL;
@@ -754,6 +757,7 @@ GUI::GUI(int argc, char **argv)
   create_message_window();
   create_statistics_window();
   create_visibility_window();
+  create_clip_window();
   create_about_window();
   create_geometry_context_window(0);
   create_mesh_context_window(0);
@@ -2951,6 +2955,83 @@ void GUI::create_visibility_window()
   vis_window->end();
 }
 
+// Create the clipping planes window
+
+void GUI::reset_clip_browser()
+{
+  int i;
+  char str[128];
+  clip_browser->clear();
+  clip_browser->add("Geometry");
+  clip_browser->add("Mesh");
+  for(i = 0; i < List_Nbr(CTX.post.list); i++) {
+    if(i == NB_BUTT_MAX)
+      break;
+    sprintf(str, "View [%d]", i);
+    clip_browser->add(str);
+  }
+  int idx = clip_choice->value();
+  clip_browser->deselect();
+  for(i = 0; i < clip_browser->size(); i++)
+    if(CTX.clip[idx] & (1<<i))
+      clip_browser->select(i+1);
+  for(i = 0; i < 4; i++)
+    clip_value[i]->value(CTX.clip_plane[idx][i]);
+}
+
+void GUI::create_clip_window()
+{
+  if(clip_window) {
+    clip_window->show();
+    return;
+  }
+
+  static Fl_Menu_Item plane_number[] = {
+    {"Plane 0", 0, 0},
+    {"Plane 1", 0, 0},
+    {"Plane 2", 0, 0},
+    {"Plane 3", 0, 0},
+    {"Plane 4", 0, 0},
+    {"Plane 5", 0, 0},
+    {0}
+  };
+
+  int BW = 105;
+  int width = 2 * BW + 3 * WB;
+  int height = 6 * BH + 3 * WB;
+
+  clip_window = new Fl_Window(width, height, "Clipping Planes");
+  clip_window->box(WINDOW_BOX);
+
+  clip_browser = new Fl_Multi_Browser(1 * WB, 1 * WB, BW, 5 * BH);
+
+  clip_choice = new Fl_Choice(2 * WB + BW, 1 * WB + 0 * BH, BW, BH);
+  clip_choice->menu(plane_number);
+  clip_choice->callback(clip_num_cb);
+
+  int BW2 = BW - 3 * fontsize / 2;
+  clip_value[0] = new Fl_Value_Input(2 * WB + BW, 1 * WB + 1 * BH, BW2, BH, "A");
+  clip_value[1] = new Fl_Value_Input(2 * WB + BW, 1 * WB + 2 * BH, BW2, BH, "B");
+  clip_value[2] = new Fl_Value_Input(2 * WB + BW, 1 * WB + 3 * BH, BW2, BH, "C");
+  clip_value[3] = new Fl_Value_Input(2 * WB + BW, 1 * WB + 4 * BH, BW2, BH, "D");
+  for(int i = 0; i < 4; i++)
+    clip_value[i]->align(FL_ALIGN_RIGHT);
+
+  reset_clip_browser();
+
+  {
+    Fl_Return_Button *o = new Fl_Return_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Apply");
+    o->callback(clip_ok_cb);
+  }
+  {
+    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o->callback(cancel_cb, (void *)clip_window);
+  }
+
+  clip_window->position(CTX.clip_position[0], CTX.clip_position[1]);
+  clip_window->end();
+}
+
 // Create the about window
 
 void GUI::create_about_window()
diff --git a/Fltk/GUI.h b/Fltk/GUI.h
index b19dba523f638d7bbbe97e8b6222ffaa776b5dc4..2dda47851a7e6bd445d6309a84dcd620aa89668a 100644
--- a/Fltk/GUI.h
+++ b/Fltk/GUI.h
@@ -40,6 +40,7 @@
 #include <FL/Fl_Multiline_Output.H>
 #include <FL/Fl_Bitmap.H>
 #include <FL/Fl_Browser.H>
+#include <FL/Fl_Multi_Browser.H>
 #include <FL/Fl_Hold_Browser.H>
 #include <FL/x.H>
 #include <FL/Fl_Color_Chooser.H>
@@ -217,6 +218,12 @@ public:
   Fl_Check_Button  *vis_butt[20] ;
   Fl_Input         *vis_input;
 
+  // clipping planes window
+  Fl_Window        *clip_window ;
+  Fl_Choice        *clip_choice ;
+  Fl_Multi_Browser *clip_browser ;
+  Fl_Value_Input   *clip_value[4];
+
   // about window
   Fl_Window        *about_window ;
 
@@ -251,6 +258,7 @@ public:
   PluginDialogBox *create_plugin_window(GMSH_Plugin *p);
   void create_view_options_window(int numview);
   void create_visibility_window();
+  void create_clip_window();
   void create_statistics_window();
   void create_message_window();
   void create_about_window();
@@ -283,6 +291,7 @@ public:
   int  arrow_shortcuts();
   void reset_visibility();
   void reset_option_browser();
+  void reset_clip_browser();
   int  selection, try_selection, quit_selection, end_selection, undo_selection;
 
 };
diff --git a/Fltk/Message.cpp b/Fltk/Message.cpp
index 4750889d3395f80d6baf05f3a8e4000a9d3bf026..9c304b8f248af7081d11b3dd0811a4aca9ccec11 100644
--- a/Fltk/Message.cpp
+++ b/Fltk/Message.cpp
@@ -1,4 +1,4 @@
-// $Id: Message.cpp,v 1.56 2004-06-17 21:16:58 geuzaine Exp $
+// $Id: Message.cpp,v 1.57 2004-07-17 22:46:29 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -238,6 +238,8 @@ void Exit(int level)
       CTX.stat_position[1] = WID->stat_window->y();
       CTX.vis_position[0] = WID->vis_window->x();
       CTX.vis_position[1] = WID->vis_window->y();
+      CTX.clip_position[0] = WID->clip_window->x();
+      CTX.clip_position[1] = WID->clip_window->y();
       CTX.ctx_position[0] = WID->context_geometry_window->x();
       CTX.ctx_position[1] = WID->context_geometry_window->y();
       CTX.solver_position[0] = WID->solver[0].window->x();
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index cf7d2085a67ac08a1a7f53ed22387be377c68471..2f6b52364c15aa83e9d60f1417979503c522ed07 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.101 2004-07-16 18:02:20 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.102 2004-07-17 22:46:29 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -105,26 +105,27 @@ double intersectCutPlane(int num, Vertex **v)
 
 void Draw_Mesh(Mesh * M)
 {
-  GLenum clip[6] = { GL_CLIP_PLANE0, GL_CLIP_PLANE1, GL_CLIP_PLANE2, 
-		     GL_CLIP_PLANE3, GL_CLIP_PLANE4, GL_CLIP_PLANE5 };
-
   InitPosition();
 
   for(int i = 0; i < 6; i++){
-    if(CTX.clip[i]){
-      glClipPlane(clip[i], CTX.clip_plane[i]);
-      glEnable(clip[i]);
-    }
-    else{
-      glDisable(clip[i]);
-    }
+    glClipPlane((GLenum)(GL_CLIP_PLANE0 + i), CTX.clip_plane[i]);
+    glDisable((GLenum)(GL_CLIP_PLANE0 + i));
   }
 
   // draw the geometry
 
   if(M->status >= 0){
     glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
+    for(int i = 0; i < 6; i++){
+      if(CTX.clip[i] & 1) 
+	glEnable((GLenum)(GL_CLIP_PLANE0 + i));
+      else
+	glDisable((GLenum)(GL_CLIP_PLANE0 + i));
+    }
     Draw_Geom(M);
+    for(int i = 0; i < 6; i++){
+      glDisable((GLenum)(GL_CLIP_PLANE0 + i));
+    }
   }
 
   // if we're in selection mode, we're done
@@ -186,6 +187,13 @@ void Draw_Mesh(Mesh * M)
       glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
     else
       glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
+
+    for(int i = 0; i < 6; i++){
+      if(CTX.clip[i] & 2) 
+	glEnable((GLenum)(GL_CLIP_PLANE0 + i));
+      else
+	glDisable((GLenum)(GL_CLIP_PLANE0 + i));
+    }
    
     if(M->status >= 3 && (CTX.mesh.volumes_faces || CTX.mesh.volumes_edges ||
 			  CTX.mesh.volumes_num || 
@@ -210,6 +218,10 @@ void Draw_Mesh(Mesh * M)
       Tree_Action(M->Vertices, Draw_Mesh_Point);
     }
     CTX.mesh.changed = 0;
+
+    for(int i = 0; i < 6; i++){
+      glDisable((GLenum)(GL_CLIP_PLANE0 + i));
+    }
   }
 
   // draw the big moving axes
diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp
index d3d632c7c249077b6f644ce79b3ceb68740c5590..1760ce8620c330559e924ca4e06fd3d64ba7022e 100644
--- a/Graphics/Post.cpp
+++ b/Graphics/Post.cpp
@@ -1,4 +1,4 @@
-// $Id: Post.cpp,v 1.71 2004-07-09 18:26:56 geuzaine Exp $
+// $Id: Post.cpp,v 1.72 2004-07-17 22:46:30 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -308,7 +308,7 @@ void Draw_TensorList(Post_View * v, double ValMin, double ValMax,
 
 void Draw_Post(void)
 {
-  int iView, nb;
+  int nb;
   double ValMin = 0., ValMax = 0.;
   Post_View *v;
 
@@ -316,7 +316,7 @@ void Draw_Post(void)
     return;
 
   if(!CTX.post.draw) {  // draw only the bbox of the visible views
-    for(iView = 0; iView < List_Nbr(CTX.post.list); iView++) {
+    for(int iView = 0; iView < List_Nbr(CTX.post.list); iView++) {
       v = (Post_View *) List_Pointer(CTX.post.list, iView);
       if(v->Visible && v->Type == DRAW_POST_3D) {
         glColor4ubv((GLubyte *) & CTX.color.fg);
@@ -360,7 +360,7 @@ void Draw_Post(void)
     return;
   }
 
-  for(iView = 0; iView < List_Nbr(CTX.post.list); iView++) {
+  for(int iView = 0; iView < List_Nbr(CTX.post.list); iView++) {
 
     v = (Post_View *) List_Pointer(CTX.post.list, iView);
 
@@ -376,6 +376,13 @@ void Draw_Post(void)
 	glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
       else
 	glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
+
+      for(int i = 0; i < 6; i++){
+	if(CTX.clip[i] & (1<<(2+iView))) 
+	  glEnable((GLenum)(GL_CLIP_PLANE0 + i));
+	else
+	  glDisable((GLenum)(GL_CLIP_PLANE0 + i));
+      }
       
       switch (v->RangeType) {
       case DRAW_POST_RANGE_DEFAULT:
@@ -580,6 +587,9 @@ void Draw_Post(void)
 	glDisable(GL_BLEND);
 	glEnable(GL_DEPTH_TEST);
       }
+
+      for(int i = 0; i < 6; i++)
+	glDisable((GLenum)(GL_CLIP_PLANE0 + i));
       
       v->Changed = 0;
     }
diff --git a/doc/VERSIONS b/doc/VERSIONS
index 0387387e360d7620a8b6a60eb2e7f26e8cf86827..cf4f8c9c0e8d5a7795c28bcf3a10ebc80ffebea4 100644
--- a/doc/VERSIONS
+++ b/doc/VERSIONS
@@ -1,8 +1,8 @@
-$Id: VERSIONS,v 1.236 2004-07-16 18:02:20 geuzaine Exp $
+$Id: VERSIONS,v 1.237 2004-07-17 22:46:30 geuzaine Exp $
 
 New since 1.54: added background mesh support for Triangle; meshes can
 now be displayed using "smoothed" normals (like post-processing
-views); small bug fixes.
+views); added GUI for clipping planes; small bug fixes.
 
 New in 1.54: integrated Netgen (3D mesh quality optimization +
 alternative 3D algorithm); Extrude Surface now always automatically