diff options
-rw-r--r-- | ComponentSelector.py | 18 | ||||
-rw-r--r-- | DockWidgets/DockWidget.py | 19 | ||||
-rw-r--r-- | DockWidgets/DockWidgetMaterialStream.py | 24 | ||||
-rw-r--r-- | DockWidgets/__pycache__/DockWidget.cpython-37.pyc | bin | 4341 -> 4329 bytes | |||
-rw-r--r-- | DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc | bin | 8132 -> 8124 bytes | |||
-rw-r--r-- | Graphics.py | 23 | ||||
-rw-r--r-- | Streams.py | 1 | ||||
-rw-r--r-- | Undo.dat | bin | 3191 -> 0 bytes | |||
-rw-r--r-- | UnitOperations.py | 3 | ||||
-rw-r--r-- | mainApp.py | 14 |
10 files changed, 64 insertions, 38 deletions
diff --git a/ComponentSelector.py b/ComponentSelector.py index 80c88d8..c5ba6f5 100644 --- a/ComponentSelector.py +++ b/ComponentSelector.py @@ -43,9 +43,8 @@ class ComponentSelector(QDialog,ui_dialog): self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setModel(self.model) - #QCompleter completes the text written in lineedit - self.lineEdit.setCompleter(self.completer) - + # QCompleter completes the text written in lineedit + self.lineEdit.setCompleter(self.completer) self.compoundSelectButton.clicked.connect(self.compound_selection) self.compoundSelectButton.setAutoDefault(False) self.pushButton.clicked.connect(self.accept) @@ -87,15 +86,20 @@ class ComponentSelector(QDialog,ui_dialog): self.temp_comp= component.replace(removing_attrib,'') return(self.temp_comp) - def compound_selection(self): - self.comp = self.lineEdit.text() #gets entered text + def compound_selection(self, *args): + if len(args) == 2: + self.comp = args[1] #helpful when loading saved data + else: + self.comp = self.lineEdit.text() #gets entered text if self.comp in self.lines: #matches with the db + if self.comp not in compound_selected: + compound_selected.append(self.comp) # appending compound in the list self.obj=self.get_object(self.comp) #obj will store the key of the dictionary #and thus store the instance of the class to which the component belongs self.removing_attrib='(' + self.obj.name + ')' #getting the attribute that is to be removed self.comp=self.get_original_name(self.comp,self.removing_attrib) #getting only air, water etc from air chemsep etc - compound_selected.append(self.comp) #appending that in the list + self.prop_list=self.obj.get_comp_prop(self.comp) #getting prop of the comp #obj is the required class object @@ -120,7 +124,7 @@ class ComponentSelector(QDialog,ui_dialog): @staticmethod def set_compounds(compounds): - #compound_selected = compounds + # compound_selected = compounds for i in compounds: compound_selected.append(i) diff --git a/DockWidgets/DockWidget.py b/DockWidgets/DockWidget.py index b3845bb..b3997f3 100644 --- a/DockWidgets/DockWidget.py +++ b/DockWidgets/DockWidget.py @@ -59,15 +59,13 @@ class DockWidget(QDockWidget,ui_dialog): print(i) if i == None: continue - l = QLineEdit() - if self.input_dict[i] != None: - l.setText(str(self.input_dict[i])) + l = QLineEdit(self.obj.variables[i]['value']) lay = QGridLayout() - lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) + 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.input_dict[i] = l except Exception as e: print(e) @@ -132,7 +130,16 @@ class DockWidget(QDockWidget,ui_dialog): self.tableWidget.setItem(rowPosition , 2, QTableWidgetItem(obj.variables[val]['unit'])) self.tableWidget.resizeColumnsToContents() + # Updating result in class + obj.variables[val]['value'] = resultval + # try: + # if obj.type == "Heater": + # print(obj.variables[val]['name'] + str(obj.variables[val]['value'])) + # except Exception as e: + # print(e) + + + except Exception as e: print(e) -
\ No newline at end of file diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index d272933..792a985 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -62,10 +62,10 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): gp = QGroupBox("Mole Fractions") lay = QGridLayout() for j in range(noc): - l = QLineEdit() - if self.input_dict[i] != '': - l.setText(str(self.obj.variables['x_pc']['value'][j])) - print('l = ', str(self.obj.variables['x_pc']['value'][j])) + l = QLineEdit(str(self.obj.variables['x_pc']['value'][j])) + # if self.input_dict[i] != '': + # l.setText(str(self.obj.variables['x_pc']['value'][j])) + # print('l = ', str(self.obj.variables['x_pc']['value'][j])) self.input_dict[i] = "x_pc" lay.addWidget(QLabel(str(compound_selected[j])+":"),j,0, alignment= Qt.AlignLeft) @@ -141,6 +141,9 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): except Exception as e: print(e) + def update_input_values(self): + self.init() + @staticmethod def show_result(lst): for i in lst: @@ -285,21 +288,22 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.input_dict = {} self.input_dict = self.obj.param_getter(self.comboBox.currentText()) - print("before", self.input_dict) - self.input_dict.pop("x_pc") - temp = self.input_dict.pop('thermo_package') + # print("before", self.input_dict) + # self.input_dict.pop("x_pc") + # temp = self.input_dict.pop('thermo_package') for i in range(len(compound_selected)): print(i) self.input_dict['x_pc[1,' + str(i+1) + ']'] = self.obj.variables['x_pc[1,' + str(i+1) +']']['value'] - self.input_dict['thermo_package'] = temp - print("after", self.input_dict) + # self.input_dict['thermo_package'] = temp + # print("after", self.input_dict) - # chaning index for updating the input data + # changing index for updating the input data indexx = self.comboBox.currentIndex() self.comboBox.setCurrentIndex(1) self.comboBox.setCurrentIndex(indexx) + except Exception as e: print(e)
\ No newline at end of file diff --git a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc Binary files differindex 61691e2..72623eb 100644 --- a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc Binary files differindex f3850cf..7d5b43a 100644 --- a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc diff --git a/Graphics.py b/Graphics.py index 8d7c220..f6b17b5 100644 --- a/Graphics.py +++ b/Graphics.py @@ -30,25 +30,18 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): self.graphicsView = graphicsView self.pos = None self.unit_operations = unit_operations - + def get_scene(self): return self.scene - def get_component_selector(self): - return ComponentSelector(self) - def create_node_item(self,unit_operation, container): return NodeItem(unit_operation, container, self.graphicsView) def load_canvas(self, obj, container): stm = ['MaterialStream','EngStm'] - compounds = obj[-1] - obj.pop() - ComponentSelector.set_compounds(compounds) - for i in obj: - if(i in self.unit_operations): - pass + if i in self.unit_operations: + pass else: self.unit_operations.append(i) print(self.unit_operations) @@ -462,6 +455,16 @@ class NodeItem(QtWidgets.QGraphicsItem): self.dock_widget.setFixedHeight(640) self.dock_widget.DockWidgetFeature(QDockWidget.AllDockWidgetFeatures) self.main_window.addDockWidget(Qt.LeftDockWidgetArea, self.dock_widget) + + # updating input values + if self.dock_widget.obj.type != 'MaterialStream': + print(self.dock_widget.obj.type) + try: + self.dock_widget.obj.param_setter(self.dock_widget.obj.param_getter(self.dock_widget.obj.mode)) + except Exception as e: + print(e) + # self.dock_widget.param() + self.dock_widget.hide() self.pic=QtGui.QPixmap("Icons/"+self.type+".png") @@ -89,6 +89,7 @@ class MaterialStream(): dict = {self.mode1:self.variables['P']['value'], self.mode2:self.variables['T']['value'], "MolFlow":self.variables['F_p[1]']['value'],"x_pc":self.variables['x_pc']['value']} + print('dictionary is :' + str(dict)) elif(mode=="PH"): self.mode1 = 'P' Binary files differdiff --git a/UnitOperations.py b/UnitOperations.py index 410cdd1..08a871d 100644 --- a/UnitOperations.py +++ b/UnitOperations.py @@ -48,7 +48,6 @@ class UnitOperation(): for k,v in params.items(): if k == 'Thermo Package': self.thermo_package = v - print('haha') elif k != self.mode: self.k = v self.variables[k]['value'] = v @@ -152,7 +151,7 @@ class UnitOperation(): self.OM_data_eqn += ('connect(' + self.name + '.Out,' + self.output_stms[0].name + '.In);\n') if self.mode: - self.OM_data_eqn += (self.name + '.' + self.mode + '=' + self.mode_val + ';\n') + self.OM_data_eqn += (self.name + '.' + self.mode + '=' + str(self.mode_val) + ';\n') return self.OM_data_eqn @@ -242,12 +242,13 @@ class MainApp(QMainWindow,ui): def undo_redo_helper(self): for i in self.container.unit_operations: type(i).counter = 1 - del self.container + self.container = None for i in dock_widget_lst: i.hide() del i lst.clear() - self.container = Container.Container(self.textBrowser, self.graphicsView) + self.container = Container(self.textBrowser, self.graphicsView) + compound_selected.clear() self.scene = self.container.graphics.get_scene() self.graphicsView.setScene(self.scene) @@ -330,10 +331,17 @@ class MainApp(QMainWindow,ui): with open(file_name, 'rb') as f: obj = pickle.load(f) print(obj) + compound_selected = obj[-1] + obj.pop() + print(compound_selected) + self.comp.set_compounds(compound_selected) + for i in compound_selected: + self.comp.compound_selection(self.comp, i) self.container.graphics.load_canvas(obj, self.container) + except Exception as e: - pass + print(e) def main(): |