From e0046e2cee2cd5c7aa0b234b7a0a01c726531189 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 20 Oct 2004 15:33:00 +0000
Subject: [PATCH] small fixes for last commit:

- only delete view.adaptive if we really delete the view (we might want to
  use the adaptive data in a duplicate view)

- add missing opt_view_global_zoom in update_view()

- don't even try to open StructuralSolver's data files if GMSHPLUGINSHOME
  is not defined
---
 Common/AdaptiveViews.cpp    |  2 +-
 Common/Views.cpp            |  7 +++----
 Fltk/Callbacks.cpp          | 10 +++++-----
 Fltk/GUI.cpp                |  9 ++++++---
 Parser/Gmsh.y               |  4 ++--
 Plugin/StructuralSolver.cpp |  5 +++++
 6 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/Common/AdaptiveViews.cpp b/Common/AdaptiveViews.cpp
index a878bcbcdb..94859f1fab 100644
--- a/Common/AdaptiveViews.cpp
+++ b/Common/AdaptiveViews.cpp
@@ -44,7 +44,7 @@ void Post_Zoom::interpolate (  Double_Matrix *coeffs, double u, double v, double
   // 2 s = (p+1) (p+2)
   // p^2 + 3p + 2 = 2s 
   // p = -3 + sqrt ( 1 + 8 s ) / 2 
-  int p = (int) ( (-3. + sqrt ( 1 + 8 * coeffs->size2())) / 2);
+  //int p = (int) ( (-3. + sqrt ( 1 + 8 * coeffs->size2())) / 2);
   int nn,ii;
   for (int i=0;i<coeffs->size1();++i)
     {
diff --git a/Common/Views.cpp b/Common/Views.cpp
index 8035afd975..67bd37e8f0 100644
--- a/Common/Views.cpp
+++ b/Common/Views.cpp
@@ -1,4 +1,4 @@
-// $Id: Views.cpp,v 1.139 2004-10-20 14:38:57 remacle Exp $
+// $Id: Views.cpp,v 1.140 2004-10-20 15:32:59 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -595,10 +595,9 @@ void FreeView(Post_View * v)
     v->normals = NULL;
     if(v->TriVertexArray) delete v->TriVertexArray;
     v->TriVertexArray = NULL;
+    if(v->adaptive) delete v->adaptive;
+    v->adaptive = 0;
   }
-
-  if (v->adaptive) delete v->adaptive;
-
 }
 
 void CopyViewOptions(Post_View * src, Post_View * dest)
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index ca3a608e70..4bff90e565 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.285 2004-10-20 14:38:57 remacle Exp $
+// $Id: Callbacks.cpp,v 1.286 2004-10-20 15:32:59 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -3577,10 +3577,6 @@ void view_options_ok_cb(CALLBACK_ARGS)
       if(force || (val != saturate_values))
         opt_view_saturate_values(i, GMSH_SET, val);
 
-      val = WID->view_value[33]->value();
-      if(force || (val != global_zoom))
-        opt_view_global_zoom(i, GMSH_SET, val);
-
       val = WID->view_butt[10]->value();
       if(force || (val != show_element))
         opt_view_show_element(i, GMSH_SET, val);
@@ -3667,6 +3663,10 @@ void view_options_ok_cb(CALLBACK_ARGS)
       if(force || (val != custom_max))
         opt_view_custom_max(i, GMSH_SET, val);
 
+      val = WID->view_value[33]->value();
+      if(force || (val != global_zoom))
+        opt_view_global_zoom(i, GMSH_SET, val);
+
       val = WID->view_value[30]->value();
       if(force || (val != nb_iso))
         opt_view_nb_iso(i, GMSH_SET, val);
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index c6a9153646..4ac9ea0365 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.365 2004-10-20 14:38:57 remacle Exp $
+// $Id: GUI.cpp,v 1.366 2004-10-20 15:32:59 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -2540,7 +2540,7 @@ void GUI::create_option_window()
       view_butt[38]->down_box(TOGGLE_BOX);
       view_butt[38]->selection_color(TOGGLE_COLOR);
 
-      view_value[33] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Global Resolution Level");
+      view_value[33] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Global resolution level");
       view_value[33]->align(FL_ALIGN_RIGHT);
       view_value[33]->minimum(1);
       view_value[33]->maximum(MAX_LEVEL_OF_ZOOM);
@@ -2725,7 +2725,10 @@ void GUI::update_view_window(int num)
   opt_view_draw_strings(num, GMSH_GUI, 0);
   opt_view_auto_position(num, GMSH_GUI, 0);
 
-  if (!v->adaptive)
+  opt_view_global_zoom(num, GMSH_GUI, 0);
+  if(v->adaptive)
+    view_value[33]->activate();
+  else
     view_value[33]->deactivate();
 
   if(v->NbSP) {
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index cb71672f03..378e7f1555 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -1,5 +1,5 @@
 %{
-// $Id: Gmsh.y,v 1.180 2004-10-20 14:38:59 remacle Exp $
+// $Id: Gmsh.y,v 1.181 2004-10-20 15:33:00 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -1271,7 +1271,7 @@ Text3D :
 InterpolationMatrix :
     tInterpolationMatrix ListOfListOfDouble tEND
     {
-      View -> adaptive = new Adaptive_Post_View ( View , $2 );
+      View->adaptive = new Adaptive_Post_View (View, $2);
     }
 ;
 
diff --git a/Plugin/StructuralSolver.cpp b/Plugin/StructuralSolver.cpp
index 11bbbdda20..e266cb5c67 100644
--- a/Plugin/StructuralSolver.cpp
+++ b/Plugin/StructuralSolver.cpp
@@ -274,6 +274,8 @@ void StructuralSolver :: RegisterBeamSections ()
   char ext[6];
 
   char *homeplugins = getenv("GMSHPLUGINSHOME");
+  if(!homeplugins) 
+    return;
 
   int nbFiles = fl_filename_list(homeplugins, &list);
   if(nbFiles <= 0)
@@ -312,6 +314,9 @@ void StructuralSolver :: RegisterMaterials ()
 {
 #if defined(HAVE_FLTK)
   char *homeplugins = getenv("GMSHPLUGINSHOME");
+  if(!homeplugins) 
+    return;
+
   char temp[256];
   int nbpar;
   sprintf(temp, "%s/%s", homeplugins,"Materials");
-- 
GitLab