Input
")) + self.label_2.setText(_translate("CalcDialog", "ɣ =")) + self.qcb_autocalc.setText(_translate("CalcDialog", "AutoCalculate")) + self.qpb_calculate.setText(_translate("CalcDialog", "Calculate")) + self.qpb_plot.setText(_translate("CalcDialog", "Plot")) + self.label_3.setText(_translate("CalcDialog", "Input")) self.qrb4_obli.setText(_translate("CalcDialog", "Ob&lique Shock")) self.qrb3_norm.setText(_translate("CalcDialog", "&Normal Shock")) self.qrb1_isen.setText(_translate("CalcDialog", "Isen&tropic")) @@ -168,10 +179,6 @@ def retranslateUi(self, CalcDialog): self.label.setToolTip(_translate("CalcDialog", "Choose a formula set")) self.label.setText(_translate("CalcDialog", "Mode")) self.qrb2_expa.setText(_translate("CalcDialog", "E&xpansion")) - self.qcb_autocalc.setText(_translate("CalcDialog", "AutoCalculate")) - self.qpb_calculate.setText(_translate("CalcDialog", "Calculate")) - self.label_3.setText(_translate("CalcDialog", "Input")) - self.label_2.setText(_translate("CalcDialog", "ɣ =")) self.label_4.setToolTip(_translate("CalcDialog", "Tabulated output")) self.label_4.setText(_translate("CalcDialog", "Result")) diff --git a/caeroc/gui/base_pyside.py b/caeroc/gui/base_pyside.py index 2ed08f9..e69de29 100644 --- a/caeroc/gui/base_pyside.py +++ b/caeroc/gui/base_pyside.py @@ -1,177 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'base.ui' -# -# Created: Sun Nov 12 16:21:39 2017 -# by: pyside-uic 0.2.15 running on PySide 1.2.4 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_CalcDialog(object): - def setupUi(self, CalcDialog): - CalcDialog.setObjectName("CalcDialog") - CalcDialog.resize(459, 692) - self.verticalLayout_2 = QtGui.QVBoxLayout(CalcDialog) - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.gridWidget = QtGui.QWidget(CalcDialog) - self.gridWidget.setObjectName("gridWidget") - self.verticalLayout = QtGui.QVBoxLayout(self.gridWidget) - self.verticalLayout.setContentsMargins(0, 0, 0, 0) - self.verticalLayout.setObjectName("verticalLayout") - self.valueFrame = QtGui.QFrame(self.gridWidget) - self.valueFrame.setObjectName("valueFrame") - self.gridLayout = QtGui.QGridLayout(self.valueFrame) - self.gridLayout.setObjectName("gridLayout") - self.modeFrame = QtGui.QFrame(self.valueFrame) - self.modeFrame.setObjectName("modeFrame") - self.gridLayout_2 = QtGui.QGridLayout(self.modeFrame) - self.gridLayout_2.setObjectName("gridLayout_2") - self.qrb4_obli = QtGui.QRadioButton(self.modeFrame) - self.qrb4_obli.setObjectName("qrb4_obli") - self.gridLayout_2.addWidget(self.qrb4_obli, 3, 2, 1, 1) - self.qrb3_norm = QtGui.QRadioButton(self.modeFrame) - self.qrb3_norm.setObjectName("qrb3_norm") - self.gridLayout_2.addWidget(self.qrb3_norm, 2, 2, 1, 1) - self.qrb1_isen = QtGui.QRadioButton(self.modeFrame) - self.qrb1_isen.setChecked(True) - self.qrb1_isen.setObjectName("qrb1_isen") - self.gridLayout_2.addWidget(self.qrb1_isen, 2, 1, 1, 1) - self.qrb5_fann = QtGui.QRadioButton(self.modeFrame) - self.qrb5_fann.setObjectName("qrb5_fann") - self.gridLayout_2.addWidget(self.qrb5_fann, 2, 3, 1, 1) - self.qrb6_rayl = QtGui.QRadioButton(self.modeFrame) - self.qrb6_rayl.setObjectName("qrb6_rayl") - self.gridLayout_2.addWidget(self.qrb6_rayl, 3, 3, 1, 1) - self.label = QtGui.QLabel(self.modeFrame) - self.label.setEnabled(False) - font = QtGui.QFont() - font.setPointSize(11) - font.setWeight(75) - font.setBold(True) - self.label.setFont(font) - self.label.setObjectName("label") - self.gridLayout_2.addWidget(self.label, 2, 0, 2, 1) - self.qrb2_expa = QtGui.QRadioButton(self.modeFrame) - font = QtGui.QFont() - font.setStrikeOut(False) - self.qrb2_expa.setFont(font) - self.qrb2_expa.setObjectName("qrb2_expa") - self.gridLayout_2.addWidget(self.qrb2_expa, 3, 1, 1, 1) - self.gridLayout.addWidget(self.modeFrame, 0, 0, 1, 2) - self.inputFrame = QtGui.QFrame(self.valueFrame) - self.inputFrame.setObjectName("inputFrame") - self.gridLayout_3 = QtGui.QGridLayout(self.inputFrame) - self.gridLayout_3.setObjectName("gridLayout_3") - self.qcb1_input = QtGui.QComboBox(self.inputFrame) - self.qcb1_input.setObjectName("qcb1_input") - self.gridLayout_3.addWidget(self.qcb1_input, 5, 3, 1, 1) - self.formFrame = QtGui.QFrame(self.inputFrame) - self.formFrame.setObjectName("formFrame") - self.formLayout = QtGui.QFormLayout(self.formFrame) - self.formLayout.setObjectName("formLayout") - self.qcb_autocalc = QtGui.QCheckBox(self.formFrame) - self.qcb_autocalc.setObjectName("qcb_autocalc") - self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.qcb_autocalc) - self.qpb_calculate = QtGui.QPushButton(self.formFrame) - self.qpb_calculate.setLayoutDirection(QtCore.Qt.LeftToRight) - self.qpb_calculate.setAutoFillBackground(False) - self.qpb_calculate.setObjectName("qpb_calculate") - self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.qpb_calculate) - self.gridLayout_3.addWidget(self.formFrame, 7, 4, 1, 1) - self.label_3 = QtGui.QLabel(self.inputFrame) - self.label_3.setEnabled(False) - font = QtGui.QFont() - font.setPointSize(11) - font.setWeight(75) - font.setUnderline(False) - font.setBold(True) - self.label_3.setFont(font) - self.label_3.setObjectName("label_3") - self.gridLayout_3.addWidget(self.label_3, 5, 0, 2, 1) - self.qdsb2_input = QtGui.QDoubleSpinBox(self.inputFrame) - self.qdsb2_input.setDecimals(8) - self.qdsb2_input.setMinimum(-99.0) - self.qdsb2_input.setSingleStep(0.1) - self.qdsb2_input.setProperty("value", 1.0) - self.qdsb2_input.setObjectName("qdsb2_input") - self.gridLayout_3.addWidget(self.qdsb2_input, 6, 4, 1, 1) - self.qcb2_input = QtGui.QComboBox(self.inputFrame) - self.qcb2_input.setObjectName("qcb2_input") - self.gridLayout_3.addWidget(self.qcb2_input, 6, 3, 1, 1) - self.qdsb1_input = QtGui.QDoubleSpinBox(self.inputFrame) - self.qdsb1_input.setDecimals(8) - self.qdsb1_input.setMaximum(999.99) - self.qdsb1_input.setSingleStep(0.1) - self.qdsb1_input.setProperty("value", 1.0) - self.qdsb1_input.setObjectName("qdsb1_input") - self.gridLayout_3.addWidget(self.qdsb1_input, 5, 4, 1, 1) - self.qdsb_gamma = QtGui.QDoubleSpinBox(self.inputFrame) - self.qdsb_gamma.setSingleStep(0.1) - self.qdsb_gamma.setProperty("value", 1.4) - self.qdsb_gamma.setObjectName("qdsb_gamma") - self.gridLayout_3.addWidget(self.qdsb_gamma, 7, 3, 1, 1) - self.label_2 = QtGui.QLabel(self.inputFrame) - self.label_2.setLayoutDirection(QtCore.Qt.LeftToRight) - self.label_2.setTextFormat(QtCore.Qt.PlainText) - self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.label_2.setObjectName("label_2") - self.gridLayout_3.addWidget(self.label_2, 7, 0, 1, 1) - self.gridLayout.addWidget(self.inputFrame, 2, 0, 4, 2) - self.verticalLayout.addWidget(self.valueFrame) - self.outputLayout = QtGui.QGridLayout() - self.outputLayout.setObjectName("outputLayout") - self.label_4 = QtGui.QLabel(self.gridWidget) - self.label_4.setEnabled(False) - font = QtGui.QFont() - font.setPointSize(11) - font.setWeight(75) - font.setBold(True) - self.label_4.setFont(font) - self.label_4.setAcceptDrops(False) - self.label_4.setObjectName("label_4") - self.outputLayout.addWidget(self.label_4, 0, 0, 1, 1) - self.qtw_output = QtGui.QTableView(self.gridWidget) - self.qtw_output.setEnabled(True) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.qtw_output.sizePolicy().hasHeightForWidth()) - self.qtw_output.setSizePolicy(sizePolicy) - self.qtw_output.setAutoFillBackground(False) - self.qtw_output.setFrameShape(QtGui.QFrame.Box) - self.qtw_output.setFrameShadow(QtGui.QFrame.Plain) - self.qtw_output.setObjectName("qtw_output") - self.qtw_output.horizontalHeader().setCascadingSectionResizes(False) - self.outputLayout.addWidget(self.qtw_output, 1, 0, 1, 1) - self.verticalLayout.addLayout(self.outputLayout) - self.buttonBox = QtGui.QDialogButtonBox(self.gridWidget) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Reset) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout.addWidget(self.buttonBox) - self.verticalLayout_2.addWidget(self.gridWidget) - - self.retranslateUi(CalcDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), CalcDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), CalcDialog.reject) - QtCore.QMetaObject.connectSlotsByName(CalcDialog) - - def retranslateUi(self, CalcDialog): - CalcDialog.setWindowTitle(QtGui.QApplication.translate("CalcDialog", "Caeroc Calculator", None, QtGui.QApplication.UnicodeUTF8)) - CalcDialog.setToolTip(QtGui.QApplication.translate("CalcDialog", "Input
", None, QtGui.QApplication.UnicodeUTF8)) - self.qrb4_obli.setText(QtGui.QApplication.translate("CalcDialog", "Ob&lique Shock", None, QtGui.QApplication.UnicodeUTF8)) - self.qrb3_norm.setText(QtGui.QApplication.translate("CalcDialog", "&Normal Shock", None, QtGui.QApplication.UnicodeUTF8)) - self.qrb1_isen.setText(QtGui.QApplication.translate("CalcDialog", "Isen&tropic", None, QtGui.QApplication.UnicodeUTF8)) - self.qrb5_fann.setText(QtGui.QApplication.translate("CalcDialog", "Fanno F&low", None, QtGui.QApplication.UnicodeUTF8)) - self.qrb6_rayl.setText(QtGui.QApplication.translate("CalcDialog", "Ra&yleigh Flow", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setToolTip(QtGui.QApplication.translate("CalcDialog", "Choose a formula set", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("CalcDialog", "Mode", None, QtGui.QApplication.UnicodeUTF8)) - self.qrb2_expa.setText(QtGui.QApplication.translate("CalcDialog", "E&xpansion", None, QtGui.QApplication.UnicodeUTF8)) - self.qcb_autocalc.setText(QtGui.QApplication.translate("CalcDialog", "AutoCalculate", None, QtGui.QApplication.UnicodeUTF8)) - self.qpb_calculate.setText(QtGui.QApplication.translate("CalcDialog", "Calculate", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setText(QtGui.QApplication.translate("CalcDialog", "Input", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setText(QtGui.QApplication.translate("CalcDialog", "ɣ =", None, QtGui.QApplication.UnicodeUTF8)) - self.label_4.setToolTip(QtGui.QApplication.translate("CalcDialog", "Tabulated output", None, QtGui.QApplication.UnicodeUTF8)) - self.label_4.setText(QtGui.QApplication.translate("CalcDialog", "Result", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/caeroc/gui/runtime.py b/caeroc/gui/runtime.py index c259ae2..733eac4 100644 --- a/caeroc/gui/runtime.py +++ b/caeroc/gui/runtime.py @@ -15,6 +15,8 @@ from PySide.QtGui import QDialog, QStandardItemModel, QApplication use_pyqt = False +import pyqtgraph as pg +import numpy as np from .. import formulae from ..logger import logger if use_pyqt: @@ -58,6 +60,8 @@ def __init__(self, parent=None): self.ui.qcb_autocalc.setChecked(self.autocalc) self.ui.qcb_autocalc.stateChanged.connect( self.on_qcb_autocalc_stateChanged) + self.ui.qpb_plot.pressed.connect( + self.on_qpb_pressed) def _setupModel(self): """Sets up the model or the table where the output is displayed.""" @@ -99,6 +103,22 @@ def _set_attr_to_key(self, extra=None): self.attr_to_key.update({v: k for k, v in self.key2_to_attr.items()}) self.attr_to_key.update(extra) + @Slot() + def on_qpb_pressed(self): + """run when plot buttong is pressed""" + # PlotWindow(None) + # x_min = self.mode.minima['M'] + x_min = 0.1 + x_max = self.mode.maxima['M'] + x_range = np.linspace(x_min, x_max, 500, endpoint=True) + y = np.zeros_like(x_range) + for index, val in enumerate(x_range): + kwargs = {'M': val} + self.mode.calculate(**kwargs) + outcome = self.mode.data['p_p0'].pop() + y[index] = outcome + pg.plot(x_range, y) + @Slot() def on_qrb1_isen_pressed(self): """Run when radio button Isentropic is pressed."""