summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DockWidgets/DockWidgetCompressorExpander.py146
-rw-r--r--DockWidgets/DockWidgetCompressorExpander.ui214
2 files changed, 360 insertions, 0 deletions
diff --git a/DockWidgets/DockWidgetCompressorExpander.py b/DockWidgets/DockWidgetCompressorExpander.py
new file mode 100644
index 0000000..841b850
--- /dev/null
+++ b/DockWidgets/DockWidgetCompressorExpander.py
@@ -0,0 +1,146 @@
+from PyQt5.QtCore import *
+from PyQt5.QtWidgets import *
+from PyQt5.QtGui import *
+from PyQt5.uic import loadUiType
+from ComponentSelector import *
+from Graphics import *
+
+ui_dialog,_ = loadUiType('DockWidgets/DockWidgetCompressorExpander.ui')
+
+class DockWidgetCompressorExpander(QDockWidget,ui_dialog):
+
+ def __init__(self,name,comptype,obj,container, parent=None):
+ QDockWidget.__init__(self,parent)
+ self.setupUi(self)
+ self.setWindowTitle(obj.name)
+ self.name=name
+ self.obj=obj
+ self.type = comptype
+ self.input_dict = {}
+ self.x_pclist = []
+ self.modes()
+ self.comboBox.currentIndexChanged.connect(self.mode_selection)
+
+ self.pushButton_2.clicked.connect(self.param)
+ self.dict = {}
+
+ self.name_type = None
+ self.container = container
+
+ # input data tab
+ def modes(self):
+ modes_list = self.obj.modes_list
+ if(modes_list):
+ for j in modes_list:
+ self.comboBox.addItem(str(self.obj.variables[j]['name']))
+ self.mode_selection()
+ else:
+ self.comboBox.setDisabled(True)
+ self.input_dict= {}
+ self.input_dict = self.obj.param_getter()
+ self.input_params_list()
+
+ def mode_selection(self):
+ self.input_dict= {}
+ for i in reversed(range(self.formLayout.count())):
+ self.formLayout.removeRow(i)
+ print(self.comboBox.currentText())
+ for i in self.obj.variables:
+ if self.obj.variables[i]['name'] == self.comboBox.currentText():
+ currentText = i
+ break
+ self.input_dict = self.obj.param_getter(currentText)
+ print('mode selection ', self.input_dict)
+ self.input_params_list()
+
+ def input_params_list(self):
+ try:
+ print("input_params_list ", self.input_dict)
+ for c,i in enumerate(self.input_dict):
+ if i == None:
+ continue
+
+ l = QLineEdit()
+ if self.input_dict[i] != None:
+ l.setText(str(self.input_dict[i]))
+ lay = QGridLayout()
+ lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft)
+ lay.addWidget(l,0,1, alignment=Qt.AlignCenter)
+ lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter)
+
+ self.formLayout.addRow(lay)
+ self.input_dict[i] = l
+
+ self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')]
+ for j in self.lines:
+ self.cbTP.addItem(str(j))
+ self.input_dict['Thermo Package'] = self.cbTP
+
+ except Exception as e:
+ print(e)
+
+ def show_error(self):
+ QMessageBox.about(self, 'Important', "Please fill all fields with data")
+
+ def param(self):
+ try:
+ self.dict={}
+ for i in self.input_dict:
+ if (self.input_dict[i] == None):
+ continue
+ elif (i == "Thermo Package"):
+ self.dict[i] = self.input_dict[i].currentText()
+ else:
+ print(self.input_dict[i], i, self.obj.type)
+ if (self.input_dict[i].text()):
+ self.dict[i] = self.input_dict[i].text()
+ else:
+ print(self.input_dict[i].text())
+ self.show_error()
+ break
+
+ self.obj.param_setter(self.dict)
+ self.hide()
+
+ except Exception as e:
+ print(e)
+
+ @staticmethod
+ def show_result(lst):
+ for i in lst:
+ try:
+ i.results_category(i.name)
+ except AttributeError:
+ pass
+
+ def clear_results(self):
+ self.tableWidget.setRowCount(0)
+
+ # result data tab
+ def results_category(self,name):
+ flag = True
+ try:
+ print("Under result category name ", name)
+ result=self.container.result
+ obj = self.container.fetch_object(name)
+ self.tableWidget.setRowCount(0)
+ variKeys = list(obj.variables.keys())
+ print(variKeys)
+ for i, val in enumerate(variKeys):
+ propertyname = name + '.' + val
+ print(i,val, propertyname)
+ if propertyname in result[0]:
+ ind = result[0].index(propertyname)
+ resultval = str(result[-1][ind])
+ print("######Resultsfetch####",val,resultval)
+ rowPosition = self.tableWidget.rowCount()
+ self.tableWidget.insertRow(rowPosition)
+ self.tableWidget.setItem(rowPosition , 0, QTableWidgetItem(obj.variables[val]['name']))
+ self.tableWidget.setItem(rowPosition , 1, QTableWidgetItem(resultval))
+ self.tableWidget.setItem(rowPosition , 2, QTableWidgetItem(obj.variables[val]['unit']))
+ self.tableWidget.resizeColumnsToContents()
+
+ except Exception as e:
+ print(e)
+
+ \ No newline at end of file
diff --git a/DockWidgets/DockWidgetCompressorExpander.ui b/DockWidgets/DockWidgetCompressorExpander.ui
new file mode 100644
index 0000000..372fc0b
--- /dev/null
+++ b/DockWidgets/DockWidgetCompressorExpander.ui
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>392</width>
+ <height>700</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>3200</width>
+ <height>5000</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>30</y>
+ <width>361</width>
+ <height>621</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Input Data</string>
+ </attribute>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="geometry">
+ <rect>
+ <x>9</x>
+ <y>9</y>
+ <width>331</width>
+ <height>71</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Mode Selection</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Mode : </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="comboBox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>100</y>
+ <width>331</width>
+ <height>111</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Parameter Selection</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QPushButton" name="pushButton_2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>280</y>
+ <width>331</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Submit</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>220</y>
+ <width>331</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Thermo Package</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cbTP">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Results</string>
+ </attribute>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QTableWidget" name="tableWidget">
+ <property name="columnCount">
+ <number>3</number>
+ </property>
+ <attribute name="horizontalHeaderDefaultSectionSize">
+ <number>110</number>
+ </attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>Attribute</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Unit</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>