Exemplo n.º 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", "Yes: Input", "Yes: Output"]
        otvalDelegate = ComboDelegate(self.treeViewNotebook,
                                      opts_list=OTOptions)
        self.treeViewNotebook.setItemDelegateForColumn(2, otvalDelegate)

        EditableOptions = ["No","Yes"]
        editableDelegate = ComboDelegate(self.treeViewNotebook,
                                         opts_list=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()
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 = 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()
Exemplo n.º 3
0
    def __init__(self, parent, case):
        """
        Constructor.
        """
        QWidget.__init__(self, parent)
        Ui_BalanceForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = BalanceModelNeptune(self.case)

        # Autocompletion for selector
        _comp_list = GuiLabelManager().getCompleter("mesh_selection")

        # tableView Pressure Drop
        self.pressureModel = StandardItemModelPressureDrop(self.mdl)
        self.tableViewPressureDrop.setModel(self.pressureModel)
        self.tableViewPressureDrop.setAlternatingRowColors(True)
        self.tableViewPressureDrop.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.tableViewPressureDrop.setSelectionMode(
            QAbstractItemView.SingleSelection)

        delegateIdxPres = IntegerDelegate(self.tableViewPressureDrop, minVal=0)
        self.tableViewPressureDrop.setItemDelegateForColumn(0, delegateIdxPres)

        delegateSelector = LabelDelegate(self.tableViewPressureDrop,
                                         auto_completion=_comp_list)
        self.tableViewPressureDrop.setItemDelegateForColumn(
            1, delegateSelector)

        self.tableViewPressureDrop.resizeColumnsToContents()
        self.tableViewPressureDrop.resizeRowsToContents()
        if QT_API == "PYQT4":
            self.tableViewPressureDrop.horizontalHeader().setResizeMode(
                1, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewPressureDrop.horizontalHeader().setSectionResizeMode(
                1, QHeaderView.Stretch)

        # tableView scalar balance
        self.modelScalarBalance = StandardItemModelScalarBalance(self.mdl)
        self.tableViewScalarBalance.setModel(self.modelScalarBalance)
        self.tableViewScalarBalance.resizeColumnToContents(0)
        self.tableViewScalarBalance.setAlternatingRowColors(True)
        self.tableViewScalarBalance.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.tableViewScalarBalance.setSelectionMode(
            QAbstractItemView.SingleSelection)

        delegateIdxScalar = IntegerDelegate(self.tableViewScalarBalance,
                                            minVal=0)
        self.tableViewScalarBalance.setItemDelegateForColumn(
            0, delegateIdxScalar)

        delegateVariable = LabelDelegate(self.tableViewScalarBalance)
        self.tableViewScalarBalance.setItemDelegateForColumn(
            1, delegateVariable)

        delegateSelector = LabelDelegate(self.tableViewScalarBalance,
                                         auto_completion=_comp_list)
        self.tableViewScalarBalance.setItemDelegateForColumn(
            1, delegateSelector)

        self.tableViewScalarBalance.resizeColumnsToContents()
        self.tableViewScalarBalance.resizeRowsToContents()
        if QT_API == "PYQT4":
            self.tableViewScalarBalance.horizontalHeader().setResizeMode(
                2, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewScalarBalance.horizontalHeader(
            ).setSectionResizeMode(2, QHeaderView.Stretch)

        # QListView layout
        self.gridlayout1 = QGridLayout(self.widgetDrag)
        self.gridlayout1.setContentsMargins(0, 0, 0, 0)
        self.DragList = QListView(self.widgetDrag)
        self.gridlayout1.addWidget(self.DragList, 0, 0, 1, 1)

        self.gridlayout2 = QGridLayout(self.widgetDrop)
        self.gridlayout2.setContentsMargins(0, 0, 0, 0)
        self.DropList = QListView(self.widgetDrop)
        self.gridlayout2.addWidget(self.DropList, 0, 0, 1, 1)

        self.modelDrag = QStringListModel()
        self.modelDrop = QStringListModel()
        self.DragList.setModel(self.modelDrag)
        self.DropList.setModel(self.modelDrop)
        self.DragList.setAlternatingRowColors(True)
        self.DragList.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.DropList.setAlternatingRowColors(True)
        self.DropList.setEditTriggers(QAbstractItemView.NoEditTriggers)

        # Connections
        self.pushButtonAddPressureDrop.clicked.connect(
            self.slotAddPressureDrop)
        self.pushButtonDeletePressureDrop.clicked.connect(
            self.slotDeletePressureDrop)
        self.tableViewScalarBalance.pressed[QModelIndex].connect(
            self.slotSelectScalarBalance)
        self.pushButtonAddScalarBalance.clicked.connect(
            self.slotAddScalarBalance)
        self.pushButtonDeleteScalarBalance.clicked.connect(
            self.slotDeleteScalarBalance)
        self.pushButtonAddVar.clicked.connect(self.slotAddVarProfile)
        self.pushButtonSuppressVar.clicked.connect(self.slotDeleteVarProfile)

        if self.mdl.getPressureDropList() != None:
            for i in range(len(self.mdl.getPressureDropList())):
                self.pressureModel.addItem(i)

        if self.mdl.getScalarBalanceList() != None:
            for i in range(len(self.mdl.getScalarBalanceList())):
                self.modelScalarBalance.addItem(i)

        #update list of variables, properties, scalars ...
        liste_label = []
        for label in self.mdl.getScalarVariables():
            liste_label.append(label)
        self.modelDrag.setStringList(sorted(liste_label, key=str.lower))

        self.__eraseEntries()

        self.case.undoStartGlobal()