import sys, os
-sys.path.append(os.path.join(os.environ['MEDFILE_ROOT_DIR'], 'lib\python2.7\site-packages\med'))
+sys.path.append(os.path.join(os.environ['MEDFILE_ROOT_DIR'], 'lib/python2.7/site-packages/med'))
import salome
salome.salome_init()
import MEDLoader
import HYDROPy
-from PyQt4 import QtCore, QtGui
-#from interpolzUI import Ui_InterpolZ
+from PyQt4 import QtCore, QtGui, uic
+
+import SalomePyQt
+import libSALOME_Swig
+salome_gui = libSALOME_Swig.SALOMEGUI_Swig()
def get_med_groups( file_path ):
- meshes = MEDLoader.MEDLoader_GetMeshNames(file_path)
+ #print "get_med_groups", file_path
+ try:
+ meshes = MEDLoader.MEDLoader_GetMeshNames(file_path)
+ except:
+ return []
if len(meshes)==0:
return []
mesh1 = meshes[0]
- groups = list(MEDLoader.MEDLoader_GetMeshGroupsNames(file_path, mesh1))
+ try:
+ groups = list(MEDLoader.MEDLoader_GetMeshGroupsNames(file_path, mesh1))
+ except:
+ return []
return groups
def get_hydro_regions( calc_case_name ):
else:
return []
+def get_selected_calc_case():
+ ind = SalomePyQt.SalomePyQt.getObjectBrowser().selectionModel().selectedIndexes()
+ aStudyId = salome.myStudyId
+ doc = HYDROPy.HYDROData_Document.Document( aStudyId )
+ for i in ind:
+ if i.column()==0:
+ name = i.data().toString()
+ case = doc.FindObjectByName( name )
+ if isinstance(case, HYDROPy.HYDROData_CalculationCase):
+ return name
+ return None
+
class InterpolzDlg( QtGui.QDialog ):
-
def __init__(self, parent = None):
QtGui.QDialog.__init__( self, parent )
+ p = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro')
+ uic.loadUi( p+'/interpolz.ui', self )
+ self.setWindowTitle( 'Generate interpolz script' )
+ self.connect( SalomePyQt.SalomePyQt.getObjectBrowser(), QtCore.SIGNAL("selectionChanged()"), self.onSelectionChanged )
+ self.connect( self.btnOutputPath, QtCore.SIGNAL( "clicked()" ), self.onOutputFile )
+ self.connect( self.btnMEDFile, QtCore.SIGNAL( "clicked()" ), self.onMEDFile )
+ self.connect( self.CalcCase, QtCore.SIGNAL( "textChanged( const QString& )" ), self.onCalcCaseChanged )
+ self.connect( self.MEDFile, QtCore.SIGNAL( "textChanged( const QString& )" ), self.onMEDChanged )
+
+ def onSelectionChanged( self ):
+ calc_case_name = get_selected_calc_case()
+ if calc_case_name is not None:
+ self.CalcCase.setText( calc_case_name )
+
+ def onOutputFile( self ):
+ caption = "Python file"
+ mask = "*.py"
+ f = QtGui.QFileDialog.getSaveFileName( self, caption, ".", mask )
+ if f!=None and f!="":
+ self.OutputPath.setText( f )
+
+ def onMEDFile( self ):
+ caption = "MED file"
+ mask = "*.med"
+ f = QtGui.QFileDialog.getOpenFileName( self, caption, ".", mask )
+ if f!=None and f!="":
+ self.MEDFile.setText( f )
+
+ def onCalcCaseChanged( self ):
+ self.regions = get_hydro_regions( str(self.CalcCase.text()) )
+ print self.regions
+
+ def onMEDChanged( self ):
+ self.med_groups = get_med_groups( str(self.MEDFile.text()) )
+ print self.med_groups
-#app = QtGui.QApplication( sys.argv )
-#dlg = InterpolzDlg()
-#dlg.show()
-#app.exec_()
+dlg = InterpolzDlg()
+dlg.show()
+dlg.CalcCase.setText( 'Case_1' )
+dlg.OutputPath.setText( '/dn26/HYDRO/interp1.py' )
+dlg.MEDFile.setText( '/dn26/HYDRO/channel.med' )
#print get_med_groups( "/dn26/HYDRO/channel.med" )
-print get_hydro_regions( "Case_1" )
+#print get_hydro_regions( "Case_1" )