mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 02:10:35 +05:00
23288: [CEA 1626] Meshgems v2.3
This commit is contained in:
parent
aa58e0af13
commit
0f0bf7c728
@ -27,6 +27,7 @@ from MGCleanerPlugDialog_ui import Ui_MGCleanerPlugDialog
|
|||||||
from MGCleanerMonViewText import MGCleanerMonViewText
|
from MGCleanerMonViewText import MGCleanerMonViewText
|
||||||
from qtsalome import *
|
from qtsalome import *
|
||||||
|
|
||||||
|
verbose = True
|
||||||
|
|
||||||
class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
|
class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
|
||||||
"""
|
"""
|
||||||
@ -41,7 +42,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
|
|||||||
self.commande=""
|
self.commande=""
|
||||||
self.num=1
|
self.num=1
|
||||||
self.__selectedMesh=None
|
self.__selectedMesh=None
|
||||||
|
|
||||||
# complex whith QResources: not used
|
# complex whith QResources: not used
|
||||||
# The icon are supposed to be located in the $SMESH_ROOT_DIR/share/salome/resources/smesh folder,
|
# The icon are supposed to be located in the $SMESH_ROOT_DIR/share/salome/resources/smesh folder,
|
||||||
# other solution could be in the same folder than this python module file:
|
# other solution could be in the same folder than this python module file:
|
||||||
@ -66,8 +67,8 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
|
|||||||
self.PB_Save.setToolTip("hypothesis to file")
|
self.PB_Save.setToolTip("hypothesis to file")
|
||||||
self.PB_MeshFile.setIcon(icon)
|
self.PB_MeshFile.setIcon(icon)
|
||||||
self.PB_MeshFile.setToolTip("source mesh from a file in disk")
|
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 a rien par le clean
|
||||||
self.paramsFile= os.path.abspath(os.path.join(os.environ["HOME"],".MGCleaner.dat"))
|
self.paramsFile= os.path.abspath(os.path.join(os.environ["HOME"],".MGCleaner.dat"))
|
||||||
self.LE_ParamsFile.setText(self.paramsFile)
|
self.LE_ParamsFile.setText(self.paramsFile)
|
||||||
self.LE_MeshFile.setText("")
|
self.LE_MeshFile.setText("")
|
||||||
@ -134,9 +135,9 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
|
|||||||
try:
|
try:
|
||||||
mydir=os.environ["SMESH_ROOT_DIR"]
|
mydir=os.environ["SMESH_ROOT_DIR"]
|
||||||
except Exception:
|
except Exception:
|
||||||
QMessageBox.warning( self, "Help", "Help unavailable $SMESH_ROOT_DIR not found")
|
QMessageBox.warning(self, "Help", "Help unavailable $SMESH_ROOT_DIR not found")
|
||||||
return
|
return
|
||||||
|
|
||||||
maDoc=mydir+"/share/doc/salome/gui/SMESH/MGCleaner/index.html"
|
maDoc=mydir+"/share/doc/salome/gui/SMESH/MGCleaner/index.html"
|
||||||
sgPyQt.helpContext(maDoc,"")
|
sgPyQt.helpContext(maDoc,"")
|
||||||
|
|
||||||
@ -230,38 +231,87 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
|
|||||||
return
|
return
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
def PBSaveHypPressed_risky(self):
|
||||||
|
"""
|
||||||
|
save hypothesis in Object Browser outside GEOM ou MESH
|
||||||
|
WARNING: at root of Object Browser is not politically correct
|
||||||
|
"""
|
||||||
|
import salome
|
||||||
|
|
||||||
|
if verbose: print("save hypothesis in Object Browser")
|
||||||
|
|
||||||
|
name = "MGCleaner"
|
||||||
|
#how ??? icon = "mesh_tree_hypo.png"
|
||||||
|
namei = "MGCleaner Parameters_%i" % self.num
|
||||||
|
datai = self.getResumeData(separator=" ; ")
|
||||||
|
|
||||||
|
myStudy = salome.myStudy
|
||||||
|
myBuilder = myStudy.NewBuilder()
|
||||||
|
#myStudy.IsStudyLocked()
|
||||||
|
myComponent = myStudy.FindComponent(name)
|
||||||
|
if myComponent == None:
|
||||||
|
print "myComponent not found, create"
|
||||||
|
myComponent = myBuilder.NewComponent(name)
|
||||||
|
AName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
|
||||||
|
AName.SetValue(name)
|
||||||
|
ACmt = myBuilder.FindOrCreateAttribute(myComponent, "AttributeComment")
|
||||||
|
ACmt.SetValue(name)
|
||||||
|
|
||||||
|
myObject = myBuilder.NewObject(myComponent)
|
||||||
|
AName = myBuilder.FindOrCreateAttribute(myObject, "AttributeName")
|
||||||
|
AName.SetValue(namei)
|
||||||
|
ACmt = myBuilder.FindOrCreateAttribute(myObject, "AttributeComment")
|
||||||
|
ACmt.SetValue(datai)
|
||||||
|
|
||||||
|
if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0)
|
||||||
|
self.num += 1
|
||||||
|
if verbose: print("save %s in Object Browser done: %s\n%s" % (name, myObject.GetID(), datai))
|
||||||
|
return True
|
||||||
|
|
||||||
def PBSaveHypPressed(self):
|
def PBSaveHypPressed(self):
|
||||||
"""save hypothesis in Object Browser"""
|
"""
|
||||||
|
save hypothesis in Object Browser
|
||||||
|
bug: affichage ne marche pas si inclusion dans dans GEOM ou MESH depuis salome 730
|
||||||
|
"""
|
||||||
import salome
|
import salome
|
||||||
import SMESH
|
import SMESH
|
||||||
from salome.kernel import studyedit
|
from salome.kernel import studyedit
|
||||||
from salome.smesh import smeshBuilder
|
from salome.smesh import smeshBuilder
|
||||||
|
#[PAL issue tracker:issue1871] Les nouveaux objets ne s'affichent pas dans SMESH
|
||||||
|
QMessageBox.warning(self, "Save", "waiting for fix: Object Browser will not display hypothesis")
|
||||||
|
|
||||||
|
if verbose: print("save hypothesis in Object Browser")
|
||||||
smesh = smeshBuilder.New(salome.myStudy)
|
smesh = smeshBuilder.New(salome.myStudy)
|
||||||
|
|
||||||
maStudy=studyedit.getActiveStudy()
|
maStudy=studyedit.getActiveStudy()
|
||||||
smesh.SetCurrentStudy(maStudy)
|
smesh.SetCurrentStudy(maStudy)
|
||||||
|
|
||||||
self.editor = studyedit.getStudyEditor()
|
self.editor = studyedit.getStudyEditor()
|
||||||
moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH")
|
moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH")
|
||||||
HypReMeshEntry = self.editor.findOrCreateItem(
|
HypReMeshEntry = self.editor.findOrCreateItem(
|
||||||
moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png") #, comment = "HypoForRemeshing" )
|
moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png")
|
||||||
|
#, comment = "HypothesisForRemeshing" )
|
||||||
|
|
||||||
monStudyBuilder=maStudy.NewBuilder()
|
monStudyBuilder=maStudy.NewBuilder()
|
||||||
monStudyBuilder.NewCommand()
|
monStudyBuilder.NewCommand()
|
||||||
newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry)
|
newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry)
|
||||||
self.editor.setAttributeValue(newStudyIter, "AttributeName", "MGCleaner Parameters_"+str(self.num))
|
name = "MGCleaner Parameters_%i" % self.num
|
||||||
self.editor.setAttributeValue(newStudyIter, "AttributeComment", self.getResumeData(separator=" ; "))
|
self.editor.setAttributeValue(newStudyIter, "AttributeName", name)
|
||||||
|
data = self.getResumeData(separator=" ; ")
|
||||||
|
self.editor.setAttributeValue(newStudyIter, "AttributeComment", data)
|
||||||
|
|
||||||
|
"""
|
||||||
|
# example storing in notebook
|
||||||
|
import salome_notebook
|
||||||
|
notebook = salome_notebook.notebook
|
||||||
|
notebook.set("MGCleaner_%i" % self.num, data)
|
||||||
|
"""
|
||||||
|
|
||||||
if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0)
|
if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0)
|
||||||
self.num+=1
|
self.num += 1
|
||||||
|
if verbose: print("save %s in Object Browser done:\n%s" % (name, data))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
"""
|
|
||||||
import salome_pluginsmanager
|
|
||||||
print "salome_pluginsmanager.plugins",salome_pluginsmanager.plugins
|
|
||||||
print "salome_pluginsmanager.current_plugins_manager",salome_pluginsmanager.current_plugins_manager
|
|
||||||
"""
|
|
||||||
|
|
||||||
def SP_toStr(self, widget):
|
def SP_toStr(self, widget):
|
||||||
"""only for a QLineEdit widget"""
|
"""only for a QLineEdit widget"""
|
||||||
#cr, pos=widget.validator().validate(res, 0) #n.b. "1,3" is acceptable !locale!
|
#cr, pos=widget.validator().validate(res, 0) #n.b. "1,3" is acceptable !locale!
|
||||||
@ -452,6 +502,10 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
|
|||||||
mySObject, myEntry = guihelper.getSObjectSelected()
|
mySObject, myEntry = guihelper.getSObjectSelected()
|
||||||
if CORBA.is_nil(mySObject) or mySObject==None:
|
if CORBA.is_nil(mySObject) or mySObject==None:
|
||||||
QMessageBox.critical(self, "Mesh", "select an input mesh")
|
QMessageBox.critical(self, "Mesh", "select an input mesh")
|
||||||
|
#self.LE_MeshSmesh.setText("")
|
||||||
|
#self.MeshIn=""
|
||||||
|
#self.LE_MeshFile.setText("")
|
||||||
|
#self.fichierIn=""
|
||||||
return
|
return
|
||||||
self.smeshStudyTool = SMeshStudyTools()
|
self.smeshStudyTool = SMeshStudyTools()
|
||||||
try:
|
try:
|
||||||
@ -533,6 +587,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
|
|||||||
if not self.CB_ComputedOverlapDistance.isChecked(): #computed default
|
if not self.CB_ComputedOverlapDistance.isChecked(): #computed default
|
||||||
self.commande+=" --overlap_distance " + self.SP_toStr(self.SP_OverlapDistance)
|
self.commande+=" --overlap_distance " + self.SP_toStr(self.SP_OverlapDistance)
|
||||||
self.commande+=" --overlap_angle " + str(self.SP_OverlapAngle.value())
|
self.commande+=" --overlap_angle " + str(self.SP_OverlapAngle.value())
|
||||||
|
if verbose: print("INFO: MGCCleaner command:\n %s" % self.commande)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
@ -559,7 +614,7 @@ __dialog=None
|
|||||||
def getDialog():
|
def getDialog():
|
||||||
"""
|
"""
|
||||||
This function returns a singleton instance of the plugin dialog.
|
This function returns a singleton instance of the plugin dialog.
|
||||||
c est obligatoire pour faire un show sans parent...
|
It is mandatory in order to call show without a parent ...
|
||||||
"""
|
"""
|
||||||
global __dialog
|
global __dialog
|
||||||
if __dialog is None:
|
if __dialog is None:
|
||||||
@ -609,3 +664,4 @@ if __name__ == "__main__":
|
|||||||
TEST_MGCleanerMonPlugDialog()
|
TEST_MGCleanerMonPlugDialog()
|
||||||
#TEST_standalone()
|
#TEST_standalone()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -19,9 +19,13 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Modules Python
|
# Modules Python
|
||||||
import string,types,os,sys
|
import os
|
||||||
|
import sys
|
||||||
|
import string
|
||||||
|
import types
|
||||||
import tempfile
|
import tempfile
|
||||||
import traceback
|
import traceback
|
||||||
|
import pprint as PP #pretty print
|
||||||
|
|
||||||
from qtsalome import *
|
from qtsalome import *
|
||||||
|
|
||||||
@ -29,6 +33,13 @@ from qtsalome import *
|
|||||||
|
|
||||||
from MGCleanerViewText_ui import Ui_ViewExe
|
from MGCleanerViewText_ui import Ui_ViewExe
|
||||||
|
|
||||||
|
verbose = True
|
||||||
|
|
||||||
|
force = os.getenv("FORCE_DISTENE_LICENSE_FILE")
|
||||||
|
if force != None:
|
||||||
|
os.environ["DISTENE_LICENSE_FILE"] = force
|
||||||
|
os.environ["DLIM8VAR"] = "NOTHING"
|
||||||
|
|
||||||
class MGCleanerMonViewText(Ui_ViewExe, QDialog):
|
class MGCleanerMonViewText(Ui_ViewExe, QDialog):
|
||||||
"""
|
"""
|
||||||
Classe permettant la visualisation de texte
|
Classe permettant la visualisation de texte
|
||||||
@ -46,48 +57,50 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
|
|||||||
|
|
||||||
self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
|
self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
|
||||||
self.monExe.readyReadStandardError.connect( self.readFromStdErr )
|
self.monExe.readyReadStandardError.connect( self.readFromStdErr )
|
||||||
|
|
||||||
# Je n arrive pas a utiliser le setEnvironment du QProcess
|
""" for test set environment
|
||||||
# fonctionne hors Salome mais pas dans Salome ???
|
env = QProcessEnvironment().systemEnvironment()
|
||||||
cmds=''
|
env.insert("HELLO", "bonjour") #Add an environment variable for debug
|
||||||
'''
|
self.monExe.setProcessEnvironment(env)
|
||||||
try :
|
if verbose:
|
||||||
LICENCE_FILE=os.environ["DISTENE_LICENCE_FILE_FOR_MGCLEANER"]
|
PP.pprint([str(i) for i in sorted(self.monExe.processEnvironment().toStringList()) if 'DISTENE' in i])
|
||||||
except:
|
"""
|
||||||
LICENCE_FILE=''
|
|
||||||
try :
|
cmds = ''
|
||||||
PATH=os.environ["DISTENE_PATH_FOR_MGCLEANER"]
|
ext = ''
|
||||||
except:
|
|
||||||
PATH=''
|
|
||||||
if LICENCE_FILE != '':
|
|
||||||
cmds+='source '+LICENCE_FILE+'\n'
|
|
||||||
else:
|
|
||||||
cmds+="# $DISTENE_LICENCE_FILE_FOR_MGCLEANER NOT SET\n"
|
|
||||||
if PATH != '':
|
|
||||||
cmds+='export PATH='+PATH+':$PATH\n'
|
|
||||||
else:
|
|
||||||
cmds+="# $DISTENE_PATH_FOR_MGCLEANER NOT SET\n"
|
|
||||||
#cmds+='env\n'
|
|
||||||
cmds+='rm -f '+self.parent().fichierOut+'\n'
|
|
||||||
'''
|
|
||||||
cmds+=txt+'\n'
|
|
||||||
cmds+='echo END_OF_MGCleaner\n'
|
|
||||||
ext=''
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
|
cmds += 'delete %s\n' % self.parent().fichierOut
|
||||||
ext = '.bat'
|
ext = '.bat'
|
||||||
else:
|
else:
|
||||||
ext = '.sh'
|
cmds += '#!/bin/bash\n'
|
||||||
nomFichier=tempfile.mktemp(suffix=ext,prefix="MGCleaner_")
|
cmds += 'pwd\n'
|
||||||
f=open(nomFichier,'w')
|
#cmds += 'which mg-cleaner.exe\n'
|
||||||
f.write(cmds)
|
cmds += 'echo "DISTENE_LICENSE_FILE="$DISTENE_LICENSE_FILE\n'
|
||||||
f.close()
|
cmds += 'echo "DLIM8VAR="$DLIM8VAR\n'
|
||||||
|
cmds += 'rm -f %s\n' % self.parent().fichierOut
|
||||||
|
ext = '.bash'
|
||||||
|
|
||||||
maBidouille=nomFichier
|
cmds += 'echo %s\n' % txt #to see what is compute command
|
||||||
self.monExe.start(maBidouille)
|
cmds += txt+'\n'
|
||||||
|
cmds += 'echo "END_OF_MGCleaner"\n'
|
||||||
|
|
||||||
|
nomFichier = os.path.splitext(self.parent().fichierOut)[0] + ext
|
||||||
|
with open(nomFichier, 'w') as f:
|
||||||
|
f.write(cmds)
|
||||||
|
self.make_executable(nomFichier)
|
||||||
|
|
||||||
|
if verbose: print("INFO: MGCleaner launch script file: %s" % nomFichier)
|
||||||
|
|
||||||
|
self.monExe.start(nomFichier)
|
||||||
self.monExe.closeWriteChannel()
|
self.monExe.closeWriteChannel()
|
||||||
self.enregistreResultatsDone=False
|
self.enregistreResultatsDone=False
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
def make_executable(self, path):
|
||||||
|
mode = os.stat(path).st_mode
|
||||||
|
mode |= (mode & 0o444) >> 2 # copy R bits to X
|
||||||
|
os.chmod(path, mode)
|
||||||
|
|
||||||
def saveFile(self):
|
def saveFile(self):
|
||||||
#recuperation du nom du fichier
|
#recuperation du nom du fichier
|
||||||
savedir=os.environ['HOME']
|
savedir=os.environ['HOME']
|
||||||
|
@ -34,11 +34,14 @@ def MGCleanerLct(context):
|
|||||||
|
|
||||||
#prior test to avoid unnecessary user GUI work with ending crash
|
#prior test to avoid unnecessary user GUI work with ending crash
|
||||||
try :
|
try :
|
||||||
os.environ['DISTENE_LICENCE_FILE_FOR_MGCLEANER']
|
os.environ['DISTENE_LICENSE_FILE']
|
||||||
except:
|
except:
|
||||||
QMessageBox.warning(None,"Products","Distene's product MeshGem Cleaner is not installed.\nrequired environment variable:\nDISTENE_LICENCE_FILE_FOR_MGCLEANER='/.../dlim8.var.sh'")
|
QMessageBox.warning(None, "Products", """\
|
||||||
|
Distene's product MeshGem Cleaner is not installed.
|
||||||
|
required environment variable:
|
||||||
|
DISTENE_LICENSE_FILE='.../dlim8.var.sh'""")
|
||||||
return
|
return
|
||||||
import MGCleanerMonPlugDialog
|
import MGCleanerMonPlugDialog
|
||||||
window=MGCleanerMonPlugDialog.getDialog()
|
window = MGCleanerMonPlugDialog.getDialog()
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
|
@ -18,17 +18,26 @@
|
|||||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
#
|
#
|
||||||
|
|
||||||
# Modules Python
|
import os
|
||||||
import string,types,os, sys
|
import sys
|
||||||
import traceback
|
import string
|
||||||
|
import types
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import traceback
|
||||||
|
import pprint as PP #pretty print
|
||||||
|
|
||||||
from qtsalome import *
|
from qtsalome import *
|
||||||
|
|
||||||
# Import des panels
|
# Import des panels
|
||||||
|
|
||||||
from ViewText_ui import Ui_ViewExe
|
from ViewText_ui import Ui_ViewExe
|
||||||
|
|
||||||
|
verbose = True
|
||||||
|
|
||||||
|
force = os.getenv("FORCE_DISTENE_LICENSE_FILE")
|
||||||
|
if force != None:
|
||||||
|
os.environ["DISTENE_LICENSE_FILE"] = force
|
||||||
|
os.environ["DLIM8VAR"] = "NOTHING"
|
||||||
|
|
||||||
class MonViewText(Ui_ViewExe, QDialog):
|
class MonViewText(Ui_ViewExe, QDialog):
|
||||||
"""
|
"""
|
||||||
Classe permettant la visualisation de texte
|
Classe permettant la visualisation de texte
|
||||||
@ -45,33 +54,40 @@ class MonViewText(Ui_ViewExe, QDialog):
|
|||||||
self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
|
self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
|
||||||
self.monExe.readyReadStandardError.connect( self.readFromStdErr )
|
self.monExe.readyReadStandardError.connect( self.readFromStdErr )
|
||||||
|
|
||||||
# Je n arrive pas a utiliser le setEnvironment du QProcess
|
cmds = ''
|
||||||
# fonctionne hors Salome mais pas dans Salome ???
|
ext = ''
|
||||||
cmds=''
|
|
||||||
#cmds+='#! /usr/bin/env python\n'
|
|
||||||
#cmds+='# -*- coding: utf-8 -*-\n'
|
|
||||||
cmds+=txt+'\n'
|
|
||||||
cmds+='echo "END_OF_Yams"\n'
|
|
||||||
if os.path.exists(self.parent().fichierOut):
|
|
||||||
os.remove(self.parent().fichierOut)
|
|
||||||
|
|
||||||
ext=''
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
ext = '.bat'
|
cmds += 'delete %s\n' % self.parent().fichierOut
|
||||||
else:
|
else:
|
||||||
ext = '.sh'
|
cmds += '#!/bin/bash\n'
|
||||||
|
cmds += 'pwd\n'
|
||||||
|
#cmds += 'which mg-surfopt.exe\n'
|
||||||
|
cmds += 'echo "DISTENE_LICENSE_FILE="$DISTENE_LICENSE_FILE\n'
|
||||||
|
cmds += 'echo "DLIM8VAR="$DLIM8VAR\n'
|
||||||
|
cmds += 'rm -f %s\n' % self.parent().fichierOut
|
||||||
|
ext = '.bash'
|
||||||
|
|
||||||
nomFichier=tempfile.mktemp(suffix=ext,prefix='Yams_')
|
cmds += 'echo %s\n' % txt #to see what is compute command
|
||||||
f=open(nomFichier,'w')
|
cmds += txt+'\n'
|
||||||
f.write(cmds)
|
cmds += 'echo "END_OF_MGSurfOpt"\n'
|
||||||
f.close()
|
|
||||||
|
nomFichier = os.path.splitext(self.parent().fichierOut)[0] + ext
|
||||||
maBidouille=nomFichier
|
with open(nomFichier, 'w') as f:
|
||||||
self.monExe.start(maBidouille)
|
f.write(cmds)
|
||||||
|
self.make_executable(nomFichier)
|
||||||
|
|
||||||
|
if verbose: print("INFO: MGSurfOpt launch script file: %s" % nomFichier)
|
||||||
|
|
||||||
|
self.monExe.start(nomFichier)
|
||||||
self.monExe.closeWriteChannel()
|
self.monExe.closeWriteChannel()
|
||||||
self.enregistreResultatsDone=False
|
self.enregistreResultatsDone=False
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
def make_executable(self, path):
|
||||||
|
mode = os.stat(path).st_mode
|
||||||
|
mode |= (mode & 0o444) >> 2 # copy R bits to X
|
||||||
|
os.chmod(path, mode)
|
||||||
|
|
||||||
def saveFile(self):
|
def saveFile(self):
|
||||||
#recuperation du nom du fichier
|
#recuperation du nom du fichier
|
||||||
savedir=os.environ['HOME']
|
savedir=os.environ['HOME']
|
||||||
@ -94,7 +110,7 @@ class MonViewText(Ui_ViewExe, QDialog):
|
|||||||
a=self.monExe.readAllStandardOutput()
|
a=self.monExe.readAllStandardOutput()
|
||||||
aa=unicode(a.data(),len(a))
|
aa=unicode(a.data(),len(a))
|
||||||
self.TB_Exe.append(aa)
|
self.TB_Exe.append(aa)
|
||||||
if "END_OF_Yams" in aa:
|
if "END_OF_MGSurfOpt" in aa:
|
||||||
self.parent().enregistreResultat()
|
self.parent().enregistreResultat()
|
||||||
self.enregistreResultatsDone=True
|
self.enregistreResultatsDone=True
|
||||||
#self.theClose()
|
#self.theClose()
|
||||||
|
@ -27,6 +27,8 @@ from YamsPlugDialog_ui import Ui_YamsPlugDialog
|
|||||||
from monViewText import MonViewText
|
from monViewText import MonViewText
|
||||||
from qtsalome import *
|
from qtsalome import *
|
||||||
|
|
||||||
|
verbose = True
|
||||||
|
|
||||||
class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
@ -47,7 +49,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
# iconfolder=os.path.dirname(os.path.abspath(__file__))
|
# iconfolder=os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
self.iconfolder=os.environ["SMESH_ROOT_DIR"]+"/share/salome/resources/smesh"
|
self.iconfolder=os.environ["SMESH_ROOT_DIR"]+"/share/salome/resources/smesh"
|
||||||
#print "monYamsPlugDialog iconfolder",iconfolder
|
#print "MGSurfOptPlugDialog iconfolder",iconfolder
|
||||||
icon = QIcon()
|
icon = QIcon()
|
||||||
icon.addFile(os.path.join(self.iconfolder,"select1.png"))
|
icon.addFile(os.path.join(self.iconfolder,"select1.png"))
|
||||||
self.PB_LoadHyp.setIcon(icon)
|
self.PB_LoadHyp.setIcon(icon)
|
||||||
@ -66,12 +68,12 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
self.PB_MeshFile.setIcon(icon)
|
self.PB_MeshFile.setIcon(icon)
|
||||||
self.PB_MeshFile.setToolTip("source mesh from a file in disk")
|
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 a rien par le clean
|
||||||
self.paramsFile= os.path.abspath(os.path.join(os.environ["HOME"],".yams.dat"))
|
self.paramsFile= os.path.abspath(os.path.join(os.environ["HOME"],".MGSurfOpt.dat"))
|
||||||
self.LE_ParamsFile.setText(self.paramsFile)
|
self.LE_ParamsFile.setText(self.paramsFile)
|
||||||
self.LE_MeshFile.setText("")
|
self.LE_MeshFile.setText("")
|
||||||
self.LE_MeshSmesh.setText("")
|
self.LE_MeshSmesh.setText("")
|
||||||
|
|
||||||
v1=QDoubleValidator(self)
|
v1=QDoubleValidator(self)
|
||||||
v1.setBottom(0.)
|
v1.setBottom(0.)
|
||||||
#v1.setTop(1000.) #per thousand... only if relative
|
#v1.setTop(1000.) #per thousand... only if relative
|
||||||
@ -103,7 +105,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
def PBHelpPressed(self):
|
def PBHelpPressed(self):
|
||||||
import SalomePyQt
|
import SalomePyQt
|
||||||
sgPyQt = SalomePyQt.SalomePyQt()
|
sgPyQt = SalomePyQt.SalomePyQt()
|
||||||
try :
|
try:
|
||||||
mydir=os.environ["SMESH_ROOT_DIR"]
|
mydir=os.environ["SMESH_ROOT_DIR"]
|
||||||
except Exception:
|
except Exception:
|
||||||
QMessageBox.warning(self, "Help", "Help unavailable $SMESH_ROOT_DIR not found")
|
QMessageBox.warning(self, "Help", "Help unavailable $SMESH_ROOT_DIR not found")
|
||||||
@ -146,7 +148,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
else:
|
else:
|
||||||
initialMeshObject=maStudy.FindObjectByName(name ,"SMESH")[0]
|
initialMeshObject=maStudy.FindObjectByName(name ,"SMESH")[0]
|
||||||
|
|
||||||
meshname = name+"_YAMS_"+str(self.num)
|
meshname = name+"_MGSO_"+str(self.num)
|
||||||
smesh.SetName(outputMesh.GetMesh(), meshname)
|
smesh.SetName(outputMesh.GetMesh(), meshname)
|
||||||
outputMesh.Compute() #no algorithms message for "Mesh_x" has been computed with warnings: - global 1D algorithm is missing
|
outputMesh.Compute() #no algorithms message for "Mesh_x" has been computed with warnings: - global 1D algorithm is missing
|
||||||
|
|
||||||
@ -158,7 +160,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
monStudyBuilder=maStudy.NewBuilder()
|
monStudyBuilder=maStudy.NewBuilder()
|
||||||
monStudyBuilder.NewCommand()
|
monStudyBuilder.NewCommand()
|
||||||
newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry)
|
newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry)
|
||||||
self.editor.setAttributeValue(newStudyIter, "AttributeName", "YAMS Parameters_"+str(self.num))
|
self.editor.setAttributeValue(newStudyIter, "AttributeName", "MGSurfOpt Parameters_"+str(self.num))
|
||||||
self.editor.setAttributeValue(newStudyIter, "AttributeComment", self.getResumeData(separator=" ; "))
|
self.editor.setAttributeValue(newStudyIter, "AttributeComment", self.getResumeData(separator=" ; "))
|
||||||
|
|
||||||
SOMesh=maStudy.FindObjectByName(meshname ,"SMESH")[0]
|
SOMesh=maStudy.FindObjectByName(meshname ,"SMESH")[0]
|
||||||
@ -183,7 +185,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
def PBSavePressed(self):
|
def PBSavePressed(self):
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
if not(self.PrepareLigneCommande()): return
|
if not(self.PrepareLigneCommande()): return
|
||||||
text = "# YAMS hypothesis parameters\n"
|
text = "# MGSurfOpt hypothesis parameters\n"
|
||||||
text += "# Params for mesh : " + self.LE_MeshSmesh.text() +"\n"
|
text += "# Params for mesh : " + self.LE_MeshSmesh.text() +"\n"
|
||||||
text += datetime.now().strftime("# Date : %d/%m/%y %H:%M:%S\n")
|
text += datetime.now().strftime("# Date : %d/%m/%y %H:%M:%S\n")
|
||||||
text += "# Command : "+self.commande+"\n"
|
text += "# Command : "+self.commande+"\n"
|
||||||
@ -202,30 +204,78 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
return
|
return
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
def PBSaveHypPressed_risky(self):
|
||||||
|
"""
|
||||||
|
save hypothesis in Object Browser outside GEOM ou MESH
|
||||||
|
WARNING: at root of Object Browser is not politically correct
|
||||||
|
"""
|
||||||
|
import salome
|
||||||
|
|
||||||
|
if verbose: print("save hypothesis in Object Browser")
|
||||||
|
|
||||||
|
name = "MGSurfOpt"
|
||||||
|
#how ??? icon = "mesh_tree_hypo.png"
|
||||||
|
namei = "MGSurfOpt Parameters_%i" % self.num
|
||||||
|
datai = self.getResumeData(separator=" ; ")
|
||||||
|
|
||||||
|
myStudy = salome.myStudy
|
||||||
|
myBuilder = myStudy.NewBuilder()
|
||||||
|
#myStudy.IsStudyLocked()
|
||||||
|
myComponent = myStudy.FindComponent(name)
|
||||||
|
if myComponent == None:
|
||||||
|
print "myComponent not found, create"
|
||||||
|
myComponent = myBuilder.NewComponent(name)
|
||||||
|
AName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
|
||||||
|
AName.SetValue(name)
|
||||||
|
ACmt = myBuilder.FindOrCreateAttribute(myComponent, "AttributeComment")
|
||||||
|
ACmt.SetValue(name)
|
||||||
|
|
||||||
|
myObject = myBuilder.NewObject(myComponent)
|
||||||
|
AName = myBuilder.FindOrCreateAttribute(myObject, "AttributeName")
|
||||||
|
AName.SetValue(namei)
|
||||||
|
ACmt = myBuilder.FindOrCreateAttribute(myObject, "AttributeComment")
|
||||||
|
ACmt.SetValue(datai)
|
||||||
|
|
||||||
|
if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0)
|
||||||
|
self.num += 1
|
||||||
|
if verbose: print("save %s in Object Browser done: %s\n%s" % (name, myObject.GetID(), datai))
|
||||||
|
return True
|
||||||
|
|
||||||
def PBSaveHypPressed(self):
|
def PBSaveHypPressed(self):
|
||||||
"""save hypothesis in Object Browser"""
|
"""
|
||||||
|
save hypothesis in Object Browser
|
||||||
|
bug: affichage ne marche pas si inclusion dans dans GEOM ou MESH depuis salome 730
|
||||||
|
"""
|
||||||
import salome
|
import salome
|
||||||
import SMESH
|
import SMESH
|
||||||
from salome.kernel import studyedit
|
from salome.kernel import studyedit
|
||||||
from salome.smesh import smeshBuilder
|
from salome.smesh import smeshBuilder
|
||||||
|
#[PAL issue tracker:issue1871] Les nouveaux objets ne s'affichent pas dans SMESH
|
||||||
|
QMessageBox.warning(self, "Save", "waiting for fix: Object Browser will not display hypothesis")
|
||||||
|
|
||||||
|
if verbose: print("save hypothesis in Object Browser")
|
||||||
smesh = smeshBuilder.New(salome.myStudy)
|
smesh = smeshBuilder.New(salome.myStudy)
|
||||||
|
|
||||||
maStudy=studyedit.getActiveStudy()
|
maStudy=studyedit.getActiveStudy()
|
||||||
smesh.SetCurrentStudy(maStudy)
|
smesh.SetCurrentStudy(maStudy)
|
||||||
|
|
||||||
self.editor = studyedit.getStudyEditor()
|
self.editor = studyedit.getStudyEditor()
|
||||||
moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH")
|
moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH")
|
||||||
HypReMeshEntry = self.editor.findOrCreateItem(
|
HypReMeshEntry = self.editor.findOrCreateItem(
|
||||||
moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png") #, comment = "HypoForRemeshing" )
|
moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png")
|
||||||
|
#, comment = "HypothesisForRemeshing" )
|
||||||
|
|
||||||
monStudyBuilder=maStudy.NewBuilder()
|
monStudyBuilder=maStudy.NewBuilder()
|
||||||
monStudyBuilder.NewCommand()
|
monStudyBuilder.NewCommand()
|
||||||
newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry)
|
newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry)
|
||||||
self.editor.setAttributeValue(newStudyIter, "AttributeName", "YAMS Parameters_"+str(self.num))
|
name = "MGSurfOpt Parameters_%i" % self.num
|
||||||
self.editor.setAttributeValue(newStudyIter, "AttributeComment", self.getResumeData(separator=" ; "))
|
self.editor.setAttributeValue(newStudyIter, "AttributeName", name)
|
||||||
|
data = self.getResumeData(separator=" ; ")
|
||||||
|
self.editor.setAttributeValue(newStudyIter, "AttributeComment", data)
|
||||||
|
|
||||||
if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0)
|
if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0)
|
||||||
self.num+=1
|
self.num += 1
|
||||||
|
if verbose: print("save %s in Object Browser done:\n%s" % (name, data))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def SP_toStr(self, widget):
|
def SP_toStr(self, widget):
|
||||||
@ -315,7 +365,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
if tit=="Verbosity": self.SP_Verbosity.setProperty("value", int(float(value)))
|
if tit=="Verbosity": self.SP_Verbosity.setProperty("value", int(float(value)))
|
||||||
if tit=="Memory": self.SP_Memory.setProperty("value", float(value))
|
if tit=="Memory": self.SP_Memory.setProperty("value", float(value))
|
||||||
except:
|
except:
|
||||||
QMessageBox.warning(self, "load YAMS Hypothesis", "Problem on '"+lig+"'")
|
QMessageBox.warning(self, "load MGSurfOpt Hypothesis", "Problem on '"+lig+"'")
|
||||||
|
|
||||||
def PBLoadPressed(self):
|
def PBLoadPressed(self):
|
||||||
"""load last hypothesis saved in tail of file"""
|
"""load last hypothesis saved in tail of file"""
|
||||||
@ -334,7 +384,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
|
|
||||||
def PBLoadHypPressed(self):
|
def PBLoadHypPressed(self):
|
||||||
"""load hypothesis saved in Object Browser"""
|
"""load hypothesis saved in Object Browser"""
|
||||||
#QMessageBox.warning(self, "load Object Browser YAMS hypothesis", "TODO")
|
#QMessageBox.warning(self, "load Object Browser MGSurfOpt hypothesis", "TODO")
|
||||||
import salome
|
import salome
|
||||||
from salome.kernel import studyedit
|
from salome.kernel import studyedit
|
||||||
from salome.smesh.smeshstudytools import SMeshStudyTools
|
from salome.smesh.smeshstudytools import SMeshStudyTools
|
||||||
@ -343,14 +393,14 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
|
|
||||||
mySObject, myEntry = guihelper.getSObjectSelected()
|
mySObject, myEntry = guihelper.getSObjectSelected()
|
||||||
if CORBA.is_nil(mySObject) or mySObject==None:
|
if CORBA.is_nil(mySObject) or mySObject==None:
|
||||||
QMessageBox.critical(self, "Hypothese", "select an Object Browser YAMS hypothesis")
|
QMessageBox.critical(self, "Hypothese", "select an Object Browser MGSurfOpt hypothesis")
|
||||||
return
|
return
|
||||||
|
|
||||||
text=mySObject.GetComment()
|
text=mySObject.GetComment()
|
||||||
|
|
||||||
#a verification
|
#a verification
|
||||||
if "Optimisation=" not in text:
|
if "Optimisation=" not in text:
|
||||||
QMessageBox.critical(self, "Load Hypothese", "Object Browser selection not a YAMS Hypothesis")
|
QMessageBox.critical(self, "Load Hypothese", "Object Browser selection not a MGSurfOptHypothesis")
|
||||||
return
|
return
|
||||||
self.loadResumeData(text, separator=" ; ")
|
self.loadResumeData(text, separator=" ; ")
|
||||||
return
|
return
|
||||||
@ -406,11 +456,11 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
|
|
||||||
mySObject, myEntry = guihelper.getSObjectSelected()
|
mySObject, myEntry = guihelper.getSObjectSelected()
|
||||||
if CORBA.is_nil(mySObject) or mySObject==None:
|
if CORBA.is_nil(mySObject) or mySObject==None:
|
||||||
#QMessageBox.critical(self, "Mesh", "select an input mesh")
|
QMessageBox.critical(self, "Mesh", "select an input mesh")
|
||||||
self.LE_MeshSmesh.setText("")
|
#self.LE_MeshSmesh.setText("")
|
||||||
self.MeshIn=""
|
#self.MeshIn=""
|
||||||
self.LE_MeshFile.setText("")
|
#self.LE_MeshFile.setText("")
|
||||||
self.fichierIn=""
|
#self.fichierIn=""
|
||||||
return
|
return
|
||||||
self.smeshStudyTool = SMeshStudyTools()
|
self.smeshStudyTool = SMeshStudyTools()
|
||||||
try:
|
try:
|
||||||
@ -518,7 +568,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
|
|||||||
self.SP_MinSize.setProperty("value", 5)
|
self.SP_MinSize.setProperty("value", 5)
|
||||||
self.SP_Verbosity.setProperty("value", 3)
|
self.SP_Verbosity.setProperty("value", 3)
|
||||||
self.SP_Memory.setProperty("value", 0)
|
self.SP_Memory.setProperty("value", 0)
|
||||||
self.PBMeshSmeshPressed()
|
#self.PBMeshSmeshPressed() #do not that! problem if done in load surfopt hypo from object browser
|
||||||
self.TWOptions.setCurrentIndex(0) # Reset current active tab to the first tab
|
self.TWOptions.setCurrentIndex(0) # Reset current active tab to the first tab
|
||||||
|
|
||||||
__dialog=None
|
__dialog=None
|
||||||
@ -530,8 +580,8 @@ def getDialog():
|
|||||||
global __dialog
|
global __dialog
|
||||||
if __dialog is None:
|
if __dialog is None:
|
||||||
__dialog = MonYamsPlugDialog()
|
__dialog = MonYamsPlugDialog()
|
||||||
else :
|
#else :
|
||||||
__dialog.clean()
|
# __dialog.clean()
|
||||||
return __dialog
|
return __dialog
|
||||||
|
|
||||||
#
|
#
|
||||||
|
9
src/Tools/YamsPlug/yamsplug_plugin.py
Normal file → Executable file
9
src/Tools/YamsPlug/yamsplug_plugin.py
Normal file → Executable file
@ -34,10 +34,13 @@ def YamsLct(context):
|
|||||||
|
|
||||||
#prior test to avoid unnecessary user GUI work with ending crash
|
#prior test to avoid unnecessary user GUI work with ending crash
|
||||||
try :
|
try :
|
||||||
os.environ['DISTENE_LICENCE_FILE_FOR_YAMS']
|
os.environ['DISTENE_LICENSE_FILE']
|
||||||
except:
|
except:
|
||||||
QMessageBox.warning(None,"Products","Distene's product Yams is not installed.\nrequired environment variable:\nDISTENE_LICENCE_FILE_FOR_YAMS='/.../dlim8.var.sh'")
|
QMessageBox.warning(None,"Products","""\
|
||||||
|
Distene's product MeshGem SurfOpt (formerly Yams) is not installed.
|
||||||
|
required environment variable:
|
||||||
|
DISTENE_LICENSE_FILE='.../dlim8.var.sh'""")
|
||||||
return
|
return
|
||||||
import monYamsPlugDialog
|
import monYamsPlugDialog
|
||||||
window=monYamsPlugDialog.getDialog()
|
window = monYamsPlugDialog.getDialog()
|
||||||
window.show()
|
window.show()
|
||||||
|
Loading…
Reference in New Issue
Block a user