EDIT_BOUNDARY_CONDITIONS_FILE_ID = 956
GENERATE_INTERPOLZ_PY_ID = 957
GEN_TELEMAC2D_PYTHON_ID = 958
+ GEN_TELEMAC2D_YACS_ID = 959
def __init__( self ):
# create top-level menu
sgPyQt.createAction( GUIcontext.GEN_TELEMAC2D_PYTHON_ID, "Generate Python script",
"Generate Python script",
- "Run Telemac2D solver to compute the case" )
+ "Generate a Python script from the eficas date" )
+ sgPyQt.createAction( GUIcontext.GEN_TELEMAC2D_YACS_ID, "Generate YACS script",
+ "Generate YACS script",
+ "Generate a YACS script from the eficas date" )
sgPyQt.createAction( GUIcontext.RUN_TELEMAC2D_ID, "Compute case", "Compute case",
"Run Telemac2D solver to compute the case" )
sgPyQt.createAction( GUIcontext.EDIT_TELEMAC2D_CASE_ID, "Edit case", "Edit case",
popup.addAction(sgPyQt.action(GUIcontext.EDIT_TELEMAC2D_CASE_ID))
popup.addAction(sgPyQt.action(GUIcontext.RUN_TELEMAC2D_ID))
popup.addAction(sgPyQt.action(GUIcontext.GEN_TELEMAC2D_PYTHON_ID))
+ popup.addAction(sgPyQt.action(GUIcontext.GEN_TELEMAC2D_YACS_ID))
elif selectedType == hydro_study.COUPLING1D2D_CASE_TYPE_ID:
popup.addAction(sgPyQt.action(GUIcontext.EDIT_COUPLING1D2D_CASE_ID))
popup.addAction(sgPyQt.action(GUIcontext.OPEN_SCHEMA_IN_YACS_ID))
with wait_cursor:
ed = hydro_study.HydroStudyEditor()
sobj = get_and_check_selected_file_path()
- print sobj
- ed.find_or_create_telemac2d_case(sobj)
+ ed.generate_study_script(sobj)
except SALOME.SALOME_Exception, exc:
salome.sg.updateObjBrowser( 0 )
msg = unicode(QApplication.translate("generate_telemac2d_python",
msg += "\n" + exc.details.text
raise HSGUIException(msg)
+###
+# Generate a python script from the eficas file
+###
+def generate_telemac2d_yacs():
+ try:
+ with wait_cursor:
+ ed = hydro_study.HydroStudyEditor()
+ sobj = get_and_check_selected_file_path()
+ ed.generate_study_yacs(sobj)
+ except SALOME.SALOME_Exception, exc:
+ salome.sg.updateObjBrowser( 0 )
+ msg = unicode(QApplication.translate("generate_telemac2d_yacs",
+ "An error happened while trying to generate telemac2d Python script:"))
+ msg += "\n" + exc.details.text
+ raise HSGUIException(msg)
###
# Open Eficas for 1D / 2D Coupling to create a new coupling case
GUIcontext.CREATE_TELEMAC2D_CASE_ID: create_telemac2d_case,
GUIcontext.RUN_TELEMAC2D_ID: run_telemac2d,
GUIcontext.GEN_TELEMAC2D_PYTHON_ID: generate_telemac2d_python,
+ GUIcontext.GEN_TELEMAC2D_YACS_ID: generate_telemac2d_yacs,
GUIcontext.EDIT_TELEMAC2D_CASE_ID: edit_telemac2d_case,
GUIcontext.CREATE_COUPLING1D2D_CASE_ID: create_coupling1d2d_case,
GUIcontext.EDIT_COUPLING1D2D_CASE_ID: edit_coupling1d2d_case,
icon = TELEMAC2D_ICON,
comment = str(filePath),
typeId = TELEMAC2D_CASE_TYPE_ID)
- # Create "Variables" item
- from TelApy.api.generate_study import generate_yacs
+
+ def generate_study_script(self, filePath)
+ """
+ Generating a python script from the eficas info
+ """
+ # Create "Python script" item
+ from TelApy.api.generate_study import generate_study_script
+ with open(filePath) as jdcfile:
+ jdc = jdcfile.read()
+ params = jdc_to_dict(jdc, ["TELEMAC2D", "_F"])
+
+ python_script = generate_study_script(params)
+ print python_script
+
+ def generate_study_yacs(self, filePath)
+ """
+ Generating a yacs file from the eficas info
+ """
+ # Create "Python script" item
+ from TelApy.api.generate_study import generate_yacs_study
with open(filePath) as jdcfile:
jdc = jdcfile.read()
params = jdc_to_dict(jdc, ["TELEMAC2D", "_F"])
- yacs_scheme = generate_yacs(params)
+ yacs_scheme = generate_yacs_study(params)
+ file_dir = os.path.basename(filePath)
+ root, sfx = filePath.splitext()
+ yacs_file = os.path.join(file_dir,root+".xml")
+
+ print yacs_file
print yacs_scheme
- # TODO: Replace that by adding yacs scheme and python script ?
def find_or_create_coupling1d2d_case(self, filePath):
self.find_or_create_hydro_component()