From ab8fb29a018f56ee803e1143f929435418c0014f Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 6 Aug 2001 10:52:52 +0000
Subject: [PATCH] Better handling of iView option

---
 Plugin/CutMap.cpp    | 17 +++++++----------
 Plugin/CutMap.h      |  1 -
 Plugin/CutPlane.cpp  | 20 +++++++-------------
 Plugin/CutPlane.h    |  1 -
 Plugin/CutSphere.cpp | 17 +++++++----------
 Plugin/CutSphere.h   |  1 -
 Plugin/Skin.cpp      | 13 +++++++------
 Plugin/Smooth.cpp    | 13 +++++++------
 Plugin/Transform.cpp | 13 +++++++------
 9 files changed, 42 insertions(+), 54 deletions(-)

diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp
index 5a0ebc8ce9..993d14ac98 100644
--- a/Plugin/CutMap.cpp
+++ b/Plugin/CutMap.cpp
@@ -1,4 +1,4 @@
-// $Id: CutMap.cpp,v 1.16 2001-08-06 10:35:47 geuzaine Exp $
+// $Id: CutMap.cpp,v 1.17 2001-08-06 10:52:52 geuzaine Exp $
 
 #include "CutMap.h"
 #include "List.h"
@@ -70,17 +70,14 @@ Post_View *GMSH_CutMapPlugin::execute (Post_View *v)
   
   if(v && iView < 0)
     vv = v;
-  else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
-    Msg(WARNING,"Plugin CutMap: View[%d] does not exist",iView);
-    return 0;
+  else{
+    if(!v && iView < 0) iView = 0;
+    if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
+      Msg(WARNING,"Plugin CutMap: View[%d] does not exist",iView);
+      return 0;
+    }
   }
 
   return GMSH_LevelsetPlugin::execute(vv);
 }
 
-void GMSH_CutMapPlugin::Run () 
-{ 
-  int iView = (int)CutMapOptions_Number[1].def;
-  if(iView < 0) CutMapOptions_Number[1].def = 0;
-  execute (0);
-}
diff --git a/Plugin/CutMap.h b/Plugin/CutMap.h
index dacb411dc5..a1aa27cd4a 100644
--- a/Plugin/CutMap.h
+++ b/Plugin/CutMap.h
@@ -22,6 +22,5 @@ public:
   virtual int getNbOptions() const;
   virtual StringXNumber* GetOption (int iopt);  
   virtual Post_View *execute (Post_View *);
-  virtual void Run();
 };
 #endif
diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp
index 008bda943c..198ff3d237 100644
--- a/Plugin/CutPlane.cpp
+++ b/Plugin/CutPlane.cpp
@@ -1,4 +1,4 @@
-// $Id: CutPlane.cpp,v 1.14 2001-08-06 10:35:47 geuzaine Exp $
+// $Id: CutPlane.cpp,v 1.15 2001-08-06 10:52:52 geuzaine Exp $
 
 #include "CutPlane.h"
 #include "List.h"
@@ -76,20 +76,14 @@ Post_View *GMSH_CutPlanePlugin::execute (Post_View *v)
 
   if(v && iView < 0)
     vv = v;
-  else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
-    Msg(WARNING,"Plugin CutPlane: View[%d] does not exist",iView);
-    return 0;
+  else{
+    if(!v && iView < 0) iView = 0;
+    if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
+      Msg(WARNING,"Plugin CutPlane: View[%d] does not exist",iView);
+      return 0;
+    }
   }
 
   return GMSH_LevelsetPlugin::execute(vv);
 }
 
-void GMSH_CutPlanePlugin::Run () 
-{ 
-  int iView = (int)CutPlaneOptions_Number[4].def;
-  if(iView < 0) CutPlaneOptions_Number[4].def = 0;
-  execute (0);
-}
-
-
-
diff --git a/Plugin/CutPlane.h b/Plugin/CutPlane.h
index 89abdb196a..4575add1a9 100644
--- a/Plugin/CutPlane.h
+++ b/Plugin/CutPlane.h
@@ -23,7 +23,6 @@ public:
   virtual int getNbOptions() const;
   virtual StringXNumber *GetOption (int iopt);  
   virtual Post_View *execute (Post_View *);
-  virtual void Run();
 };
 
 #endif
diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp
index eb6634096c..cb76ec4163 100644
--- a/Plugin/CutSphere.cpp
+++ b/Plugin/CutSphere.cpp
@@ -1,4 +1,4 @@
-// $Id: CutSphere.cpp,v 1.13 2001-08-06 10:35:47 geuzaine Exp $
+// $Id: CutSphere.cpp,v 1.14 2001-08-06 10:52:52 geuzaine Exp $
 
 #include <string.h>
 #include "CutSphere.h"
@@ -77,17 +77,14 @@ Post_View *GMSH_CutSpherePlugin::execute (Post_View *v)
 
   if(v && iView < 0)
     vv = v;
-  else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
-    Msg(WARNING,"Plugin CutSphere: View[%d] does not exist",iView);
-    return 0;
+  else{
+    if(!v && iView < 0) iView = 0;
+    if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
+      Msg(WARNING,"Plugin CutSphere: View[%d] does not exist",iView);
+      return 0;
+    }
   }
 
   return GMSH_LevelsetPlugin::execute(vv);
 }
 
-void GMSH_CutSpherePlugin::Run () 
-{ 
-  int iView = (int)CutSphereOptions_Number[4].def;
-  if(iView < 0) CutSphereOptions_Number[4].def = 0;
-  execute (0);
-}
diff --git a/Plugin/CutSphere.h b/Plugin/CutSphere.h
index cb3493c842..bee21ba1e2 100644
--- a/Plugin/CutSphere.h
+++ b/Plugin/CutSphere.h
@@ -23,7 +23,6 @@ public:
   virtual int getNbOptions() const;
   virtual StringXNumber* GetOption (int iopt);  
   virtual Post_View *execute (Post_View *);
-  virtual void Run();
 };
 
 #endif
diff --git a/Plugin/Skin.cpp b/Plugin/Skin.cpp
index c80e564260..b5ee53fac3 100644
--- a/Plugin/Skin.cpp
+++ b/Plugin/Skin.cpp
@@ -1,4 +1,4 @@
-// $Id: Skin.cpp,v 1.3 2001-08-06 10:35:47 geuzaine Exp $
+// $Id: Skin.cpp,v 1.4 2001-08-06 10:52:52 geuzaine Exp $
 
 #include "Plugin.h"
 #include "Skin.h"
@@ -117,9 +117,12 @@ Post_View *GMSH_SkinPlugin::execute (Post_View *v)
 
   if(v && iView < 0)
     vv = v;
-  else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
-    Msg(WARNING,"Plugin Skin: View[%d] does not exist",iView);
-    return 0;
+  else{
+    if(!v && iView < 0) iView = 0;
+    if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
+      Msg(WARNING,"Plugin Skin: View[%d] does not exist",iView);
+      return 0;
+    }
   }
 
   if(vv->NbSS){
@@ -156,8 +159,6 @@ Post_View *GMSH_SkinPlugin::execute (Post_View *v)
 
 void GMSH_SkinPlugin::Run ()
 {
-  int iView = (int)SkinOptions_Number[0].def;
-  if(iView < 0) SkinOptions_Number[0].def = 0;
   execute(0);
 }
 
diff --git a/Plugin/Smooth.cpp b/Plugin/Smooth.cpp
index 4cfe690459..f9df89a2a5 100644
--- a/Plugin/Smooth.cpp
+++ b/Plugin/Smooth.cpp
@@ -1,4 +1,4 @@
-// $Id: Smooth.cpp,v 1.3 2001-08-06 10:35:47 geuzaine Exp $
+// $Id: Smooth.cpp,v 1.4 2001-08-06 10:52:52 geuzaine Exp $
 
 #include "Plugin.h"
 #include "Smooth.h"
@@ -61,9 +61,12 @@ Post_View *GMSH_SmoothPlugin::execute (Post_View *v)
 
   if(v && iView < 0)
     vv = v;
-  else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
-    Msg(WARNING,"Plugin Smooth: View[%d] does not exist",iView);
-    return 0;
+  else{
+    if(!v && iView < 0) iView = 0;
+    if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
+      Msg(WARNING,"Plugin Smooth: View[%d] does not exist",iView);
+      return 0;
+    }
   }
 
   vv->smooth();
@@ -72,8 +75,6 @@ Post_View *GMSH_SmoothPlugin::execute (Post_View *v)
 
 void GMSH_SmoothPlugin::Run ()
 {
-  int iView = (int)SmoothOptions_Number[0].def;
-  if(iView < 0) SmoothOptions_Number[0].def = 0;
   execute(0);
 }
 
diff --git a/Plugin/Transform.cpp b/Plugin/Transform.cpp
index 89e6374a3c..1dd55f120e 100644
--- a/Plugin/Transform.cpp
+++ b/Plugin/Transform.cpp
@@ -1,4 +1,4 @@
-// $Id: Transform.cpp,v 1.3 2001-08-06 10:35:47 geuzaine Exp $
+// $Id: Transform.cpp,v 1.4 2001-08-06 10:52:52 geuzaine Exp $
 
 #include "Plugin.h"
 #include "Transform.h"
@@ -95,9 +95,12 @@ Post_View *GMSH_TransformPlugin::execute (Post_View *v)
 
   if(v && iView < 0)
     vv = v;
-  else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
-    Msg(WARNING,"Plugin Transform: View[%d] does not exist",iView);
-    return 0;
+  else{
+    if(!v && iView < 0) iView = 0;
+    if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){
+      Msg(WARNING,"Plugin Transform: View[%d] does not exist",iView);
+      return 0;
+    }
   }
   
   vv->transform(mat);
@@ -106,8 +109,6 @@ Post_View *GMSH_TransformPlugin::execute (Post_View *v)
 
 void GMSH_TransformPlugin::Run ()
 {
-  int iView = (int)TransformOptions_Number[9].def;
-  if(iView < 0) TransformOptions_Number[9].def = 0;
   execute(0);
 }
 
-- 
GitLab