コード例 #1
0
ファイル: bombaCurva.py プロジェクト: edusegzy/pychemqt
    def __init__(self, curva=[], parent=None):
        """curva: Parametro opcional indicando la curva de la bomba"""
        super(Ui_bombaCurva, self).__init__(parent)
        self.setWindowTitle(
            QtGui.QApplication.translate("pychemqt", "Pump curves dialog"))
        self.showMaximized()

        self.gridLayout = QtGui.QGridLayout(self)
        self.botones = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Open
            | QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Reset,
            QtCore.Qt.Vertical)
        self.botones.clicked.connect(self.botones_clicked)
        self.gridLayout.addWidget(self.botones, 1, 1, 3, 1)
        self.gridLayout.addItem(
            QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed), 1, 2, 3, 1)
        self.gridLayout.addWidget(
            QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Curves")),
            1, 3)
        self.lista = QtGui.QComboBox()
        self.lista.currentIndexChanged.connect(self.cambiarCurvaVista)
        self.gridLayout.addWidget(self.lista, 1, 4)
        self.gridLayout.addWidget(
            QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Diameter")),
            2, 3)
        self.diametro = Entrada_con_unidades(int, width=60, textounidad='"')
        self.gridLayout.addWidget(self.diametro, 2, 4)
        self.gridLayout.addWidget(
            QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "RPM")), 3,
            3)
        self.rpm = Entrada_con_unidades(int, width=60, textounidad="rpm")
        self.gridLayout.addWidget(self.rpm, 3, 4)
        self.gridLayout.addItem(
            QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed), 4, 1, 1, 4)

        self.Tabla = Tabla(
            4,
            horizontalHeader=[
                QtGui.QApplication.translate("pychemqt", "Flowrate"),
                QtGui.QApplication.translate("pychemqt", "Head"),
                QtGui.QApplication.translate("pychemqt", "Power"),
                QtGui.QApplication.translate("pychemqt", "NPSH")
            ],
            verticalOffset=1,
            filas=1,
            stretch=False)
        self.Tabla.setColumnWidth(0, 100)
        self.unidadesCaudal = QtGui.QComboBox()
        self.Tabla.setCellWidget(0, 0, self.unidadesCaudal)
        self.Tabla.setColumnWidth(1, 80)
        self.unidadesCarga = QtGui.QComboBox()
        self.Tabla.setCellWidget(0, 1, self.unidadesCarga)
        self.Tabla.setColumnWidth(2, 80)
        self.unidadesPotencia = QtGui.QComboBox()
        self.Tabla.setCellWidget(0, 2, self.unidadesPotencia)
        self.Tabla.setColumnWidth(3, 80)
        self.unidadesNPSH = QtGui.QComboBox()
        self.Tabla.setCellWidget(0, 3, self.unidadesNPSH)
        self.Tabla.setRowHeight(0, 24)
        self.Tabla.setFixedWidth(360)
        self.Tabla.setConnected()
        self.Tabla.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.gridLayout.addWidget(self.Tabla, 5, 1, 1, 4)
        self.gridLayout.addItem(
            QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed), 1, 5, 5, 1)

        self.checkCarga = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "Heat"))
        self.gridLayout.addWidget(self.checkCarga, 1, 6)
        self.checkPotencia = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "Power"))
        self.gridLayout.addWidget(self.checkPotencia, 1, 7)
        self.checkNPSH = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "NPSH"))
        self.gridLayout.addWidget(self.checkNPSH, 1, 8)
        self.rejilla = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "Grid"))
        self.rejilla.toggled.connect(self.rejilla_toggled)
        self.gridLayout.addWidget(self.rejilla, 1, 9)
        self.gridLayout.addItem(
            QtGui.QSpacerItem(1000, 20, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Fixed), 1, 10)
        self.Plot = Plot(self, width=5, height=1, dpi=100)
        self.gridLayout.addWidget(self.Plot, 2, 6, 4, 5)

        self.buttonBox = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.gridLayout.addWidget(self.buttonBox, 6, 9, 1, 2)

        if curva:
            self.curvas = curva
            for i in curva:
                self.lista.addItem(str(i[0]) + '", ' + str(i[1]) + " rpm")
            self.lista.setCurrentIndex(self.lista.count() - 1)
            self.cambiarCurvaVista(self.lista.count() - 1)

            #            self.curva=curva[-1]
            #            self.diametro.setValue(self.curva[0])
            #            self.rpm.setValue(self.curva[1])
            #            self.Tabla.setMatrix(self.curva[2:])
            #            self.Tabla.addRow()
            self.actualizarPlot()
        else:
            self.curva = []

        for i in Length.__text__:
            self.unidadesCarga.addItem(i)
            self.unidadesNPSH.addItem(i)
        for i in VolFlow.__text__:
            self.unidadesCaudal.addItem(i)
        for i in Power.__text__:
            self.unidadesPotencia.addItem(i)

        self.oldIndices = [0, 0, 0, 0]
        self.unidadesCaudal.currentIndexChanged.connect(
            partial(self.cambiar_unidades, 0, VolFlow, "VolFlow"))
        self.unidadesCarga.currentIndexChanged.connect(
            partial(
                self.cambiar_unidades,
                1,
                Length,
                "Head",
            ))
        self.unidadesPotencia.currentIndexChanged.connect(
            partial(self.cambiar_unidades, 2, Power, "Power"))
        self.unidadesNPSH.currentIndexChanged.connect(
            partial(
                self.cambiar_unidades,
                3,
                Length,
                "Head",
            ))

        Config = config.getMainWindowConfig()
        self.unidadesCaudal.setCurrentIndex(Config.getint("Units", "QLiq"))
        self.unidadesCarga.setCurrentIndex(Config.getint("Units", "Head"))
        self.unidadesPotencia.setCurrentIndex(Config.getint("Units", "Power"))
        self.unidadesNPSH.setCurrentIndex(Config.getint("Units", "Head"))

        self.checkCarga.toggled.connect(self.actualizarPlot)
        self.checkPotencia.toggled.connect(self.actualizarPlot)
        self.checkNPSH.toggled.connect(self.actualizarPlot)