save load params

This commit is contained in:
cvw 2013-04-29 11:24:24 +00:00
parent 6b258aaf7a
commit 72e70c5f55
3 changed files with 104 additions and 90 deletions

View File

@ -45,7 +45,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
# 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:
# iconfolder=os.path.dirname(os.path.abspath(__file__)) # iconfolder=os.path.dirname(os.path.abspath(__file__))
iconfolder=os.environ['SMESH_ROOT_DIR']+'/share/salome/resources/smesh' iconfolder=os.environ["SMESH_ROOT_DIR"]+"/share/salome/resources/smesh"
#print "MGCleanerMonPlugDialog iconfolder",iconfolder #print "MGCleanerMonPlugDialog iconfolder",iconfolder
icon = QIcon() icon = QIcon()
icon.addFile(os.path.join(iconfolder,"select1.png")) icon.addFile(os.path.join(iconfolder,"select1.png"))
@ -55,7 +55,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
self.PB_ParamsFileExplorer.setIcon(icon) self.PB_ParamsFileExplorer.setIcon(icon)
#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.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("")
self.LE_MeshSmesh.setText("") self.LE_MeshSmesh.setText("")
@ -75,15 +75,15 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
self.connect(self.LE_MeshFile,SIGNAL("returnPressed()"),self.meshFileNameChanged) self.connect(self.LE_MeshFile,SIGNAL("returnPressed()"),self.meshFileNameChanged)
self.connect(self.LE_ParamsFile,SIGNAL("returnPressed()"),self.paramsFileNameChanged) self.connect(self.LE_ParamsFile,SIGNAL("returnPressed()"),self.paramsFileNameChanged)
#QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL('stateChanged(int)'), self.change) #QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL("stateChanged(int)"), self.change)
self.connect(self.CB_FillHoles,SIGNAL("stateChanged(int)"),self.SP_minHoleSize.setEnabled) self.connect(self.CB_FillHoles,SIGNAL("stateChanged(int)"),self.SP_MinHoleSize.setEnabled)
self.connect(self.CB_computedToleranceDisplacement,SIGNAL("stateChanged(int)"),self.SP_toleranceDisplacement.setDisabled) self.connect(self.CB_ComputedToleranceDisplacement,SIGNAL("stateChanged(int)"),self.SP_ToleranceDisplacement.setDisabled)
self.connect(self.CB_computedResolutionLength,SIGNAL("stateChanged(int)"),self.SP_resolutionLength.setDisabled) self.connect(self.CB_ComputedResolutionLength,SIGNAL("stateChanged(int)"),self.SP_ResolutionLength.setDisabled)
self.connect(self.CB_computedOverlapDistance,SIGNAL("stateChanged(int)"),self.SP_overlapDistance.setDisabled) self.connect(self.CB_ComputedOverlapDistance,SIGNAL("stateChanged(int)"),self.SP_OverlapDistance.setDisabled)
def PBHelpPressed(self): def PBHelpPressed(self):
try : try :
mydir=os.environ['SMESH_ROOT_DIR'] mydir=os.environ["SMESH_ROOT_DIR"]
except Exception: except Exception:
QMessageBox.warning( self, "Help unavailable $SMESH_ROOT_DIR not found") QMessageBox.warning( self, "Help unavailable $SMESH_ROOT_DIR not found")
maDoc=mydir+"/share/doc/salome/gui/SMESH/MGCleaner/_downloads/mg-cleaner_user_manual.pdf" maDoc=mydir+"/share/doc/salome/gui/SMESH/MGCleaner/_downloads/mg-cleaner_user_manual.pdf"
@ -106,20 +106,20 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
maStudy=studyedit.getActiveStudy() maStudy=studyedit.getActiveStudy()
smesh.SetCurrentStudy(maStudy) smesh.SetCurrentStudy(maStudy)
(outputMesh, status) = smesh.CreateMeshesFromGMF(self.fichierOut) (outputMesh, status) = smesh.CreateMeshesFromGMF(self.fichierOut)
meshname = 'MGCleaner'+str(self.num) meshname = "MGCleaner"+str(self.num)
smesh.SetName(outputMesh.GetMesh(), meshname) smesh.SetName(outputMesh.GetMesh(), meshname)
outputMesh.Compute() outputMesh.Compute()
self.editor = studyedit.getStudyEditor() # self.editor = studyedit.getStudyEditor() #
moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH") moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH")
HypReMeshEntry = self.editor.findOrCreateItem( moduleEntry, name = 'HypoForRemesh', HypReMeshEntry = self.editor.findOrCreateItem( moduleEntry, name = "HypoForRemesh",
comment = 'HypoForRemeshing') comment = "HypoForRemeshing")
monStudyBuilder=maStudy.NewBuilder(); monStudyBuilder=maStudy.NewBuilder();
monStudyBuilder.NewCommand(); monStudyBuilder.NewCommand();
newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry) newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry)
aNameAttrib=monStudyBuilder.FindOrCreateAttribute(newStudyIter,"AttributeName") aNameAttrib=monStudyBuilder.FindOrCreateAttribute(newStudyIter,"AttributeName")
hypoName = 'anHypo_MGCleaner_'+str(self.num) hypoName = "anHypo_MGCleaner_"+str(self.num)
aNameAttrib.SetValue(hypoName) aNameAttrib.SetValue(hypoName)
aCommentAttrib=monStudyBuilder.FindOrCreateAttribute(newStudyIter,"AttributeComment") aCommentAttrib=monStudyBuilder.FindOrCreateAttribute(newStudyIter,"AttributeComment")
aCommentAttrib.SetValue(str(self.commande)) aCommentAttrib.SetValue(str(self.commande))
@ -133,33 +133,37 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
def PBSavePressed(self,NomHypo=False): def PBSavePressed(self,NomHypo=False):
if NomHypo: if NomHypo:
text = '# Params for Hypothese : anHypo_MGCleaner_'+str(self.num - 1)+"\n" text = "# Params for Hypothese : anHypo_MGCleaner_"+str(self.num - 1)+"\n"
else: else:
text = '# Save intermediate params \n' text = "# Save intermediate params \n"
text += "# Params for mesh : " + self.LE_MeshSmesh.text() +'\n' text += "# Params for mesh : " + self.LE_MeshSmesh.text() +"\n"
if self.RB_Fix1.isChecked():
CheckOrFix="fix1pass"
else:
if self.RB_Fix2.isChecked():
CheckOrFix="fix2pass"
else:
CheckOrFix="check"
text+="CheckOrFix=" + CheckOrFix+"\n"
""" text+="PreserveTopology=" + str(self.CB_PreserveTopology.isChecked())+"\n"
for RB in self.GBOptim.findChildren(QRadioButton,): text+="FillHoles=" + str(self.CB_FillHoles.isChecked())+"\n"
if RB.isChecked()==True: text+="MinHoleSize=" + str(self.SP_MinHoleSize.value())+"\n"
text+="Optimisation ='"+RB.text()+"'\n" text+="ComputedToleranceDisplacement=" + str(self.CB_ComputedToleranceDisplacement.isChecked())+"\n"
break text+="ToleranceDisplacement=" + str(self.SP_ToleranceDisplacement.value())+"\n"
for RB in self.GBUnit.findChildren(QRadioButton,): text+="ComputedResolutionLength=" + str(self.CB_ComputedResolutionLength.isChecked())+"\n"
if RB.isChecked()==True: text+="ResolutionLength=" + str(self.SP_ResolutionLength.value())+"\n"
text+="Units ='"+RB.text()+"'\n" text+="FoldingAngle=" + str(self.SP_FoldingAngle.value())+"\n"
text+='Chordal_Tolerance_Deviation='+str(self.SP_Tolerance.value())+'\n' text+="RemeshPlanes=" + str(self.CB_RemeshPlanes.isChecked())+"\n"
text+='Ridge_Detection=' + str(self.CB_Ridge.isChecked())+'\n' text+="ComputedOverlapDistance=" + str(self.CB_ComputedOverlapDistance.isChecked())+"\n"
text+='Split_Edge=' + str(self.CB_SplitEdge.isChecked())+'\n' text+="OverlapDistance=" + str(self.SP_OverlapDistance.value())+"\n"
text+='Point_Smoothing=' + str(self.CB_Point.isChecked())+'\n' text+="OverlapAngle=" + str(self.SP_OverlapAngle.value())+"\n"
text+='Geometrical_Approximation='+ str(self.SP_Geomapp.value()) +'\n' text+="Verbosity=" + str(self.SP_Verbosity.value())+"\n"
text+='Ridge_Angle=' + str(self.SP_Ridge.value()) +'\n' text+="\n\n"
text+='Maximum_Size=' + str(self.SP_MaxSize.value()) +'\n'
text+='Minimum_Size=' + str(self.SP_MaxSize.value()) +'\n'
text+='Mesh_Gradation=' + str(self.SP_Gradation.value())+'\n'
text+='Verbosity=' + str(self.SP_Verbosity.value())+'\n'
text+='\n\n'
"""
try: try:
f=open(self.paramsFile,'a') f=open(self.paramsFile,"a")
except: except:
QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile) QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile)
return return
@ -172,7 +176,7 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
def PBLoadPressed(self): def PBLoadPressed(self):
try: try:
f=open(self.paramsFile,'r') f=open(self.paramsFile,"r")
except : except :
QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile) QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile)
return return
@ -182,30 +186,38 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
QMessageBox.warning(self, "File", "Unable to read "+self.paramsFile) QMessageBox.warning(self, "File", "Unable to read "+self.paramsFile)
return return
f.close() f.close()
d={}
exec text in d self.clean()
for RB in self.GBOptim.findChildren(QRadioButton,): for slig in reversed(text.split("\n")):
if d['Optimisation']== RB.text(): lig=slig.strip()
RB.setChecked(True) #print "load params",self.paramsFile,lig
break if lig=="": continue #skip blanck lines
for RB in self.GBUnit.findChildren(QRadioButton,): if lig[0]=="#": break
if d['Units']==RB.text(): try:
RB.setChecked(True) tit,value=lig.split("=")
break if tit=="CheckOrFix":
self.SP_Tolerance.setValue(d['Chordal_Tolerance_Deviation']) self.RB_Fix1.setChecked(False)
self.RB_Fix2.setChecked(False)
self.CB_Ridge.setChecked(d['Ridge_Detection']) self.RB_Check.setChecked(False)
self.CB_Point.setChecked(d['Point_Smoothing']) if value=="fix1pass": self.RB_Fix1.setChecked(True)
self.CB_SplitEdge.setChecked(d['Split_Edge']) if value=="fix2pass": self.RB_Fix2.setChecked(True)
self.SP_Geomapp.setValue(d['Geometrical_Approximation']) if value=="check": self.RB_Check.setChecked(True)
self.SP_Ridge.setValue(d['Ridge_Angle']) if tit=="PreserveTopology": self.CB_PreserveTopology.setChecked(bool(value))
self.SP_MaxSize.setValue(d['Maximum_Size']) if tit=="FillHoles": self.CB_FillHoles.setChecked(bool(value))
self.SP_MinSize.setValue(d['Minimum_Size']) if tit=="MinHoleSize": self.SP_MinHoleSize.setProperty("value", float(value))
self.SP_Gradation.setValue(d['Mesh_Gradation']) if tit=="ComputedToleranceDisplacement": self.CB_ComputedToleranceDisplacement.setChecked(bool(value))
if tit=="ToleranceDisplacement": self.SP_ToleranceDisplacement.setProperty("value", float(value))
self.SP_Verbosity.setValue(d['Verbosity']) if tit=="ComputedResolutionLength": self.CB_ComputedResolutionLength.setChecked(bool(value))
self.SP_Memory.setValue(d['Memory']) if tit=="ResolutionLength": self.SP_ResolutionLength.setProperty("value", float(value))
if tit=="FoldingAngle": self.SP_FoldingAngle.setProperty("value", float(value))
if tit=="RemeshPlanes": self.CB_RemeshPlanes.setChecked(bool(value))
if tit=="ComputedOverlapDistance": self.CB_ComputedOverlapDistance.setChecked(bool(value))
if tit=="OverlapDistance": self.SP_OverlapDistance.setProperty("value", float(value))
if tit=="OverlapAngle": self.SP_OverlapAngle.setProperty("value", float(value))
if tit=="Verbosity": self.SP_Verbosity.setProperty("value", int(float(value)))
except:
QMessageBox.warning(self, "File", "Problem to read '"+lig+"'")
def PBCancelPressed(self): def PBCancelPressed(self):
self.close() self.close()
@ -303,17 +315,17 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
else: else:
self.commande+=" --topology ignore" self.commande+=" --topology ignore"
if self.CB_FillHoles.isChecked(): #no fill holes default if self.CB_FillHoles.isChecked(): #no fill holes default
self.commande+=" --min_hole_size " + str(self.SP_minHoleSize.value()) self.commande+=" --min_hole_size " + str(self.SP_MinHoleSize.value())
if not self.CB_computedToleranceDisplacement.isChecked(): #computed default if not self.CB_ComputedToleranceDisplacement.isChecked(): #computed default
self.commande+=" --tolerance_displacement " + str(self.SP_toleranceDisplacement.value()) self.commande+=" --tolerance_displacement " + str(self.SP_ToleranceDisplacement.value())
if not self.CB_computedResolutionLength.isChecked(): #computed default if not self.CB_ComputedResolutionLength.isChecked(): #computed default
self.commande+=" --tolerance_displacement " + str(self.SP_resolutionLength.value()) self.commande+=" --tolerance_displacement " + str(self.SP_ResolutionLength.value())
self.commande+=" --folding_angle " + str(self.SP_foldingAngle.value()) self.commande+=" --folding_angle " + str(self.SP_FoldingAngle.value())
if self.CB_RemeshPlanes.isChecked(): #no remesh default if self.CB_RemeshPlanes.isChecked(): #no remesh default
self.commande+=" --remesh_planes" self.commande+=" --remesh_planes"
if not self.CB_computedOverlapDistance.isChecked(): #computed default if not self.CB_ComputedOverlapDistance.isChecked(): #computed default
self.commande+=" --overlap_distance " + str(self.SP_overlapDistance.value()) self.commande+=" --overlap_distance " + str(self.SP_OverlapDistance.value())
self.commande+=" --overlap_angle " + str(self.SP_overlapAngle.value()) self.commande+=" --overlap_angle " + str(self.SP_OverlapAngle.value())
return True return True
def clean(self): def clean(self):
@ -324,17 +336,17 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
self.CB_FillHoles.setChecked(False) self.CB_FillHoles.setChecked(False)
self.CB_RemeshPlanes.setChecked(False) self.CB_RemeshPlanes.setChecked(False)
self.SP_minHoleSize.setProperty("value", 0) self.SP_MinHoleSize.setProperty("value", 0)
self.SP_toleranceDisplacement.setProperty("value", 0) self.SP_ToleranceDisplacement.setProperty("value", 0)
self.SP_resolutionLength.setProperty("value", 0) self.SP_ResolutionLength.setProperty("value", 0)
self.SP_foldingAngle.setProperty("value", 15) self.SP_FoldingAngle.setProperty("value", 15)
self.SP_overlapDistance.setProperty("value", 0) self.SP_OverlapDistance.setProperty("value", 0)
self.SP_overlapAngle.setProperty("value", 15) self.SP_OverlapAngle.setProperty("value", 15)
self.SP_Verbosity.setProperty("value", 3) self.SP_Verbosity.setProperty("value", 3)
self.CB_computedToleranceDisplacement.setChecked(True) self.CB_ComputedToleranceDisplacement.setChecked(True)
self.CB_computedResolutionLength.setChecked(True) self.CB_ComputedResolutionLength.setChecked(True)
self.CB_computedOverlapDistance.setChecked(True) self.CB_ComputedOverlapDistance.setChecked(True)
__dialog=None __dialog=None
def getDialog(): def getDialog():
@ -356,7 +368,7 @@ def getDialog():
# ============================================================================== # ==============================================================================
# #
def TEST_MGCleanerMonPlugDialog(): def TEST_MGCleanerMonPlugDialog():
print 'TEST_MGCleanerMonPlugDialog' print "TEST_MGCleanerMonPlugDialog"
import sys import sys
from PyQt4.QtGui import QApplication from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QObject, SIGNAL, SLOT from PyQt4.QtCore import QObject, SIGNAL, SLOT

View File

@ -1,4 +1,4 @@
# -*- coding: iso-8859-1 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2007-2013 EDF R&D # Copyright (C) 2007-2013 EDF R&D
# #
# This library is free software; you can redistribute it and/or # This library is free software; you can redistribute it and/or
@ -40,6 +40,8 @@ class MGCleanerMonViewText(Ui_ViewExe,QDialog):
self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) ) self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) )
self.connect( self.PB_Ok,SIGNAL("clicked()"), self, SLOT("close()") ) self.connect( self.PB_Ok,SIGNAL("clicked()"), self, SLOT("close()") )
self.connect( self.PB_Save,SIGNAL("clicked()"), self.saveFile ) self.connect( self.PB_Save,SIGNAL("clicked()"), self.saveFile )
self.PB_Save.setToolTip("Save trace in log file")
self.PB_Ok.setToolTip("Close view")
self.monExe=QProcess(self) self.monExe=QProcess(self)

View File

@ -426,7 +426,7 @@ Default is not to mesh planes.</string>
<string>You can control </string> <string>You can control </string>
</property> </property>
#1 #1
<widget class="QDoubleSpinBox" name="SP_minHoleSize"> <widget class="QDoubleSpinBox" name="SP_MinHoleSize">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
@ -469,7 +469,7 @@ Set 'Fill holes' in 'Simple Remeshing Options'.</string>
</property> </property>
</widget> </widget>
#2 #2
<widget class="QDoubleSpinBox" name="SP_toleranceDisplacement"> <widget class="QDoubleSpinBox" name="SP_ToleranceDisplacement">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
@ -514,7 +514,7 @@ Unused in collision resolution .
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="CB_computedToleranceDisplacement"> <widget class="QCheckBox" name="CB_ComputedToleranceDisplacement">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>650</x> <x>650</x>
@ -535,7 +535,7 @@ Unused in collision resolution .
</widget> </widget>
#3 #3
<widget class="QDoubleSpinBox" name="SP_resolutionLength"> <widget class="QDoubleSpinBox" name="SP_ResolutionLength">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
@ -578,7 +578,7 @@ Default is computed from model.</string>
<string>Distance threshold for two points distinct (--resolution_length)</string> <string>Distance threshold for two points distinct (--resolution_length)</string>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="CB_computedResolutionLength"> <widget class="QCheckBox" name="CB_ComputedResolutionLength">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>650</x> <x>650</x>
@ -598,7 +598,7 @@ Default is computed from model.</string>
</property> </property>
</widget> </widget>
#4 #4
<widget class="QDoubleSpinBox" name="SP_foldingAngle"> <widget class="QDoubleSpinBox" name="SP_FoldingAngle">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
@ -640,7 +640,7 @@ Default is 15 degrees.</string>
</property> </property>
</widget> </widget>
#5 #5
<widget class="QDoubleSpinBox" name="SP_overlapDistance"> <widget class="QDoubleSpinBox" name="SP_OverlapDistance">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
@ -684,7 +684,7 @@ Default is computed from model.</string>
(--overlap_distance)</string> (--overlap_distance)</string>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="CB_computedOverlapDistance"> <widget class="QCheckBox" name="CB_ComputedOverlapDistance">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>650</x> <x>650</x>
@ -704,7 +704,7 @@ Default is computed from model.</string>
</property> </property>
</widget> </widget>
#6 #6
<widget class="QDoubleSpinBox" name="SP_overlapAngle"> <widget class="QDoubleSpinBox" name="SP_OverlapAngle">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>