diff options
author | pravindalve | 2023-02-23 21:23:29 +0530 |
---|---|---|
committer | GitHub | 2023-02-23 21:23:29 +0530 |
commit | 7740d1ca0c2e6bf34900460b0c58fa4d528577fb (patch) | |
tree | 0061e4117d1f16fd2fc9e37d078d5b5585af0aef | |
parent | 651b94f869dde8c3ca75fd1a0e41c32bc01c240d (diff) | |
parent | c5f533673ea9ab4315e76940f6d014e349f97884 (diff) | |
download | Chemical-Simulator-GUI-7740d1ca0c2e6bf34900460b0c58fa4d528577fb.tar.gz Chemical-Simulator-GUI-7740d1ca0c2e6bf34900460b0c58fa4d528577fb.tar.bz2 Chemical-Simulator-GUI-7740d1ca0c2e6bf34900460b0c58fa4d528577fb.zip |
Merge pull request #54 from brenda-br/Fix-35
Fix #51, 52, 53, 55, 56, 57, 58, 59, 60, 61
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Container.py | 51 | ||||
-rw-r--r-- | DockWidgets/DockWidget.py | 16 | ||||
-rw-r--r-- | DockWidgets/DockWidgetMaterialStream.py | 19 | ||||
-rw-r--r-- | DockWidgets/__pycache__/DockWidget.cpython-37.pyc | bin | 4932 -> 4724 bytes | |||
-rw-r--r-- | DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc | bin | 9254 -> 9411 bytes | |||
-rw-r--r-- | Graphics.py | 76 | ||||
-rw-r--r-- | OMChem/Flowsheet.py | 12 | ||||
-rw-r--r-- | Streams.py | 24 | ||||
-rw-r--r-- | Undo.dat | bin | 5449 -> 0 bytes | |||
-rw-r--r-- | icons/bpe.png | bin | 0 -> 1695 bytes | |||
-rw-r--r-- | icons/help.png | bin | 0 -> 4967 bytes | |||
-rw-r--r-- | icons/open.png | bin | 0 -> 3316 bytes | |||
-rw-r--r-- | icons/redo.png | bin | 0 -> 3833 bytes | |||
-rw-r--r-- | icons/save.png | bin | 0 -> 3711 bytes | |||
-rw-r--r-- | icons/simulating.png | bin | 0 -> 6777 bytes | |||
-rw-r--r-- | icons/stop.png | bin | 0 -> 5514 bytes | |||
-rw-r--r-- | icons/undo.png | bin | 0 -> 3817 bytes | |||
-rw-r--r-- | main.ui | 49 | ||||
-rw-r--r-- | mainApp.py | 28 |
20 files changed, 223 insertions, 54 deletions
@@ -12,3 +12,5 @@ __pycache__/* DockWidgets/__pycache__/* Undo.dat test.py +Undo.dat +Undo.dat diff --git a/Container.py b/Container.py index a975bc9..fe5fae4 100644 --- a/Container.py +++ b/Container.py @@ -34,17 +34,18 @@ class Container(): self.obj = obj self.scene = self.graphics.get_scene() box = self.graphics.create_node_item(self.obj, self) - self.scene.addItem(box) - box.setPos(2500-30, 2500-30) + if box is not None: + self.scene.addItem(box) + box.setPos(2500-30, 2500-30) - if(obj in self.unit_operations): - pass - else: - self.unit_operations.append(obj) - data = self.unit_operations[:] - data.append(compound_selected) - push('Undo', data) - self.msg.append("<span style=\"color:blue\">["+str(self.current_time())+"]<b> "+obj.name+" </b>is instantiated .""</span>") + if(obj in self.unit_operations): + pass + else: + self.unit_operations.append(obj) + data = self.unit_operations[:] + data.append(compound_selected) + push('Undo', data) + self.msg.append("<span style=\"color:blue\">["+str(self.current_time())+"]<b> "+obj.name+" </b>is instantiated .""</span>") ''' Deletes the selected item from the canvas and also the objects created for that type. @@ -119,6 +120,8 @@ class Container(): def simulate(self,mode): + self.disableInterfaceforSimulation(True) + for i in self.graphics.scene.items(): if (isinstance(i, NodeItem)): try: @@ -144,7 +147,7 @@ class Container(): elif mode=='EQN': self.msg.append("<span>["+str(self.current_time())+"] Simulating in <b>equation</b> mode ... </span>") - self.flowsheet.simulate_EQN() + self.flowsheet.simulate_EQN(self.msg) self.result=self.flowsheet.result_data if(len(self.result)== 4): @@ -160,6 +163,32 @@ class Container(): for i in self.graphics.scene.items(): if (isinstance(i, NodeItem) and i.type == 'MaterialStream'): i.update_tooltip_selectedVar() + no_input_lines = len(i.input[0].in_lines) + no_output_lines = len(i.output[0].out_lines) + if(no_input_lines>0): #Checks if material stream is input or output stream if it is output stream it continues + i.obj.disableInputDataTab(i.dock_widget) + + self.disableInterfaceforSimulation(False) + + def enableToolbar(self,status): + self.graphicsView.parent().parent().actionNew.setProperty('enabled',status) + self.graphicsView.parent().parent().actionZoomIn.setProperty('enabled',status) + self.graphicsView.parent().parent().actionZoomOut.setProperty('enabled',status) + self.graphicsView.parent().parent().actionResetZoom.setProperty('enabled',status) + self.graphicsView.parent().parent().actionEquationOriented.setProperty('enabled',status) + self.graphicsView.parent().parent().actionTerminate.setProperty('enabled',not status) + self.graphicsView.parent().parent().actionSelectCompounds.setProperty('enabled',status) + + def disableInterfaceforSimulation(self,status): + self.graphicsView.parent().parent().menubar.setProperty('enabled',not status) + self.enableToolbar(not status) + self.graphicsView.parent().parent().dockWidget.setProperty('enabled',not status) + self.graphicsView.setInteractive(not status) + if status: + QApplication.instance().setOverrideCursor(QCursor(Qt.WaitCursor)) + else: + QApplication.instance().restoreOverrideCursor() + QApplication.instance().setOverrideCursor(QCursor(Qt.ArrowCursor)) def flat_list(lst): flat_lst=[] diff --git a/DockWidgets/DockWidget.py b/DockWidgets/DockWidget.py index 71e9624..bb8ddf5 100644 --- a/DockWidgets/DockWidget.py +++ b/DockWidgets/DockWidget.py @@ -57,7 +57,7 @@ class DockWidget(QDockWidget,ui_dialog): try: print("input_params_list ", self.input_dict) for c,i in enumerate(self.input_dict): - print(i) + #print(i) if i == None: continue l = QLineEdit(str(self.obj.variables[i]['value'])) @@ -77,16 +77,16 @@ class DockWidget(QDockWidget,ui_dialog): def param(self): try: self.dict = {} - print("param.input_dict ", self.input_dict) + #print("param.input_dict ", self.input_dict) for i in self.input_dict: if (self.input_dict[i] == None): continue else: - print(self.input_dict[i], i, self.obj.type) + #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()) + #print(self.input_dict[i].text()) self.show_error() break @@ -121,19 +121,19 @@ class DockWidget(QDockWidget,ui_dialog): def results_category(self,name): flag = True try: - print("Under result category name ", name) + #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) + #print(variKeys) for i, val in enumerate(variKeys): propertyname = name + '.' + val - print(i,val, propertyname) + #print(i,val, propertyname) if propertyname in result[0]: ind = result[0].index(propertyname) resultval = str(result[-1][ind]) - print("######Resultsfetch####",val,resultval) + #print("######Resultsfetch####",val,resultval) rowPosition = self.tableWidget.rowCount() self.tableWidget.insertRow(rowPosition) self.tableWidget.setItem(rowPosition , 0, QTableWidgetItem(obj.variables[val]['name'])) diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index a6396ef..422119e 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -95,7 +95,10 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): l.setText(str(self.input_dict[i])) lay = QGridLayout() - lay.addWidget(QLabel(i+":"),0,0, alignment=Qt.AlignLeft) + if i !='MolFlow': + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) + else: + lay.addWidget(QLabel(i+":"),0,0, alignment=Qt.AlignLeft) lay.addWidget(l,0,1, alignment=Qt.AlignCenter) if(i != 'MolFlow'): lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) @@ -252,13 +255,13 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): compound_no = int(k[k.index(',') + 1]) - 1 # compound is from python list if phase_no == 1: - child = QTreeWidgetItem(mroot, [compound_selected[compound_no], str(resultval), + child = QTreeWidgetItem(mroot, [compound_selected[compound_no], str(round(float(resultval),4)), obj.variables[k.split('.')[1]]['unit']]) elif phase_no == 2: - child = QTreeWidgetItem(lroot, [compound_selected[compound_no], str(resultval), + child = QTreeWidgetItem(lroot, [compound_selected[compound_no], str(round(float(resultval),4)), obj.variables[k.split('.')[1]]['unit']]) elif phase_no == 3: - child = QTreeWidgetItem(vroot, [compound_selected[compound_no], str(resultval), + child = QTreeWidgetItem(vroot, [compound_selected[compound_no], str(round(float(resultval),4)), obj.variables[k.split('.')[1]]['unit']]) if (compound_no + 1) == len(compound_selected): j += 1 @@ -296,7 +299,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): mrowPosition = self.mTableWidget.rowCount() self.mTableWidget.insertRow(mrowPosition) self.mTableWidget.setItem(mrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) - self.mTableWidget.setItem(mrowPosition , 1, QTableWidgetItem(resultval)) + self.mTableWidget.setItem(mrowPosition , 1, QTableWidgetItem(str(round(float(resultval),4)))) self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) self.mTableWidget.resizeColumnsToContents() @@ -304,14 +307,14 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): lrowPosition = self.lTableWidget.rowCount() self.lTableWidget.insertRow(lrowPosition) self.lTableWidget.setItem(lrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) - self.lTableWidget.setItem(lrowPosition , 1, QTableWidgetItem(resultval)) + self.lTableWidget.setItem(lrowPosition , 1, QTableWidgetItem(str(round(float(resultval),4)))) self.lTableWidget.setItem(lrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) self.lTableWidget.resizeColumnsToContents() if '3' in val.split('.')[1]: vrowPosition = self.vTableWidget.rowCount() self.vTableWidget.insertRow(vrowPosition) self.vTableWidget.setItem(vrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) - self.vTableWidget.setItem(vrowPosition , 1, QTableWidgetItem(resultval)) + self.vTableWidget.setItem(vrowPosition , 1, QTableWidgetItem(str(round(float(resultval),4)))) self.vTableWidget.setItem(vrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) self.vTableWidget.resizeColumnsToContents() if not '[' in val: @@ -319,7 +322,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): mrowPosition = self.mTableWidget.rowCount() self.mTableWidget.insertRow(mrowPosition) self.mTableWidget.setItem(mrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) - self.mTableWidget.setItem(mrowPosition , 1, QTableWidgetItem(resultval)) + self.mTableWidget.setItem(mrowPosition , 1, QTableWidgetItem(str(round(float(resultval),4)))) self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) self.mTableWidget.resizeColumnsToContents() diff --git a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc Binary files differindex 51ca871..bb3ffa1 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 193f8e9..1830c79 100644 --- a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc diff --git a/Graphics.py b/Graphics.py index 862845b..1d9e7ef 100644 --- a/Graphics.py +++ b/Graphics.py @@ -36,7 +36,11 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): return self.scene def create_node_item(self,unit_operation, container): - return NodeItem(unit_operation, container, self.graphicsView) + tempItem = NodeItem(unit_operation, container, self.graphicsView) + if tempItem.ok: + return tempItem + else: + return None def update_compounds(self): for i in self.graphicsView.items(): @@ -288,7 +292,7 @@ class NodeSocket(QtWidgets.QGraphicsItem): painter.drawEllipse(self.rect.x()+2,self.rect.y()+2,(self.rect.height()/3)*2,(self.rect.width()/3)*2) def mousePressEvent(self, event): - cursor = QCursor( Qt.PointingHandCursor ) + cursor = QCursor( Qt.ArrowCursor ) QApplication.instance().setOverrideCursor(cursor) if self.type == 'op': @@ -313,6 +317,12 @@ class NodeSocket(QtWidgets.QGraphicsItem): def mouseMoveEvent(self, event): if self.type == 'op': + item = self.scene().itemAt(event.scenePos().toPoint(),QtGui.QTransform()) + if(isinstance(item,NodeSocket)): + QApplication.instance().setOverrideCursor(QCursor( Qt.PointingHandCursor)) + else: + QApplication.instance().restoreOverrideCursor() + QApplication.instance().setOverrideCursor(QCursor( Qt.ArrowCursor)) pointB = self.mapToScene(event.pos()) self.new_line.pointB = pointB if self.other_line: @@ -342,6 +352,17 @@ class NodeSocket(QtWidgets.QGraphicsItem): self.new_line.source.parent.obj.add_connection(0, self.new_line.source.id, self.new_line.target.parent.obj) if self.new_line.target.parent.obj.type not in stm: self.new_line.target.parent.obj.add_connection(1, self.new_line.target.id, self.new_line.source.parent.obj) # Input stream if flag is 1 + + sc = self.new_line.source.parent + tg = self.new_line.target.parent + if(sc.obj.type == 'MaterialStream'): + sc_no_input_lines = len(sc.input[0].in_lines) + if(sc_no_input_lines > 0): + sc.obj.disableInputDataTab(sc.dock_widget) + if(tg.obj.type == 'MaterialStream'): + tg_no_input_lines = len(tg.input[0].in_lines) + if(tg_no_input_lines > 0): + tg.obj.disableInputDataTab(tg.dock_widget) elif (self.type =='in') and (item.type == 'op'): self.new_line.source = item @@ -353,7 +374,17 @@ class NodeSocket(QtWidgets.QGraphicsItem): self.new_line.source.parent.obj.add_connection(0, self.new_line.source.id, self.new_line.target.parent.obj) if self.new_line.target.parent.obj.type not in stm: self.new_line.target.parent.obj.add_connection(1, self.new_line.target.id, self.new_line.source.parent.obj) - + + sc = self.new_line.source.parent + tg = self.new_line.target.parent + if(sc.obj.type == 'MaterialStream'): + sc_no_input_lines = len(sc.input[0].in_lines) + if(sc_no_input_lines > 0): + sc.obj.disableInputDataTab(sc.dock_widget) + if(tg.obj.type == 'MaterialStream'): + tg_no_input_lines = len(tg.input[0].in_lines) + if(tg_no_input_lines > 0): + tg.obj.disableInputDataTab(tg.dock_widget) else: self.scene().removeItem(self.new_line) @@ -395,7 +426,7 @@ class NodeSocket(QtWidgets.QGraphicsItem): def show(self): # set pen to show self.pen = QPen(QtGui.QColor(0,70,70,220), 1, Qt.SolidLine) - self.brush = QBrush(QtGui.QColor(33,225,162,255)) + self.brush = QBrush(QtGui.QColor(140,199,198,255)) def hide(self): # set pen to transparent @@ -430,7 +461,7 @@ class NodeItem(QtWidgets.QGraphicsItem): self.setAcceptHoverEvents(True) self.name = self.obj.name self.type = self.obj.type - + self.ok = True if (self.obj.modes_list): default_tooltip = f"{self.name}\n\n" default_tooltip_dict = self.obj.param_getter_tooltip(self.obj.mode) @@ -439,11 +470,19 @@ class NodeItem(QtWidgets.QGraphicsItem): default_tooltip = default_tooltip + f" {i} : {j}\n" self.setToolTip(default_tooltip) + dlg = QMessageBox() + dlg.setWindowTitle("Error") + dlg.setIcon(QMessageBox.Critical) + dlg.setText('Enter valid input value!') if self.obj.type == 'Mixer' and not self.obj.saved: - text, ok = QInputDialog.getText(self.container.graphicsView, 'Mixer', 'Enter number of input:', + text, self.ok = QInputDialog.getText(self.container.graphicsView, 'Mixer', 'Enter number of input(2-4):', echo=QLineEdit.Normal, text=str(self.obj.no_of_inputs)) - if ok and text: + while self.ok and (int(text)< 2 or int(text) > 4): + dlg.exec_() + text, self.ok = QInputDialog.getText(self.container.graphicsView, 'Mixer', 'Enter number of input(2-4):', + echo=QLineEdit.Normal, text=str(self.obj.no_of_inputs)) + if self.ok: self.nin = int(text) self.obj.no_of_inputs = self.nin self.obj.variables['NI']['value'] = self.nin @@ -454,9 +493,13 @@ class NodeItem(QtWidgets.QGraphicsItem): # self.obj.no_of_outputs = self.nop # self.obj.variables['No']['value'] = self.nop elif self.obj.type == 'DistillationColumn'and not self.obj.saved: - text, ok = QInputDialog.getText(self.container.graphicsView, 'DistillationColumn', 'Enter number of input:', + text, self.ok = QInputDialog.getText(self.container.graphicsView, 'DistillationColumn', 'Enter number of input(1-8):', echo=QLineEdit.Normal, text=str(self.obj.no_of_inputs)) - if ok and text: + while self.ok and (int(text)< 1 or int(text) > 8): + dlg.exec_() + text, self.ok = QInputDialog.getText(self.container.graphicsView, 'DistillationColumn', 'Enter number of input(1-8):', + echo=QLineEdit.Normal, text=str(self.obj.no_of_inputs)) + if self.ok: self.nin = int(text) self.obj.no_of_inputs = self.nin self.obj.variables['Ni']['value'] = self.nin @@ -506,6 +549,7 @@ class NodeItem(QtWidgets.QGraphicsItem): self.setFlag(QtWidgets.QGraphicsPixmapItem.ItemIsMovable) self.setFlag(QtWidgets.QGraphicsPixmapItem.ItemIsSelectable) + self.setFlag(QGraphicsItem.ItemSendsGeometryChanges) # Brush self.brush = QtGui.QBrush() @@ -634,6 +678,20 @@ class NodeItem(QtWidgets.QGraphicsItem): for op in i.output: op.hide() + def itemChange(self, change, value): + newPos = value + if change == self.ItemPositionChange and self.scene(): + rect = self.container.graphicsView.sceneRect() + width = self.boundingRect().width() + height = self.boundingRect().height() + eWH1 = QPointF(newPos.x()+width,newPos.y()+height) + eWH2 = QPointF(newPos.x()-width,newPos.y()-height) + if not rect.__contains__(eWH1) or not rect.__contains__(eWH2) : + newPos.setX(min(rect.right()-width-40, max(newPos.x(), rect.left()))) + newPos.setY(min(rect.bottom()-height-35, max(newPos.y(), rect.top()))) + self.obj.set_pos(newPos) + return super(NodeItem,self).itemChange(change, newPos) + def findMainWindow(self): ''' Global function to find the (open) QMainWindow in application diff --git a/OMChem/Flowsheet.py b/OMChem/Flowsheet.py index c38b94e..f47c203 100644 --- a/OMChem/Flowsheet.py +++ b/OMChem/Flowsheet.py @@ -21,7 +21,7 @@ class Flowsheet(): self.stdout=None self.stderr=None - def get_omc_path(self): + def get_omc_path(self,msg): try: self.omhome = os.environ.get('OPENMODELICAHOME') if self.omhome is None: @@ -32,6 +32,8 @@ class Flowsheet(): self.omhome = '/usr' return os.path.join(self.omhome, 'bin', 'omc') except BaseException: + msg.parent().parent().parent().container.disableInterfaceforSimulation(False) + msg.append("<span style=\"color:red\"><b>Installation Error : </b>The OpenModelica compiler is missing in the System path please install it.</span>") print("The OpenModelica compiler is missing in the System path please install it" ) raise @@ -44,9 +46,9 @@ class Flowsheet(): def add_compound_list(self,C): self.compounds = C - def send_for_simulation_Eqn(self): + def send_for_simulation_Eqn(self,msg): self.result_data = [] - self.omc_path = self.get_omc_path() + self.omc_path = self.get_omc_path(msg) #print(self.omc_path) if self.sim_method == 'Eqn': @@ -94,7 +96,7 @@ class Flowsheet(): resultval = str(self.result_data[-1][ind]) unit[0].Prop[key] = resultval - def simulate_EQN(self): + def simulate_EQN(self,msg): self.data = [] self.sim_method = 'Eqn' self.data.append("model Flowsheet\n") @@ -154,7 +156,7 @@ class Flowsheet(): #print('Initiating Simulation in Equation Oriented Mode') - self.send_for_simulation_Eqn() + self.send_for_simulation_Eqn(msg) def simulate_SM(self,ip,op): self.sim_method = 'SM' @@ -156,11 +156,11 @@ class MaterialStream(): vapMolFrac_name = self.variables['xvap']['name'] vapMolFrac_val = self.variables['xvap']['value'] vapMolFrac_unit = self.variables['xvap']['unit'] - mixMolFlo_name = self.variables['F_pc']['name'] - mixMolFlo_val = self.variables['F_pc']['value'] - mixMolFlo_unit = self.variables['F_pc']['unit'] + mixMolFlo_name = self.variables['F_p[1]']['name'] + mixMolFlo_val = self.variables['F_p[1]']['value'] + mixMolFlo_unit = self.variables['F_p[1]']['unit'] mixMassFlo_name = self.variables['Fm_p[1]']['name'] - mixMassFlo_val = self.variables['Fm_p[1]']['value'] + mixMassFlo_val = round(float(self.variables['Fm_p[1]']['value']),2) mixMassFlo_unit = self.variables['Fm_p[1]']['unit'] dict = {pressure_name:str(pressure_val)+' '+pressure_unit, @@ -427,3 +427,19 @@ class MaterialStream(): for key,value in self.eqn_dict.items(): self.OM_data_eqn = self.OM_data_eqn + self.name + '.'+ key + ' = ' + str(value) + ';\n' return self.OM_data_eqn + + def disableInputDataTab(self,dockwidget): + #setting the value of input data tab in dock widget and disabling them + dockwidget.comboBox.setDisabled(True) + dockwidget.input_dict['P'].setText(str(round(float(self.variables['P']['value']),2))) + dockwidget.input_dict['P'].setDisabled(True) + dockwidget.input_dict['T'].setText(str(round(float(self.variables['T']['value']),2))) + dockwidget.input_dict['T'].setDisabled(True) + dockwidget.input_dict['MolFlow'].setText(str(round(float(self.variables['F_p[1]']['value']),2))) + dockwidget.input_dict['MolFlow'].setDisabled(True) + dockwidget.cbTP.setCurrentText(str(self.thermo_package)) + dockwidget.cbTP.setDisabled(True) + dockwidget.pushButton_2.setDisabled(True) + for index,k in enumerate(dockwidget.x_pclist): + k.setText(str(round(float(self.variables['x_pc[1,'+ str(index+1)+']']['value']),2))) + k.setDisabled(True) Binary files differdiff --git a/icons/bpe.png b/icons/bpe.png Binary files differnew file mode 100644 index 0000000..000730a --- /dev/null +++ b/icons/bpe.png diff --git a/icons/help.png b/icons/help.png Binary files differnew file mode 100644 index 0000000..785ca95 --- /dev/null +++ b/icons/help.png diff --git a/icons/open.png b/icons/open.png Binary files differnew file mode 100644 index 0000000..305d09d --- /dev/null +++ b/icons/open.png diff --git a/icons/redo.png b/icons/redo.png Binary files differnew file mode 100644 index 0000000..7881e86 --- /dev/null +++ b/icons/redo.png diff --git a/icons/save.png b/icons/save.png Binary files differnew file mode 100644 index 0000000..e09beb3 --- /dev/null +++ b/icons/save.png diff --git a/icons/simulating.png b/icons/simulating.png Binary files differnew file mode 100644 index 0000000..b8ff48f --- /dev/null +++ b/icons/simulating.png diff --git a/icons/stop.png b/icons/stop.png Binary files differnew file mode 100644 index 0000000..d365d34 --- /dev/null +++ b/icons/stop.png diff --git a/icons/undo.png b/icons/undo.png Binary files differnew file mode 100644 index 0000000..d6906b8 --- /dev/null +++ b/icons/undo.png @@ -11,7 +11,7 @@ </rect> </property> <property name="windowTitle"> - <string>MainWindow</string> + <string>Untitled - Chemical Simulator GUI</string> </property> <property name="windowIcon"> <iconset> @@ -115,7 +115,7 @@ </property> <property name="minimumSize"> <size> - <width>0</width> + <width>89</width> <height>150</height> </size> </property> @@ -2024,6 +2024,7 @@ <addaction name="separator"/> <addaction name="actionEquationOriented"/> <addaction name="actionSequentialMode"/> + <addaction name="actionTerminate"/> <addaction name="separator"/> <addaction name="actionSelectCompounds"/> </widget> @@ -2075,6 +2076,18 @@ <string>Sequential mode</string> </property> </action> + <action name="actionTerminate"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset> + <normaloff>Icons/stop.png</normaloff>Icons/stop.png</iconset> + </property> + <property name="text"> + <string>Stop Simulation</string> + </property> + </action> <action name="actionSelectCompounds"> <property name="icon"> <iconset> @@ -2094,36 +2107,66 @@ </property> </action> <action name="actionHelp"> + <property name="icon"> + <iconset> + <normaloff>Icons/help.png</normaloff>Icons/help.png</iconset> + </property> <property name="text"> <string>Help</string> </property> </action> <action name="actionSave"> + <property name="icon"> + <iconset> + <normaloff>Icons/save.png</normaloff>Icons/save.png</iconset> + </property> <property name="text"> <string>Save</string> </property> </action> <action name="actionOpen"> + <property name="icon"> + <iconset> + <normaloff>Icons/open.png</normaloff>Icons/open.png</iconset> + </property> <property name="text"> <string>Open</string> </property> </action> <action name="actionBinaryPhaseEnvelope"> + <property name="icon"> + <iconset> + <normaloff>Icons/bpe.png</normaloff>Icons/bpe.png</iconset> + </property> <property name="text"> <string>Binary Phase Envelope</string> </property> </action> <action name="actionTerminate"> <property name="text"> - <string>Terminate</string> + <string>Stop Simulation</string> </property> </action> <action name="actionUndo"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset> + <normaloff>Icons/undo.png</normaloff>Icons/undo.png</iconset> + </property> <property name="text"> <string>Undo</string> </property> </action> <action name="actionRedo"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset> + <normaloff>Icons/redo.png</normaloff>Icons/redo.png</iconset> + </property> <property name="text"> <string>Redo</string> </property> @@ -173,16 +173,17 @@ class MainApp(QMainWindow,ui): os.chdir(self.container.flowsheet.root_dir) if self.thrd: thread_id = self.thrd.ident - print('____________________Going to terminate simulation thread with Thread ID:',thread_id,'____________________') - print('____________________Going to terminate the new process created for omc____________________') + # print('____________________Going to terminate simulation thread with Thread ID:',thread_id,'____________________') + # print('____________________Going to terminate the new process created for omc____________________') self.container.flowsheet.process.terminate() print('____________________New process created for omc is terminated.____________________') res = ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, ctypes.py_object(SystemExit)) - self.textBrowser.append("<span style=\"color:red\">["+str(self.current_time())+"]<b> Terminating the simulation </b></span>") - print('____________________Simulation thread terminated____________________') + self.textBrowser.append("<span style=\"color:red\">["+str(self.current_time())+"]<b>Simulation Terminated.</b></span>") + self.container.disableInterfaceforSimulation(False) + # print('____________________Simulation thread terminated____________________') if res > 1: ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, 0) - print('Exception raise (Thread termination) failure') + # print('Exception raise (Thread termination) failure') ''' Resets the zoom level to default scaling @@ -230,6 +231,7 @@ class MainApp(QMainWindow,ui): New is used to delete all the existing work. ''' def new(self): + self.setWindowTitle('Untitled - Chemical Simulator GUI') self.undo_redo_helper() self.comp = ComponentSelector(self) self.textBrowser.append("<span>[" + str(self.current_time()) + "] <b>New</b> flowsheet is created ... </span>") @@ -314,13 +316,15 @@ class MainApp(QMainWindow,ui): data.append(self.container.result) file_format = 'sim' - initial_path = QDir.currentPath() + 'untitled.' + file_format + initial_path = QDir.currentPath() + ' untitled.' + file_format file_name, _ = QFileDialog.getSaveFileName(self, "Save As", initial_path, "%s Files (*.%s);; All Files (*)" % (file_format.upper(), file_format)) try: with open(file_name, 'wb') as f: pickle.dump(data, f, pickle.HIGHEST_PROTOCOL) + fileName = file_name.split('/')[-1].split('.')[0] + self.setWindowTitle(fileName+' - Chemical Simulator GUI') except Exception as e: pass @@ -336,6 +340,9 @@ class MainApp(QMainWindow,ui): initial_path, "%s Files (*.%s);; All Files (*)" % (file_format.upper(), file_format)) if file_name: + fileName = file_name.split('/')[-1].split('.')[0] + self.setWindowTitle(fileName+' - Chemical Simulator GUI') + self.undo_redo_helper() with open(file_name, 'rb') as f: @@ -353,8 +360,17 @@ class MainApp(QMainWindow,ui): DockWidget.show_result(dock_widget_lst) for i in dock_widget_lst: + #Submitting values i.param() + #Disbaling input data tab for output stream + for i in self.container.graphics.scene.items(): + if (isinstance(i, NodeItem) and i.type == 'MaterialStream'): + i.update_tooltip_selectedVar() + no_input_lines = len(i.input[0].in_lines) + no_output_lines = len(i.output[0].out_lines) + if(no_input_lines>0): #Checks if material stream is input or output stream if it is output stream it continues + i.obj.disableInputDataTab(i.dock_widget) except Exception as e: print(e) |