]> SALOME platform Git repositories - modules/hydrosolver.git/commitdiff
Salome HOME
refs #1808 lot 18 (see also HYDRO - interpolZ)
authorisn <isn@opencascade.com>
Mon, 13 Aug 2018 16:04:02 +0000 (19:04 +0300)
committerisn <isn@opencascade.com>
Fri, 7 Sep 2018 09:40:00 +0000 (12:40 +0300)
src/salome_hydro/generate_interpolz.py
src/salome_hydro/interpolz.template
src/salome_hydro/interpolz.ui
src/salome_hydro/interpolz_gui.py

index 52f4d076f340bc8736363125f5cf9a77e05414b6..030eb80864c86d35f322d90b9056b0bb32acf430 100644 (file)
@@ -27,7 +27,7 @@ def replace( lines, pattern, subst ):
         lines[i] = new_line
 
 
-def generate( path, calc_case, med_file, med_groups_regions, z_undef, interp ):
+def generate( path, calc_case, med_file, med_groups_regions, z_undef, regions_interp_method ):
   f = open( path, "w" )
   tf = open( hydro_solver_root+"/interpolz.template", "r" )
   templ = tf.readlines()
@@ -36,7 +36,7 @@ def generate( path, calc_case, med_file, med_groups_regions, z_undef, interp ):
   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 )
+  replace( templ, "<dict_region_interpolation_method>", regions_interp_method )
 
   for line in templ:
     f.write( line )
@@ -44,4 +44,4 @@ def generate( path, calc_case, med_file, med_groups_regions, z_undef, interp ):
 
 
 if __name__=='__main__':
-    generate( "test_interpolz.py", "case_1", "mesh.med", {"group_1":"reg_1", "group_2":"reg_2"}, -9999, "linear" )
+    generate( "test_interpolz.py", "case_1", "mesh.med", {"group_1":"reg_1", "group_2":"reg_2"}, -9999, {"reg_1" : "0", "reg_2": "1"} )
index e045a12e5aa207647203dc772ca75bf09f8acb25..aca2687513f30c981cbfe8e7dbec7f933b1c05d4 100644 (file)
@@ -14,8 +14,8 @@ medFile = <MED_file_path_from_dlg>
 zUndef = <z_undef_value_from_dlg>
 
 # Interpolation method
-interpolMethod = <interpolation_method_value_from_dlg>
+<dict_region_interpolation_method>
 
 # Z interpolation on the bathymetry/altimetry on the mesh nodes
-statZ = interpolZ(caseName, medFile, dictGroupRegion, zUndef,interpolMethod)
+statZ = interpolZ(caseName, medFile, dictGroupRegion, zUndef, dict_region_interpolation_method)
 
index 58c9743ad921177839ae892076009b5b18484634..e9be98f86a93ec28d96912d68a4303457c0465de 100644 (file)
           <string>Region</string>
          </property>
         </column>
+        <column>
+         <property name="text">
+          <string>Interpolation method</string>
+         </property>
+        </column>
        </widget>
       </item>
      </layout>
       <property name="spacing">
        <number>0</number>
       </property>
-      <property name="margin">
+      <property name="leftMargin">
+       <number>0</number>
+      </property>
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
        <number>0</number>
       </property>
       <item>
index 29365218685e9a82af105af36dee861d840ec70b..3d4a008c7b0d860d1b392259a24c2e419b8dfdcf 100644 (file)
@@ -98,6 +98,7 @@ class InterpolzDlg( QDialog ):
         self.UndefZ.setValue( -9999 )
         self.InterpMethod.addItem( "Interpolation at the nearest point" )
         self.InterpMethod.addItem( "Linear interpolation on a cloud triangulation" )
+        self.InterpMethod.currentIndexChanged.connect(self.onInterpChanged)
         self.ApplyClose.clicked.connect(self.onApplyClose)
         self.Apply.clicked.connect(self.onApply)
         self.Close.clicked.connect(self.onClose)
@@ -135,6 +136,7 @@ class InterpolzDlg( QDialog ):
         if self.Groups.item( i, 0 ) is None:
           self.Groups.setItem( i, 0, QTableWidgetItem() )
           self.Groups.setItem( i, 1, QTableWidgetItem() )
+          self.Groups.setItem( i, 2, QTableWidgetItem() )
         self.Groups.item( i, 0 ).setText( self.med_groups[i] )
 
         cb = QComboBox( self.Groups )
@@ -143,6 +145,17 @@ class InterpolzDlg( QDialog ):
           cb.addItem( r )
         self.Groups.setCellWidget( i, 1, cb )
 
+        icb = QComboBox( self.Groups )
+        icb.addItem( 'Interpolation at the nearest point' )
+        icb.addItem( 'Linear interpolation on a cloud triangulation' )
+        self.Groups.setCellWidget( i, 2, icb )
+
+    def onInterpChanged( self ):
+      n = self.Groups.rowCount()
+      for i in range( 0, n ):
+        icb = self.Groups.cellWidget(i, 2)
+        icb.setCurrentIndex(self.InterpMethod.currentIndex())
     def onApplyClose( self ):
         if self.onApply():
             self.onClose()
@@ -152,13 +165,16 @@ class InterpolzDlg( QDialog ):
         calc_case = str(self.CalcCase.text())
         med_file = str(self.MEDFile.text())
         med_groups_regions = {}
+        regions_interp_method = {}
         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 and hydro_reg != 'None' :
                 med_groups_regions[med_group] = hydro_reg
+            interp_ind = str( self.Groups.cellWidget( i, 2 ).currentIndex() )
+            regions_interp_method[hydro_reg] = interp_ind
         z_undef = self.UndefZ.value()
-        interp = str(self.InterpMethod.currentText())
+        #interp = str(self.InterpMethod.currentText())
 
         msg = ""
         if len(path)==0:
@@ -169,15 +185,16 @@ class InterpolzDlg( QDialog ):
             msg = "Please choose the MED file"
         elif len(med_groups_regions)==0:
             msg = "Please fill groups table"
-        elif len(interp)==0:
-            msg = "Please choose interpolation method"
+        #elif len(interp)==0:
+        #    msg = "Please choose interpolation method"
 
         result = False
         if len(msg)==0:
             iinterp = 0
-            if 'Linear' in interp:
-              iinterp = 1
-            generate( path, calc_case, med_file, med_groups_regions, z_undef, iinterp )
+            #if 'Linear' in interp:
+            #  iinterp = 1
+            #generate( path, calc_case, med_file, med_groups_regions, z_undef, iinterp )
+            generate( path, calc_case, med_file, med_groups_regions, z_undef, regions_interp_method )
             msg = "InterpolZ script is successfully generated"
             result = True