Example #1
0
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_NotebookForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.parent = parent
        self.case.undoStopGlobal()
        self.mdl = NotebookModel(self.case)

        self.modelVar = VariableStandardItemModel(self.parent, self.case, self.mdl)
        self.treeViewNotebook.setModel(self.modelVar)
        self.treeViewNotebook.setAlternatingRowColors(True)
        self.treeViewNotebook.setSelectionBehavior(QAbstractItemView.SelectItems)
        self.treeViewNotebook.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.treeViewNotebook.setEditTriggers(QAbstractItemView.DoubleClicked)
        self.treeViewNotebook.expandAll()
        self.treeViewNotebook.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.treeViewNotebook.setDragEnabled(False)

        nameDelegate = LabelDelegate(self.treeViewNotebook,
                                     xml_model=self.mdl,
                                     forbidden_labels=_forbidden_labels)
        self.treeViewNotebook.setItemDelegateForColumn(0, nameDelegate)

        valDelegate = FloatDelegate(self.treeViewNotebook, self.mdl)
        self.treeViewNotebook.setItemDelegateForColumn(1, valDelegate)

        OTOptions = {"No":"on", "Yes: Input":"on", "Yes: Output":"on"}
        otvalDelegate = ComboDelegate(self.treeViewNotebook,
                                      OptsList=OTOptions)
        self.treeViewNotebook.setItemDelegateForColumn(2, otvalDelegate)

        EditableOptions = {"No":"on", "Yes":"on"}
        editableDelegate = ComboDelegate(self.treeViewNotebook,
                                         OptsList=EditableOptions)
        self.treeViewNotebook.setItemDelegateForColumn(3, editableDelegate)

        descriptionDelegate = LabelDelegate(self.treeViewNotebook)
        self.treeViewNotebook.setItemDelegateForColumn(4, descriptionDelegate)

        self.treeViewNotebook.resizeColumnToContents(0)
        self.treeViewNotebook.resizeColumnToContents(2)
        self.treeViewNotebook.resizeColumnToContents(4)

        # Connections
        self.toolButtonAdd.clicked.connect(self.slotAddVariable)
        self.toolButtonDelete.clicked.connect(self.slotDeleteVariable)
        self.toolButtonImport.clicked.connect(self.slotImportVariable)

        self.modelVar.dataChanged.connect(self.dataChanged)

        self.case.undoStartGlobal()
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_CathareCouplingForm.__init__(self)
        self.setupUi(self)

        self.case = case

        self.case.undoStopGlobal()

        self.__model = CathareCouplingModel(self.case)

        # Main combo box
        self.activateCathareCpl = QtPage.ComboModel(self.comboBoxActiveCpl, 2,
                                                    1)
        self.activateCathareCpl.addItem(self.tr("No coupling"), "off")
        self.activateCathareCpl.addItem(self.tr("Activate coupling"), "on")

        # Models
        self.modelCathare = StandardItemModelCathare(self.__model)
        self.tableViewCathare.setModel(self.modelCathare)

        if QT_API == "PYQT4":
            self.tableViewCathare.verticalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewCathare.horizontalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewCathare.horizontalHeader().setResizeMode(
                4, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewCathare.verticalHeader().setSectionResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewCathare.horizontalHeader().setSectionResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewCathare.horizontalHeader().setSectionResizeMode(
                4, QHeaderView.Stretch)

        delegateCathareElt = LabelDelegate(self.tableViewCathare)
        self.tableViewCathare.setItemDelegateForColumn(0, delegateCathareElt)

        delegateCathareFCell = LabelDelegate(self.tableViewCathare)
        self.tableViewCathare.setItemDelegateForColumn(1, delegateCathareFCell)

        delegateCathareLCell = LabelDelegate(self.tableViewCathare)
        self.tableViewCathare.setItemDelegateForColumn(2, delegateCathareLCell)

        ncfdBcList = ['off']
        ncfdBcState = ['na']
        if self.case:
            d = LocalizationModel('BoundaryZone', self.case)
            for zone in d.getZones():
                ncfdBcList.append(zone.getLabel())
                ncfdBcState.append("on")
        delegateNeptuneBc = ComboDelegate(self.tableViewCathare,
                                          opts_list=ncfdBcList,
                                          opts_state=ncfdBcState)
        self.tableViewCathare.setItemDelegateForColumn(3, delegateNeptuneBc)

        # Create a selection delegate with autocompletion for mesh
        # selection examples
        _comp_list = GuiLabelManager().getCompleter("mesh_selection")
        delegateNeptune1dZone = LabelDelegate(self.tableViewCathare,
                                              xml_model=self.__model,
                                              accepted_regex="[ -~]*",
                                              auto_completion=_comp_list)
        self.tableViewCathare.setItemDelegateForColumn(4,
                                                       delegateNeptune1dZone)

        # Connections
        self.pushButtonAdd.clicked.connect(self.slotAddCathare)
        self.pushButtonDelete.clicked.connect(self.slotDeleteCathare)

        self.comboBoxActiveCpl.activated[str].connect(self.slotActivateCpl)

        self.radioButtonOnePhase.clicked.connect(self.slotOnePhase)
        self.radioButtonAllPhases.clicked.connect(self.slotAllPhases)

        self.lineEditCathareFile.textChanged[str].connect(self.slotCathareFile)
        self.toolButtonCathareFile.pressed.connect(self.searchCathareJDD)
        self.lineEditCplName.textChanged[str].connect(self.slotCplName)

        self.lineEditCplTime.textChanged[str].connect(self.slotCplTime)
        self.lineEditCathareInitTime.textChanged[str].connect(
            self.slotCathareTime)

        self.lineEditCathareInstance.textChanged[str].connect(
            self.slotCathareInstanceName)
        self.toolButtonCathareInstance.pressed.connect(self.searchCathareDir)
        self.lineEditNeptuneInstance.textChanged[str].connect(
            self.slotNeptuneInstanceName)
        self.toolButtonNeptuneInstance.pressed.connect(self.searchNeptuneDir)

        # Insert list of Cathare couplings for view
        for c in self.__model.getCathareCouplingList():
            [
                cathare_elt, cathare_first_cell, cathare_last_cell, neptune_bc,
                neptune_1d_zone
            ] = c

            self.modelCathare.addItem(cathare_elt, cathare_first_cell,
                                      cathare_last_cell, neptune_bc,
                                      neptune_1d_zone)

        # ------------------------------------------
        # Activate the coupling parameters if needed
        if self.__model.getCathareActivationStatus() != 0:
            self.activateCathareCpl.setItem(str_model="on")

        if self.__getActivationState() == 'off':
            self.groupBoxCathareCpls.hide()
            self.groupBoxCplParameters.hide()
        else:
            self.groupBoxCathareCpls.show()
            self.groupBoxCplParameters.show()

        # ------------------------------------------
        if self.__model.getNphases() == 0 or self.__model.getNphases() == 1:
            self.radioButtonOnePhase.setChecked(True)
            self.radioButtonAllPhases.setChecked(False)
        else:
            self.radioButtonOnePhase.setChecked(False)
            self.radioButtonAllPhases.setChecked(True)

        # ------------------------------------------
        if self.__getActivationState() == 'on':
            self.lineEditCathareFile.setText(str(
                self.__model.getCathareFile()))
            self.lineEditCplName.setText(str(self.__model.getCplName()))

            self.lineEditCplTime.setText(str(self.__model.getCplTime()))
            self.lineEditCathareInitTime.setText(
                str(self.__model.getCathareTime()))

            self.lineEditCathareInstance.setText(
                str(self.__model.getCathareInstanceName()))
            self.lineEditNeptuneInstance.setText(
                str(self.__model.getNeptuneInstanceName()))

        # ------------------------------------------
        self.case.undoStartGlobal()