summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrenda-br2023-02-16 21:46:01 +0530
committerbrenda-br2023-02-16 21:46:01 +0530
commite518e76814763ee66c02e8c87b642f5e5c1a271b (patch)
treeb5e83cc8e2fa13c55723a25db33e142e43c50037
parentc21e2857f6c0de9ab94c4b768fbde0de817aede4 (diff)
downloadChemical-Simulator-GUI-e518e76814763ee66c02e8c87b642f5e5c1a271b.tar.gz
Chemical-Simulator-GUI-e518e76814763ee66c02e8c87b642f5e5c1a271b.tar.bz2
Chemical-Simulator-GUI-e518e76814763ee66c02e8c87b642f5e5c1a271b.zip
Fix #58 Stop Simulation Button added
-rw-r--r--Container.py35
-rw-r--r--Undo.datbin61657 -> 0 bytes
-rw-r--r--icons/stop.pngbin0 -> 5514 bytes
-rw-r--r--main.ui18
-rw-r--r--mainApp.py11
5 files changed, 46 insertions, 18 deletions
diff --git a/Container.py b/Container.py
index 8bb1b1d..5e6836c 100644
--- a/Container.py
+++ b/Container.py
@@ -119,12 +119,9 @@ class Container():
self.msg.append("<span style=\"color:red\">"+stdout+"</span>")
def simulate(self,mode):
- self.graphicsView.parent().parent().menubar.setProperty('enabled',False)
- self.graphicsView.parent().parent().toolBar.setProperty('enabled',False)
- self.graphicsView.parent().parent().dockWidget.setProperty('enabled',False)
- self.graphicsView.setInteractive(False)
- QApplication.instance().setOverrideCursor(QCursor(Qt.WaitCursor))
+ self.disableInterfaceforSimulation(True)
+
for i in self.graphics.scene.items():
if (isinstance(i, NodeItem)):
try:
@@ -170,13 +167,29 @@ class Container():
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))
- self.graphicsView.parent().parent().menubar.setProperty('enabled',True)
- self.graphicsView.parent().parent().toolBar.setProperty('enabled',True)
- self.graphicsView.parent().parent().dockWidget.setProperty('enabled',True)
- self.graphicsView.setInteractive(True)
- QApplication.instance().restoreOverrideCursor()
- QApplication.instance().setOverrideCursor(QCursor(Qt.ArrowCursor))
def flat_list(lst):
flat_lst=[]
for sublist in lst:
diff --git a/Undo.dat b/Undo.dat
index 7cf571d..e69de29 100644
--- a/Undo.dat
+++ b/Undo.dat
Binary files differ
diff --git a/icons/stop.png b/icons/stop.png
new file mode 100644
index 0000000..d365d34
--- /dev/null
+++ b/icons/stop.png
Binary files differ
diff --git a/main.ui b/main.ui
index c41747e..9a4f48d 100644
--- a/main.ui
+++ b/main.ui
@@ -115,7 +115,7 @@
</property>
<property name="minimumSize">
<size>
- <width>0</width>
+ <width>89</width>
<height>150</height>
</size>
</property>
@@ -2025,6 +2025,8 @@
<addaction name="actionEquationOriented"/>
<addaction name="actionSequentialMode"/>
<addaction name="separator"/>
+ <addaction name="actionTerminate"/>
+ <addaction name="separator"/>
<addaction name="actionSelectCompounds"/>
</widget>
<action name="actionZoomIn">
@@ -2075,6 +2077,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>
@@ -2115,7 +2129,7 @@
</action>
<action name="actionTerminate">
<property name="text">
- <string>Terminate</string>
+ <string>Stop Simulation</string>
</property>
</action>
<action name="actionUndo">
diff --git a/mainApp.py b/mainApp.py
index 8381000..ea957bd 100644
--- a/mainApp.py
+++ b/mainApp.py
@@ -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