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()
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 )
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"} )
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)
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 )
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()
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:
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