Back to index

salome-smesh  6.5.0
Public Member Functions | Private Member Functions | Private Attributes
spadderpy.gui.plugindialog.PluginDialog Class Reference
Inheritance diagram for spadderpy.gui.plugindialog.PluginDialog:
Inheritance graph
[legend]
Collaboration diagram for spadderpy.gui.plugindialog.PluginDialog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def setupJobManager
def viewInputFrame
def getInputFrame
def clear
def update
def onInput
def onProcessInput
def onCompute
def onRefresh
def onPublish
def onClear

Private Member Functions

def __setGuiState
def __getJobManager
def __log
def __exportMesh

Private Attributes

 __ui
 __configId
 __inputDialog
 __jobManager
 __listInputData
 __isRunning
 __jobid

Detailed Description

Definition at line 57 of file plugindialog.py.


Constructor & Destructor Documentation

def spadderpy.gui.plugindialog.PluginDialog.__init__ (   self,
  parent = None,
  name = None,
  modal = 0,
  fl = 0 
)

Definition at line 59 of file plugindialog.py.

00059 
00060     def __init__(self,parent = None,name = None,modal = 0,fl = 0):
00061         QDialog.__init__(self,parent)
00062         # Set up the user interface from Designer.
00063         self.__ui = Ui_PluginDialog()
00064         self.__ui.setupUi(self)
00065 
00066         # The default display strategy is to use a separate dialog box
00067         # to select the input data.
00068         self.viewInputFrame(False)
00069 
00070         # The icon are supposed to be located in the plugin folder,
00071         # i.e. in the same folder than this python module file
00072         iconfolder=os.path.dirname(os.path.abspath(__file__))
00073         icon = QIcon()
00074         icon.addFile(os.path.join(iconfolder,"input.png"))
00075         self.__ui.btnInput.setIcon(icon)
00076         icon = QIcon()
00077         icon.addFile(os.path.join(iconfolder,"compute.png"))
00078         self.__ui.btnCompute.setIcon(icon)
00079         icon = QIcon()
00080         icon.addFile(os.path.join(iconfolder,"refresh.png"))
00081         self.__ui.btnRefresh.setIcon(icon)
00082         icon = QIcon()
00083         icon.addFile(os.path.join(iconfolder,"publish.png"))
00084         self.__ui.btnPublish.setIcon(icon)
00085         icon = QIcon()
00086         icon.addFile(os.path.join(iconfolder,"clear.png"))
00087         self.__ui.btnClear.setIcon(icon)
00088 
00089         # Then, we can connect the slot to there associated button event
00090         self.connect(self.__ui.btnInput,       SIGNAL('clicked()'), self.onInput )
00091         self.connect(self.__ui.btnCompute,     SIGNAL('clicked()'), self.onCompute )
00092         self.connect(self.__ui.btnRefresh,     SIGNAL('clicked()'), self.onRefresh )
00093         self.connect(self.__ui.btnPublish,     SIGNAL('clicked()'), self.onPublish )
00094         self.connect(self.__ui.btnClear,       SIGNAL('clicked()'), self.onClear )
00095 
00096         self.clear()
00097 
00098         self.setupJobManager()
00099         


Member Function Documentation

def spadderpy.gui.plugindialog.PluginDialog.__exportMesh (   self,
  meshName,
  meshObject 
) [private]
This function exports the specified mesh object to a med
file whose name (basepath) is built from the specified mesh
name. This returns the filename.

Definition at line 206 of file plugindialog.py.

00206 
00207     def __exportMesh(self, meshName, meshObject):
00208         '''
00209         This function exports the specified mesh object to a med
00210         file whose name (basepath) is built from the specified mesh
00211         name. This returns the filename.
00212         '''
00213         filename=str("/tmp/padder_inputfile_"+meshName+".med")
00214         meshObject.ExportToMEDX( filename, 0, SMESH.MED_V2_2, 1 )
00215         return filename

Here is the caller graph for this function:

This function requests a pointer to the MeshJobManager
servant. Note that the component is loaded on first demand,
and then the reference is recycled.

Definition at line 175 of file plugindialog.py.

00175 
00176     def __getJobManager(self):
00177         """
00178         This function requests a pointer to the MeshJobManager
00179         servant. Note that the component is loaded on first demand,
00180         and then the reference is recycled.
00181         """
00182         if self.__dict__.has_key("__jobManager") and self.__jobManager is not None:
00183             return self.__jobManager
00184 
00185         # WARN: we first have to update the SALOME components catalog
00186         # with the SPADDER components (because they are not defined in
00187         # the SMESH catalog, and then they are not in the default
00188         # catalog)
00189         from salome.smesh import spadder
00190         spadder.loadSpadderCatalog()
00191         # Then we can load the MeshJobManager component
00192         component=salome.lcc.FindOrLoadComponent("FactoryServer","MeshJobManager")
00193         if component is None:
00194             msg="ERR: the SALOME component MeshJobManager can't be reached"
00195             self.__log(msg)
00196             raise AdminException(msg)
00197 
00198         self.__jobManager = component
00199         return self.__jobManager

Here is the call graph for this function:

Here is the caller graph for this function:

def spadderpy.gui.plugindialog.PluginDialog.__log (   self,
  message 
) [private]
This function prints the specified message in the log area

Definition at line 200 of file plugindialog.py.

00200 
00201     def __log(self, message):
00202         """
00203         This function prints the specified message in the log area
00204         """ 
00205         self.__ui.txtLog.append(message)

Here is the caller graph for this function:

def spadderpy.gui.plugindialog.PluginDialog.__setGuiState (   self,
  states = ["CAN_SELECT"] 
) [private]

Definition at line 154 of file plugindialog.py.

00154 
00155     def __setGuiState(self,states=["CAN_SELECT"]):
00156         if "CAN_SELECT" in states:
00157             self.__ui.btnInput.setEnabled(True)
00158         else:
00159             self.__ui.btnInput.setEnabled(False)
00160             
00161         if "CAN_COMPUTE" in states:
00162             self.__ui.btnCompute.setEnabled(True)
00163         else:
00164             self.__ui.btnCompute.setEnabled(False)
00165 
00166         if "CAN_REFRESH" in states:
00167             self.__ui.btnRefresh.setEnabled(True)
00168         else:
00169             self.__ui.btnRefresh.setEnabled(False)
00170 
00171         if "CAN_PUBLISH" in states:
00172             self.__ui.btnPublish.setEnabled(True)
00173         else:
00174             self.__ui.btnPublish.setEnabled(False)

Here is the caller graph for this function:

This function clears the log area and the states of the buttons

Definition at line 216 of file plugindialog.py.

00216 
00217     def clear(self):
00218         """
00219         This function clears the log area and the states of the buttons
00220         """
00221         self.__listInputData = []
00222         self.__ui.txtLog.clear()
00223         self.__setGuiState(["CAN_SELECT"])
00224         self.__isRunning = False
00225         self.__ui.lblStatusBar.setText("Ready")

Here is the caller graph for this function:

Definition at line 151 of file plugindialog.py.

00151 
00152     def getInputFrame(self):
00153         return self.__ui.frameInput
        
This function is the slot connected on the Clear button. It
erases data in the dialog box and cancel the current job if
one is running.

Definition at line 364 of file plugindialog.py.

00364 
00365     def onClear(self):
00366         """
00367         This function is the slot connected on the Clear button. It
00368         erases data in the dialog box and cancel the current job if
00369         one is running.
00370         """
00371         self.clear()
00372         
00373 
00374 
__dialog=None

Here is the call graph for this function:

This function is the slot connected to the Compute button. It
initializes a mesh computation job and start it using the
SALOME launcher.  

Definition at line 260 of file plugindialog.py.

00260 
00261     def onCompute(self):
00262         '''
00263         This function is the slot connected to the Compute button. It
00264         initializes a mesh computation job and start it using the
00265         SALOME launcher.  
00266         '''
00267         # We first have to create the list of parameters for the
00268         # initialize function. For that, we have to create the files
00269         # from the mesh objects:
00270         meshJobParameterList=[]
00271         concreteIndex=0
00272         for inputData in self.__listInputData:
00273             # For each input data, we have to create a
00274             # MeshJobParameter and add it to the list.
00275             filename  = self.__exportMesh(inputData.meshName, inputData.meshObject)
00276             if inputData.meshType == InputData.MESHTYPES.CONCRETE:
00277                 filetype = MESHJOB.MED_CONCRETE
00278             else:
00279                 filetype = MESHJOB.MED_STEELBAR
00280 
00281             parameter = MESHJOB.MeshJobParameter(
00282                 file_name  = filename,
00283                 file_type  = filetype,
00284                 group_name = inputData.groupName)
00285             meshJobParameterList.append(parameter)
00286 
00287         jobManager = self.__getJobManager()
00288         self.__jobid = jobManager.initialize(meshJobParameterList, self.__configId)
00289         if self.__jobid < 0:
00290             self.__log("ERR: the job can't be initialized")
00291             return
00292         self.__log("INF: the job has been initialized with jobid = "+str(self.__jobid))
00293         
00294         startOk = jobManager.start(self.__jobid)
00295         if not startOk:
00296             self.__log("ERR: the job with jobid = "+str(self.__jobid)+" can't be started")
00297             return
00298         self.__log("INF: the job "+str(self.__jobid)+" has been started")
00299         self.__ui.lblStatusBar.setText("Submission OK")
00300         self.__setGuiState(["CAN_REFRESH"])
00301         self.__isRunning = True

Here is the call graph for this function:

This function is the slot connected to the Input button
(signal clicked()). It opens the dialog window to input
data. The dialog is opened in a window modal mode so that the
SALOME study objects can be selected. In conterpart, this
class must listen to signals emitted by the child dialog
windows to process the validation event (see the slot
onProcessInput which is connected to this event).

Definition at line 234 of file plugindialog.py.

00234 
00235     def onInput(self):
00236         '''
00237         This function is the slot connected to the Input button
00238         (signal clicked()). It opens the dialog window to input
00239         data. The dialog is opened in a window modal mode so that the
00240         SALOME study objects can be selected. In conterpart, this
00241         class must listen to signals emitted by the child dialog
00242         windows to process the validation event (see the slot
00243         onProcessInput which is connected to this event).
00244         '''
00245         self.__inputDialog.setData(self.__listInputData)
00246         self.__inputDialog.open()

This function is the slot connected to the signal
inputValidated(), emit by the input dialog window when it's
validated, i.e. OK is pressed and data are valid.

Definition at line 247 of file plugindialog.py.

00247 
00248     def onProcessInput(self):
00249         """
00250         This function is the slot connected to the signal
00251         inputValidated(), emit by the input dialog window when it's
00252         validated, i.e. OK is pressed and data are valid.
00253         """
00254         # The processing simply consists in requesting the input data
00255         # from the dialog window.
00256         self.__listInputData = self.__inputDialog.getData()
00257         self.__ui.lblStatusBar.setText("Input data OK")
00258         self.__log("INF: Press \"Compute\" to start the job")
00259         self.__setGuiState(["CAN_SELECT", "CAN_COMPUTE"])
        

Here is the call graph for this function:

This function is the slot connected on the Publish button. It
requests the mesh job manager to download the results data
from the computation resource host and load the med file in
the SALOME study. 

Definition at line 322 of file plugindialog.py.

00322 
00323     def onPublish(self):
00324         """
00325         This function is the slot connected on the Publish button. It
00326         requests the mesh job manager to download the results data
00327         from the computation resource host and load the med file in
00328         the SALOME study. 
00329         """
00330         jobManager = self.__getJobManager()
00331         state = jobManager.getState(self.__jobid)
00332         if state in run_states:
00333             self.__log("WRN: jobid = "+str(self.__jobid)+" is not finished (state="+str(state)+")")
00334             return
00335 
00336         if state not in end_states:
00337             self.__log("ERR: jobid = "+str(self.__jobid)+" ended abnormally with state="+str(state))
00338             return
00339 
00340         meshJobResults = jobManager.finalize(self.__jobid)
00341         if state == "ERROR":
00342             self.__log("ERR: jobid = "+str(self.__jobid)+" ended with error: "+meshJobResults.status)
00343             return
00344 
00345         logsdirname = os.path.join(meshJobResults.results_dirname, "logs")
00346         self.__log("INF:  jobid="+str(self.__jobid)+" ended normally   : "+meshJobResults.status)
00347         self.__log("INF:  jobid="+str(self.__jobid)+" see log files in : "+logsdirname)
00348 
00349         medfilename = os.path.join(meshJobResults.results_dirname,
00350                                    meshJobResults.outputmesh_filename)
00351 
00352         smesh.SetCurrentStudy(studyedit.getActiveStudy())
00353         ([outputMesh], status) = smesh.CreateMeshesFromMED(medfilename)
00354 
00355         # By convention, the name of the output mesh in the study is
00356         # build from a constant string 'padder' and the session jobid
00357         meshname = 'padder_'+str(self.__jobid)
00358         smesh.SetName(outputMesh.GetMesh(), meshname)
00359         if salome.sg.hasDesktop():
00360             salome.sg.updateObjBrowser(0)
00361 
00362         self.__ui.lblStatusBar.setText("Publication OK")
00363         self.__setGuiState(["CAN_SELECT"])

Here is the call graph for this function:

This function is the slot connected on the Refresh button. It
requests the mesh job manager to get the state of the job and
display it in the log area.

Definition at line 302 of file plugindialog.py.

00302 
00303     def onRefresh(self):
00304         """
00305         This function is the slot connected on the Refresh button. It
00306         requests the mesh job manager to get the state of the job and
00307         display it in the log area.
00308         """
00309         jobManager = self.__getJobManager()
00310         state = jobManager.getState(self.__jobid)
00311         self.__log("INF: job state = "+str(state))
00312         self.__ui.lblStatusBar.setText("")
00313         if state in run_states:
00314             return
00315 
00316         self.__isRunning = False
00317         if state == "FINISHED":
00318             self.__setGuiState(["CAN_PUBLISH"])
00319         else:
00320             self.__setGuiState(["CAN_SELECT"])
00321 

Here is the call graph for this function:

Here is the caller graph for this function:

This function configures the jobmanager by transmiting 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
be used.

Definition at line 100 of file plugindialog.py.

00100 
00101     def setupJobManager(self):
00102         '''
00103         This function configures the jobmanager by transmiting the
00104         parameters required for a local execution and a remote
00105         execution. The choice between "local" and "remote" is done at
00106         the initialize step, by specifing the name of the resource to
00107         be used.
00108         '''
00109         # We first 
00110         
00111         configReader = ConfigReader()
00112         config = configReader.getLocalConfig()
00113         configId = config.resname
00114         self.__getJobManager().configure(configId, config)
00115         # Note that the resname parameter is used as the key identifier of
00116         # the configuration in the job manager. As is, there can be then
00117         # only one configuration for each machine defined in the resources
00118         # catalog (no need to have further, I thing)
00119         config = configReader.getRemoteConfig()
00120         configId = config.resname
00121         self.__getJobManager().configure(configId, config)
00122 
00123         # We specify the default configuration identifier as the
00124         # resource name of the default configuration
00125         self.__configId = configReader.getDefaultConfig().resname
00126 

Here is the call graph for this function:

This function can be used to programmatically force the
refresh of the dialog box, the job state in particular.

Definition at line 226 of file plugindialog.py.

00226 
00227     def update(self):
00228         '''
00229         This function can be used to programmatically force the
00230         refresh of the dialog box, the job state in particular.
00231         '''
00232         if self.__isRunning:
00233             self.onRefresh()

Here is the call graph for this function:

def spadderpy.gui.plugindialog.PluginDialog.viewInputFrame (   self,
  view = True 
)

Definition at line 127 of file plugindialog.py.

00127 
00128     def viewInputFrame(self, view=True):
00129         # By default, the top input frame is visible and the input
00130         # button is not visible.
00131         if view is False:
00132             self.__ui.frameInput.setVisible(False)
00133             self.__ui.btnInput.setVisible(True)
00134             # We create the input dialog that will be displayed when
00135             # button input is pressed:
00136             self.__inputDialog = InputDialog(self)
00137             # The window is kept on the top to ease the selection of
00138             # items in the object browser:
00139             self.__inputDialog.setWindowFlags(
00140                 self.__inputDialog.windowFlags() | Qt.WindowStaysOnTopHint)
00141             # The signal inputValidated emited from inputDialog is
00142             # connected to the slot function onProcessInput:
00143             self.connect(self.__inputDialog, SIGNAL('inputValidated()'), self.onProcessInput)
00144             
00145         else:
00146             self.__ui.frameInput.setVisible(True)
00147             self.__ui.btnInput.setVisible(False)
00148             # This case is NOT IMPLEMENTED YET (not really). It could
00149             # be used to draw the input frame directly in the frame
00150             # frameInput of this dialog box.


Member Data Documentation

Definition at line 124 of file plugindialog.py.

Definition at line 135 of file plugindialog.py.

Definition at line 223 of file plugindialog.py.

Definition at line 287 of file plugindialog.py.

Definition at line 197 of file plugindialog.py.

Definition at line 220 of file plugindialog.py.

Definition at line 62 of file plugindialog.py.


The documentation for this class was generated from the following file: