Exemplo n.º 1
0
    def __init__(self, parent=None):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_CathareCouplingForm.__init__(self)
        self.setupUi(self)
Exemplo n.º 2
0
    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 = CathareEltDelegate(self.tableViewCathare)
        self.tableViewCathare.setItemDelegateForColumn(0, delegateCathareElt)

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

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

        delegateNeptuneBc = NcfdBcDelegate(self.tableViewCathare, case=case)
        self.tableViewCathare.setItemDelegateForColumn(3, delegateNeptuneBc)

        delegateNeptune1dZone = SelectionCriteriaDelegate(self.tableViewCathare,
                                                          self.__model)
        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.lineEditCplName.textChanged[str].connect(self.slotCplName)

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

        # 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.case.undoStartGlobal()
Exemplo n.º 3
0
    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()