Salome HOME
0023235: [CEA 1730] Patches for SMESH on Windows
[modules/smesh.git] / src / Tools / MGCleanerPlug / MGCleanerMonPlugDialog.py
index 6511268a8243fafc594de24c204aee4ed261e953..b51f9ebc64394eb74578b7da7c8237590f2b7d83 100644 (file)
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
-# Copyright (C) 2007-2013  EDF R&D
+# Copyright (C) 2013-2016  EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,7 +22,8 @@
 # Modules Eficas
 
 import os, subprocess
-from MGCleanerPlugDialog import Ui_MGCleanerPlugDialog
+import tempfile
+from MGCleanerPlugDialog_ui import Ui_MGCleanerPlugDialog
 from MGCleanerMonViewText import MGCleanerMonViewText
 from PyQt4.QtGui import *
 from PyQt4.QtCore import *
@@ -67,7 +68,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
     self.PB_MeshFile.setIcon(icon)
     self.PB_MeshFile.setToolTip("source mesh from a file in disk")
     
-    #Ces parametres ne sont pas remis à rien par le clean
+    #Ces parametres ne sont pas remis ?? rien par le clean
     self.paramsFile= os.path.abspath(os.path.join(os.environ["HOME"],".MGCleaner.dat"))
     self.LE_ParamsFile.setText(self.paramsFile)
     self.LE_MeshFile.setText("")
@@ -129,14 +130,20 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
     self.connect(self.CB_ComputedOverlapDistance,SIGNAL("stateChanged(int)"),self.SP_OverlapDistance.setDisabled)
 
   def PBHelpPressed(self):
+    import SalomePyQt
+    sgPyQt = SalomePyQt.SalomePyQt()
     try:
       mydir=os.environ["SMESH_ROOT_DIR"]
     except Exception:
       QMessageBox.warning( self, "Help", "Help unavailable $SMESH_ROOT_DIR not found")
       return
-    maDoc=mydir+"/share/doc/salome/gui/SMESH/MGCleaner/_downloads/mg-cleaner_user_manual.pdf"
-    command="xdg-open "+maDoc+";"
-    subprocess.call(command, shell=True)
+    
+    maDoc=mydir+"/share/doc/salome/gui/SMESH/MGCleaner/index.html"
+    sgPyQt.helpContext(maDoc,"")
+    
+    #maDoc=mydir+"/share/doc/salome/gui/SMESH/MGCleaner/_downloads/mg-cleaner_user_manual.pdf"
+    #command="xdg-open "+maDoc+";"
+    #subprocess.call(command, shell=True)
 
   def PBOKPressed(self):
     if not(self.PrepareLigneCommande()):
@@ -347,15 +354,15 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
   def PBLoadPressed(self):
     """load last hypothesis saved in tail of file"""
     try:
-        f=open(self.paramsFile,"r")
-    except :
-        QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile)
-        return
+      f=open(self.paramsFile,"r")
+    except:
+      QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile)
+      return
     try:
-        text=f.read()
-    except :
-        QMessageBox.warning(self, "File", "Unable to read "+self.paramsFile)
-        return
+      text=f.read()
+    except:
+      QMessageBox.warning(self, "File", "Unable to read "+self.paramsFile)
+      return
     f.close()
     self.loadResumeData(text, separator="\n")
 
@@ -464,7 +471,9 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
     self.fichierIn=""
 
   def prepareFichier(self):
-    self.fichierIn="/tmp/ForMGCleaner_"+str(self.num)+".mesh"
+    self.fichierIn=tempfile.mktemp(suffix=".mesh",prefix="ForMGCleaner_")
+    if os.path.exists(self.fichierIn):
+        os.remove(self.fichierIn)
     self.__selectedMesh.ExportGMF(self.__selectedMesh, self.fichierIn, True)
 
   def PrepareLigneCommande(self):
@@ -526,7 +535,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
       self.commande+=" --overlap_distance " + self.SP_toStr(self.SP_OverlapDistance)
     self.commande+=" --overlap_angle " + str(self.SP_OverlapAngle.value())
     return True
-    
+
   def clean(self):
     self.RB_Check.setChecked(False)
     self.RB_Fix1.setChecked(False)
@@ -555,7 +564,7 @@ def getDialog():
   """
   global __dialog
   if __dialog is None:
-      __dialog = MGCleanerMonPlugDialog()
+    __dialog = MGCleanerMonPlugDialog()
   #else :
   #   __dialog.clean()
   return __dialog
@@ -570,10 +579,10 @@ def TEST_standalone():
   """
   works only if a salome is launched yet with a study loaded
   to launch standalone python do:
-  /export/home/wambeke/2013/V6_main_MGC_CO6.4_64/APPLI/runSession
+  ./APPLI/runSession
   python
   or (do not works)
-  python /export/home/wambeke/2013/V6_main_MGC_CO6.4_64/INSTALL/SMESH/share/salome/plugins/smesh/MGCleanerMonPlugDialog.py
+  python ./INSTALL/SMESH/share/salome/plugins/smesh/MGCleanerMonPlugDialog.py
   """
   import salome
   import SMESH
@@ -588,7 +597,6 @@ def TEST_standalone():
 # ==============================================================================
 #
 def TEST_MGCleanerMonPlugDialog():
-  #print "TEST_MGCleanerMonPlugDialog"
   import sys
   from PyQt4.QtGui import QApplication
   from PyQt4.QtCore import QObject, SIGNAL, SLOT