Back to index

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

List of all members.

Public Member Functions

def __init__
def clear
def accept
def onSelectSmeshObject
def onAddInput
def onDeleteInput
def setData
def getData
def checkData

Public Attributes

 MESHTYPE_ICONS
 smeshStudyTool
 checkDataMessage

Static Public Attributes

list TBL_HEADER_LABEL = ["Input Mesh", "Output group name"]

Private Member Functions

def __addInputInGui
def __addInputInMap
def __delInputFromMap

Private Attributes

 __ui
 __inputModel
 __selectedMesh
 __dictInputData
 __nbConcreteMesh
 __nbSteelbarMesh

Detailed Description

Definition at line 42 of file inputdialog.py.


Constructor & Destructor Documentation

def spadderpy.gui.inputdialog.InputDialog.__init__ (   self,
  parent = None,
  name = "InputDialog",
  modal = 0 
)
This initializes a dialog windows to define the input data of
the plugin function. The input data consist in a list of
meshes characterizes each by a name, a pointer to the smesh
servant object, a type and a group name (see data model in the
inputdata.py).

Definition at line 46 of file inputdialog.py.

00046 
00047     def __init__(self, parent=None, name="InputDialog", modal=0):
00048         """
00049         This initializes a dialog windows to define the input data of
00050         the plugin function. The input data consist in a list of
00051         meshes characterizes each by a name, a pointer to the smesh
00052         servant object, a type and a group name (see data model in the
00053         inputdata.py).
00054         """
00055         GenericDialog.__init__(self, parent, name, modal)
00056         # Set up the user interface from Designer.
00057         self.__ui = Ui_InputFrame()
00058         # BE CAREFULL HERE, the ui form is NOT drawn in the global
00059         # dialog (already containing some generic widgets) but in the
00060         # center panel created in the GenericDialog as a void
00061         # container for the form. The InputFrame form is supposed
00062         # here to create only the widgets to be placed in the center
00063         # panel. Then, the setupUi function of this form draws itself
00064         # in the specified panel, i.e. the panel returned by
00065         # self.getPanel().
00066         self.__ui.setupUi(self.getPanel())
00067 
00068         self.setWindowTitle("Specification of input files")
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,"select.png"))
00075         self.__ui.btnSmeshObject.setIcon(icon)
00076         icon = QIcon()
00077         icon.addFile(os.path.join(iconfolder,"addinput.png"))
00078         self.__ui.btnAddInput.setIcon(icon)
00079         icon = QIcon()
00080         icon.addFile(os.path.join(iconfolder,"deleteinput.png"))
00081         self.__ui.btnDeleteInput.setIcon(icon)
00082 
00083         # We specify here the items in the combo box (even if already
00084         # defined in the designer) so that we can be sure of the item
00085         # indexation.
00086         self.MESHTYPE_ICONS = {}
00087         meshTypeIndex = InputData.MESHTYPES.CONCRETE
00088         self.__ui.cmbMeshType.setItemText(meshTypeIndex, "Béton")
00089         icon = QIcon()
00090         icon.addFile(os.path.join(iconfolder,"concrete.png"))
00091         self.__ui.cmbMeshType.setItemIcon(meshTypeIndex, icon)
00092         self.MESHTYPE_ICONS[meshTypeIndex] = icon
00093 
00094         meshTypeIndex = InputData.MESHTYPES.STEELBAR
00095         self.__ui.cmbMeshType.setItemText(meshTypeIndex, "Acier")
00096         icon = QIcon()
00097         icon.addFile(os.path.join(iconfolder,"steelbar.png"))
00098         self.__ui.cmbMeshType.setItemIcon(meshTypeIndex, icon)
00099         self.MESHTYPE_ICONS[meshTypeIndex] = icon
00100         
00101         # The click on btnSmeshObject (signal clicked() emitted by the
00102         # button btnSmeshObject) is connected to the slot
00103         # onSelectSmeshObject, etc ...
00104         self.connect(self.__ui.btnSmeshObject, SIGNAL('clicked()'), self.onSelectSmeshObject )
00105         self.connect(self.__ui.btnAddInput,    SIGNAL('clicked()'), self.onAddInput )
00106         self.connect(self.__ui.btnDeleteInput, SIGNAL('clicked()'), self.onDeleteInput )
00107 
00108         # Set up the model of the Qt table list
00109         self.__inputModel = QStandardItemModel(0,2)
00110         self.__inputModel.setHorizontalHeaderLabels(InputDialog.TBL_HEADER_LABEL)
00111         self.__ui.tblListInput.setModel(self.__inputModel)
00112         self.__ui.tblListInput.verticalHeader().hide()
00113         self.__ui.tblListInput.horizontalHeader().setStretchLastSection(True)
00114         # Note that the type is not display explicitly in the Qt table
00115         # because it is specified using an icon on the text of the
00116         # name item. 
00117 
00118         # Note that PADDER does not support group name longer than 8
00119         # characters. We apply then this limit in the gui field.
00120         self.__ui.txtGroupName.setMaxLength(GROUPNAME_MAXLENGTH)
00121 
00122         self.clear()
00123 
00124         self.smeshStudyTool = SMeshStudyTools()


Member Function Documentation

def spadderpy.gui.inputdialog.InputDialog.__addInputInGui (   self,
  meshName,
  meshObject,
  meshType,
  groupName 
) [private]
This function adds an entry with the specified data int the
GUI table (for data visualization purpose).

Definition at line 199 of file inputdialog.py.

00199 
00200     def __addInputInGui(self, meshName, meshObject, meshType, groupName):
00201         """
00202         This function adds an entry with the specified data int the
00203         GUI table (for data visualization purpose).
00204         """
00205         # The mesh name is used as the key index in the model. We have
00206         # to check first if this item already exists in the list.
00207         tblItems = self.__inputModel.findItems(meshName)
00208         row = self.__inputModel.rowCount()
00209         if not tblItems:
00210             tblItems = []
00211             tblItems.append(QStandardItem()) # input mesh name
00212             tblItems.append(QStandardItem()) # output group name
00213         else:
00214             row = tblItems[0].index().row()
00215             tblItems.append(self.__inputModel.item(row,1))
00216 
00217         tblItems[0].setText(meshName)
00218         tblItems[0].setIcon(self.MESHTYPE_ICONS[meshType])
00219         tblItems[1].setText(groupName)
00220         self.__inputModel.setItem(row,0,tblItems[0])
00221         self.__inputModel.setItem(row,1,tblItems[1])
00222         self.__ui.tblListInput.setCurrentIndex(tblItems[0].index())

Here is the caller graph for this function:

def spadderpy.gui.inputdialog.InputDialog.__addInputInMap (   self,
  meshName,
  meshObject,
  meshType,
  groupName 
) [private]
This function adds an entry with the specified data in the
internal map (for data management purpose).

Definition at line 223 of file inputdialog.py.

00223 
00224     def __addInputInMap(self, meshName, meshObject, meshType, groupName):
00225         """
00226         This function adds an entry with the specified data in the
00227         internal map (for data management purpose).
00228         """
00229         # if the entry already exists, we remove it to replace by a
00230         # new one
00231         if self.__dictInputData.has_key(meshName):
00232             self.__delInputFromMap(meshName)
00233         
00234         inputData = InputData()
00235         inputData.meshName   = meshName
00236         inputData.meshObject = meshObject
00237         inputData.meshType   = meshType
00238         inputData.groupName  = groupName
00239         # The key of the map is the mesh name
00240         self.__dictInputData[meshName] = inputData
00241         if inputData.meshType == InputData.MESHTYPES.CONCRETE:
00242             self.__nbConcreteMesh += 1
00243         else:
00244             self.__nbSteelbarMesh += 1
00245 
00246         print inputData
00247         print "meshType = ",inputData.meshType
00248         print "nb concrete mesh ",self.__nbConcreteMesh
00249         print "nb steelbar mesh ",self.__nbSteelbarMesh
00250             

Here is the call graph for this function:

Here is the caller graph for this function:

def spadderpy.gui.inputdialog.InputDialog.__delInputFromMap (   self,
  meshName 
) [private]
This function removes the specified entry from the internal
map (for data management purpose) 

Definition at line 266 of file inputdialog.py.

00266 
00267     def __delInputFromMap(self, meshName):
00268         """
00269         This function removes the specified entry from the internal
00270         map (for data management purpose) 
00271         """
00272         inputData = self.__dictInputData.pop(meshName)
00273         if inputData.meshType == InputData.MESHTYPES.CONCRETE:
00274             self.__nbConcreteMesh -= 1
00275         else:
00276             self.__nbSteelbarMesh -= 1
00277 
00278         print inputData
00279         print "nb concrete mesh ",self.__nbConcreteMesh
00280         print "nb steelbar mesh ",self.__nbSteelbarMesh
00281 

Here is the caller graph for this function:

This function is the slot connected to the button OK

Definition at line 141 of file inputdialog.py.

00141 
00142     def accept(self):
00143         """
00144         This function is the slot connected to the button OK
00145         """
00146         # The dialog is raised in a non modal mode to get
00147         # interactivity with the parents windows. Then we have to emit
00148         # a signal to warn the parent observer that the dialog has
00149         # been validated so that it can process the event
00150         GenericDialog.accept(self)
00151         if self.wasOk():
00152             self.emit(SIGNAL('inputValidated()'))

This function checks if the data are valid, from the dialog
window point of view.

Definition at line 310 of file inputdialog.py.

00310 
00311     def checkData(self):
00312         """
00313         This function checks if the data are valid, from the dialog
00314         window point of view.
00315         """
00316         if self.__nbConcreteMesh < 1:
00317             self.checkDataMessage = "You must define at least one CONCRETE mesh"
00318             return False        
00319         if self.__nbConcreteMesh > 1:
00320             self.checkDataMessage  = "You define multiple CONCRETE meshes."
00321             self.checkDataMessage += "You should verify first that your version of PADDER support this configuration."
00322             # just warn the user, but don't block
00323             QMessageBox.information(self, "Info", self.checkDataMessage)
00324             return True
00325         if self.__nbSteelbarMesh < 1:
00326             self.checkDataMessage = "You must define at least one STEELBAR mesh"
00327             return False
00328         return True
00329 
00330 
00331 # ==============================================================================
00332 # Basic use case
00333 # ==============================================================================
#
This function clears the data gui area and associated values.

Definition at line 125 of file inputdialog.py.

00125 
00126     def clear(self):
00127         """
00128         This function clears the data gui area and associated values.
00129         """
00130         self.__ui.txtSmeshObject.setText("")
00131         self.__ui.txtGroupName.setText("")
00132         self.__inputModel.clear()
00133         self.__inputModel.setHorizontalHeaderLabels(InputDialog.TBL_HEADER_LABEL)
00134         if not DEBUG_MODE:
00135             self.__ui.txtSmeshObject.setEnabled(False)
00136             self.__ui.btnAddInput.setEnabled(False)
00137         self.__selectedMesh = None
00138         self.__dictInputData = {}
00139         self.__nbConcreteMesh = 0
00140         self.__nbSteelbarMesh = 0

Here is the caller graph for this function:

This function returns a list of InputData that corresponds to
the data in the dialog widgets of the current dialog.

Definition at line 301 of file inputdialog.py.

00301 
00302     def getData(self):
00303         """
00304         This function returns a list of InputData that corresponds to
00305         the data in the dialog widgets of the current dialog.
00306         """
00307         # Note that the values() function returns a copy of the list
00308         # of values.
00309         return self.__dictInputData.values()
        
This function is the slot connected to the Add button. It
creates a new entry in the list of input data, or updates this
entry if it already exists.

Definition at line 185 of file inputdialog.py.

00185 
00186     def onAddInput(self):
00187         """
00188         This function is the slot connected to the Add button. It
00189         creates a new entry in the list of input data, or updates this
00190         entry if it already exists.
00191         """
00192         meshName   = str(self.__ui.txtSmeshObject.text().trimmed())
00193         meshObject = self.__selectedMesh
00194         meshType   = self.__ui.cmbMeshType.currentIndex()
00195         groupName  = str(self.__ui.txtGroupName.text().trimmed())
00196 
00197         self.__addInputInGui(meshName, meshObject, meshType, groupName)
00198         self.__addInputInMap(meshName, meshObject, meshType, groupName)

Here is the call graph for this function:

This function is the slot connected to the Delete button. It
remove from the data list the entry selected in the Qt table.

Definition at line 251 of file inputdialog.py.

00251 
00252     def onDeleteInput(self):
00253         """
00254         This function is the slot connected to the Delete button. It
00255         remove from the data list the entry selected in the Qt table.
00256         """
00257         selectedIdx = self.__ui.tblListInput.selectedIndexes()
00258         if selectedIdx:
00259             row  = selectedIdx[0].row()
00260             tblItem  = self.__inputModel.item(row,0)
00261             meshName = str(tblItem.text())
00262             self.__inputModel.takeRow(row)
00263             # Don't forget to remove this entry from the mesh object
00264             # internal dictionnary
00265             self.__delInputFromMap(meshName)

Here is the call graph for this function:

This function is the slot connected on the mesh selection
button. It memorizes the selected mesh and put its name in the
text field of the dialog box.

Definition at line 153 of file inputdialog.py.

00153 
00154     def onSelectSmeshObject(self):
00155         '''
00156         This function is the slot connected on the mesh selection
00157         button. It memorizes the selected mesh and put its name in the
00158         text field of the dialog box.
00159         '''
00160         mySObject, myEntry = guihelper.getSObjectSelected()
00161         if CORBA.is_nil(mySObject):
00162             self.__ui.txtSmeshObject.setText("You must choose a mesh")
00163             self.__ui.txtGroupName.setText("")
00164             self.__ui.txtSmeshObject.setEnabled(False)
00165             self.__ui.btnAddInput.setEnabled(False)
00166             self.__selectedMesh = None
00167             return
00168 
00169         self.smeshStudyTool.updateStudy(studyedit.getActiveStudyId())
00170         self.__selectedMesh = self.smeshStudyTool.getMeshObjectFromSObject(mySObject)
00171         if CORBA.is_nil(self.__selectedMesh):
00172             self.__ui.txtSmeshObject.setText("The selected object is not a mesh")
00173             self.__ui.txtGroupName.setText("")
00174             self.__ui.txtSmeshObject.setEnabled(False)
00175             self.__ui.btnAddInput.setEnabled(False)
00176             self.__selectedMesh = None
00177             return
00178         myName = mySObject.GetName()
00179         self.__ui.txtSmeshObject.setText(myName)
00180         self.__ui.txtSmeshObject.setEnabled(True)
00181         self.__ui.btnAddInput.setEnabled(True)
00182 
00183         # We can suggest a default group name from the mesh name
00184         self.__ui.txtGroupName.setText(myName)

Here is the caller graph for this function:

def spadderpy.gui.inputdialog.InputDialog.setData (   self,
  listInputData = [] 
)
This function fills the dialog widgets with values provided by
the specified data list.

Definition at line 282 of file inputdialog.py.

00282 
00283     def setData(self, listInputData=[]):
00284         """
00285         This function fills the dialog widgets with values provided by
00286         the specified data list.
00287         """
00288         self.clear()
00289         for inputData in listInputData:
00290 
00291             meshName   = inputData.meshName
00292             meshObject = inputData.meshObject
00293             meshType   = inputData.meshType
00294             groupName  = inputData.groupName
00295             
00296             self.__addInputInGui(meshName, meshObject, meshType, groupName)
00297             self.__addInputInMap(meshName, meshObject, meshType, groupName)
00298 
00299             if not DEBUG_MODE:
00300                 self.onSelectSmeshObject()

Here is the call graph for this function:


Member Data Documentation

Definition at line 137 of file inputdialog.py.

Definition at line 108 of file inputdialog.py.

Definition at line 138 of file inputdialog.py.

Definition at line 139 of file inputdialog.py.

Definition at line 136 of file inputdialog.py.

Definition at line 56 of file inputdialog.py.

Definition at line 316 of file inputdialog.py.

Definition at line 85 of file inputdialog.py.

Definition at line 123 of file inputdialog.py.

list spadderpy.gui.inputdialog.InputDialog.TBL_HEADER_LABEL = ["Input Mesh", "Output group name"] [static]

Definition at line 44 of file inputdialog.py.


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