예제 #1
0
class UI_equipment(UI_equip):
    """Mixer equipment edition dialog"""
    Equipment = Mixer()

    def __init__(self, equipment=None, entradas=1, parent=None):
        """
        equipment: Initial equipment instance to model
        entradas: Stream Input number to equipment
        """
        super().__init__(Mixer, salida=False, parent=parent)

        # Input tab
        for i in range(entradas):
            entrada = UI_corriente.Ui_corriente()
            entrada.Changed.connect(partial(self.cambiarEntrada, i))
            self.Entrada.addTab(entrada, str(i+1))

        # Calculate tab
        lyt_Calc = QtWidgets.QGridLayout(self.tabCalculo)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Output Pressure Method")), 1, 1)
        self.criterio = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_METODO:
            self.criterio.addItem(txt)
        self.criterio.currentIndexChanged.connect(self.criterio_Changed)
        lyt_Calc.addWidget(self.criterio, 1, 2)

        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            2, 1, 1, 3)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Output Pressure")), 3, 1)
        self.Pout = Entrada_con_unidades(Pressure)
        self.Pout.valueChanged.connect(partial(self.changeParams, "Pout"))
        lyt_Calc.addWidget(self.Pout, 3, 2)
        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 4, 1, 1, 3)

        self.criterio_Changed(0)

        if equipment:
            self.setEquipment(equipment)
        else:
            self.Equipment = Mixer(entradas=entradas)

    def criterio_Changed(self, int):
        self.Pout.setEnabled(int == 2)
        self.changeParams("criterio", int)

    def cambiarEntrada(self, ind, corriente):
        self.Equipment(id_entrada=ind, entrada=corriente)

    def rellenarInput(self):
        UI_equip.rellenarInput(self)
        for i, entrada in enumerate(self.Equipment.kwargs["entrada"]):
            if entrada:
                self.Entrada.widget(i).setCorriente(entrada)
예제 #2
0
class UI_equipment (UI_equip):
    """Valve equipment edition dialog"""
    Equipment = Valve()

    def __init__(self, equipment=None, parent=None):
        """
        equipment: Initial equipment instance to model
        """
        super(UI_equipment, self).__init__(Valve, entrada=False,
                                           salida=False, parent=parent)

        # Calculate tab
        lyt_Calc = QtGui.QGridLayout(self.tabCalculo)
        lyt_Calc.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Valve operation")), 1, 1)
        self.off = QtGui.QComboBox()
        for txt in self.Equipment.TEXT_WORKING:
            self.off.addItem(txt)
        self.off.currentIndexChanged.connect(self.criterio_Changed)
        lyt_Calc.addWidget(self.off, 1, 2)
        lyt_Calc.addItem(QtGui.QSpacerItem(
            20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed),
            2, 1, 1, 6)
        lyt_Calc.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Pout")), 3, 1)
        self.Pout = Entrada_con_unidades(Pressure)
        self.Pout.valueChanged.connect(partial(self.changeParams, "Pout"))
        lyt_Calc.addWidget(self.Pout, 3, 2)
        lyt_Calc.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "DeltaP")), 4, 1)
        self.DeltaP = Entrada_con_unidades(Pressure)
        self.DeltaP.valueChanged.connect(partial(self.changeParams, "DeltaP"))
        lyt_Calc.addWidget(self.DeltaP, 4, 2)
        lyt_Calc.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "T dew point")), 5, 1)
        self.Dew = Entrada_con_unidades(Temperature)
        self.Dew.valueChanged.connect(partial(self.changeParams, "Dew"))
        lyt_Calc.addWidget(self.Dew, 5, 2)
        lyt_Calc.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "T bubble point")), 6, 1)
        self.Bubble = Entrada_con_unidades(Temperature)
        self.Bubble.valueChanged.connect(partial(self.changeParams, "Bubble"))
        lyt_Calc.addWidget(self.Bubble, 6, 2)
        lyt_Calc.addItem(QtGui.QSpacerItem(
            20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding),
            10, 1, 1, 6)

        self.criterio_Changed(0)
        if equipment:
            self.setEquipment(equipment)

    def criterio_Changed(self, int):
        self.Pout.setEnabled(int == 1)
        self.DeltaP.setEnabled(int == 1)
        self.Dew.setEnabled(int == 1)
        self.Bubble.setEnabled(int == 1)
        self.calculo(off=int)
예제 #3
0
class UI_equipment (UI_equip):
    """Valve equipment edition dialog"""
    Equipment = Valve()

    def __init__(self, equipment=None, parent=None):
        """
        equipment: Initial equipment instance to model
        """
        super().__init__(Valve, entrada=False, salida=False, parent=parent)

        # Calculate tab
        lyt_Calc = QtWidgets.QGridLayout(self.tabCalculo)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Valve operation")), 1, 1)
        self.off = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_WORKING:
            self.off.addItem(txt)
        self.off.currentIndexChanged.connect(self.criterio_Changed)
        lyt_Calc.addWidget(self.off, 1, 2)
        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            2, 1, 1, 6)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Pout")), 3, 1)
        self.Pout = Entrada_con_unidades(Pressure)
        self.Pout.valueChanged.connect(partial(self.changeParams, "Pout"))
        lyt_Calc.addWidget(self.Pout, 3, 2)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "DeltaP")), 4, 1)
        self.DeltaP = Entrada_con_unidades(Pressure)
        self.DeltaP.valueChanged.connect(partial(self.changeParams, "DeltaP"))
        lyt_Calc.addWidget(self.DeltaP, 4, 2)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "T dew point")), 5, 1)
        self.Dew = Entrada_con_unidades(Temperature)
        self.Dew.valueChanged.connect(partial(self.changeParams, "Dew"))
        lyt_Calc.addWidget(self.Dew, 5, 2)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "T bubble point")), 6, 1)
        self.Bubble = Entrada_con_unidades(Temperature)
        self.Bubble.valueChanged.connect(partial(self.changeParams, "Bubble"))
        lyt_Calc.addWidget(self.Bubble, 6, 2)
        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 6)

        self.criterio_Changed(0)
        if equipment:
            self.setEquipment(equipment)

    def criterio_Changed(self, int):
        self.Pout.setEnabled(int == 1)
        self.DeltaP.setEnabled(int == 1)
        self.Dew.setEnabled(int == 1)
        self.Bubble.setEnabled(int == 1)
        self.calculo(off=int)
예제 #4
0
class UI_equipment(UI_equip):
    Equipment = Scrubber()
    """Scrubber equipment definition dialog"""
    def __init__(self, equipment=None, parent=None):
        """
        equipment: Initial equipment instance to model
        """
        super().__init__(Scrubber, parent=parent)

        # Input tab
        self.entradaGas = UI_corriente.Ui_corriente(psychro=True)
        self.entradaGas.Changed.connect(
            partial(self.changeParams, "entradaGas"))
        self.Entrada.addTab(
            self.entradaGas,
            QtWidgets.QApplication.translate("equipment", "Gas"))
        self.entradaLiquido = UI_corriente.Ui_corriente()
        self.entradaLiquido.Changed.connect(
            partial(self.changeParams, "entradaLiquido"))
        self.Entrada.addTab(
            self.entradaLiquido,
            QtWidgets.QApplication.translate("pychemqt", "Liquid"))

        # Calculate tab
        gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo)
        gridLayout_Calculo.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Mode")), 1, 1)
        self.tipo_calculo = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_TIPO:
            self.tipo_calculo.addItem(txt)
        self.tipo_calculo.currentIndexChanged.connect(
            self.on_tipoCalculo_currentIndexChanged)
        gridLayout_Calculo.addWidget(self.tipo_calculo, 1, 2, 1, 5)
        gridLayout_Calculo.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Method")), 2, 1)
        self.modelo_rendimiento = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_MODEL:
            self.modelo_rendimiento.addItem(txt)
        self.modelo_rendimiento.currentIndexChanged.connect(
            self.on_modeloRendimiento_currentIndexChanged)
        gridLayout_Calculo.addWidget(self.modelo_rendimiento, 2, 2, 1, 5)
        gridLayout_Calculo.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "ΔP method")), 3,
            1)
        self.modelo_DeltaP = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_MODEL_DELTAP:
            self.modelo_DeltaP.addItem(txt)
        self.modelo_DeltaP.currentIndexChanged.connect(
            self.on_modeloDeltaP_currentIndexChanged)
        gridLayout_Calculo.addWidget(self.modelo_DeltaP, 3, 2, 1, 5)

        gridLayout_Calculo.addItem(
            QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed,
                                  QtWidgets.QSizePolicy.Fixed), 4, 1, 1, 6)
        gridLayout_Calculo.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Diameter")), 5,
            1)
        self.diametro = Entrada_con_unidades(Length)
        self.diametro.valueChanged.connect(
            partial(self.changeParams, "diametro"))
        gridLayout_Calculo.addWidget(self.diametro, 5, 2)
        gridLayout_Calculo.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Efficiency")), 6,
            1)
        self.rendimientoAdmisible = Entrada_con_unidades(float, spinbox=True)
        self.rendimientoAdmisible.valueChanged.connect(
            partial(self.changeParams, "rendimientoAdmisible"))
        gridLayout_Calculo.addWidget(self.rendimientoAdmisible, 6, 2)

        self.groupJohnstone = QtWidgets.QWidget()
        gridLayout_Calculo.addWidget(self.groupJohnstone, 7, 1, 1, 2)
        JohnstoneLayout = QtWidgets.QHBoxLayout(self.groupJohnstone)
        JohnstoneLayout.setSpacing(0)
        JohnstoneLayout.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt",
                                                 "Ventury Constant")))
        self.k = Entrada_con_unidades(float, spinbox=True)
        self.k.valueChanged.connect(partial(self.changeParams, "k"))
        JohnstoneLayout.addWidget(self.k)

        self.groupCalvert = QtWidgets.QWidget()
        gridLayout_Calculo.addWidget(self.groupCalvert, 7, 1, 1, 2)
        CalvertLayout = QtWidgets.QHBoxLayout(self.groupCalvert)
        CalvertLayout.setSpacing(0)
        CalvertLayout.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "f parameter")))
        self.f = Entrada_con_unidades(float, spinbox=True)
        self.f.valueChanged.connect(partial(self.changeParams, "f"))
        CalvertLayout.addWidget(self.f)

        self.groupLt = QtWidgets.QWidget()
        gridLayout_Calculo.addWidget(self.groupLt, 5, 4, 1, 2)
        LtLayout = QtWidgets.QHBoxLayout(self.groupLt)
        LtLayout.setSpacing(0)
        LtLayout.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Length throat")))
        self.Lt = Entrada_con_unidades(Length)
        self.Lt.valueChanged.connect(partial(self.changeParams, "Lt"))
        LtLayout.addWidget(self.Lt)

        gridLayout_Calculo.addItem(
            QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding), 8, 1, 1, 6)
        self.groupBox_Calculo = QtWidgets.QGroupBox(
            QtWidgets.QApplication.translate("pychemqt", "Results"))
        gridLayout_Calculo.addWidget(self.groupBox_Calculo, 9, 1, 1, 5)
        gridLayout_1 = QtWidgets.QGridLayout(self.groupBox_Calculo)
        gridLayout_1.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Efficiency")), 1,
            1)
        self.rendimiento = Entrada_con_unidades(float,
                                                retornar=False,
                                                readOnly=True)
        gridLayout_1.addWidget(self.rendimiento, 1, 2)
        gridLayout_1.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "DeltaP")), 2, 1)
        self.deltaP = Entrada_con_unidades(DeltaP,
                                           retornar=False,
                                           readOnly=True)
        gridLayout_1.addWidget(self.deltaP, 2, 2)

        gridLayout_Calculo.addItem(
            QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding), 11, 1, 1,
            6)

        # Output Tab
        self.SalidaGas = UI_corriente.Ui_corriente(readOnly=True, psychro=True)
        self.Salida.addTab(
            self.SalidaGas,
            QtWidgets.QApplication.translate("pychemqt", "Clean Gas"))
        self.SalidaLiquido = UI_corriente.Ui_corriente(readOnly=True)
        self.Salida.addTab(
            self.SalidaLiquido,
            QtWidgets.QApplication.translate("pychemqt", "Liquid"))

        self.on_tipoCalculo_currentIndexChanged(0)
        self.on_modeloRendimiento_currentIndexChanged(0)
        self.on_modeloDeltaP_currentIndexChanged(0)
        if equipment:
            self.setEquipment(equipment)

    def on_tipoCalculo_currentIndexChanged(self, modelo):
        self.rendimientoAdmisible.setEnabled(modelo)
        self.rendimientoAdmisible.setReadOnly(not modelo)
        self.diametro.setEnabled(not modelo)
        self.diametro.setReadOnly(modelo)
        self.changeParams("tipo_calculo", modelo)

    def on_modeloRendimiento_currentIndexChanged(self, modelo):
        self.groupJohnstone.setVisible(False)
        self.groupCalvert.setVisible(False)
        if modelo == 0:
            self.groupJohnstone.setVisible(True)
        elif modelo == 1:
            self.groupCalvert.setVisible(True)
        self.changeParams("modelo_rendimiento", modelo)

    def on_modeloDeltaP_currentIndexChanged(self, modelo):
        self.groupLt.setVisible(False)
        if modelo in (3, 4):
            self.groupLt.setVisible(True)
        self.changeParams("modelo_DeltaP", modelo)
예제 #5
0
class PsychroInput(QtWidgets.QWidget):
    """Widget with parameter for psychrometric state"""
    parameters = ["tdb", "twb", "tdp", "w", "HR", "v", "h"]
    stateChanged = QtCore.pyqtSignal(PsyState)
    pressureChanged = QtCore.pyqtSignal()

    def __init__(self, state=None, readOnly=False, parent=None):
        """
        constructor
        optional state parameter to assign initial psychrometric state
        """
        super(PsychroInput, self).__init__(parent)

        self.state = PsychroState(P=101325)

        layout = QtWidgets.QGridLayout(self)
        self.checkPresion = QtWidgets.QRadioButton(
            QtWidgets.QApplication.translate("pychemqt", "Pressure"))
        layout.addWidget(self.checkPresion, 1, 1, 1, 1)
        self.P = Entrada_con_unidades(Pressure, value=101325)
        self.P.valueChanged.connect(self.changePressure)
        layout.addWidget(self.P, 1, 2, 1, 1)
        self.checkAltitud = QtWidgets.QRadioButton(
            QtWidgets.QApplication.translate("pychemqt", "Altitude"))
        layout.addWidget(self.checkAltitud, 2, 1, 1, 1)
        self.z = Entrada_con_unidades(Length, value=0)
        self.checkPresion.toggled.connect(self.P.setEnabled)
        self.checkAltitud.toggled.connect(self.z.setEnabled)
        self.z.valueChanged.connect(self.changeAltitude)
        self.checkPresion.setChecked(True)
        self.z.setEnabled(False)
        layout.addWidget(self.z, 2, 2, 1, 1)
        layout.addItem(QtWidgets.QSpacerItem(
            10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            3, 1, 1, 2)

        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Select point")), 4, 1, 1, 2)
        self.variables = QtWidgets.QComboBox()
        for txt in PsyState.TEXT_MODE:
            self.variables.addItem(txt)
        self.variables.currentIndexChanged.connect(self.updateInputs)
        layout.addWidget(self.variables, 5, 1, 1, 2)

        layout.addWidget(QtWidgets.QLabel("Tdb:"), 6, 1, 1, 1)
        self.tdb = Entrada_con_unidades(Temperature)
        self.tdb.valueChanged.connect(partial(self.updateKwargs, "tdb"))
        layout.addWidget(self.tdb, 6, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel("Twb:"), 7, 1, 1, 1)
        self.twb = Entrada_con_unidades(Temperature)
        self.twb.valueChanged.connect(partial(self.updateKwargs, "twb"))
        layout.addWidget(self.twb, 7, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel("Tdp:"), 8, 1, 1, 1)
        self.tdp = Entrada_con_unidades(Temperature)
        self.tdp.valueChanged.connect(partial(self.updateKwargs, "tdp"))
        layout.addWidget(self.tdp, 8, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Humidity Ratio:")), 9, 1, 1, 1)
        self.w = Entrada_con_unidades(float, textounidad="kgw/kgda")
        self.w.valueChanged.connect(partial(self.updateKwargs, "w"))
        layout.addWidget(self.w, 9, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Relative humidity:")), 10, 1, 1, 1)
        self.HR = Entrada_con_unidades(float, textounidad="%")
        self.HR.valueChanged.connect(partial(self.updateKwargs, "HR"))
        layout.addWidget(self.HR, 10, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Volume")), 11, 1, 1, 1)
        self.v = Entrada_con_unidades(SpecificVolume)
        self.v.valueChanged.connect(partial(self.updateKwargs, "v"))
        layout.addWidget(self.v, 11, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Enthalpy")), 12, 1, 1, 1)
        self.h = Entrada_con_unidades(Enthalpy)
        self.h.valueChanged.connect(partial(self.updateKwargs, "h"))
        layout.addWidget(self.h, 12, 2, 1, 1)
        layout.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            13, 1, 1, 2)

        self.setReadOnly(readOnly)
        self.updateInputs(0)
        if state:
            self.setState(state)

    def updateInputs(self, index):
        """Update inputs appearance to highlight active"""
        for par in self.parameters:
            self.__getattribute__(par).setReadOnly(True)
            self.__getattribute__(par).setResaltado(False)
        for par in PsyState.VAR_NAME[index]:
            self.__getattribute__(par).setReadOnly(False)
            self.__getattribute__(par).setResaltado(True)

        index = self.variables.currentIndex()
        kwargs = {"P": self.P.value}
        for par in PsyState.VAR_NAME[index]:
            if self.__getattribute__(par).value:
                kwargs[par] = self.state.__getattribute__(par)
        self.state = PsychroState(**kwargs)

    def setReadOnly(self, readOnly):
        self.checkPresion.setEnabled(not readOnly)
        self.checkAltitud.setEnabled(not readOnly)
        self.P.setReadOnly(readOnly)
        self.z.setReadOnly(readOnly)
        self.variables.setEnabled(not readOnly)
        for par in self.parameters:
            self.__getattribute__(par).setReadOnly(True)
            self.__getattribute__(par).setResaltado(False)

    def updateKwargs(self, key, value):
        """Update kwargs of state instance, if its correctly defined show it"""
        kwargs = {key: value}
        self.state(**kwargs)
        if self.state.status:
            self.setState(self.state)
            self.stateChanged.emit(self.state)

    def setState(self, state):
        """Fill data input with state properties"""
        self.state = state
        if state.w < state.ws:
            for p in self.parameters:
                self.__getattribute__(p).setValue(state.__getattribute__(p))

    def changePressure(self, value):
        """Change pressure to global plot and for states"""
        self.z.setValue(_height(value))
        self.state = PsychroState(P=value)
        self.pressureChanged.emit()

    def changeAltitude(self, value):
        """Change pressure through altitude and ICAO equation"""
        presion = _Pbar(value)
        self.P.setValue(presion)
        self.state = PsychroState(P=value)
        self.pressureChanged.emit()
예제 #6
0
class UI_confResolution_widget(QtWidgets.QWidget):
    """PFD resolution widget"""
    def __init__(self, config=None, parent=None):
        self.standards = [(600, 400), (640, 480), (720, 400), (800, 600),
                          (832, 624), (1024, 768), (1152, 864), (1280, 1024),
                          (1700, 1250), (1900, 1425), (2400, 1800),
                          (4000, 3000)]
        super(UI_confResolution_widget, self).__init__(parent)
        layout = QtWidgets.QGridLayout(self)
        layout.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt",
                                                 "Use default resolution:")),
            0, 0)
        self.standard = QtWidgets.QComboBox()
        self.standard.addItem("")
        for resolucion in self.standards:
            self.standard.addItem("%ix%i" % resolucion)
        self.standard.currentIndexChanged.connect(self.changeResolution)
        layout.addWidget(self.standard, 0, 1)

        self.checkCustom = QtWidgets.QCheckBox(
            QtWidgets.QApplication.translate("pychemqt",
                                             "Use Custom resolution"))
        layout.addWidget(self.checkCustom, 1, 0, 1, 2)
        label = QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Width:"))
        label.setIndent(50)
        layout.addWidget(label, 2, 0)
        self.x = Entrada_con_unidades(int, width=60, spinbox=True, step=1)
        layout.addWidget(self.x, 2, 1)
        label = QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Height:"))
        label.setIndent(50)
        layout.addWidget(label, 3, 0)
        self.y = Entrada_con_unidades(int, width=60, spinbox=True, step=1)
        layout.addWidget(self.y, 3, 1)

        self.checkCustom.toggled.connect(self.x.setEnabled)
        self.checkCustom.toggled.connect(self.y.setEnabled)

        if config and config.has_section("PFD"):
            x = config.getint("PFD", "x")
            y = config.getint("PFD", "y")
            self.x.setValue(x)
            self.y.setValue(y)
            if (x, y) in self.standards:
                self.standard.setCurrentIndex(self.standards.index((x, y)) + 1)
                self.checkCustom.setChecked(False)
                self.x.setEnabled(False)
                self.y.setEnabled(False)
            else:
                self.standard.setCurrentIndex(0)
                self.checkCustom.setChecked(True)

    def changeResolution(self):
        """Change resolution with value of current opction selected"""
        x, y = self.standard.currentText().split("x")
        self.x.setValue(int(x))
        self.y.setValue(int(y))

    def value(self, config):
        """Function result to wizard"""
        if not config.has_section("PFD"):
            config.add_section("PFD")
        config.set("PFD", "x", str(self.x.value))
        config.set("PFD", "y", str(self.y.value))
        return config

    @classmethod
    def default(cls, config):
        config.add_section("PFD")
        Preferences = ConfigParser()
        Preferences.read(conf_dir + "pychemqtrc")
        config.set("PFD", "x", Preferences.get("PFD", "x"))
        config.set("PFD", "y", Preferences.get("PFD", "y"))
        return config
예제 #7
0
class UI_confResolution_widget(QtWidgets.QWidget):
    """PFD resolution widget"""
    def __init__(self, config=None, parent=None):
        self.standards = [(600, 400), (640, 480), (720, 400), (800, 600),
                          (832, 624), (1024, 768), (1152, 864), (1280, 1024),
                          (1700, 1250), (1900, 1425), (2400, 1800), (4000, 3000)]
        super(UI_confResolution_widget, self).__init__(parent)
        layout = QtWidgets.QGridLayout(self)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Use default resolution:")), 0, 0)
        self.standard = QtWidgets.QComboBox()
        self.standard.addItem("")
        for resolucion in self.standards:
            self.standard.addItem("%ix%i" % resolucion)
        self.standard.currentIndexChanged.connect(self.changeResolution)
        layout.addWidget(self.standard, 0, 1)

        self.checkCustom = QtWidgets.QCheckBox(QtWidgets.QApplication.translate(
            "pychemqt", "Use Custom resolution"))
        layout.addWidget(self.checkCustom, 1, 0, 1, 2)
        label = QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Width:"))
        label.setIndent(50)
        layout.addWidget(label, 2, 0)
        self.x = Entrada_con_unidades(int, width=60, spinbox=True, step=1)
        layout.addWidget(self.x, 2, 1)
        label = QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Height:"))
        label.setIndent(50)
        layout.addWidget(label, 3, 0)
        self.y = Entrada_con_unidades(int, width=60, spinbox=True, step=1)
        layout.addWidget(self.y, 3, 1)

        self.checkCustom.toggled.connect(self.x.setEnabled)
        self.checkCustom.toggled.connect(self.y.setEnabled)

        if config and config.has_section("PFD"):
            x = config.getint("PFD", "x")
            y = config.getint("PFD", "y")
            self.x.setValue(x)
            self.y.setValue(y)
            if (x, y) in self.standards:
                self.standard.setCurrentIndex(self.standards.index((x, y))+1)
                self.checkCustom.setChecked(False)
                self.x.setEnabled(False)
                self.y.setEnabled(False)
            else:
                self.standard.setCurrentIndex(0)
                self.checkCustom.setChecked(True)

    def changeResolution(self):
        """Change resolution with value of current opction selected"""
        x, y = self.standard.currentText().split("x")
        self.x.setValue(int(x))
        self.y.setValue(int(y))

    def value(self, config):
        """Function result to wizard"""
        if not config.has_section("PFD"):
            config.add_section("PFD")
        config.set("PFD", "x", str(self.x.value))
        config.set("PFD", "y", str(self.y.value))
        return config

    @classmethod
    def default(cls, config):
        config.add_section("PFD")
        Preferences = ConfigParser()
        Preferences.read(conf_dir+"pychemqtrc")
        config.set("PFD", "x", Preferences.get("PFD", "x"))
        config.set("PFD", "y", Preferences.get("PFD", "y"))
        return config
예제 #8
0
class PsychroInput(QtWidgets.QWidget):
    """Widget with parameter for psychrometric state"""
    parameters = ["tdb", "twb", "tdp", "w", "HR", "v", "h"]
    stateChanged = QtCore.pyqtSignal(PsyState)
    pressureChanged = QtCore.pyqtSignal()

    def __init__(self, state=None, readOnly=False, parent=None):
        """
        constructor
        optional state parameter to assign initial psychrometric state"""
        super(PsychroInput, self).__init__(parent)

        self.state = PsychroState(P=101325)
        self.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)

        layout = QtWidgets.QGridLayout(self)
        self.checkPresion = QtWidgets.QRadioButton(
                QtWidgets.QApplication.translate("pychemqt", "Pressure"))
        layout.addWidget(self.checkPresion, 1, 1, 1, 1)
        self.P = Entrada_con_unidades(unidades.Pressure, value=101325)
        self.P.valueChanged.connect(self.changePressure)
        layout.addWidget(self.P, 1, 2, 1, 1)
        self.checkAltitud = QtWidgets.QRadioButton(
                QtWidgets.QApplication.translate("pychemqt", "Altitude"))
        layout.addWidget(self.checkAltitud, 2, 1, 1, 1)
        self.z = Entrada_con_unidades(unidades.Length, value=0)
        self.checkPresion.toggled.connect(self.P.setEnabled)
        self.checkAltitud.toggled.connect(self.z.setEnabled)
        self.z.valueChanged.connect(self.changeAltitude)
        self.checkPresion.setChecked(True)
        self.z.setEnabled(False)
        layout.addWidget(self.z, 2, 2, 1, 1)
        layout.addItem(QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed,
                                         QtWidgets.QSizePolicy.Fixed), 3, 1, 1, 2)

        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Select point")), 4, 1, 1, 2)
        self.variables = QtWidgets.QComboBox()
        for txt in PsyState.TEXT_MODE:
            self.variables.addItem(txt)
        self.variables.currentIndexChanged.connect(self.updateInputs)
        layout.addWidget(self.variables, 5, 1, 1, 2)

        layout.addWidget(QtWidgets.QLabel("Tdb:"), 6, 1, 1, 1)
        self.tdb = Entrada_con_unidades(unidades.Temperature)
        self.tdb.valueChanged.connect(partial(self.updateKwargs, "tdb"))
        layout.addWidget(self.tdb, 6, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel("Twb:"), 7, 1, 1, 1)
        self.twb = Entrada_con_unidades(unidades.Temperature)
        self.twb.valueChanged.connect(partial(self.updateKwargs, "twb"))
        layout.addWidget(self.twb, 7, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel("Tdp:"), 8, 1, 1, 1)
        self.tdp = Entrada_con_unidades(unidades.Temperature)
        self.tdp.valueChanged.connect(partial(self.updateKwargs, "tdp"))
        layout.addWidget(self.tdp, 8, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Humidity Ratio:")), 9, 1, 1, 1)
        self.w = Entrada_con_unidades(float, textounidad="kgw/kgda")
        self.w.valueChanged.connect(partial(self.updateKwargs, "w"))
        layout.addWidget(self.w, 9, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Relative humidity:")), 10, 1, 1, 1)
        self.HR = Entrada_con_unidades(float, textounidad="%")
        self.HR.valueChanged.connect(partial(self.updateKwargs, "HR"))
        layout.addWidget(self.HR, 10, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Volume")), 11, 1, 1, 1)
        self.v = Entrada_con_unidades(unidades.SpecificVolume)
        self.v.valueChanged.connect(partial(self.updateKwargs, "v"))
        layout.addWidget(self.v, 11, 2, 1, 1)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Enthalpy")), 12, 1, 1, 1)
        self.h = Entrada_con_unidades(unidades.Enthalpy)
        self.h.valueChanged.connect(partial(self.updateKwargs, "h"))
        layout.addWidget(self.h, 12, 2, 1, 1)
        layout.addItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed,
                                         QtWidgets.QSizePolicy.Fixed),13,1,1,2)

        self.setReadOnly(readOnly)
        self.updateInputs(0)
        if state:
            self.setState(state)

    def updateInputs(self, index):
        """Update inputs appearance to highlight active"""
        for par in self.parameters:
            self.__getattribute__(par).setReadOnly(True)
            self.__getattribute__(par).setResaltado(False)
        for par in PsyState.VAR_NAME[index]:
            self.__getattribute__(par).setReadOnly(False)
            self.__getattribute__(par).setResaltado(True)

        index = self.variables.currentIndex()
        kwargs = {"P": self.P.value}
        for par in PsyState.VAR_NAME[index]:
            if self.__getattribute__(par).value:
                kwargs[par] = self.state.__getattribute__(par)
        self.state = PsychroState(**kwargs)

    def setReadOnly(self, readOnly):
        self.checkPresion.setEnabled(not readOnly)
        self.checkAltitud.setEnabled(not readOnly)
        self.P.setReadOnly(readOnly)
        self.z.setReadOnly(readOnly)
        self.variables.setEnabled(not readOnly)
        for par in self.parameters:
            self.__getattribute__(par).setReadOnly(True)
            self.__getattribute__(par).setResaltado(False)

    def updateKwargs(self, key, value):
        """Update kwargs of state instance, if its correctly defined show it"""
        kwargs = {key: value}
        self.state(**kwargs)
        if self.state.status:
            self.setState(self.state)
            self.stateChanged.emit(self.state)

    def setState(self, state):
        """Fill data input with state properties"""
        self.state = state
        if state.w < state.ws:
            for par in self.parameters:
                self.__getattribute__(par).setValue(state.__getattribute__(par))

    def changePressure(self, value):
        """Change pressure to global plot and for states"""
        self.z.setValue(_height(value))
        self.state = PsychroState(P=value)
        self.pressureChanged.emit()

    def changeAltitude(self, value):
        """Change pressure through altitude and ICAO equation"""
        presion = _Pbar(value)
        self.P.setValue(presion)
        self.state = PsychroState(P=value)
        self.pressureChanged.emit()
예제 #9
0
class UI_equipment(UI_equip):
    Equipment = Scrubber()
    """Scrubber equipment definition dialog"""
    def __init__(self, equipment=None, parent=None):
        """
        equipment: Initial equipment instance to model
        """
        super().__init__(Scrubber, parent=parent)

        # Input tab
        self.entradaGas = UI_corriente.Ui_corriente(psychro=True)
        self.entradaGas.Changed.connect(
            partial(self.changeParams, "entradaGas"))
        self.Entrada.addTab(
            self.entradaGas,
            QtWidgets.QApplication.translate("equipment", "Gas"))
        self.entradaLiquido = UI_corriente.Ui_corriente()
        self.entradaLiquido.Changed.connect(
            partial(self.changeParams, "entradaLiquido"))
        self.Entrada.addTab(
            self.entradaLiquido,
            QtWidgets.QApplication.translate("pychemqt", "Liquid"))

        # Calculate tab
        gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo)
        gridLayout_Calculo.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Mode")), 1, 1)
        self.tipo_calculo = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_TIPO:
            self.tipo_calculo.addItem(txt)
        self.tipo_calculo.currentIndexChanged.connect(
            self.on_tipoCalculo_currentIndexChanged)
        gridLayout_Calculo.addWidget(self.tipo_calculo, 1, 2, 1, 5)
        gridLayout_Calculo.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Method")), 2, 1)
        self.modelo_rendimiento = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_MODEL:
            self.modelo_rendimiento.addItem(txt)
        self.modelo_rendimiento.currentIndexChanged.connect(
            self.on_modeloRendimiento_currentIndexChanged)
        gridLayout_Calculo.addWidget(self.modelo_rendimiento, 2, 2, 1, 5)
        gridLayout_Calculo.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "ΔP method")), 3, 1)
        self.modelo_DeltaP = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_MODEL_DELTAP:
            self.modelo_DeltaP.addItem(txt)
        self.modelo_DeltaP.currentIndexChanged.connect(
            self.on_modeloDeltaP_currentIndexChanged)
        gridLayout_Calculo.addWidget(self.modelo_DeltaP, 3, 2, 1, 5)

        gridLayout_Calculo.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Fixed,
            QtWidgets.QSizePolicy.Fixed), 4, 1, 1, 6)
        gridLayout_Calculo.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Diameter")), 5, 1)
        self.diametro = Entrada_con_unidades(Length)
        self.diametro.valueChanged.connect(
            partial(self.changeParams, "diametro"))
        gridLayout_Calculo.addWidget(self.diametro, 5, 2)
        gridLayout_Calculo.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Efficiency")), 6, 1)
        self.rendimientoAdmisible = Entrada_con_unidades(float, spinbox=True)
        self.rendimientoAdmisible.valueChanged.connect(
            partial(self.changeParams, "rendimientoAdmisible"))
        gridLayout_Calculo.addWidget(self.rendimientoAdmisible, 6, 2)

        self.groupJohnstone = QtWidgets.QWidget()
        gridLayout_Calculo.addWidget(self.groupJohnstone, 7, 1, 1, 2)
        JohnstoneLayout = QtWidgets.QHBoxLayout(self.groupJohnstone)
        JohnstoneLayout.setSpacing(0)
        JohnstoneLayout.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Ventury Constant")))
        self.k = Entrada_con_unidades(float, spinbox=True)
        self.k.valueChanged.connect(partial(self.changeParams, "k"))
        JohnstoneLayout.addWidget(self.k)

        self.groupCalvert = QtWidgets.QWidget()
        gridLayout_Calculo.addWidget(self.groupCalvert, 7, 1, 1, 2)
        CalvertLayout = QtWidgets.QHBoxLayout(self.groupCalvert)
        CalvertLayout.setSpacing(0)
        CalvertLayout.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "f parameter")))
        self.f = Entrada_con_unidades(float, spinbox=True)
        self.f.valueChanged.connect(partial(self.changeParams, "f"))
        CalvertLayout.addWidget(self.f)

        self.groupLt = QtWidgets.QWidget()
        gridLayout_Calculo.addWidget(self.groupLt, 5, 4, 1, 2)
        LtLayout = QtWidgets.QHBoxLayout(self.groupLt)
        LtLayout.setSpacing(0)
        LtLayout.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Length throat")))
        self.Lt = Entrada_con_unidades(Length)
        self.Lt.valueChanged.connect(partial(self.changeParams, "Lt"))
        LtLayout.addWidget(self.Lt)

        gridLayout_Calculo.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 8, 1, 1, 6)
        self.groupBox_Calculo = QtWidgets.QGroupBox(
            QtWidgets.QApplication.translate("pychemqt", "Results"))
        gridLayout_Calculo.addWidget(self.groupBox_Calculo, 9, 1, 1, 5)
        gridLayout_1 = QtWidgets.QGridLayout(self.groupBox_Calculo)
        gridLayout_1.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Efficiency")), 1, 1)
        self.rendimiento = Entrada_con_unidades(
            float, retornar=False, readOnly=True)
        gridLayout_1.addWidget(self.rendimiento, 1, 2)
        gridLayout_1.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "DeltaP")), 2, 1)
        self.deltaP = Entrada_con_unidades(
            DeltaP, retornar=False, readOnly=True)
        gridLayout_1.addWidget(self.deltaP, 2, 2)

        gridLayout_Calculo.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 11, 1, 1, 6)

        # Output Tab
        self.SalidaGas = UI_corriente.Ui_corriente(readOnly=True, psychro=True)
        self.Salida.addTab(
            self.SalidaGas,
            QtWidgets.QApplication.translate("pychemqt", "Clean Gas"))
        self.SalidaLiquido = UI_corriente.Ui_corriente(readOnly=True)
        self.Salida.addTab(
            self.SalidaLiquido,
            QtWidgets.QApplication.translate("pychemqt", "Liquid"))

        self.on_tipoCalculo_currentIndexChanged(0)
        self.on_modeloRendimiento_currentIndexChanged(0)
        self.on_modeloDeltaP_currentIndexChanged(0)
        if equipment:
            self.setEquipment(equipment)

    def on_tipoCalculo_currentIndexChanged(self, modelo):
        self.rendimientoAdmisible.setEnabled(modelo)
        self.rendimientoAdmisible.setReadOnly(not modelo)
        self.diametro.setEnabled(not modelo)
        self.diametro.setReadOnly(modelo)
        self.changeParams("tipo_calculo", modelo)

    def on_modeloRendimiento_currentIndexChanged(self, modelo):
        self.groupJohnstone.setVisible(False)
        self.groupCalvert.setVisible(False)
        if modelo == 0:
            self.groupJohnstone.setVisible(True)
        elif modelo == 1:
            self.groupCalvert.setVisible(True)
        self.changeParams("modelo_rendimiento", modelo)

    def on_modeloDeltaP_currentIndexChanged(self, modelo):
        self.groupLt.setVisible(False)
        if modelo in (3, 4):
            self.groupLt.setVisible(True)
        self.changeParams("modelo_DeltaP", modelo)
예제 #10
0
class Ui_Contribution(newComponent):
    """Dialog to define hypotethical new component with several group
    contribucion methods"""
    ViewDetails = View_Contribution

    def __init__(self, metodo, parent=None):
        """Metodo: name of group contribution method:
            Joback, Constantinou, Wilson, Marrero, Elliott, Ambrose, Klincewicz
        """
        super(Ui_Contribution, self).__init__(parent)

        # Initialization variables
        self.grupo = []
        self.indices = []
        self.contribucion = []

        func = {}
        for f in _methods:
            func[f.__name__] = f
        self.unknown = func[metodo]()

        title = self.unknown.__title__
        title += " " + QtWidgets.QApplication.translate(
            "pychemqt", "new component definition")
        self.setWindowTitle(title)

        lyt = QtWidgets.QVBoxLayout(self)
        widget = QtWidgets.QWidget()
        layout = QtWidgets.QGridLayout(widget)

        layout.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Name")), 1, 0)
        self.nombre = QtWidgets.QLineEdit()
        self.nombre.textChanged.connect(partial(self.changeParams, "name"))
        layout.addWidget(self.nombre, 1, 1, 1, 3)

        self.Group = QtWidgets.QTableWidget()
        self.Group.verticalHeader().hide()
        self.Group.setRowCount(0)
        self.Group.setColumnCount(2)
        self.Group.setHorizontalHeaderItem(0, QtWidgets.QTableWidgetItem("Nk"))
        self.Group.setHorizontalHeaderItem(
            1,
            QtWidgets.QTableWidgetItem(
                QtWidgets.QApplication.translate("pychemqt", "Group")))
        self.Group.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.Group.setSortingEnabled(True)
        self.Group.horizontalHeader().setStretchLastSection(True)
        self.Group.setColumnWidth(0, 50)
        self.Group.setItemDelegateForColumn(0, SpinEditor(self))
        self.Group.cellChanged.connect(self.cellChanged)
        self.Group.setEditTriggers(QtWidgets.QAbstractItemView.AllEditTriggers)
        layout.addWidget(self.Group, 2, 0, 3, 3)

        self.Formula = QtWidgets.QLabel()
        font = QtGui.QFont()
        font.setPointSize(12)
        self.Formula.setFont(font)
        self.Formula.setAlignment(QtCore.Qt.AlignCenter
                                  | QtCore.Qt.AlignVCenter)
        self.Formula.setFixedHeight(50)
        layout.addWidget(self.Formula, 2, 3)
        self.btnDelete = QtWidgets.QPushButton(
            QtGui.QIcon(
                QtGui.QPixmap(
                    os.path.join(IMAGE_PATH, "button", "editDelete.png"))),
            QtWidgets.QApplication.translate("pychemqt", "Delete"))
        self.btnDelete.clicked.connect(self.borrar)
        layout.addWidget(self.btnDelete, 3, 3)
        self.btnClear = QtWidgets.QPushButton(
            QtGui.QIcon(
                QtGui.QPixmap(os.path.join(IMAGE_PATH, "button",
                                           "clear.png"))),
            QtWidgets.QApplication.translate("pychemqt", "Clear"))
        self.btnClear.clicked.connect(self.clear)
        layout.addWidget(self.btnClear, 4, 3)

        self.line = QtWidgets.QFrame()
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        layout.addWidget(self.line, 5, 0, 1, 4)

        self.groupContributions = QtWidgets.QListWidget()
        self.groupContributions.currentItemChanged.connect(self.selectChanged)
        self.groupContributions.itemDoubleClicked.connect(self.add)
        layout.addWidget(self.groupContributions, 6, 0, 6, 3)
        self.btnAdd = QtWidgets.QPushButton(
            QtGui.QIcon(
                QtGui.QPixmap(os.path.join(IMAGE_PATH, "button", "add.png"))),
            QtWidgets.QApplication.translate("pychemqt", "Add"))
        self.btnAdd.setDisabled(True)
        self.btnAdd.clicked.connect(self.add)
        layout.addWidget(self.btnAdd, 6, 3)
        layout.addItem(
            QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding), 7, 1)

        # Show selection for method with several order contributions
        if self.unknown.SecondOrder:
            self.Order1 = QtWidgets.QRadioButton(
                QtWidgets.QApplication.translate("pychemqt", "1st order"))
            self.Order1.setChecked(True)
            self.Order1.toggled.connect(self.Order)
            layout.addWidget(self.Order1, 9, 3)
            self.Order2 = QtWidgets.QRadioButton(
                QtWidgets.QApplication.translate("pychemqt", "2nd order"))
            self.Order2.toggled.connect(self.Order)
            layout.addWidget(self.Order2, 10, 3)

            if self.unknown.ThirdOrder:
                self.Order3 = QtWidgets.QRadioButton(
                    QtWidgets.QApplication.translate("pychemqt", "3rd order"))
                layout.addWidget(self.Order3, 11, 3)
                self.Order3.toggled.connect(self.Order)

        layout.addItem(
            QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed,
                                  QtWidgets.QSizePolicy.Fixed), 12, 1)
        labelTb = QtWidgets.QLabel("Tb")
        labelTb.setToolTip(
            QtWidgets.QApplication.translate(
                "pychemqt", "Experimental Boiling Temperature"))
        layout.addWidget(labelTb, 13, 0)
        self.Tb = Entrada_con_unidades(Temperature)
        self.Tb.valueChanged.connect(partial(self.changeParams, "Tb"))
        layout.addWidget(self.Tb, 13, 1)
        labelM = QtWidgets.QLabel("M")
        labelM.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Molecular Weight"))
        layout.addWidget(labelM, 14, 0)
        self.M = Entrada_con_unidades(float, textounidad="g/mol")
        self.M.valueChanged.connect(partial(self.changeParams, "M"))
        layout.addWidget(self.M, 14, 1)
        label = QtWidgets.QLabel("SG")
        label.setToolTip(
            QtWidgets.QApplication.translate(
                "pychemqt", "Experimental Specific Gravity at 60ºF"))
        layout.addWidget(label, 15, 0)
        self.SG = Entrada_con_unidades(float)
        self.SG.valueChanged.connect(partial(self.changeParams, "SG"))
        layout.addWidget(self.SG, 15, 1)
        lyt.addWidget(widget)

        # Show widget for specific method
        if metodo == "Constantinou":
            # Disable Tb as input parameter
            labelTb.setEnabled(False)
            self.Tb.setEnabled(False)

        elif metodo == "Wilson":
            self.Tb.setResaltado(True)
            layout.addWidget(
                QtWidgets.QLabel(
                    QtWidgets.QApplication.translate("pychemqt", "Rings")), 16,
                0)
            self.ring = QtWidgets.QSpinBox()
            self.ring.setFixedWidth(80)
            self.ring.valueChanged.connect(partial(self.changeParams, "ring"))
            layout.addWidget(self.ring, 16, 1)

        elif metodo == "Elliott":
            self.M.setResaltado(True)

        elif metodo == "Ambrose":
            self.Tb.setResaltado(True)
            layout.addWidget(
                QtWidgets.QLabel(
                    QtWidgets.QApplication.translate("pychemqt",
                                                     "Platt number")), 16, 0)
            self.plat = QtWidgets.QSpinBox()
            self.plat.setFixedWidth(80)
            tr = "The Platt number is the number of pairs of carbon atoms "
            tr += "which are separated by three carbon-carbon bonds and is an "
            tr += "indicator of the degree of branching in the molecule. The "
            tr += "Platt number of an n-alkane is equal to the number of "
            tr += "carbons minus three"
            self.plat.setToolTip(
                QtWidgets.QApplication.translate("pychemqt", tr))
            self.plat.valueChanged.connect(partial(self.changeParams, "platt"))
            layout.addWidget(self.plat, 16, 1)

        elif metodo == "Klincewicz":
            self.Tb.setResaltado(True)

            self.nogroupKlincewicz = QtWidgets.QCheckBox(
                QtWidgets.QApplication.translate(
                    "pychemqt", "Use the simple no group contribution method"))
            self.nogroupKlincewicz.toggled.connect(self.nogroupCheckToggled)
            layout.addWidget(self.nogroupKlincewicz, 16, 0, 1, 4)
            layout.addWidget(
                QtWidgets.QLabel(
                    QtWidgets.QApplication.translate("pychemqt", "Atoms")), 17,
                0)
            self.atoms = QtWidgets.QSpinBox()
            self.atoms.setFixedWidth(80)
            self.atoms.valueChanged.connect(partial(self.changeParams,
                                                    "atoms"))
            layout.addWidget(self.atoms, 17, 1)

        newComponent.loadUI(self)

        for i, nombre in enumerate(self.unknown.coeff["txt"]):
            self.groupContributions.addItem(nombre[0])

        if self.unknown.SecondOrder:
            self.Order()
        if metodo == "Klincewicz":
            self.nogroupCheckToggled(False)

    def Order(self):
        """Show/Hide group of undesired order"""
        for i in range(self.unknown.FirstOrder):
            item = self.groupContributions.item(i)
            item.setHidden(not self.Order1.isChecked())
        for i in range(self.unknown.FirstOrder, self.unknown.SecondOrder):
            item = self.groupContributions.item(i)
            item.setHidden(not self.Order2.isChecked())
        if self.unknown.ThirdOrder:
            for i in range(self.unknown.SecondOrder, self.unknown.ThirdOrder):
                item = self.groupContributions.item(i)
                item.setHidden(not self.Order3.isChecked())

    def nogroupCheckToggled(self, boolean):
        """Set advanced properties input status for Klincewitcz method"""
        self.changeParams("nogroup", boolean)
        self.M.setResaltado(boolean)
        self.atoms.setEnabled(boolean)
        self.Group.setDisabled(boolean)
        self.Formula.setDisabled(boolean)
        self.btnDelete.setDisabled(boolean)
        self.btnClear.setDisabled(boolean)
        self.btnAdd.setDisabled(boolean)
        self.groupContributions.setDisabled(boolean)

    def borrar(self, indice=None):
        """Remove some group contribution from added group list"""
        if not indice:
            indice = self.Group.currentRow()
        if indice != -1:
            self.Group.removeRow(indice)
            del self.grupo[indice]
            del self.indices[indice]
            del self.contribucion[indice]
            self.calculo(**{
                "group": self.indices,
                "contribution": self.contribucion
            })

    def clear(self):
        """Clear widgets from dialog"""
        self.Group.clearContents()
        self.Group.setRowCount(0)
        self.grupo = []
        self.indices = []
        self.contribucion = []
        self.Formula.clear()
        self.M.clear()
        self.nombre.clear()
        self.Tb.clear()
        self.SG.clear()
        self.unknown.clear()
        self.status.setState(self.unknown.status, self.unknown.msg)

    def cellChanged(self, i, j):
        """Process the user manual count of group contribution changed"""
        if j == 0:
            valor = int(self.Group.item(i, j).text())
            if valor <= 0:
                self.borrar(i)
            else:
                self.contribucion[i] = int(valor)
        kw = {"group": self.indices, "contribution": self.contribucion}
        self.calculo(**kw)

    def selectChanged(self, i):
        """The add button is only enabled when the group list have any selected
        row"""
        self.btnAdd.setEnabled(i != -1)

    def add(self):
        """Add the current selected item to the list of group"""
        indice = self.Group.rowCount()
        grupo = self.groupContributions.currentItem().text()
        if grupo not in self.grupo:
            self.grupo.append(grupo)
            self.indices.append(self.groupContributions.currentRow())
            self.contribucion.append(1)
            self.Group.setRowCount(indice + 1)
            self.Group.setItem(indice, 0, QtWidgets.QTableWidgetItem("1"))
            self.Group.item(indice,
                            0).setTextAlignment(QtCore.Qt.AlignRight
                                                | QtCore.Qt.AlignVCenter)
            self.Group.setItem(indice, 1, QtWidgets.QTableWidgetItem(grupo))
            self.Group.item(indice, 1).setFlags(QtCore.Qt.ItemIsSelectable
                                                | QtCore.Qt.ItemIsEnabled)
            self.Group.setRowHeight(indice, 20)
        else:
            indice = self.grupo.index(grupo)
            self.contribucion[indice] += 1
            self.Group.item(indice, 0).setText(
                str(int(self.Group.item(indice, 0).text()) + 1))
        kw = {"group": self.indices, "contribution": self.contribucion}
        self.calculo(**kw)

    def calculo(self, **kwargs):
        """Calculate function"""
        newComponent.calculo(self, **kwargs)
        if self.unknown.status in (1, 3):
            self.Formula.setText(self.unknown.formula)
예제 #11
0
class Definicion_Petro(newComponent):
    """Dialog for define hypothetical crude and oil fraction"""
    ViewDetails = View_Petro

    def __init__(self, parent=None):
        super(Definicion_Petro, self).__init__(parent)
        self.setWindowTitle(QtGui.QApplication.translate(
            "pychemqt", "Petrol component definition"))
        layout = QtGui.QGridLayout(self)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Name")), 1, 1)
        self.nombre = QtGui.QLineEdit()
        self.nombre.textChanged.connect(partial(self.changeParams, "name"))
        layout.addWidget(self.nombre, 1, 2, 1, 4)
        layout.addItem(QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed,
                                         QtGui.QSizePolicy.Fixed), 2, 1, 1, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Boiling point")), 3, 1)
        self.Tb = Entrada_con_unidades(Temperature)
        self.Tb.valueChanged.connect(partial(self.changeParams, "Tb"))
        layout.addWidget(self.Tb, 3, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Molecular Weight")), 4, 1)
        self.M = Entrada_con_unidades(float, textounidad="g/mol")
        self.M.valueChanged.connect(partial(self.changeParams, "M"))
        layout.addWidget(self.M, 4, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Specific Gravity")), 5, 1)
        self.SG = Entrada_con_unidades(float)
        self.SG.valueChanged.connect(partial(self.changeParams, "SG"))
        layout.addWidget(self.SG, 5, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "API gravity")), 6, 1)
        self.API = Entrada_con_unidades(float)
        self.API.valueChanged.connect(partial(self.changeParams, "API"))
        layout.addWidget(self.API, 6, 2)
        layout.addWidget(QtGui.QLabel("K watson:"), 7, 1)
        self.Kw = Entrada_con_unidades(float)
        self.Kw.valueChanged.connect(partial(self.changeParams, "Kw"))
        layout.addWidget(self.Kw, 7, 2)
        layout.addWidget(QtGui.QLabel("C/H:"), 8, 1)
        self.CH = Entrada_con_unidades(float)
        self.CH.valueChanged.connect(partial(self.changeParams, "CH"))
        layout.addWidget(self.CH, 8, 2)
        layout.addWidget(QtGui.QLabel(u"ν<sub>100F</sub>:"), 9, 1)
        self.v100 = Entrada_con_unidades(Diffusivity)
        self.v100.valueChanged.connect(partial(self.changeParams, "v100"))
        layout.addWidget(self.v100, 9, 2)
        layout.addWidget(QtGui.QLabel(u"ν<sub>210F</sub>:"), 10, 1)
        self.v210 = Entrada_con_unidades(Diffusivity)
        self.v210.valueChanged.connect(partial(self.changeParams, "v210"))
        layout.addWidget(self.v210, 10, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Refraction index")), 11, 1)
        self.n = Entrada_con_unidades(float)
        self.n.valueChanged.connect(partial(self.changeParams, "n"))
        layout.addWidget(self.n, 11, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Huang parameter")), 12, 1)
        self.I = Entrada_con_unidades(float)
        self.I.valueChanged.connect(partial(self.changeParams, "I"))
        layout.addWidget(self.I, 12, 2)
        layout.addWidget(QtGui.QLabel("%S"), 13, 1)
        self.S = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.S.valueChanged.connect(partial(self.changeParams, "S"))
        layout.addWidget(self.S, 13, 2)
        layout.addWidget(QtGui.QLabel("%H"), 14, 1)
        self.H = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.H.valueChanged.connect(partial(self.changeParams, "H"))
        layout.addWidget(self.H, 14, 2)
        layout.addWidget(QtGui.QLabel("%N"), 15, 1)
        self.N = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.N.valueChanged.connect(partial(self.changeParams, "N"))
        layout.addWidget(self.N, 15, 2)

        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Carbons number")), 19, 1)
        self.carbonos = Entrada_con_unidades(int, width=50, spinbox=True,
                                             step=1, start=7, min=5, max=100)
        self.N.valueChanged.connect(partial(self.changeParams, "Nc"))
        layout.addWidget(self.carbonos, 19, 2)

        layout.addItem(QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Expanding,
                                         QtGui.QSizePolicy.Expanding), 3, 3, 15, 1)
        self.checkCurva = QtGui.QCheckBox(QtGui.QApplication.translate(
            "pychemqt", "Define destillation curve"))
        layout.addWidget(self.checkCurva, 3, 4, 1, 2)
        self.tipoCurva = QtGui.QComboBox()
        self.tipoCurva.addItem("ASTM D86")
        self.tipoCurva.addItem("TBP")
        self.tipoCurva.addItem("EFV")
        self.tipoCurva.addItem("ASTM D1186")
        self.tipoCurva.addItem("ASTM D2887 (SD)")
        self.tipoCurva.setEnabled(False)
        layout.addWidget(self.tipoCurva, 4, 4, 1, 2)
        self.textoPresion = QtGui.QLabel(
            QtGui.QApplication.translate("pychemqt", "Pressure"))
        self.textoPresion.setEnabled(False)
        layout.addWidget(self.textoPresion, 5, 4)
        self.presion = Entrada_con_unidades(Pressure, value=101325.)
        self.presion.setEnabled(False)
        self.presion.valueChanged.connect(partial(self.changeParams, "P_dist"))
        layout.addWidget(self.presion, 5, 5)
        self.curvaDestilacion = Tabla(
            2, filas=1, horizontalHeader=["%dist", "Tb, "+Temperature.text()],
            verticalHeader=False, dinamica=True)
        self.curvaDestilacion.setEnabled(False)
        self.curvaDestilacion.editingFinished.connect(self.changeCurva)
        layout.addWidget(self.curvaDestilacion, 6, 4, 13, 2)
        self.checkBlend = QtGui.QCheckBox(QtGui.QApplication.translate(
            "pychemqt", "Blend if its necessary"))
        layout.addWidget(self.checkBlend, 19, 4, 1, 2)

        self.checkCurva.toggled.connect(self.tipoCurva.setEnabled)
        self.checkCurva.toggled.connect(self.presion.setEnabled)
        self.checkCurva.toggled.connect(self.textoPresion.setEnabled)
        self.checkCurva.toggled.connect(self.curvaDestilacion.setEnabled)

        layout.addItem(QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed,
                                         QtGui.QSizePolicy.Fixed), 20, 1, 1, 2)
        self.checkCrudo = QtGui.QCheckBox(QtGui.QApplication.translate(
            "pychemqt", "Use petrol fraction from list"))
        self.checkCrudo.toggled.connect(self.changeUnknown)
        layout.addWidget(self.checkCrudo, 21, 1, 1, 2)
        self.crudo = QtGui.QComboBox()
        self.crudo.setEnabled(False)
        self.crudo.addItem("")
        for i in crudo[1:]:
            self.crudo.addItem("%s (%s)  API: %s %S: %s" % (i[0], i[1], i[3], i[4]))
            # i[0]+" ("+i[1]+")"+"   API: "+str(i[3])+"  %S: "+str(i[4]))
        self.crudo.currentIndexChanged.connect(partial(
            self.changeParams, "indice"))
        layout.addWidget(self.crudo, 23, 1, 1, 5)
        layout.addWidget(QtGui.QLabel("Pseudo C+"), 24, 1)
        self.Cplus = Entrada_con_unidades(int, width=50, spinbox=True, step=1,
                                          min=6)
        self.Cplus.valueChanged.connect(partial(self.changeParams, "Cplus"))
        layout.addWidget(self.Cplus, 24, 2)
        self.checkCrudo.toggled.connect(self.crudo.setEnabled)
        self.checkCrudo.toggled.connect(self.Cplus.setEnabled)
        layout.addItem(QtGui.QSpacerItem(5, 5, QtGui.QSizePolicy.Expanding,
                                         QtGui.QSizePolicy.Expanding), 29, 1, 1, 2)

        newComponent.loadUI(self)

        self.Petroleo = Petroleo()
        self.Crudo = Crudo()

    @property
    def unknown(self):
        if self.checkCrudo.isChecked():
            return self.Crudo
        else:
            return self.Petroleo

    def changeUnknown(self):
        self.status.setState(self.unknown.status, self.unknown.msg)
        self.buttonShowDetails.setEnabled(self.unknown.status)
        self.buttonBox.button(QtGui.QDialogButtonBox.Save).setEnabled(
            self.unknown.status)

    def changeCurva(self):
        temp = self.curvaDestilacion.getColumn(0)
        T_dist = self.curvaDestilacion.getColumn(1)
        curvas = ["D86", "TBP", "EFV", "D1160", "SD"]
        x = curvas.pop(self.tipoCurva.currentIndex())
        kwargs = {}
        kwargs[x] = temp
        kwargs["Tdist"] = T_dist
        for curva in curvas:
            kwargs[curva] = []
        self.calculo(**kwargs)
예제 #12
0
class Ui_ReferenceState(QtWidgets.QDialog):
    """Dialog for select reference state"""
    def __init__(self, config=None, parent=None):
        """config: instance with project config to set initial values"""
        super(Ui_ReferenceState, self).__init__(parent)
        self.setWindowTitle(QtWidgets.QApplication.translate(
            "pychemqt", "Select reference state"))
        layout = QtWidgets.QGridLayout(self)
        self.OTO = QtWidgets.QRadioButton(QtWidgets.QApplication.translate(
            "pychemqt", "OTO,  h,s=0 at 298K and 1 atm"))
        layout.addWidget(self.OTO, 0, 1, 1, 7)
        self.NBP = QtWidgets.QRadioButton(QtWidgets.QApplication.translate(
            "pychemqt", "NBP,  h,s=0 saturated liquid at Tb"))
        layout.addWidget(self.NBP, 1, 1, 1, 7)
        self.IIR = QtWidgets.QRadioButton(QtWidgets.QApplication.translate(
            "pychemqt", "IIR,  h=200,s=1 saturated liquid at 273K"))
        layout.addWidget(self.IIR, 2, 1, 1, 7)
        self.ASHRAE = QtWidgets.QRadioButton(QtWidgets.QApplication.translate(
            "pychemqt", "ASHRAE,  h,s=0 saturated liquid at 243K"))
        layout.addWidget(self.ASHRAE, 3, 1, 1, 7)
        self.personalizado = QtWidgets.QRadioButton(
            QtWidgets.QApplication.translate("pychemqt", "Custom"))
        self.personalizado.toggled.connect(self.setEnabled)
        layout.addWidget(self.personalizado, 4, 1, 1, 7)

        layout.addItem(QtWidgets.QSpacerItem(
            10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            5, 1)
        layout.addWidget(QtWidgets.QLabel("T:"), 5, 2)
        self.T = Entrada_con_unidades(unidades.Temperature, value=298.15)
        layout.addWidget(self.T, 5, 3)
        layout.addWidget(QtWidgets.QLabel("P:"), 6, 2)
        self.P = Entrada_con_unidades(unidades.Pressure, value=101325)
        layout.addWidget(self.P, 6, 3)
        layout.addItem(QtWidgets.QSpacerItem(
            10, 10, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Fixed), 5, 4, 2, 1)
        layout.addWidget(QtWidgets.QLabel("h:"), 5, 5)
        self.h = Entrada_con_unidades(unidades.Enthalpy, value=0)
        layout.addWidget(self.h, 5, 6)
        layout.addWidget(QtWidgets.QLabel("s:"), 6, 5)
        self.s = Entrada_con_unidades(unidades.SpecificHeat, value=0)
        layout.addWidget(self.s, 6, 6)
        layout.addItem(QtWidgets.QSpacerItem(
            10, 10, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 7, 7)

        buttonBox = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        layout.addWidget(buttonBox, 8, 1, 1, 7)

        if config and config.has_option("MEoS", "reference"):
            self.setEnabled(False)
            if config.get("MEoS", "reference") == "OTO":
                self.OTO.setChecked(True)
            elif config.get("MEoS", "reference") == "NBP":
                self.NBP.setChecked(True)
            elif config.get("MEoS", "reference") == "IIR":
                self.IIR.setChecked(True)
            elif config.get("MEoS", "reference") == "ASHRAE":
                self.ASHRAE.setChecked(True)
            else:
                self.personalizado.setChecked(True)
                self.setEnabled(True)
                self.T.setValue(config.getfloat("MEoS", "T"))
                self.P.setValue(config.getfloat("MEoS", "P"))
                self.h.setValue(config.getfloat("MEoS", "h"))
                self.s.setValue(config.getfloat("MEoS", "s"))
        else:
            self.OTO.setChecked(True)
            self.setEnabled(False)

    def setEnabled(self, bool):
        """Enable custom entriees"""
        self.T.setEnabled(bool)
        self.P.setEnabled(bool)
        self.h.setEnabled(bool)
        self.s.setEnabled(bool)
예제 #13
0
class Definicion_Petro(newComponent):
    """Dialog for define hypothetical crude and oil fraction"""
    ViewDetails = View_Petro

    def __init__(self, parent=None):
        super(Definicion_Petro, self).__init__(parent)
        self.setWindowTitle(
            QtGui.QApplication.translate("pychemqt",
                                         "Petrol component definition"))
        layout = QtGui.QGridLayout(self)
        layout.addWidget(
            QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Name")), 1,
            1)
        self.nombre = QtGui.QLineEdit()
        self.nombre.textChanged.connect(partial(self.changeParams, "name"))
        layout.addWidget(self.nombre, 1, 2, 1, 4)
        layout.addItem(
            QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed), 2, 1, 1, 2)
        layout.addWidget(
            QtGui.QLabel(
                QtGui.QApplication.translate("pychemqt", "Boiling point")), 3,
            1)
        self.Tb = Entrada_con_unidades(Temperature)
        self.Tb.valueChanged.connect(partial(self.changeParams, "Tb"))
        layout.addWidget(self.Tb, 3, 2)
        layout.addWidget(
            QtGui.QLabel(
                QtGui.QApplication.translate("pychemqt", "Molecular Weight")),
            4, 1)
        self.M = Entrada_con_unidades(float, textounidad="g/mol")
        self.M.valueChanged.connect(partial(self.changeParams, "M"))
        layout.addWidget(self.M, 4, 2)
        layout.addWidget(
            QtGui.QLabel(
                QtGui.QApplication.translate("pychemqt", "Specific Gravity")),
            5, 1)
        self.SG = Entrada_con_unidades(float)
        self.SG.valueChanged.connect(partial(self.changeParams, "SG"))
        layout.addWidget(self.SG, 5, 2)
        layout.addWidget(
            QtGui.QLabel(
                QtGui.QApplication.translate("pychemqt", "API gravity")), 6, 1)
        self.API = Entrada_con_unidades(float)
        self.API.valueChanged.connect(partial(self.changeParams, "API"))
        layout.addWidget(self.API, 6, 2)
        layout.addWidget(QtGui.QLabel("K watson:"), 7, 1)
        self.Kw = Entrada_con_unidades(float)
        self.Kw.valueChanged.connect(partial(self.changeParams, "Kw"))
        layout.addWidget(self.Kw, 7, 2)
        layout.addWidget(QtGui.QLabel("C/H:"), 8, 1)
        self.CH = Entrada_con_unidades(float)
        self.CH.valueChanged.connect(partial(self.changeParams, "CH"))
        layout.addWidget(self.CH, 8, 2)
        layout.addWidget(QtGui.QLabel(u"ν<sub>100F</sub>:"), 9, 1)
        self.v100 = Entrada_con_unidades(Diffusivity)
        self.v100.valueChanged.connect(partial(self.changeParams, "v100"))
        layout.addWidget(self.v100, 9, 2)
        layout.addWidget(QtGui.QLabel(u"ν<sub>210F</sub>:"), 10, 1)
        self.v210 = Entrada_con_unidades(Diffusivity)
        self.v210.valueChanged.connect(partial(self.changeParams, "v210"))
        layout.addWidget(self.v210, 10, 2)
        layout.addWidget(
            QtGui.QLabel(
                QtGui.QApplication.translate("pychemqt", "Refraction index")),
            11, 1)
        self.n = Entrada_con_unidades(float)
        self.n.valueChanged.connect(partial(self.changeParams, "n"))
        layout.addWidget(self.n, 11, 2)
        layout.addWidget(
            QtGui.QLabel(
                QtGui.QApplication.translate("pychemqt", "Huang parameter")),
            12, 1)
        self.I = Entrada_con_unidades(float)
        self.I.valueChanged.connect(partial(self.changeParams, "I"))
        layout.addWidget(self.I, 12, 2)
        layout.addWidget(QtGui.QLabel("%S"), 13, 1)
        self.S = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.S.valueChanged.connect(partial(self.changeParams, "S"))
        layout.addWidget(self.S, 13, 2)
        layout.addWidget(QtGui.QLabel("%H"), 14, 1)
        self.H = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.H.valueChanged.connect(partial(self.changeParams, "H"))
        layout.addWidget(self.H, 14, 2)
        layout.addWidget(QtGui.QLabel("%N"), 15, 1)
        self.N = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.N.valueChanged.connect(partial(self.changeParams, "N"))
        layout.addWidget(self.N, 15, 2)

        layout.addWidget(
            QtGui.QLabel(
                QtGui.QApplication.translate("pychemqt", "Carbons number")),
            19, 1)
        self.carbonos = Entrada_con_unidades(int,
                                             width=50,
                                             spinbox=True,
                                             step=1,
                                             start=7,
                                             min=5,
                                             max=100)
        self.N.valueChanged.connect(partial(self.changeParams, "Nc"))
        layout.addWidget(self.carbonos, 19, 2)

        layout.addItem(
            QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding), 3, 3, 15, 1)
        self.checkCurva = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt",
                                         "Define destillation curve"))
        layout.addWidget(self.checkCurva, 3, 4, 1, 2)
        self.tipoCurva = QtGui.QComboBox()
        self.tipoCurva.addItem("ASTM D86")
        self.tipoCurva.addItem("TBP")
        self.tipoCurva.addItem("EFV")
        self.tipoCurva.addItem("ASTM D1186")
        self.tipoCurva.addItem("ASTM D2887 (SD)")
        self.tipoCurva.setEnabled(False)
        layout.addWidget(self.tipoCurva, 4, 4, 1, 2)
        self.textoPresion = QtGui.QLabel(
            QtGui.QApplication.translate("pychemqt", "Pressure"))
        self.textoPresion.setEnabled(False)
        layout.addWidget(self.textoPresion, 5, 4)
        self.presion = Entrada_con_unidades(Pressure, value=101325.)
        self.presion.setEnabled(False)
        self.presion.valueChanged.connect(partial(self.changeParams, "P_dist"))
        layout.addWidget(self.presion, 5, 5)
        self.curvaDestilacion = Tabla(
            2,
            filas=1,
            horizontalHeader=["%dist", "Tb, " + Temperature.text()],
            verticalHeader=False,
            dinamica=True)
        self.curvaDestilacion.setEnabled(False)
        self.curvaDestilacion.editingFinished.connect(self.changeCurva)
        layout.addWidget(self.curvaDestilacion, 6, 4, 13, 2)
        self.checkBlend = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "Blend if its necessary"))
        layout.addWidget(self.checkBlend, 19, 4, 1, 2)

        self.checkCurva.toggled.connect(self.tipoCurva.setEnabled)
        self.checkCurva.toggled.connect(self.presion.setEnabled)
        self.checkCurva.toggled.connect(self.textoPresion.setEnabled)
        self.checkCurva.toggled.connect(self.curvaDestilacion.setEnabled)

        layout.addItem(
            QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed), 20, 1, 1, 2)
        self.checkCrudo = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt",
                                         "Use petrol fraction from list"))
        self.checkCrudo.toggled.connect(self.changeUnknown)
        layout.addWidget(self.checkCrudo, 21, 1, 1, 2)
        self.crudo = QtGui.QComboBox()
        self.crudo.setEnabled(False)
        self.crudo.addItem("")
        for i in crudo[1:]:
            self.crudo.addItem("%s (%s)  API: %s %S: %s" %
                               (i[0], i[1], i[3], i[4]))
            # i[0]+" ("+i[1]+")"+"   API: "+str(i[3])+"  %S: "+str(i[4]))
        self.crudo.currentIndexChanged.connect(
            partial(self.changeParams, "indice"))
        layout.addWidget(self.crudo, 23, 1, 1, 5)
        layout.addWidget(QtGui.QLabel("Pseudo C+"), 24, 1)
        self.Cplus = Entrada_con_unidades(int,
                                          width=50,
                                          spinbox=True,
                                          step=1,
                                          min=6)
        self.Cplus.valueChanged.connect(partial(self.changeParams, "Cplus"))
        layout.addWidget(self.Cplus, 24, 2)
        self.checkCrudo.toggled.connect(self.crudo.setEnabled)
        self.checkCrudo.toggled.connect(self.Cplus.setEnabled)
        layout.addItem(
            QtGui.QSpacerItem(5, 5, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding), 29, 1, 1, 2)

        newComponent.loadUI(self)

        self.Petroleo = Petroleo()
        self.Crudo = Crudo()

    @property
    def unknown(self):
        if self.checkCrudo.isChecked():
            return self.Crudo
        else:
            return self.Petroleo

    def changeUnknown(self):
        self.status.setState(self.unknown.status, self.unknown.msg)
        self.buttonShowDetails.setEnabled(self.unknown.status)
        self.buttonBox.button(QtGui.QDialogButtonBox.Save).setEnabled(
            self.unknown.status)

    def changeCurva(self):
        temp = self.curvaDestilacion.getColumn(0)
        T_dist = self.curvaDestilacion.getColumn(1)
        curvas = ["D86", "TBP", "EFV", "D1160", "SD"]
        x = curvas.pop(self.tipoCurva.currentIndex())
        kwargs = {}
        kwargs[x] = temp
        kwargs["Tdist"] = T_dist
        for curva in curvas:
            kwargs[curva] = []
        self.calculo(**kwargs)
예제 #14
0
class ConfLine(QtWidgets.QWidget):
    """Composite widget with line format configuration tools"""
    join = [QtCore.Qt.MiterJoin, QtCore.Qt.BevelJoin, QtCore.Qt.RoundJoin]
    cap = [QtCore.Qt.FlatCap, QtCore.Qt.RoundCap, QtCore.Qt.SquareCap]
    line = [QtCore.Qt.SolidLine, QtCore.Qt.DashLine, QtCore.Qt.DotLine,
            QtCore.Qt.DashDotLine, QtCore.Qt.DashDotDotLine]

    def __init__(self, pen=None, parent=None):
        super(ConfLine, self).__init__(parent)
        lyt = QtWidgets.QVBoxLayout(self)

        lyt1 = QtWidgets.QHBoxLayout()
        lyt1.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Line")))
        self.ColorButtonLine = ColorSelector()
        self.ColorButtonLine.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Default line color"))
        lyt1.addWidget(self.ColorButtonLine)
        self.width = Entrada_con_unidades(
            float, width=50, decimales=1, spinbox=True, step=0.1,
            textounidad="px")
        self.width.entrada.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt", "Line Width"))
        lyt1.addWidget(self.width)
        lyt.addLayout(lyt1)

        lyt2 = QtWidgets.QHBoxLayout()
        lyt2.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Join")))
        self.mitterLimit = Entrada_con_unidades(
            float, width=50, decimales=1, spinbox=True, step=0.1)
        self.mitterLimit.entrada.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt", "Mitter Limit"))
        lyt2.addWidget(self.mitterLimit)
        toolJoinMitter = QtWidgets.QToolButton()
        toolJoinMitter.setIcon(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"] +
            os.path.join("images", "button", "stroke-join-miter.png"))))
        toolJoinMitter.setIconSize(QtCore.QSize(24, 24))
        toolJoinMitter.setCheckable(True)
        toolJoinMitter.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt",
            "Join mitter: The triangular notch between the two lines is not "
            "filled"))
        lyt2.addWidget(toolJoinMitter)
        toolJoinBevel = QtWidgets.QToolButton()
        toolJoinBevel.setIcon(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"] +
            os.path.join("images", "button", "stroke-join-bevel.png"))))
        toolJoinBevel.setIconSize(QtCore.QSize(24, 24))
        toolJoinBevel.setCheckable(True)
        toolJoinBevel.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt",
            "Join bevel: The triangular notch between the two lines is "
            "filled"))
        lyt2.addWidget(toolJoinBevel)
        toolJoinRound = QtWidgets.QToolButton()
        toolJoinRound.setIcon(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"] +
            os.path.join("images", "button", "stroke-join-round.png"))))
        toolJoinRound.setIconSize(QtCore.QSize(24, 24))
        toolJoinRound.setCheckable(True)
        toolJoinRound.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt",
            "Join round: A circular arc between the two lines is filled"))
        lyt2.addWidget(toolJoinRound)

        self.groupJoint = QtWidgets.QButtonGroup()
        self.groupJoint.addButton(toolJoinMitter)
        self.groupJoint.addButton(toolJoinBevel)
        self.groupJoint.addButton(toolJoinRound)
        self.groupJoint.buttonClicked["int"].connect(self.mitterlimitEnabled)
        lyt.addLayout(lyt2)

        lyt3 = QtWidgets.QHBoxLayout()
        lyt3.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Cap")))
        toolCapFlat = QtWidgets.QToolButton()
        toolCapFlat.setIcon(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"] +
            os.path.join("images", "button", "stroke-cap-butt.png"))))
        toolCapFlat.setIconSize(QtCore.QSize(24, 24))
        toolCapFlat.setCheckable(True)
        toolCapFlat.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt",
            "Flat Cap: A square line end that does not cover the end point of "
            "the line"))
        lyt3.addWidget(toolCapFlat)
        toolCapRound = QtWidgets.QToolButton()
        toolCapRound.setIcon(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"] +
            os.path.join("images", "button", "stroke-cap-round.png"))))
        toolCapRound.setIconSize(QtCore.QSize(24, 24))
        toolCapRound.setCheckable(True)
        toolCapRound.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt", "Round Cap: A rounded line end"))
        lyt3.addWidget(toolCapRound)
        toolCapSquare = QtWidgets.QToolButton()
        toolCapSquare.setIcon(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"] +
            os.path.join("images", "button", "stroke-cap-square.png"))))
        toolCapSquare.setIconSize(QtCore.QSize(24, 24))
        toolCapSquare.setCheckable(True)
        toolCapSquare.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt",
            "Square Cap: A square line end that covers the end point and "
            "extends beyond it by half the line width"))
        lyt3.addWidget(toolCapSquare)

        self.groupCap = QtWidgets.QButtonGroup()
        self.groupCap.addButton(toolCapFlat)
        self.groupCap.addButton(toolCapRound)
        self.groupCap.addButton(toolCapSquare)
        lyt.addLayout(lyt3)

        lyt4 = QtWidgets.QHBoxLayout()
        lyt4.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate("pychemqt", "Dash")))
        self.guion = PFDLineCombo()
        lyt4.addWidget(self.guion)
        self.dashOffset = Entrada_con_unidades(
            float, width=50, decimales=1, spinbox=True, step=0.1)
        self.dashOffset.entrada.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt", "Dash offset"))
        lyt4.addWidget(self.dashOffset)
        lyt.addLayout(lyt4)
        lyt.addItem(QtWidgets.QSpacerItem(
            0, 0, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding))

        if pen:
            self.ColorButtonLine.setColor(pen.color().name())
            self.groupJoint.button((self.join.index(
                pen.joinStyle())+2)*-1).setChecked(True)
            self.mitterLimit.setValue(pen.miterLimit())
            self.groupCap.button((self.cap.index(
                pen.capStyle())+2)*-1).setChecked(True)
            self.guion.setCurrentIndex(self.line.index(pen.style()))
            self.dashOffset.setValue(pen.dashOffset())
            self.width.setValue(pen.widthF())

    def mitterlimitEnabled(self, id):
        self.mitterLimit.setEnabled(id == -2)

    def pen(self):
        """Return a QPen with the live configuration"""
        pen = QtGui.QPen(QtGui.QColor(self.ColorButtonLine.color.name()))
        pen.setWidthF(self.width.value)
        pen.setJoinStyle(self.join[abs(self.groupJoint.checkedId())-2])
        pen.setMiterLimit(self.mitterLimit.value)
        pen.setCapStyle(self.cap[abs(self.groupCap.checkedId())-2])
        pen.setStyle(self.line[self.guion.currentIndex()])
        pen.setDashOffset(self.dashOffset.value)
        return pen
예제 #15
0
class ConfLine(QtWidgets.QWidget):
    """Composite widget with line format configuration tools"""
    join = [QtCore.Qt.MiterJoin, QtCore.Qt.BevelJoin, QtCore.Qt.RoundJoin]
    cap = [QtCore.Qt.FlatCap, QtCore.Qt.RoundCap, QtCore.Qt.SquareCap]
    line = [
        QtCore.Qt.SolidLine, QtCore.Qt.DashLine, QtCore.Qt.DotLine,
        QtCore.Qt.DashDotLine, QtCore.Qt.DashDotDotLine
    ]

    def __init__(self, pen=None, parent=None):
        super(ConfLine, self).__init__(parent)
        lyt = QtWidgets.QVBoxLayout(self)

        lyt1 = QtWidgets.QHBoxLayout()
        lyt1.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Line")))
        self.ColorButtonLine = ColorSelector()
        self.ColorButtonLine.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Default line color"))
        lyt1.addWidget(self.ColorButtonLine)
        self.width = Entrada_con_unidades(float,
                                          width=50,
                                          decimales=1,
                                          spinbox=True,
                                          step=0.1,
                                          textounidad="px")
        self.width.entrada.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Line Width"))
        lyt1.addWidget(self.width)
        lyt.addLayout(lyt1)

        lyt2 = QtWidgets.QHBoxLayout()
        lyt2.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Join")))
        self.mitterLimit = Entrada_con_unidades(float,
                                                width=50,
                                                decimales=1,
                                                spinbox=True,
                                                step=0.1)
        self.mitterLimit.entrada.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Mitter Limit"))
        lyt2.addWidget(self.mitterLimit)
        toolJoinMitter = QtWidgets.QToolButton()
        toolJoinMitter.setIcon(
            QtGui.QIcon(
                QtGui.QPixmap(os.environ["CheProcess"] + os.path.join(
                    "images", "button", "stroke-join-miter.png"))))
        toolJoinMitter.setIconSize(QtCore.QSize(24, 24))
        toolJoinMitter.setCheckable(True)
        toolJoinMitter.setToolTip(
            QtWidgets.QApplication.translate(
                "pychemqt",
                "Join mitter: The triangular notch between the two lines is not "
                "filled"))
        lyt2.addWidget(toolJoinMitter)
        toolJoinBevel = QtWidgets.QToolButton()
        toolJoinBevel.setIcon(
            QtGui.QIcon(
                QtGui.QPixmap(os.environ["CheProcess"] + os.path.join(
                    "images", "button", "stroke-join-bevel.png"))))
        toolJoinBevel.setIconSize(QtCore.QSize(24, 24))
        toolJoinBevel.setCheckable(True)
        toolJoinBevel.setToolTip(
            QtWidgets.QApplication.translate(
                "pychemqt",
                "Join bevel: The triangular notch between the two lines is "
                "filled"))
        lyt2.addWidget(toolJoinBevel)
        toolJoinRound = QtWidgets.QToolButton()
        toolJoinRound.setIcon(
            QtGui.QIcon(
                QtGui.QPixmap(os.environ["CheProcess"] + os.path.join(
                    "images", "button", "stroke-join-round.png"))))
        toolJoinRound.setIconSize(QtCore.QSize(24, 24))
        toolJoinRound.setCheckable(True)
        toolJoinRound.setToolTip(
            QtWidgets.QApplication.translate(
                "pychemqt",
                "Join round: A circular arc between the two lines is filled"))
        lyt2.addWidget(toolJoinRound)

        self.groupJoint = QtWidgets.QButtonGroup()
        self.groupJoint.addButton(toolJoinMitter)
        self.groupJoint.addButton(toolJoinBevel)
        self.groupJoint.addButton(toolJoinRound)
        self.groupJoint.buttonClicked["int"].connect(self.mitterlimitEnabled)
        lyt.addLayout(lyt2)

        lyt3 = QtWidgets.QHBoxLayout()
        lyt3.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Cap")))
        toolCapFlat = QtWidgets.QToolButton()
        toolCapFlat.setIcon(
            QtGui.QIcon(
                QtGui.QPixmap(
                    os.environ["CheProcess"] +
                    os.path.join("images", "button", "stroke-cap-butt.png"))))
        toolCapFlat.setIconSize(QtCore.QSize(24, 24))
        toolCapFlat.setCheckable(True)
        toolCapFlat.setToolTip(
            QtWidgets.QApplication.translate(
                "pychemqt",
                "Flat Cap: A square line end that does not cover the end point of "
                "the line"))
        lyt3.addWidget(toolCapFlat)
        toolCapRound = QtWidgets.QToolButton()
        toolCapRound.setIcon(
            QtGui.QIcon(
                QtGui.QPixmap(
                    os.environ["CheProcess"] +
                    os.path.join("images", "button", "stroke-cap-round.png"))))
        toolCapRound.setIconSize(QtCore.QSize(24, 24))
        toolCapRound.setCheckable(True)
        toolCapRound.setToolTip(
            QtWidgets.QApplication.translate("pychemqt",
                                             "Round Cap: A rounded line end"))
        lyt3.addWidget(toolCapRound)
        toolCapSquare = QtWidgets.QToolButton()
        toolCapSquare.setIcon(
            QtGui.QIcon(
                QtGui.QPixmap(os.environ["CheProcess"] + os.path.join(
                    "images", "button", "stroke-cap-square.png"))))
        toolCapSquare.setIconSize(QtCore.QSize(24, 24))
        toolCapSquare.setCheckable(True)
        toolCapSquare.setToolTip(
            QtWidgets.QApplication.translate(
                "pychemqt",
                "Square Cap: A square line end that covers the end point and "
                "extends beyond it by half the line width"))
        lyt3.addWidget(toolCapSquare)

        self.groupCap = QtWidgets.QButtonGroup()
        self.groupCap.addButton(toolCapFlat)
        self.groupCap.addButton(toolCapRound)
        self.groupCap.addButton(toolCapSquare)
        lyt.addLayout(lyt3)

        lyt4 = QtWidgets.QHBoxLayout()
        lyt4.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("pychemqt", "Dash")))
        self.guion = PFDLineCombo()
        lyt4.addWidget(self.guion)
        self.dashOffset = Entrada_con_unidades(float,
                                               width=50,
                                               decimales=1,
                                               spinbox=True,
                                               step=0.1)
        self.dashOffset.entrada.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Dash offset"))
        lyt4.addWidget(self.dashOffset)
        lyt.addLayout(lyt4)
        lyt.addItem(
            QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))

        if pen:
            self.ColorButtonLine.setColor(pen.color().name())
            self.groupJoint.button(
                (self.join.index(pen.joinStyle()) + 2) * -1).setChecked(True)
            self.mitterLimit.setValue(pen.miterLimit())
            self.groupCap.button(
                (self.cap.index(pen.capStyle()) + 2) * -1).setChecked(True)
            self.guion.setCurrentIndex(self.line.index(pen.style()))
            self.dashOffset.setValue(pen.dashOffset())
            self.width.setValue(pen.widthF())

    def mitterlimitEnabled(self, id):
        self.mitterLimit.setEnabled(id == -2)

    def pen(self):
        """Return a QPen with the live configuration"""
        pen = QtGui.QPen(QtGui.QColor(self.ColorButtonLine.color.name()))
        pen.setWidthF(self.width.value)
        pen.setJoinStyle(self.join[abs(self.groupJoint.checkedId()) - 2])
        pen.setMiterLimit(self.mitterLimit.value)
        pen.setCapStyle(self.cap[abs(self.groupCap.checkedId()) - 2])
        pen.setStyle(self.line[self.guion.currentIndex()])
        pen.setDashOffset(self.dashOffset.value)
        return pen