]> SALOME platform Git repositories - modules/hydrosolver.git/commitdiff
Salome HOME
Lot 6: generation of the interpolz
authorasl <asl@opencascade.com>
Wed, 12 Oct 2016 07:10:39 +0000 (10:10 +0300)
committerasl <asl@opencascade.com>
Wed, 12 Oct 2016 07:10:39 +0000 (10:10 +0300)
.gitignore
src/salome_hydro/interpolz.template
src/salome_hydro/interpolz.ui
src/salome_hydro/interpolzUI.py [new file with mode: 0644]
src/salome_hydro/interpolz_gui.py

index 24743af9cbd2eb75e33415a8d7975ea32d8a8c3e..913ee4fe898f28a759e4357a7477c05d80a1dea4 100644 (file)
@@ -1,2 +1,3 @@
 .svn
 .yamm
+*.pyc
index 1596f43f1ac93cb79b4a0baa81beedf4005b93a6..102b67feb84e19fa12ba88c75ec2eb395d68437c 100644 (file)
@@ -1,5 +1,4 @@
-\94\94\94Z interpolation with HYDRO\94\94\94
-
+# Z interpolation with HYDRO
 from salome.hydrotools.interpolZ import interpolZ
 
 # Calculation case name in HYDRO
@@ -11,7 +10,7 @@ medFile = <MED_file_path_from_dlg>
 # Dictionary [med group name] = region name
 <dictGroupRegion>
 
-# Value to use for Z when the node is not in a region (used to detect problems)                       
+# Value to use for Z when the node is not in a region (used to detect problems)
 zUndef = <z_undef_value_from_dlg>
 
 # Interpolation method
index f3b1c17d8ae354fa9b114bf452d66c0e1f825023..eac18739e219c51e815abb7bad2536669f88056b 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
- <class>Dialog</class>
+ <class>InterpolZ</class>
  <widget class="QDialog" name="Dialog">
   <property name="geometry">
    <rect>
diff --git a/src/salome_hydro/interpolzUI.py b/src/salome_hydro/interpolzUI.py
new file mode 100644 (file)
index 0000000..860581c
--- /dev/null
@@ -0,0 +1,134 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'interpolz.ui'
+#
+# Created: Wed Oct 12 08:40:47 2016
+#      by: PyQt4 UI code generator 4.9.6
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+try:
+    _fromUtf8 = QtCore.QString.fromUtf8
+except AttributeError:
+    def _fromUtf8(s):
+        return s
+
+try:
+    _encoding = QtGui.QApplication.UnicodeUTF8
+    def _translate(context, text, disambig):
+        return QtGui.QApplication.translate(context, text, disambig, _encoding)
+except AttributeError:
+    def _translate(context, text, disambig):
+        return QtGui.QApplication.translate(context, text, disambig)
+
+class Ui_InterpolZ(object):
+    def setupUi(self, Dialog):
+        Dialog.setObjectName(_fromUtf8("Dialog"))
+        Dialog.setGeometry(QtCore.QRect(0, 0, 656, 500))
+        self.gridLayout_2 = QtGui.QGridLayout(Dialog)
+        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
+        self.gridLayout = QtGui.QGridLayout()
+        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
+        self.lblCalcCase = QtGui.QLabel(Dialog)
+        self.lblCalcCase.setObjectName(_fromUtf8("lblCalcCase"))
+        self.gridLayout.addWidget(self.lblCalcCase, 0, 1, 1, 1)
+        self.CalcCase = QtGui.QLineEdit(Dialog)
+        self.CalcCase.setObjectName(_fromUtf8("CalcCase"))
+        self.gridLayout.addWidget(self.CalcCase, 0, 2, 1, 1)
+        self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
+        self.grpPaths = QtGui.QGroupBox(Dialog)
+        self.grpPaths.setObjectName(_fromUtf8("grpPaths"))
+        self.gridLayout_4 = QtGui.QGridLayout(self.grpPaths)
+        self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4"))
+        self.gridLayout_3 = QtGui.QGridLayout()
+        self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
+        self.lblOutputPath = QtGui.QLabel(self.grpPaths)
+        self.lblOutputPath.setObjectName(_fromUtf8("lblOutputPath"))
+        self.gridLayout_3.addWidget(self.lblOutputPath, 0, 0, 1, 1)
+        self.OutputPath = QtGui.QLineEdit(self.grpPaths)
+        self.OutputPath.setObjectName(_fromUtf8("OutputPath"))
+        self.gridLayout_3.addWidget(self.OutputPath, 0, 2, 1, 1)
+        self.lblMEDFile = QtGui.QLabel(self.grpPaths)
+        self.lblMEDFile.setObjectName(_fromUtf8("lblMEDFile"))
+        self.gridLayout_3.addWidget(self.lblMEDFile, 1, 0, 1, 1)
+        self.MEDFile = QtGui.QLineEdit(self.grpPaths)
+        self.MEDFile.setObjectName(_fromUtf8("MEDFile"))
+        self.gridLayout_3.addWidget(self.MEDFile, 1, 2, 1, 1)
+        self.btnOutputPath = QtGui.QToolButton(self.grpPaths)
+        self.btnOutputPath.setObjectName(_fromUtf8("btnOutputPath"))
+        self.gridLayout_3.addWidget(self.btnOutputPath, 0, 3, 1, 1)
+        self.btnMEDFile = QtGui.QToolButton(self.grpPaths)
+        self.btnMEDFile.setObjectName(_fromUtf8("btnMEDFile"))
+        self.gridLayout_3.addWidget(self.btnMEDFile, 1, 3, 1, 1)
+        self.gridLayout_4.addLayout(self.gridLayout_3, 0, 0, 1, 1)
+        self.gridLayout_2.addWidget(self.grpPaths, 1, 0, 1, 1)
+        self.grpParams = QtGui.QGroupBox(Dialog)
+        self.grpParams.setObjectName(_fromUtf8("grpParams"))
+        self.gridLayout_6 = QtGui.QGridLayout(self.grpParams)
+        self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6"))
+        self.gridLayout_5 = QtGui.QGridLayout()
+        self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5"))
+        self.lblUndefZ = QtGui.QLabel(self.grpParams)
+        self.lblUndefZ.setObjectName(_fromUtf8("lblUndefZ"))
+        self.gridLayout_5.addWidget(self.lblUndefZ, 0, 0, 1, 1)
+        self.UndefZ = QtGui.QLineEdit(self.grpParams)
+        self.UndefZ.setObjectName(_fromUtf8("UndefZ"))
+        self.gridLayout_5.addWidget(self.UndefZ, 0, 1, 1, 1)
+        self.lblInterpMethod = QtGui.QLabel(self.grpParams)
+        self.lblInterpMethod.setObjectName(_fromUtf8("lblInterpMethod"))
+        self.gridLayout_5.addWidget(self.lblInterpMethod, 1, 0, 1, 1)
+        self.InterpMethod = QtGui.QComboBox(self.grpParams)
+        self.InterpMethod.setObjectName(_fromUtf8("InterpMethod"))
+        self.gridLayout_5.addWidget(self.InterpMethod, 1, 1, 1, 1)
+        self.gridLayout_6.addLayout(self.gridLayout_5, 0, 0, 1, 1)
+        self.Groups = QtGui.QTableWidget(self.grpParams)
+        self.Groups.setObjectName(_fromUtf8("Groups"))
+        self.Groups.setColumnCount(0)
+        self.Groups.setRowCount(0)
+        self.gridLayout_6.addWidget(self.Groups, 1, 0, 1, 1)
+        self.gridLayout_2.addWidget(self.grpParams, 2, 0, 1, 1)
+        self.frame = QtGui.QFrame(Dialog)
+        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
+        self.frame.setFrameShadow(QtGui.QFrame.Raised)
+        self.frame.setObjectName(_fromUtf8("frame"))
+        self.horizontalLayout_2 = QtGui.QHBoxLayout(self.frame)
+        self.horizontalLayout_2.setSpacing(0)
+        self.horizontalLayout_2.setMargin(0)
+        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
+        self.ApplyClose = QtGui.QPushButton(self.frame)
+        self.ApplyClose.setObjectName(_fromUtf8("ApplyClose"))
+        self.horizontalLayout_2.addWidget(self.ApplyClose)
+        self.Apply = QtGui.QPushButton(self.frame)
+        self.Apply.setObjectName(_fromUtf8("Apply"))
+        self.horizontalLayout_2.addWidget(self.Apply)
+        self.Close = QtGui.QPushButton(self.frame)
+        self.Close.setObjectName(_fromUtf8("Close"))
+        self.horizontalLayout_2.addWidget(self.Close)
+        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+        self.horizontalLayout_2.addItem(spacerItem)
+        self.Help = QtGui.QPushButton(self.frame)
+        self.Help.setObjectName(_fromUtf8("Help"))
+        self.horizontalLayout_2.addWidget(self.Help)
+        self.gridLayout_2.addWidget(self.frame, 3, 0, 1, 1)
+
+        self.retranslateUi(Dialog)
+        QtCore.QMetaObject.connectSlotsByName(Dialog)
+
+    def retranslateUi(self, Dialog):
+        Dialog.setWindowTitle(_translate("InterpolZ", "Dialog", None))
+        self.lblCalcCase.setText(_translate("InterpolZ", "Calculation case:", None))
+        self.grpPaths.setTitle(_translate("InterpolZ", "Paths", None))
+        self.lblOutputPath.setText(_translate("InterpolZ", "Output path:", None))
+        self.lblMEDFile.setText(_translate("InterpolZ", "MED file:", None))
+        self.btnOutputPath.setText(_translate("InterpolZ", "...", None))
+        self.btnMEDFile.setText(_translate("InterpolZ", "...", None))
+        self.grpParams.setTitle(_translate("InterpolZ", "Parameters", None))
+        self.lblUndefZ.setText(_translate("InterpolZ", "Undefined Z:", None))
+        self.lblInterpMethod.setText(_translate("InterpolZ", "Interpolation method:", None))
+        self.ApplyClose.setText(_translate("InterpolZ", "Apply and Close", None))
+        self.Apply.setText(_translate("InterpolZ", "Apply", None))
+        self.Close.setText(_translate("InterpolZ", "Close", None))
+        self.Help.setText(_translate("InterpolZ", "Help", None))
+
index 7e507f0d27e14e69225d97cb5bd8712a9cc9214d..91e4adcbca58530ba41c4b8e0609f7cdb73d2c96 100644 (file)
@@ -1,23 +1,48 @@
 
 import sys, os
+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
+
+def get_med_groups( file_path ):
+    meshes = MEDLoader.MEDLoader_GetMeshNames(file_path)
+    if len(meshes)==0:
+        return []
+    mesh1 = meshes[0]
+    groups = list(MEDLoader.MEDLoader_GetMeshGroupsNames(file_path, mesh1))
+    return groups
+
+def get_hydro_regions( calc_case_name ):
+    aStudyId = salome.myStudyId
+    doc = HYDROPy.HYDROData_Document.Document( aStudyId )
+    case = doc.FindObjectByName( calc_case_name )
+    if isinstance(case, HYDROPy.HYDROData_CalculationCase):
+      regions = case.GetRegions()
+      regions_names = []
+      for r in regions:
+        rname = r.GetName()
+        regions_names.append( str(rname) )
+      return regions_names
+    else:
+      return []
 
 class InterpolzDlg( QtGui.QDialog ):
 
     def __init__(self, parent = None):
         QtGui.QDialog.__init__( self, parent )
-               
+
 
 #app = QtGui.QApplication( sys.argv )
 #dlg = InterpolzDlg()
 #dlg.show()
 #app.exec_()
 
-sys.path.append(os.path.join(os.environ['MEDFILE_ROOT_DIR'], 'lib\python2.7\site-packages\med'))
-import medfile
-import medmesh
-import medenum
-
-file_path = "c:/hydro/channel.med"
-f = medfile.MEDfileOpen(str(file_path), medenum.MED_ACC_RDEXT)
-print medmesh.MEDmeshInfo(fid, 1)
+#print get_med_groups( "/dn26/HYDRO/channel.med" )
+print get_hydro_regions( "Case_1" )