From e66bc1a00ae89970f2068120fb7d6f81b5a023a3 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 18 Nov 2004 16:35:03 +0000
Subject: [PATCH] New General.ClipFactor option to fine-tune the position of
 the near and far clipping planes (default = 10; setting a smaller value leads
 to a better z-buffer resolution, but zooms/rotations can then lead to
 undesired clipping).

---
 Common/Context.h        |  1 +
 Common/DefaultOptions.h |  2 ++
 Common/Options.cpp      |  9 ++++++++-
 Common/Options.h        |  1 +
 Graphics/Draw.cpp       |  4 ++--
 doc/VERSIONS            | 10 +++++-----
 6 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/Common/Context.h b/Common/Context.h
index 4f32a536b9..9a39c2b09d 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -93,6 +93,7 @@ public :
   double proj[16];            // current projection matrix
   double r[3];                // position angles (if succ. rot. along x, y and z) 
   double t[3], s[3];          // current translation and scale 
+  double clip_factor;         // clipping plane distance factor
   int rlock[3], tlock[3], slock[3];
                               // locks for r, t and s 
   double quaternion[4];       // the actual quaternion used for "trackball" rotating 
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 308e6ed96f..10eb972112 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -452,6 +452,8 @@ StringXNumber GeneralOptions_Number[] = {
     "Third coefficient in equation for clipping plane 5" },
   { F,   "Clip5D" , opt_general_clip5d , 0.0 , 
     "Fourth coefficient in equation for clipping plane 5" },
+  { F,   "ClipFactor" , opt_general_clip_factor , 10.0 , 
+    "Near and far clipping plane distance factor (decrease value for better z-buffer resolution)" },
   { 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. , 
diff --git a/Common/Options.cpp b/Common/Options.cpp
index d57bc8069c..79cfa2dfc2 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.204 2004-11-13 22:52:44 geuzaine Exp $
+// $Id: Options.cpp,v 1.205 2004-11-18 16:35:03 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -2250,6 +2250,13 @@ double opt_general_scale2(OPT_ARGS_NUM)
   return CTX.s[2];
 }
 
+double opt_general_clip_factor(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET)
+    CTX.clip_factor = val;
+  return CTX.clip_factor;
+}
+
 double opt_general_point_size(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
diff --git a/Common/Options.h b/Common/Options.h
index 9001b6573d..be42c9ae9e 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -246,6 +246,7 @@ double opt_general_translation2(OPT_ARGS_NUM);
 double opt_general_scale0(OPT_ARGS_NUM);
 double opt_general_scale1(OPT_ARGS_NUM);
 double opt_general_scale2(OPT_ARGS_NUM);
+double opt_general_clip_factor(OPT_ARGS_NUM);
 double opt_general_point_size(OPT_ARGS_NUM);
 double opt_general_line_width(OPT_ARGS_NUM);
 double opt_general_shine(OPT_ARGS_NUM);
diff --git a/Graphics/Draw.cpp b/Graphics/Draw.cpp
index ecf9acf1f2..d185806350 100644
--- a/Graphics/Draw.cpp
+++ b/Graphics/Draw.cpp
@@ -1,4 +1,4 @@
-// $Id: Draw.cpp,v 1.65 2004-11-16 21:04:54 geuzaine Exp $
+// $Id: Draw.cpp,v 1.66 2004-11-18 16:35:03 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -127,7 +127,7 @@ void Orthogonalize(int x, int y)
   if(CTX.ortho) {
     double maxz = MAX(fabs(CTX.min[2]), fabs(CTX.max[2]));
     if(maxz < CTX.lc) maxz = CTX.lc;
-    double clip = maxz * CTX.s[2] * 10;
+    double clip = maxz * CTX.s[2] * CTX.clip_factor;
     glOrtho(CTX.vxmin, CTX.vxmax, CTX.vymin, CTX.vymax, -clip, clip);
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
diff --git a/doc/VERSIONS b/doc/VERSIONS
index 5111ef7e5c..7a4367085d 100644
--- a/doc/VERSIONS
+++ b/doc/VERSIONS
@@ -1,13 +1,13 @@
-$Id: VERSIONS,v 1.265 2004-11-13 22:52:46 geuzaine Exp $
+$Id: VERSIONS,v 1.266 2004-11-18 16:35:03 geuzaine Exp $
 
 New since 1.56: generalized displacement maps to display arbitrary
 view types; the arrows representing a vector field can now also be
 colored by the values from other scalar, vector or tensor fields; new
 adaptive high order visualization mode; new options for solvers
-(SocketCommand and NameCommand) and views (ArrowSizeProportional);
-fixed display of undesired solver plugin popups; enhanced interactive
-plugin behaviour; new Plugin(HarmonicToTime); new Plugin(Integrate);
-various small bug fixes and enhancements;
+(SocketCommand and NameCommand) and views (ArrowSizeProportional,
+Normals, Tangents); fixed display of undesired solver plugin popups;
+enhanced interactive plugin behaviour; new Plugin(HarmonicToTime); new
+Plugin(Integrate); various small bug fixes and enhancements;
 
 New in 1.56: new post-processing option to draw a scalar view raised
 by a displacement view without using Plugin(DisplacementRaise) (makes
-- 
GitLab