From: isn Date: Mon, 13 Aug 2018 16:04:02 +0000 (+0300) Subject: refs #1808 lot 18 (see also HYDRO - interpolZ) X-Git-Tag: HYDRO_V2_0_0^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=70a085460de382000c89df3dc0da9e8abd5d424f;p=modules%2Fhydrosolver.git refs #1808 lot 18 (see also HYDRO - interpolZ) --- diff --git a/src/salome_hydro/generate_interpolz.py b/src/salome_hydro/generate_interpolz.py index 52f4d07..030eb80 100644 --- a/src/salome_hydro/generate_interpolz.py +++ b/src/salome_hydro/generate_interpolz.py @@ -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 ) replace( templ, "", med_groups_regions ) replace( templ, "", z_undef ) - replace( templ, "", interp ) + replace( templ, "", 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"} ) diff --git a/src/salome_hydro/interpolz.template b/src/salome_hydro/interpolz.template index e045a12..aca2687 100644 --- a/src/salome_hydro/interpolz.template +++ b/src/salome_hydro/interpolz.template @@ -14,8 +14,8 @@ medFile = zUndef = # Interpolation method -interpolMethod = + # 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) diff --git a/src/salome_hydro/interpolz.ui b/src/salome_hydro/interpolz.ui index 58c9743..e9be98f 100644 --- a/src/salome_hydro/interpolz.ui +++ b/src/salome_hydro/interpolz.ui @@ -120,6 +120,11 @@ Region + + + Interpolation method + + @@ -137,7 +142,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 diff --git a/src/salome_hydro/interpolz_gui.py b/src/salome_hydro/interpolz_gui.py index 2936521..3d4a008 100644 --- a/src/salome_hydro/interpolz_gui.py +++ b/src/salome_hydro/interpolz_gui.py @@ -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