mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 01:40:33 +05:00
padder: add numerical parameters in the gui + transmission to the component and then the padder executable
This commit is contained in:
parent
7dbb2914d9
commit
465570a935
@ -38,6 +38,14 @@ from inputdata import InputData
|
|||||||
DEBUG_MODE=True
|
DEBUG_MODE=True
|
||||||
GROUPNAME_MAXLENGTH=8
|
GROUPNAME_MAXLENGTH=8
|
||||||
|
|
||||||
|
INPUTDATA_KEY_FILES="meshfiles"
|
||||||
|
INPUTDATA_KEY_PARAM="parameters"
|
||||||
|
|
||||||
|
PARAM_KEY_NBITER = "NbIteration"
|
||||||
|
PARAM_KEY_RMINRMAX = "RminRmax"
|
||||||
|
PARAM_NBITER_DEFAULT_VALUE = 3
|
||||||
|
PARAM_RMINRMAX_DEFAULT_VALUE = 1.5
|
||||||
|
|
||||||
class InputDialog(GenericDialog):
|
class InputDialog(GenericDialog):
|
||||||
|
|
||||||
TBL_HEADER_LABEL=["Input Mesh", "Output group name"]
|
TBL_HEADER_LABEL=["Input Mesh", "Output group name"]
|
||||||
@ -116,7 +124,8 @@ class InputDialog(GenericDialog):
|
|||||||
# name item.
|
# name item.
|
||||||
|
|
||||||
# Setup default values for numerical parameters
|
# Setup default values for numerical parameters
|
||||||
self.__ui.txtParamNbIter.setValue(3)
|
self.__ui.txtParamNbIter.setValue(PARAM_NBITER_DEFAULT_VALUE)
|
||||||
|
self.__ui.txtParamRminRmax.setValue(PARAM_RMINRMAX_DEFAULT_VALUE)
|
||||||
|
|
||||||
# Note that PADDER does not support group name longer than 8
|
# Note that PADDER does not support group name longer than 8
|
||||||
# characters. We apply then this limit in the gui field.
|
# characters. We apply then this limit in the gui field.
|
||||||
@ -138,7 +147,7 @@ class InputDialog(GenericDialog):
|
|||||||
self.__ui.txtSmeshObject.setEnabled(False)
|
self.__ui.txtSmeshObject.setEnabled(False)
|
||||||
self.__ui.btnAddInput.setEnabled(False)
|
self.__ui.btnAddInput.setEnabled(False)
|
||||||
self.__selectedMesh = None
|
self.__selectedMesh = None
|
||||||
self.__dictInputData = {}
|
self.__dictInputFiles = {}
|
||||||
self.__nbConcreteMesh = 0
|
self.__nbConcreteMesh = 0
|
||||||
self.__nbSteelbarMesh = 0
|
self.__nbSteelbarMesh = 0
|
||||||
|
|
||||||
@ -231,7 +240,7 @@ class InputDialog(GenericDialog):
|
|||||||
"""
|
"""
|
||||||
# if the entry already exists, we remove it to replace by a
|
# if the entry already exists, we remove it to replace by a
|
||||||
# new one
|
# new one
|
||||||
if self.__dictInputData.has_key(meshName):
|
if self.__dictInputFiles.has_key(meshName):
|
||||||
self.__delInputFromMap(meshName)
|
self.__delInputFromMap(meshName)
|
||||||
|
|
||||||
inputData = InputData()
|
inputData = InputData()
|
||||||
@ -240,7 +249,7 @@ class InputDialog(GenericDialog):
|
|||||||
inputData.meshType = meshType
|
inputData.meshType = meshType
|
||||||
inputData.groupName = groupName
|
inputData.groupName = groupName
|
||||||
# The key of the map is the mesh name
|
# The key of the map is the mesh name
|
||||||
self.__dictInputData[meshName] = inputData
|
self.__dictInputFiles[meshName] = inputData
|
||||||
if inputData.meshType == InputData.MESHTYPES.CONCRETE:
|
if inputData.meshType == InputData.MESHTYPES.CONCRETE:
|
||||||
self.__nbConcreteMesh += 1
|
self.__nbConcreteMesh += 1
|
||||||
else:
|
else:
|
||||||
@ -272,7 +281,7 @@ class InputDialog(GenericDialog):
|
|||||||
This function removes the specified entry from the internal
|
This function removes the specified entry from the internal
|
||||||
map (for data management purpose)
|
map (for data management purpose)
|
||||||
"""
|
"""
|
||||||
inputData = self.__dictInputData.pop(meshName)
|
inputData = self.__dictInputFiles.pop(meshName)
|
||||||
if inputData.meshType == InputData.MESHTYPES.CONCRETE:
|
if inputData.meshType == InputData.MESHTYPES.CONCRETE:
|
||||||
self.__nbConcreteMesh -= 1
|
self.__nbConcreteMesh -= 1
|
||||||
else:
|
else:
|
||||||
@ -283,33 +292,51 @@ class InputDialog(GenericDialog):
|
|||||||
print "nb steelbar mesh ",self.__nbSteelbarMesh
|
print "nb steelbar mesh ",self.__nbSteelbarMesh
|
||||||
|
|
||||||
|
|
||||||
def setData(self, listInputData=[]):
|
def setData(self, dictInputData={}):
|
||||||
"""
|
"""
|
||||||
This function fills the dialog widgets with values provided by
|
This function fills the dialog widgets with values provided by
|
||||||
the specified data list.
|
the specified data list.
|
||||||
"""
|
"""
|
||||||
self.clear()
|
self.clear()
|
||||||
for inputData in listInputData:
|
if dictInputData.has_key(INPUTDATA_KEY_FILES):
|
||||||
|
listInputData = dictInputData["meshfiles"]
|
||||||
|
for inputData in listInputData:
|
||||||
|
|
||||||
meshName = inputData.meshName
|
meshName = inputData.meshName
|
||||||
meshObject = inputData.meshObject
|
meshObject = inputData.meshObject
|
||||||
meshType = inputData.meshType
|
meshType = inputData.meshType
|
||||||
groupName = inputData.groupName
|
groupName = inputData.groupName
|
||||||
|
|
||||||
self.__addInputInGui(meshName, meshObject, meshType, groupName)
|
self.__addInputInGui(meshName, meshObject, meshType, groupName)
|
||||||
self.__addInputInMap(meshName, meshObject, meshType, groupName)
|
self.__addInputInMap(meshName, meshObject, meshType, groupName)
|
||||||
|
|
||||||
if not DEBUG_MODE:
|
if not DEBUG_MODE:
|
||||||
self.onSelectSmeshObject()
|
self.onSelectSmeshObject()
|
||||||
|
|
||||||
|
if dictInputData.has_key(INPUTDATA_KEY_PARAM):
|
||||||
|
dictInputParameters = dictInputData[INPUTDATA_KEY_PARAM]
|
||||||
|
if dictInputParameters.has_key(PARAM_KEY_NBITER):
|
||||||
|
self.__ui.txtParamNbIter.setValue(dictInputParameters[PARAM_KEY_NBITER])
|
||||||
|
if dictInputParameters.has_key(PARAM_KEY_RMINRMAX):
|
||||||
|
self.__ui.txtParamRminRmax.setValue(dictInputParameters[PARAM_KEY_RMINRMAX])
|
||||||
|
|
||||||
def getData(self):
|
def getData(self):
|
||||||
"""
|
"""
|
||||||
This function returns a list of InputData that corresponds to
|
This function returns a list of InputData that corresponds to
|
||||||
the data in the dialog widgets of the current dialog.
|
the data in the dialog widgets of the current dialog.
|
||||||
"""
|
"""
|
||||||
|
# Get the list of mesh files
|
||||||
# Note that the values() function returns a copy of the list
|
# Note that the values() function returns a copy of the list
|
||||||
# of values.
|
# of values.
|
||||||
return self.__dictInputData.values()
|
dictInputData={}
|
||||||
|
dictInputData[INPUTDATA_KEY_FILES] = self.__dictInputFiles.values()
|
||||||
|
|
||||||
|
# Get the list of additionnal parameters
|
||||||
|
dictInputParameters = {}
|
||||||
|
dictInputParameters[PARAM_KEY_NBITER] = self.__ui.txtParamNbIter.value()
|
||||||
|
dictInputParameters[PARAM_KEY_RMINRMAX] = self.__ui.txtParamRminRmax.value()
|
||||||
|
dictInputData[INPUTDATA_KEY_PARAM] = dictInputParameters
|
||||||
|
return dictInputData
|
||||||
|
|
||||||
def checkData(self):
|
def checkData(self):
|
||||||
"""
|
"""
|
||||||
@ -328,7 +355,6 @@ class InputDialog(GenericDialog):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#def setParameters(self,
|
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Basic use case
|
# Basic use case
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
from qtsalome import QDialog, QIcon, Qt
|
from qtsalome import QDialog, QIcon, Qt
|
||||||
|
|
||||||
from plugindialog_ui import Ui_PluginDialog
|
from plugindialog_ui import Ui_PluginDialog
|
||||||
from inputdialog import InputDialog
|
from inputdialog import InputDialog, INPUTDATA_KEY_FILES, INPUTDATA_KEY_PARAM
|
||||||
|
from inputdialog import PARAM_KEY_NBITER, PARAM_KEY_RMINRMAX
|
||||||
from inputdata import InputData
|
from inputdata import InputData
|
||||||
# __GBO__: uncomment this line and comment the previous one to use the
|
# __GBO__: uncomment this line and comment the previous one to use the
|
||||||
# demo input dialog instead of the real one.
|
# demo input dialog instead of the real one.
|
||||||
@ -95,7 +96,7 @@ class PluginDialog(QDialog):
|
|||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
self.setupJobManager()
|
self.setupJobManager()
|
||||||
|
|
||||||
|
|
||||||
def setupJobManager(self):
|
def setupJobManager(self):
|
||||||
'''
|
'''
|
||||||
@ -105,8 +106,8 @@ class PluginDialog(QDialog):
|
|||||||
the initialize step, by specifing the name of the resource to
|
the initialize step, by specifing the name of the resource to
|
||||||
be used.
|
be used.
|
||||||
'''
|
'''
|
||||||
# We first
|
# We first
|
||||||
|
|
||||||
configReader = ConfigReader()
|
configReader = ConfigReader()
|
||||||
config = configReader.getLocalConfig()
|
config = configReader.getLocalConfig()
|
||||||
configId = config.resname
|
configId = config.resname
|
||||||
@ -140,7 +141,7 @@ class PluginDialog(QDialog):
|
|||||||
# The signal inputValidated emitted from inputDialog is
|
# The signal inputValidated emitted from inputDialog is
|
||||||
# connected to the slot function onProcessInput:
|
# connected to the slot function onProcessInput:
|
||||||
self.__inputDialog.inputValidated.connect( self.onProcessInput )
|
self.__inputDialog.inputValidated.connect( self.onProcessInput )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.__ui.frameInput.setVisible(True)
|
self.__ui.frameInput.setVisible(True)
|
||||||
self.__ui.btnInput.setVisible(False)
|
self.__ui.btnInput.setVisible(False)
|
||||||
@ -150,13 +151,13 @@ class PluginDialog(QDialog):
|
|||||||
|
|
||||||
def getInputFrame(self):
|
def getInputFrame(self):
|
||||||
return self.__ui.frameInput
|
return self.__ui.frameInput
|
||||||
|
|
||||||
def __setGuiState(self,states=["CAN_SELECT"]):
|
def __setGuiState(self,states=["CAN_SELECT"]):
|
||||||
if "CAN_SELECT" in states:
|
if "CAN_SELECT" in states:
|
||||||
self.__ui.btnInput.setEnabled(True)
|
self.__ui.btnInput.setEnabled(True)
|
||||||
else:
|
else:
|
||||||
self.__ui.btnInput.setEnabled(False)
|
self.__ui.btnInput.setEnabled(False)
|
||||||
|
|
||||||
if "CAN_COMPUTE" in states:
|
if "CAN_COMPUTE" in states:
|
||||||
self.__ui.btnCompute.setEnabled(True)
|
self.__ui.btnCompute.setEnabled(True)
|
||||||
else:
|
else:
|
||||||
@ -200,7 +201,7 @@ class PluginDialog(QDialog):
|
|||||||
def __log(self, message):
|
def __log(self, message):
|
||||||
"""
|
"""
|
||||||
This function prints the specified message in the log area
|
This function prints the specified message in the log area
|
||||||
"""
|
"""
|
||||||
self.__ui.txtLog.append(message)
|
self.__ui.txtLog.append(message)
|
||||||
|
|
||||||
def __exportMesh(self, meshName, meshObject):
|
def __exportMesh(self, meshName, meshObject):
|
||||||
@ -218,6 +219,7 @@ class PluginDialog(QDialog):
|
|||||||
This function clears the log area and the states of the buttons
|
This function clears the log area and the states of the buttons
|
||||||
"""
|
"""
|
||||||
self.__listInputData = []
|
self.__listInputData = []
|
||||||
|
self.__dictInputParameters = {}
|
||||||
self.__ui.txtLog.clear()
|
self.__ui.txtLog.clear()
|
||||||
self.__setGuiState(["CAN_SELECT"])
|
self.__setGuiState(["CAN_SELECT"])
|
||||||
self.__isRunning = False
|
self.__isRunning = False
|
||||||
@ -241,7 +243,10 @@ class PluginDialog(QDialog):
|
|||||||
windows to process the validation event (see the slot
|
windows to process the validation event (see the slot
|
||||||
onProcessInput which is connected to this event).
|
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()
|
self.__inputDialog.open()
|
||||||
|
|
||||||
def onProcessInput(self):
|
def onProcessInput(self):
|
||||||
@ -252,16 +257,19 @@ class PluginDialog(QDialog):
|
|||||||
"""
|
"""
|
||||||
# The processing simply consists in requesting the input data
|
# The processing simply consists in requesting the input data
|
||||||
# from the dialog window.
|
# 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.__ui.lblStatusBar.setText("Input data OK")
|
||||||
self.__log("INF: Press \"Compute\" to start the job")
|
self.__log("INF: Press \"Compute\" to start the job")
|
||||||
self.__setGuiState(["CAN_SELECT", "CAN_COMPUTE"])
|
self.__setGuiState(["CAN_SELECT", "CAN_COMPUTE"])
|
||||||
|
|
||||||
def onCompute(self):
|
def onCompute(self):
|
||||||
'''
|
'''
|
||||||
This function is the slot connected to the Compute button. It
|
This function is the slot connected to the Compute button. It
|
||||||
initializes a mesh computation job and start it using the
|
initializes a mesh computation job and start it using the
|
||||||
SALOME launcher.
|
SALOME launcher.
|
||||||
'''
|
'''
|
||||||
# We first have to create the list of parameters for the
|
# We first have to create the list of parameters for the
|
||||||
# initialize function. For that, we have to create the files
|
# initialize function. For that, we have to create the files
|
||||||
@ -283,14 +291,22 @@ class PluginDialog(QDialog):
|
|||||||
group_name = inputData.groupName)
|
group_name = inputData.groupName)
|
||||||
meshJobFileList.append(parameter)
|
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.keys():
|
||||||
|
value = self.__dictInputParameters[inputParameterKey]
|
||||||
|
parameter = MESHJOB.MeshJobParameter(name=inputParameterKey,value=str(value))
|
||||||
|
meshJobParameterList.append(parameter)
|
||||||
|
|
||||||
jobManager = self.__getJobManager()
|
jobManager = self.__getJobManager()
|
||||||
self.__jobid = jobManager.initialize(meshJobFileList, self.__configId)
|
self.__jobid = jobManager.initialize(meshJobFileList, meshJobParameterList, self.__configId)
|
||||||
if self.__jobid < 0:
|
if self.__jobid < 0:
|
||||||
self.__log("ERR: the job can't be initialized")
|
self.__log("ERR: the job can't be initialized")
|
||||||
self.__log("ERR: %s"%jobManager.getLastErrorMessage())
|
self.__log("ERR: %s"%jobManager.getLastErrorMessage())
|
||||||
return
|
return
|
||||||
self.__log("INF: the job has been initialized with jobid = "+str(self.__jobid))
|
self.__log("INF: the job has been initialized with jobid = "+str(self.__jobid))
|
||||||
|
|
||||||
startOk = jobManager.start(self.__jobid)
|
startOk = jobManager.start(self.__jobid)
|
||||||
if not startOk:
|
if not startOk:
|
||||||
self.__log("ERR: the job with jobid = "+str(self.__jobid)+" can't be started")
|
self.__log("ERR: the job with jobid = "+str(self.__jobid)+" can't be started")
|
||||||
@ -326,7 +342,7 @@ class PluginDialog(QDialog):
|
|||||||
This function is the slot connected on the Publish button. It
|
This function is the slot connected on the Publish button. It
|
||||||
requests the mesh job manager to download the results data
|
requests the mesh job manager to download the results data
|
||||||
from the computation resource host and load the med file in
|
from the computation resource host and load the med file in
|
||||||
the SALOME study.
|
the SALOME study.
|
||||||
"""
|
"""
|
||||||
jobManager = self.__getJobManager()
|
jobManager = self.__getJobManager()
|
||||||
state = jobManager.getState(self.__jobid)
|
state = jobManager.getState(self.__jobid)
|
||||||
@ -372,13 +388,13 @@ class PluginDialog(QDialog):
|
|||||||
one is running.
|
one is running.
|
||||||
"""
|
"""
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__dialog=None
|
__dialog=None
|
||||||
def getDialog():
|
def getDialog():
|
||||||
"""
|
"""
|
||||||
This function returns a singleton instance of the plugin dialog.
|
This function returns a singleton instance of the plugin dialog.
|
||||||
"""
|
"""
|
||||||
global __dialog
|
global __dialog
|
||||||
if __dialog is None:
|
if __dialog is None:
|
||||||
@ -402,5 +418,5 @@ def TEST_PluginDialog():
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
TEST_PluginDialog()
|
TEST_PluginDialog()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user