]> SALOME platform Git repositories - modules/hydrosolver.git/commitdiff
Salome HOME
yamm adaptation and lot 6 pre/V7_8_BR
authorPaul RASCLE <paul.rascle@edf.fr>
Wed, 14 Dec 2016 15:10:36 +0000 (16:10 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Wed, 14 Dec 2016 15:10:36 +0000 (16:10 +0100)
src/HYDROGUI/BndConditionsDialog.py
src/HYDROTools/CMakeLists.txt
src/salome_hydro/generate_interpolz.py
src/salome_hydro/interpolz_gui.py
src/salome_hydro/telemac2d/CMakeLists.txt
tests/boundaryConditionsDlgTest.py
tests/boundaryConditionsTest.py

index 5156d8460bb0902e5cbc2b599a37460f625652c1..7cc6f7c441e20442c5995cc4d1787dca9455c733 100644 (file)
@@ -24,9 +24,9 @@ from MEDLoader import MEDFileMesh
 
 # TODO: get rid of sys.path.append() ?
 hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome')
-sys.path.append(os.path.join(hydro_solver_root, 'salome', 'hydrotools'))
+#sys.path.append(os.path.join(hydro_solver_root, 'salome', 'hydrotools'))
 
-import boundaryConditions
+from salome.hydro import boundaryConditions
 
 ROW_PROPERTY_NAME = "row"
 
@@ -37,54 +37,54 @@ def get_med_groups_on_edges(file_path):
         groups = list(med_file_mesh.getGroupsOnSpecifiedLev(-1))
     except:
         return []
-          
+
     return groups
 
-"""Get preset name corresponding to the given values of LIHBOR, LIUBOR, LIVBOR and LITBOR"""    
+"""Get preset name corresponding to the given values of LIHBOR, LIUBOR, LIVBOR and LITBOR"""
 def get_preset_name(presets, lihbor, liubor, livbor, litbor):
     name = ''
-    
+
     for preset_name in presets:
         values = presets[preset_name]
-        
+
         p_lihbor = values[0]
         p_liubor = values[1]
         p_livbor = values[2]
         p_litbor = values[3]
-        
+
         if not p_lihbor or p_lihbor == lihbor:
             if not p_liubor or p_liubor == liubor:
                 if not p_livbor or p_livbor == livbor:
                     if not p_litbor or p_litbor == litbor:
                         name = preset_name
-                        
+
     return name
 
-"""Convert string to integer, return None if conversion is not possible"""    
+"""Convert string to integer, return None if conversion is not possible"""
 def get_int(str):
     value = None
-    
+
     if str.isdigit():
         value = int(str)
-            
+
     return value
 
-"""Item delegate for LIHBOR, LIUBOR, LIVBOR and LITBOR columns"""    
+"""Item delegate for LIHBOR, LIUBOR, LIVBOR and LITBOR columns"""
 class ValueDelegate(QtGui.QStyledItemDelegate):
-    
+
     def __init__(self, parent = None):
         QtGui.QStyledItemDelegate.__init__(self, parent)
-        
+
     def createEditor(self, parent, option, index):
         line_edit = QtGui.QLineEdit(parent)
-        
+
         validator = QtGui.QIntValidator(parent)
         validator.setRange(0, 6)
-        
+
         line_edit.setValidator(validator)
 
         return line_edit
-        
+
     def setEditorData(self, editor, index):
         value, is_ok = index.model().data(index, QtCore.Qt.EditRole).toInt()
 
@@ -92,45 +92,45 @@ class ValueDelegate(QtGui.QStyledItemDelegate):
             editor.setText(str(value))
         else:
             editor.setText('')
-    
+
     def setModelData(self, editor, model, index):
         model.setData(index, editor.text(), QtCore.Qt.EditRole)
 
     def updateEditorGeometry(self, editor, option, index):
         editor.setGeometry(option.rect)
-    
-"""Boundary conditions definition dialog"""    
+
+"""Boundary conditions definition dialog"""
 class BoundaryConditionsDialog(QtGui.QDialog):
 
     def __init__(self, parent = None, modal = 0):
         QtGui.QDialog.__init__(self, parent)
         uic.loadUi(os.path.join(hydro_solver_root, 'BndConditionsDialog.ui'), self )
-                                                       
+
         # Connections
         self.medFileButton.clicked.connect(self.on_med_file_browse)
         self.bndConditionsFileButton.clicked.connect(self.on_bnd_file_browse)
         self.resultBndConditionsFileButton.clicked.connect(self.on_result_file_browse)
-        
+
         self.sameAsInputCB.toggled.connect(self.resultBndConditionsFileEdit.setDisabled)
         self.sameAsInputCB.toggled.connect(self.resultBndConditionsFileButton.setDisabled)
-        
+
         self.boundaryConditionsTable.cellChanged.connect(self.on_cell_changed)
-        
+
         self.applyAndCloseButton.clicked.connect(self.on_apply_and_close)
         self.applyButton.clicked.connect(self.on_apply)
         self.closeButton.clicked.connect(self.reject)
         self.helpButton.clicked.connect(self.on_help)
-        
+
         # Set widgets properties
         self.init_widgets()
-      
+
         # Input conditions
         self.input_conditions = {}
-      
+
         # Init presets
         self.presets = {}
         self.init_presets()
-    
+
     """Initialize presets"""
     def init_presets(self):
         # TODO: determine another presets path
@@ -138,56 +138,56 @@ class BoundaryConditionsDialog(QtGui.QDialog):
         file_path = os.path.join(presets_data_root, 'bnd_conditions_presets.txt')
         reader = boundaryConditions.PresetReader(file_path)
         self.presets = reader.read()
-    
+
     """Initialize widget properties"""
     def init_widgets(self):
         self.medFileEdit.setReadOnly(True)
         self.bndConditionsFileEdit.setReadOnly(True)
         self.resultBndConditionsFileEdit.setReadOnly(True)
-        
+
         delegate = ValueDelegate(self.boundaryConditionsTable)
         self.boundaryConditionsTable.setItemDelegateForColumn(1, delegate)
         self.boundaryConditionsTable.setItemDelegateForColumn(2, delegate)
         self.boundaryConditionsTable.setItemDelegateForColumn(3, delegate)
         self.boundaryConditionsTable.setItemDelegateForColumn(4, delegate)
-    
+
     """Process cell data changes"""
     def on_cell_changed(self, row, column):
         lihbor = liubor = livbor = litbor = None
-        
+
         item = self.boundaryConditionsTable.item(row, 1)
         if item:
             lihbor = get_int(str(item.text()))
-        
+
         item = self.boundaryConditionsTable.item(row, 2)
         if item:
             liubor = get_int(str(item.text()))
-            
+
         item = self.boundaryConditionsTable.item(row, 3)
         if item:
             livbor = get_int(str(item.text()))
-            
+
         item = self.boundaryConditionsTable.item(row, 4)
         if item:
             litbor = get_int(str(item.text()))
-            
+
         preset_name = get_preset_name(self.presets, lihbor, liubor, livbor, litbor)
-        
+
         combo = self.boundaryConditionsTable.cellWidget(row, 0)
         if isinstance(combo, QtGui.QComboBox):
             ind = combo.findText(preset_name)
             if ind >= 0:
                 combo.setCurrentIndex(ind)
-    
+
     """Save the user data to boundary conditions file"""
     def on_apply(self):
         # Save boundary conditions file
         if not self.is_valid():
             return False
-        
+
         file_path = self.resultBndConditionsFileEdit.text()
         writer = boundaryConditions.BoundaryConditionWriter(file_path)
-        
+
         conditions = []
         for row_nb in xrange(0, self.boundaryConditionsTable.rowCount()):
             lihbor = str(self.boundaryConditionsTable.item(row_nb, 1).text())
@@ -196,39 +196,39 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             litbor = str(self.boundaryConditionsTable.item(row_nb, 4).text())
             group_name = str(self.boundaryConditionsTable.item(row_nb, 5).text())
             conditions.append(boundaryConditions.BoundaryCondition(lihbor, liubor, livbor, litbor, group_name))
-                
+
         writer.write(conditions)
-                    
+
         return True
-    
+
     """Save the user data to boundary conditions file and close the dialog"""
     def on_apply_and_close(self):
         if self.on_apply():
             self.accept()
-       
+
     """Select MED file"""
     def on_med_file_browse(self):
         # Get file path
         file_path = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open MED file"), "", self.tr("MED files (*.med)"))
         if not file_path:
             return
-        
+
         # Get names of groups on edges
         groups = get_med_groups_on_edges(str(file_path))
-        
+
         if len(groups) > 0:
             # Display the path
             self.medFileEdit.setText(file_path)
-            
+
             # Update table
             self.set_groups(groups)
         else:
             QtGui.QMessageBox.warning(self, self.tr("Warning"), self.tr("Can't get group names from the selected MED file."))
-    
+
     """Select boundary conditions file"""
     def on_bnd_file_browse(self):
         file_path = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open boundary conditions file"))
-        
+
         if file_path:
             self.bndConditionsFileEdit.setText(file_path)
             reader = boundaryConditions.BoundaryConditionReader(file_path)
@@ -237,52 +237,52 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             self.input_conditions.clear()
             for cnd in conditions:
                 self.input_conditions[cnd.group] = (cnd.lihbor, cnd.liubor, cnd.livbor, cnd.litbor)
-            
+
             # Check read errors
             read_errors = reader.errors
             if len( read_errors ) > 0:
                 msg = "\n".join(read_errors)
                 QtGui.QMessageBox.warning(self, self.tr("Warning"), msg)
-            
+
             if len(self.input_conditions) > 0:
                 self.update_table()
             else:
                 QtGui.QMessageBox.warning(self, self.tr("Warning"), self.tr("No conditions have been read from the file."))
-    
+
     """Called on preset selection in the first column of the table"""
     def on_preset_changed(self):
         combo = self.sender()
-        
+
         preset = str(combo.currentText())
-       
+
         if preset and self.presets.has_key(preset):
             values = self.presets[preset]
             row_nb, is_ok = combo.property(ROW_PROPERTY_NAME).toInt()
-            
+
             if is_ok and row_nb >= 0 and row_nb < self.boundaryConditionsTable.rowCount():
                 lihbor = values[0]
                 liubor = values[1]
                 livbor = values[2]
                 litbor = values[3]
-                
+
                 if lihbor:
                     self.boundaryConditionsTable.item(row_nb, 1).setText(str(lihbor))
-                    
+
                 if liubor:
-                    self.boundaryConditionsTable.item(row_nb, 2).setText(str(liubor))    
-                    
+                    self.boundaryConditionsTable.item(row_nb, 2).setText(str(liubor))
+
                 if livbor:
-                    self.boundaryConditionsTable.item(row_nb, 3).setText(str(livbor))    
-                    
+                    self.boundaryConditionsTable.item(row_nb, 3).setText(str(livbor))
+
                 if litbor:
-                    self.boundaryConditionsTable.item(row_nb, 4).setText(str(litbor))    
-        
+                    self.boundaryConditionsTable.item(row_nb, 4).setText(str(litbor))
+
     """Define result file path"""
     def on_result_file_browse(self):
         file_path = QtGui.QFileDialog.getSaveFileName(self, self.tr("Select output file path"))
         if file_path:
             self.resultBndConditionsFileEdit.setText(file_path)
-    
+
     """Set groups list"""
     def set_groups(self, groups):
         self.boundaryConditionsTable.setRowCount(0)
@@ -290,31 +290,31 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             # Add row
             row_nb = self.boundaryConditionsTable.rowCount()
             self.boundaryConditionsTable.insertRow(row_nb)
-            
+
             # 'Preset' column
             combo = QtGui.QComboBox(self)
             combo.addItem('')
             if len(self.presets) > 0:
                 combo.addItems(self.presets.keys())
-            
+
             combo.setProperty(ROW_PROPERTY_NAME, row_nb)
-            
+
             combo.currentIndexChanged.connect(self.on_preset_changed)
-                
+
             self.boundaryConditionsTable.setCellWidget(row_nb, 0, combo)
-            
+
             # 'LIHBOR' column
             self.boundaryConditionsTable.setItem(row_nb, 1, QtGui.QTableWidgetItem(''))
-            
+
             # 'LIUBOR' column
             self.boundaryConditionsTable.setItem(row_nb, 2, QtGui.QTableWidgetItem(''))
-            
+
             # 'LIVBOR' column
             self.boundaryConditionsTable.setItem(row_nb, 3, QtGui.QTableWidgetItem(''))
-            
+
             # 'LITBOR' column
             self.boundaryConditionsTable.setItem(row_nb, 4, QtGui.QTableWidgetItem(''))
-            
+
             # 'Group' column
             item = QtGui.QTableWidgetItem(group)
             font = item.font()
@@ -322,47 +322,47 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             item.setFont(font)
             item.setFlags(QtCore.Qt.ItemIsEnabled)
             self.boundaryConditionsTable.setItem(row_nb, 5, item)
-        
+
         self.update_table()
-    
+
     """Update conditions data in the table from the conditions input file"""
     def update_table(self):
         is_updated = False
-    
-        nb_rows = self.boundaryConditionsTable.rowCount()   
+
+        nb_rows = self.boundaryConditionsTable.rowCount()
         for row_nb in xrange(0, nb_rows):
             group_name = str(self.boundaryConditionsTable.item(row_nb, 5).text())
             if self.input_conditions.has_key(group_name):
                 values = self.input_conditions[group_name]
-                
+
                 lihbor = str(values[0])
                 liubor = str(values[1])
                 livbor = str(values[2])
                 litbor = str(values[3])
-                
+
                 self.boundaryConditionsTable.item(row_nb, 1).setText(lihbor)
                 self.boundaryConditionsTable.item(row_nb, 2).setText(liubor)
                 self.boundaryConditionsTable.item(row_nb, 3).setText(livbor)
                 self.boundaryConditionsTable.item(row_nb, 4).setText(litbor)
-                
+
                 is_updated = True
-                
+
         if not is_updated and nb_rows > 0 and len(self.input_conditions) > 0:
             QtGui.QMessageBox.information(self, self.tr("Information"), self.tr("No one group name from the MED file is presented in the input list of conditions."))
-    
+
     """Get output file path"""
     def get_output_path(self):
         path = self.bndConditionsFileEdit.text()
-        
+
         if not self.sameAsInputCB.isChecked():
             path = self.resultBndConditionsFileEdit.text()
-        
+
         return path
-    
+
     """Check if the input data is valid"""
     def is_valid(self):
         is_ok = False
-    
+
         if self.boundaryConditionsTable.rowCount() < 1:
             QtGui.QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Boundary conditions list is empty."))
         elif self.get_output_path().isEmpty():
@@ -374,48 +374,48 @@ class BoundaryConditionsDialog(QtGui.QDialog):
                 liubor = str(self.boundaryConditionsTable.item(row_nb, 2).text())
                 livbor = str(self.boundaryConditionsTable.item(row_nb, 3).text())
                 litbor = str(self.boundaryConditionsTable.item(row_nb, 4).text())
-                
+
                 if (not lihbor) or (not liubor) or (not livbor) or (not litbor):
                     has_empty_cells = True
                     break
-            
+
             if has_empty_cells:
                 QtGui.QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Table has empty cell(s)."))
             else:
                 is_ok = True
-            
+
         return is_ok
-        
+
     """Shows help page"""
     def on_help(self):
         msg = """
         <h2>Boundary conditions dialog</h2>
-        
+
         This dialog is used to read and write boundary conditions files.
         Below is the description of the dialog controls.
-        
-        <h3>MED file</h3> 
-        This field allows selection of a med file (via the standard file open dialog). 
-        The file must contain groups of edges, if this is not the case a warning message appears. 
+
+        <h3>MED file</h3>
+        This field allows selection of a med file (via the standard file open dialog).
+        The file must contain groups of edges, if this is not the case a warning message appears.
         The filling of this field is mandatory.
 
-        <h3>Boundary conditions file</h3> 
-        This field allows selecting the file of boundary conditions (via the standard file open dialog). 
-        The data from this file is displayed in the table "Boundary conditions". 
+        <h3>Boundary conditions file</h3>
+        This field allows selecting the file of boundary conditions (via the standard file open dialog).
+        The data from this file is displayed in the table "Boundary conditions".
         This field is optional; if it is not selected the table will not be prefilled.
 
-        <h3>Result boundary conditions file</h3> 
-        This field allows selecting the file in which to save the data (via the standard file save dialog). 
+        <h3>Result boundary conditions file</h3>
+        This field allows selecting the file in which to save the data (via the standard file save dialog).
         This field is mandatory if the "Same as the input" check box is unchecked.
-         
-        <h3>Boundary conditions table</h3> 
+
+        <h3>Boundary conditions table</h3>
         Contains data representing the list of boundary conditions.
         The first column contains a list of presets.
         The last columns is read-only, it contains names of group of edges from the selected MED file.
         Other columns is for LIHBOR, LIUBOR, LIVBOR and LITBOR parameters, which can take a value ranging between 0 and 6.
         <br>
         <br>
-        When the table is filled and the output file is defined, the user clicks on "Apply" or "Apply and Close" button 
+        When the table is filled and the output file is defined, the user clicks on "Apply" or "Apply and Close" button
         to perform the data export to the file.
         Click on "Close" button does not lead to saving the data and just closes the dialog.
         """
index 1e3e7d5c6b189d78e29d91a579423c9fed388775..61a10ecd69b0811f3ba2d4fb4cc594c42fe55671 100644 (file)
@@ -27,4 +27,4 @@ SET(PYFILES
 
 # --- rules ---
 
-SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydrotools)
+SALOME_INSTALL_SCRIPTS("${PYFILES}" ${SALOME_INSTALL_PYTHON}/salome/hydro)
index fe3ebc0c098a9d7603c75cc8d62a34ace974235c..52f4d076f340bc8736363125f5cf9a77e05414b6 100644 (file)
@@ -3,44 +3,44 @@ import os
 hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro')
 
 def replace( lines, pattern, subst ):
-       for i in range( 0, len( lines ) ):
-               line = lines[i]
-               if pattern in lines[i]:
-                       if isinstance( subst, list ):
-                               del lines[i]
-                               for s in subst:
-                                       new_line = line.replace( pattern, repr(s) )
-                                       lines.insert( i, new_line )
-                       elif isinstance( subst, dict ):
-                               del lines[i]
-                               name = pattern[1:-1]
-                               lines.insert( i, "%s = {}\n" % name )
-                               keys = subst.keys()
-                               keys.sort()
-                               i = i+1
-                               for k in keys:
-                                       v = subst[k]
-                                       lines.insert( i, "%s[%s] = %s\n" % (name, repr(k), repr(v) ) )
-                                       i = i+1
-                       else:
-                               new_line = line.replace( pattern, repr(subst) )
-                               lines[i] = new_line
-                               
+  for i in range( 0, len( lines ) ):
+    line = lines[i]
+    if pattern in lines[i]:
+      if isinstance( subst, list ):
+        del lines[i]
+        for s in subst:
+          new_line = line.replace( pattern, repr(s) )
+          lines.insert( i, new_line )
+      elif isinstance( subst, dict ):
+        del lines[i]
+        name = pattern[1:-1]
+        lines.insert( i, "%s = {}\n" % name )
+        keys = subst.keys()
+        keys.sort()
+        i = i+1
+        for k in keys:
+          v = subst[k]
+          lines.insert( i, "%s[%s] = %s\n" % (name, repr(k), repr(v) ) )
+          i = i+1
+      else:
+        new_line = line.replace( pattern, repr(subst) )
+        lines[i] = new_line
+
 
 def generate( path, calc_case, med_file, med_groups_regions, z_undef, interp ):
-       f = open( path, "w" )
-       tf = open( hydro_solver_root+"/interpolz.template", "r" )
-       templ = tf.readlines()
-       
-       replace( templ, "<case_name_from_dlg>", calc_case )
-       replace( templ, "<MED_file_path_from_dlg>", med_file )
-       replace( templ, "<dictGroupRegion>", med_groups_regions )
-       replace( templ, "<z_undef_value_from_dlg>", z_undef )
-       replace( templ, "<interpolation_method_value_from_dlg>", interp )
-               
-       for line in templ:
-               f.write( line )
-       f.close()
+  f = open( path, "w" )
+  tf = open( hydro_solver_root+"/interpolz.template", "r" )
+  templ = tf.readlines()
+
+  replace( templ, "<case_name_from_dlg>", calc_case )
+  replace( templ, "<MED_file_path_from_dlg>", med_file )
+  replace( templ, "<dictGroupRegion>", med_groups_regions )
+  replace( templ, "<z_undef_value_from_dlg>", z_undef )
+  replace( templ, "<interpolation_method_value_from_dlg>", interp )
+
+  for line in templ:
+    f.write( line )
+  f.close()
 
 
 if __name__=='__main__':
index c15d84d672a6cc053c65c8c7b404b7d84515f606..2f5c5bc4e36a81c8cb0e79f0b8e4877bb1ee0991 100644 (file)
@@ -1,8 +1,8 @@
 
 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['MED3HOME'], 'lib/python2.7/site-packages/med'))
 hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro')
-sys.path.append(hydro_solver_root)
+#sys.path.append(hydro_solver_root)
 
 import salome
 salome.salome_init()
@@ -29,6 +29,7 @@ def get_med_groups( file_path ):
     mesh1 = meshes[0]
     try:
         groups = list(MEDLoader.MEDLoader_GetMeshGroupsNames(file_path, mesh1))
+
     except:
         return []
     return groups
@@ -43,12 +44,12 @@ def get_hydro_regions( calc_case_name ):
       for r in regions:
         rname = r.GetName()
         regions_names.append( str(rname) )
-      
-      shape_groups = case.GetGeometryGroups()
-      for sg in shape_groups:
-          sgname = sg.GetName()
-          regions_names.append( sgname )
-      
+
+      #shape_groups = case.GetGeometryGroups()
+      #for sg in shape_groups:
+          #sgname = sg.GetName()
+          #regions_names.append( sgname )
+
       return regions_names
     else:
       return []
@@ -64,7 +65,7 @@ def get_selected_calc_case():
             if isinstance(case, HYDROPy.HYDROData_CalculationCase):
                 return name
     return None
-    
+
 class InterpolzDlg( QtGui.QDialog ):
     def __init__(self, parent = None):
         QtGui.QDialog.__init__( self, parent )
@@ -79,34 +80,35 @@ class InterpolzDlg( QtGui.QDialog ):
         self.UndefZ.setRange( -100000, 100000 )
         self.UndefZ.setValue( -9999 )
         self.InterpMethod.addItem( "Interpolation at the nearest point" )
+        self.InterpMethod.addItem( "Linear interpolation on a cloud triangulation" )
         self.connect( self.ApplyClose, QtCore.SIGNAL( "clicked()" ), self.onApplyClose )
         self.connect( self.Apply, QtCore.SIGNAL( "clicked()" ), self.onApply )
         self.connect( self.Close, QtCore.SIGNAL( "clicked()" ), self.onClose )
         self.connect( self.Help, QtCore.SIGNAL( "clicked()" ), self.onHelp )
-         
+
     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()) )
       self.onMEDChanged()
-        
+
     def onMEDChanged( self ):
       self.med_groups = get_med_groups( str(self.MEDFile.text()) )
       #print self.med_groups
@@ -117,8 +119,9 @@ class InterpolzDlg( QtGui.QDialog ):
           self.Groups.setItem( i, 0, QtGui.QTableWidgetItem() )
           self.Groups.setItem( i, 1, QtGui.QTableWidgetItem() )
         self.Groups.item( i, 0 ).setText( self.med_groups[i] )
-        
+
         cb = QtGui.QComboBox( self.Groups )
+        cb.addItem( 'None' )
         for r in self.regions:
           cb.addItem( r )
         self.Groups.setCellWidget( i, 1, cb )
@@ -126,7 +129,7 @@ class InterpolzDlg( QtGui.QDialog ):
     def onApplyClose( self ):
         if self.onApply():
             self.onClose()
-        
+
     def onApply( self ):
         path = str(self.OutputPath.text())
         calc_case = str(self.CalcCase.text())
@@ -135,11 +138,11 @@ class InterpolzDlg( QtGui.QDialog ):
         for i in range( 0, self.Groups.rowCount() ):
             med_group = str( self.Groups.item( i, 0 ).text() )
             hydro_reg = str( self.Groups.cellWidget( i, 1 ).currentText() )
-            if len(med_group)>0 and len(hydro_reg)>0:
+            if len(med_group)>0 and len(hydro_reg)>0 and hydro_reg != 'None':
                 med_groups_regions[med_group] = hydro_reg
         z_undef = self.UndefZ.value()
         interp = str(self.InterpMethod.currentText())
-        
+
         msg = ""
         if len(path)==0:
             msg = "Please input the output path"
@@ -151,18 +154,21 @@ class InterpolzDlg( QtGui.QDialog ):
             msg = "Please fill groups table"
         elif len(interp)==0:
             msg = "Please choose interpolation method"
-        
+
         result = False
         if len(msg)==0:
-            generate( path, calc_case, med_file, med_groups_regions, z_undef, interp )
+            iinterp = 0
+            if "Linear" in interp:
+              iinterp =1
+            generate( path, calc_case, med_file, med_groups_regions, z_undef, iinterp )
             msg = "InterpolZ script is successfully generated"
             result = True
-            
+
         QtGui.QMessageBox.information( self, "", msg )
         return result
-        
+
     def onClose( self ):
-        self.close()     
+        self.close()
 
     """Shows help page"""
     def onHelp( self ):
index e6fc7f98433bb8c0ec6242b71bd1f6e8de1f5b5e..181eca976053d9c9db0c19b7b106a9c80438a772 100644 (file)
@@ -30,53 +30,53 @@ SET(INSTALL_DIR ${SALOME_INSTALL_PYTHON}/salome/hydro/telemac2d)
 
 SALOME_INSTALL_SCRIPTS("${PYFILES}" ${INSTALL_DIR})
 
-# This macro is used to transform the list of libraries against which the
-# module is linked into a list of linker flags (-L and -l). If we just use the
-# list of libraries in the linker command, the full path of the libraries is
-# registered in the module dependencies, so it doesn't work when the installation
-# is moved.
-MACRO(LIB_LIST_TO_LINKER_FLAGS LINKER_FLAGS_VAR LIB_LIST)
-  SET(${LINKER_FLAGS_VAR})
-  FOREACH(LIB ${LIB_LIST})
-    GET_FILENAME_COMPONENT(DIRNAME ${LIB} PATH)
-    # Get the library filename without the shortest extension. We can't use
-    # command GET_FILENAME_COMPONENT with option NAME_WE because it returns
-    # the filename without the longest extension. For example, we need to get
-    # "libpython2.7" from "libpython2.7.so" and not "libpython2".
-    GET_FILENAME_COMPONENT(LIBFILENAME ${LIB} NAME)
-    STRING(FIND ${LIBFILENAME} "." DOTPOS REVERSE)
-    STRING(SUBSTRING ${LIBFILENAME} 0 ${DOTPOS} FILENAME_WO_EXT)
-    STRING(SUBSTRING ${FILENAME_WO_EXT} 3 -1 LIBNAME)
-    LIST(APPEND ${LINKER_FLAGS_VAR} "-L${DIRNAME}" "-l${LIBNAME}")
-  ENDFOREACH(LIB ${LIB_LIST})
-ENDMACRO(LIB_LIST_TO_LINKER_FLAGS)
-
-SET (MEDFILE_LIBRARIES ${MEDFILE_ROOT_DIR}/lib/libmedC.so)
-LIB_LIST_TO_LINKER_FLAGS(LINKER_FLAGS "${TELEMAC_LIBRARIES};${HDF5_hdf5_LIBRARY};${MEDFILE_LIBRARIES};${PYTHON_LIBRARY}")
-
-# Python wrapping for Telemac2D created with f2py
-SET(T2D_WRAP_API_LIB _apit2d.so)
-SET(T2D_WRAP_API_PYF_FILE apit2d.pyf)
-SET(T2D_WRAP_API_SRC_FILES ${TELEMAC_API_SRC_DIR}/api_handle_var_t2d.f90
-                           ${TELEMAC_API_SRC_DIR}/api_interface_t2d.f90
-                           ${TELEMAC_API_SRC_DIR}/api_handle_error_t2d.f90)
-
-# This sed string is used to add necessary definitions to the pyf file
-SET(SEDSTRING "s:python module _apit2d ! in:python module _apit2d ! in\\nusercode '''const int nb_var_t2d=100\\;\\n''':")
-
-ADD_CUSTOM_COMMAND(OUTPUT ${T2D_WRAP_API_LIB}
-                   COMMAND f2py -c ${T2D_WRAP_API_PYF_FILE} -I${TELEMAC_INCLUDE_DIR} ${LINKER_FLAGS}
-                   MAIN_DEPENDENCY ${T2D_WRAP_API_PYF_FILE}
-                  )
-
-ADD_CUSTOM_COMMAND(OUTPUT ${T2D_WRAP_API_PYF_FILE}
-                   COMMAND f2py -h ${T2D_WRAP_API_PYF_FILE} -m _apit2d ${T2D_WRAP_API_SRC_FILES}
-                           skip: get_boolean_t2d_d get_double_t2d_d get_integer_t2d_d get_string_t2d_d get_var_size_t2d_d
-                                 set_boolean_t2d_d set_double_t2d_d set_integer_t2d_d set_string_t2d_d :
-                   COMMAND sed -i -e \"${SEDSTRING}\" ${T2D_WRAP_API_PYF_FILE}
-                   MAIN_DEPENDENCY ${T2D_WRAP_API_SRC_FILES}
-                  )
-
-ADD_CUSTOM_TARGET(BUILD_T2D_WRAP_API_LIB ALL DEPENDS ${T2D_WRAP_API_LIB})
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${T2D_WRAP_API_LIB} DESTINATION ${INSTALL_DIR})
-
+# This macro is used to transform the list of libraries against which the
+# module is linked into a list of linker flags (-L and -l). If we just use the
+# list of libraries in the linker command, the full path of the libraries is
+# registered in the module dependencies, so it doesn't work when the installation
+# is moved.
+MACRO(LIB_LIST_TO_LINKER_FLAGS LINKER_FLAGS_VAR LIB_LIST)
+  SET(${LINKER_FLAGS_VAR})
+  FOREACH(LIB ${LIB_LIST})
+    GET_FILENAME_COMPONENT(DIRNAME ${LIB} PATH)
+    # Get the library filename without the shortest extension. We can't use
+    # command GET_FILENAME_COMPONENT with option NAME_WE because it returns
+    # the filename without the longest extension. For example, we need to get
+    # "libpython2.7" from "libpython2.7.so" and not "libpython2".
+    GET_FILENAME_COMPONENT(LIBFILENAME ${LIB} NAME)
+    STRING(FIND ${LIBFILENAME} "." DOTPOS REVERSE)
+    STRING(SUBSTRING ${LIBFILENAME} 0 ${DOTPOS} FILENAME_WO_EXT)
+    STRING(SUBSTRING ${FILENAME_WO_EXT} 3 -1 LIBNAME)
+    LIST(APPEND ${LINKER_FLAGS_VAR} "-L${DIRNAME}" "-l${LIBNAME}")
+  ENDFOREACH(LIB ${LIB_LIST})
+ENDMACRO(LIB_LIST_TO_LINKER_FLAGS)
+#
+# SET (MEDFILE_LIBRARIES ${MED3HOME}/lib/libmedC.so)
+LIB_LIST_TO_LINKER_FLAGS(LINKER_FLAGS "${TELEMAC_LIBRARIES};${HDF5_hdf5_LIBRARY};${MEDFILE_LIBRARIES};${PYTHON_LIBRARY}")
+#
+# Python wrapping for Telemac2D created with f2py
+SET(T2D_WRAP_API_LIB _apit2d.so)
+SET(T2D_WRAP_API_PYF_FILE apit2d.pyf)
+SET(T2D_WRAP_API_SRC_FILES ${TELEMAC_API_SRC_DIR}/api_handle_var_t2d.f90
+                           ${TELEMAC_API_SRC_DIR}/api_interface_t2d.f90
+                           ${TELEMAC_API_SRC_DIR}/api_handle_error_t2d.f90)
+#
+# This sed string is used to add necessary definitions to the pyf file
+SET(SEDSTRING "s:python module _apit2d ! in:python module _apit2d ! in\\nusercode '''const int nb_var_t2d=100\\;\\n''':")
+#
+ADD_CUSTOM_COMMAND(OUTPUT ${T2D_WRAP_API_LIB}
+                   COMMAND f2py -c ${T2D_WRAP_API_PYF_FILE} -I${TELEMAC_INCLUDE_DIR} ${LINKER_FLAGS}
+                   MAIN_DEPENDENCY ${T2D_WRAP_API_PYF_FILE}
+                  )
+#
+ADD_CUSTOM_COMMAND(OUTPUT ${T2D_WRAP_API_PYF_FILE}
+                   COMMAND f2py -h ${T2D_WRAP_API_PYF_FILE} -m _apit2d ${T2D_WRAP_API_SRC_FILES}
+                           skip: get_boolean_t2d_d get_double_t2d_d get_integer_t2d_d get_string_t2d_d get_var_size_t2d_d
+                                 set_boolean_t2d_d set_double_t2d_d set_integer_t2d_d set_string_t2d_d :
+                   COMMAND sed -i -e \"${SEDSTRING}\" ${T2D_WRAP_API_PYF_FILE}
+                   MAIN_DEPENDENCY ${T2D_WRAP_API_SRC_FILES}
+                  )
+#
+ADD_CUSTOM_TARGET(BUILD_T2D_WRAP_API_LIB ALL DEPENDS ${T2D_WRAP_API_LIB})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${T2D_WRAP_API_LIB} DESTINATION ${INSTALL_DIR})
+#
index b38b0c07ba5bb815ebad9fc57dbf75828626ce13..150bc6dd4107b11c181fd8202bc0834a87f1b923 100644 (file)
@@ -6,8 +6,8 @@ from PyQt4 import QtGui
 cur_dir = os.path.dirname(os.path.realpath(__file__))
 data_dir = os.path.join(cur_dir, "data")
 
-hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome')
-sys.path.append(hydro_solver_root)
+#hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome')
+#sys.path.append(hydro_solver_root)
 from BndConditionsDialog import BoundaryConditionsDialog
 
 # Show the dialog
index 1ea91eb60c09b5b97fbf1afc8c47756ced552cf7..bcdba0741bf0f2286f353082c910e03f7a945754 100644 (file)
@@ -8,52 +8,52 @@ import unittest
 cur_dir = os.path.dirname(os.path.realpath(__file__))
 data_dir = os.path.join(cur_dir, "data")
 
-hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome')
-sys.path.append(hydro_solver_root)
+#hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome')
+#sys.path.append(hydro_solver_root)
 import boundaryConditions
 
+
 class TestBoundaryConditions(unittest.TestCase):
     def testReadPresets(self):
         file_path = os.path.join(data_dir, "bnd_conditions_presets.txt")
         reader = boundaryConditions.PresetReader(file_path)
         presets = reader.read()
         self.assertEqual(3, len(presets))
-        
+
         self.assertEqual(True, presets.has_key("Closed boundaries/walls"))
         self.assertEqual((2,2,2,2), presets["Closed boundaries/walls"])
-        
+
         self.assertEqual(True, presets.has_key("Incident waves"))
         self.assertEqual((1,1,1,None), presets["Incident waves"])
-        
+
         self.assertEqual(True, presets.has_key("Free T"))
         self.assertEqual((None,None,None,4), presets["Free T"])
-        
+
     def testRead(self):
         file_path = os.path.join(data_dir, "bnd_conditions1.cli")
         reader = boundaryConditions.BoundaryConditionReader(file_path)
         conditions = reader.read()
         self.assertEqual(7, len(conditions))
         self.assertEqual(0, len(reader.errors))
-        
+
     def testWrite(self):
         file_path = os.path.join(tempfile.gettempdir(), "bnd_conditions_w.cli")
         writer = boundaryConditions.BoundaryConditionWriter(file_path)
-        
+
         cnd1 = boundaryConditions.BoundaryCondition(5, 4, 4, 4, "group1")
         cnd2 = boundaryConditions.BoundaryCondition(4, 5, 5, 5, "group2")
-        
+
         writer.write([cnd1, cnd2])
         self.assertEqual(True, os.path.exists(file_path))
         self.assertEqual(0, len(writer.errors))
-        
+
         os.remove(file_path)
-        
+
     def testReadWrite(self):
         input_file_path = os.path.join(data_dir, "bnd_conditions1.cli")
         reader = boundaryConditions.BoundaryConditionReader(input_file_path)
         conditions = reader.read()
-        
+
         output_file_path = os.path.join(tempfile.gettempdir(), "bnd_conditions1_w.cli")
         writer = boundaryConditions.BoundaryConditionWriter(output_file_path)
         writer.write(conditions)
@@ -62,5 +62,5 @@ class TestBoundaryConditions(unittest.TestCase):
             self.assertEqual(True, filecmp.cmp(input_file_path, output_file_path))
         finally:
             os.remove(output_file_path)
-        
+
 unittest.main()
\ No newline at end of file