Salome HOME
Merge remote branch 'origin/V8_5_asterstudy'
[modules/smesh.git] / src / Tools / padder / spadderpy / gui / plugindialog.py
index f576bf317064666452c049c6db361f941b55dddb..cb14896ab3aa3f7194ab4efa53a0e962cd8afb7d 100644 (file)
 
 from qtsalome import QDialog, QIcon, Qt
 
-from plugindialog_ui import Ui_PluginDialog
-from .inputdialog import InputDialog
-from .inputdata import InputData
+from salome.smesh.spadder.gui.plugindialog_ui import Ui_PluginDialog
+from salome.smesh.spadder.gui.inputdialog import InputDialog, INPUTDATA_KEY_FILES, INPUTDATA_KEY_PARAM
+from salome.smesh.spadder.gui.inputdialog import PARAM_KEY_NBITER, PARAM_KEY_RMAXRMIN
+from salome.smesh.spadder.gui.inputdata import InputData
 # __GBO__: uncomment this line and comment the previous one to use the
 # demo input dialog instead of the real one.
 #from demoinputdialog import InputDialog
@@ -37,7 +38,7 @@ from salome.kernel.uiexception import AdminException
 from omniORB import CORBA
 import SMESH
 from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
 import MESHJOB
 
 gui_states = ["CAN_SELECT", "CAN_COMPUTE", "CAN_REFRESH", "CAN_PUBLISH"]
@@ -99,10 +100,10 @@ class PluginDialog(QDialog):
 
     def setupJobManager(self):
         '''
-        This function configures the jobmanager by transmiting the
+        This function configures the jobmanager by transmitting the
         parameters required for a local execution and a remote
         execution. The choice between "local" and "remote" is done at
-        the initialize step, by specifing the name of the resource to
+        the initialize step, by specifying the name of the resource to
         be used.
         '''
         # We first
@@ -210,7 +211,7 @@ class PluginDialog(QDialog):
         name. This returns the filename.
         '''
         filename=str("/tmp/padder_inputfile_"+meshName+".med")
-        meshObject.ExportToMEDX( filename, 0, SMESH.MED_V2_2, 1, 1 )
+        meshObject.ExportMED(filename, False, True, True)
         return filename
 
     def clear(self):
@@ -218,6 +219,7 @@ class PluginDialog(QDialog):
         This function clears the log area and the states of the buttons
         """
         self.__listInputData = []
+        self.__dictInputParameters = {}
         self.__ui.txtLog.clear()
         self.__setGuiState(["CAN_SELECT"])
         self.__isRunning = False
@@ -241,7 +243,10 @@ class PluginDialog(QDialog):
         windows to process the validation event (see the slot
         onProcessInput which is connected to this event).
         '''
-        self.__inputDialog.setData(self.__listInputData)
+        dictInputData = {}
+        dictInputData[INPUTDATA_KEY_FILES] = self.__listInputData
+        dictInputData[INPUTDATA_KEY_PARAM] = self.__dictInputParameters
+        self.__inputDialog.setData(dictInputData)
         self.__inputDialog.open()
 
     def onProcessInput(self):
@@ -252,7 +257,10 @@ class PluginDialog(QDialog):
         """
         # The processing simply consists in requesting the input data
         # from the dialog window.
-        self.__listInputData = self.__inputDialog.getData()
+        dictInputData = self.__inputDialog.getData()
+        self.__listInputData = dictInputData[INPUTDATA_KEY_FILES]
+        self.__dictInputParameters = dictInputData[INPUTDATA_KEY_PARAM]
+
         self.__ui.lblStatusBar.setText("Input data OK")
         self.__log("INF: Press \"Compute\" to start the job")
         self.__setGuiState(["CAN_SELECT", "CAN_COMPUTE"])
@@ -283,8 +291,16 @@ class PluginDialog(QDialog):
                 group_name = inputData.groupName)
             meshJobFileList.append(parameter)
 
+        # And to create a list of the additional parameters.
+        # WARN: the CORBA interface requires string values.
+        meshJobParameterList=[]
+        for inputParameterKey in self.__dictInputParameters:
+            value = self.__dictInputParameters[inputParameterKey]
+            parameter = MESHJOB.MeshJobParameter(name=inputParameterKey,value=str(value))
+            meshJobParameterList.append(parameter)
+
         jobManager = self.__getJobManager()
-        self.__jobid = jobManager.initialize(meshJobFileList, self.__configId)
+        self.__jobid = jobManager.initialize(meshJobFileList, meshJobParameterList, self.__configId)
         if self.__jobid < 0:
             self.__log("ERR: the job can't be initialized")
             self.__log("ERR: %s"%jobManager.getLastErrorMessage())
@@ -352,7 +368,7 @@ class PluginDialog(QDialog):
         medfilename = os.path.join(meshJobResults.results_dirname,
                                    meshJobResults.outputmesh_filename)
 
-        smesh.SetCurrentStudy(studyedit.getActiveStudy())
+        smesh.UpdateStudy()
         ([outputMesh], status) = smesh.CreateMeshesFromMED(medfilename)
 
         # By convention, the name of the output mesh in the study is
@@ -360,7 +376,7 @@ class PluginDialog(QDialog):
         meshname = 'padder_'+str(self.__jobid)
         smesh.SetName(outputMesh.GetMesh(), meshname)
         if salome.sg.hasDesktop():
-            salome.sg.updateObjBrowser(False)
+            salome.sg.updateObjBrowser()
 
         self.__ui.lblStatusBar.setText("Publication OK")
         self.__setGuiState(["CAN_SELECT"])