X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FTools%2Fpadder%2Fspadderpy%2Fgui%2Finputdialog.py;h=3fd0c7fa6e553ccc98ca96fda041543fad39e8bf;hp=c9d8ae618cb9bcca0cbde8a6ce73112be00f5b77;hb=465570a935abb5f7603ddc070aabd3addc5e1c03;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6 diff --git a/src/Tools/padder/spadderpy/gui/inputdialog.py b/src/Tools/padder/spadderpy/gui/inputdialog.py index c9d8ae618..3fd0c7fa6 100644 --- a/src/Tools/padder/spadderpy/gui/inputdialog.py +++ b/src/Tools/padder/spadderpy/gui/inputdialog.py @@ -1,10 +1,10 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2011-2012 EDF R&D +# Copyright (C) 2011-2016 EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,8 +30,7 @@ from salome.smesh.smeshstudytools import SMeshStudyTools from omniORB import CORBA -from PyQt4.QtCore import QObject, SIGNAL, SLOT -from PyQt4.QtGui import QIcon, QStandardItemModel, QStandardItem, QMessageBox +from qtsalome import QIcon, QStandardItemModel, QStandardItem, QMessageBox, pyqtSignal from inputframe_ui import Ui_InputFrame from inputdata import InputData @@ -39,10 +38,20 @@ from inputdata import InputData DEBUG_MODE=True 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): TBL_HEADER_LABEL=["Input Mesh", "Output group name"] + inputValidated = pyqtSignal() + def __init__(self, parent=None, name="InputDialog", modal=0): """ This initializes a dialog windows to define the input data of @@ -96,13 +105,13 @@ class InputDialog(GenericDialog): icon.addFile(os.path.join(iconfolder,"steelbar.png")) self.__ui.cmbMeshType.setItemIcon(meshTypeIndex, icon) self.MESHTYPE_ICONS[meshTypeIndex] = icon - + # The click on btnSmeshObject (signal clicked() emitted by the # button btnSmeshObject) is connected to the slot # onSelectSmeshObject, etc ... - self.connect(self.__ui.btnSmeshObject, SIGNAL('clicked()'), self.onSelectSmeshObject ) - self.connect(self.__ui.btnAddInput, SIGNAL('clicked()'), self.onAddInput ) - self.connect(self.__ui.btnDeleteInput, SIGNAL('clicked()'), self.onDeleteInput ) + self.__ui.btnSmeshObject.clicked.connect( self.onSelectSmeshObject ) + self.__ui.btnAddInput.clicked.connect( self.onAddInput ) + self.__ui.btnDeleteInput.clicked.connect( self.onDeleteInput ) # Set up the model of the Qt table list self.__inputModel = QStandardItemModel(0,2) @@ -112,7 +121,11 @@ class InputDialog(GenericDialog): self.__ui.tblListInput.horizontalHeader().setStretchLastSection(True) # Note that the type is not display explicitly in the Qt table # because it is specified using an icon on the text of the - # name item. + # name item. + + # Setup default values for numerical parameters + 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 # characters. We apply then this limit in the gui field. @@ -134,7 +147,7 @@ class InputDialog(GenericDialog): self.__ui.txtSmeshObject.setEnabled(False) self.__ui.btnAddInput.setEnabled(False) self.__selectedMesh = None - self.__dictInputData = {} + self.__dictInputFiles = {} self.__nbConcreteMesh = 0 self.__nbSteelbarMesh = 0 @@ -148,7 +161,7 @@ class InputDialog(GenericDialog): # been validated so that it can process the event GenericDialog.accept(self) if self.wasOk(): - self.emit(SIGNAL('inputValidated()')) + self.inputValidated.emit() def onSelectSmeshObject(self): ''' @@ -188,10 +201,10 @@ class InputDialog(GenericDialog): creates a new entry in the list of input data, or updates this entry if it already exists. """ - meshName = str(self.__ui.txtSmeshObject.text().trimmed()) + meshName = str(self.__ui.txtSmeshObject.text()).strip() meshObject = self.__selectedMesh meshType = self.__ui.cmbMeshType.currentIndex() - groupName = str(self.__ui.txtGroupName.text().trimmed()) + groupName = str(self.__ui.txtGroupName.text()).strip() self.__addInputInGui(meshName, meshObject, meshType, groupName) self.__addInputInMap(meshName, meshObject, meshType, groupName) @@ -227,16 +240,16 @@ class InputDialog(GenericDialog): """ # if the entry already exists, we remove it to replace by a # new one - if self.__dictInputData.has_key(meshName): + if self.__dictInputFiles.has_key(meshName): self.__delInputFromMap(meshName) - + inputData = InputData() inputData.meshName = meshName inputData.meshObject = meshObject inputData.meshType = meshType inputData.groupName = groupName # The key of the map is the mesh name - self.__dictInputData[meshName] = inputData + self.__dictInputFiles[meshName] = inputData if inputData.meshType == InputData.MESHTYPES.CONCRETE: self.__nbConcreteMesh += 1 else: @@ -246,7 +259,7 @@ class InputDialog(GenericDialog): print "meshType = ",inputData.meshType print "nb concrete mesh ",self.__nbConcreteMesh print "nb steelbar mesh ",self.__nbSteelbarMesh - + def onDeleteInput(self): """ @@ -266,9 +279,9 @@ class InputDialog(GenericDialog): def __delInputFromMap(self, meshName): """ 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: self.__nbConcreteMesh -= 1 else: @@ -279,51 +292,67 @@ class InputDialog(GenericDialog): print "nb steelbar mesh ",self.__nbSteelbarMesh - def setData(self, listInputData=[]): + def setData(self, dictInputData={}): """ This function fills the dialog widgets with values provided by the specified data list. """ self.clear() - for inputData in listInputData: + if dictInputData.has_key(INPUTDATA_KEY_FILES): + listInputData = dictInputData["meshfiles"] + for inputData in listInputData: + + meshName = inputData.meshName + meshObject = inputData.meshObject + meshType = inputData.meshType + groupName = inputData.groupName - meshName = inputData.meshName - meshObject = inputData.meshObject - meshType = inputData.meshType - groupName = inputData.groupName - - self.__addInputInGui(meshName, meshObject, meshType, groupName) - self.__addInputInMap(meshName, meshObject, meshType, groupName) + self.__addInputInGui(meshName, meshObject, meshType, groupName) + self.__addInputInMap(meshName, meshObject, meshType, groupName) - if not DEBUG_MODE: - self.onSelectSmeshObject() + if not DEBUG_MODE: + 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): """ This function returns a list of InputData that corresponds to 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 # 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): """ This function checks if the data are valid, from the dialog window point of view. """ - if self.__nbConcreteMesh < 1: - self.checkDataMessage = "You must define at least one CONCRETE mesh" - return False + if self.__nbConcreteMesh == 0 and self.__nbSteelbarMesh == 0: + self.checkDataMessage = "You must define at least one mesh (CONCRETE or STEELBAR)" + return False if self.__nbConcreteMesh > 1: self.checkDataMessage = "You define multiple CONCRETE meshes." self.checkDataMessage += "You should verify first that your version of PADDER support this configuration." # just warn the user, but don't block QMessageBox.information(self, "Info", self.checkDataMessage) return True - if self.__nbSteelbarMesh < 1: - self.checkDataMessage = "You must define at least one STEELBAR mesh" - return False + return True @@ -333,10 +362,9 @@ class InputDialog(GenericDialog): # def TEST_InputDialog(): import sys - from PyQt4.QtCore import QObject, SIGNAL, SLOT - from PyQt4.QtGui import QApplication + from qtsalome import QApplication app = QApplication(sys.argv) - QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) + app.lastWindowClosed.connect( app.quit ) dlg=InputDialog() dlg.displayAndWait() @@ -345,10 +373,9 @@ def TEST_InputDialog(): def TEST_InputDialog_setData(): import sys - from PyQt4.QtCore import QObject, SIGNAL, SLOT - from PyQt4.QtGui import QApplication + from qtsalome import QApplication app = QApplication(sys.argv) - QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) + app.lastWindowClosed.connect( app.quit ) dlg=InputDialog() @@ -360,9 +387,9 @@ def TEST_InputDialog_setData(): inputData.groupName = "myGroup" listInputData = [] listInputData.append(inputData) - + dlg.setData2(listInputData) - + dlg.displayAndWait() if dlg.wasOk(): print "OK has been pressed"