From c9cf87cd94d97c2166e3acdaec8f638c11d4a779 Mon Sep 17 00:00:00 2001 From: brenda-br Date: Thu, 2 Mar 2023 17:47:08 +0530 Subject: Commenting Undo and Redo Functions --- Chemical Simulator GUI.exe | Bin 57150217 -> 57148865 bytes Container.py | 6 +-- Graphics.py | 26 +++++----- Redo.dat | 0 Undo.dat | 0 mainApp.py | 126 ++++++++++++++++++++++----------------------- 6 files changed, 79 insertions(+), 79 deletions(-) delete mode 100644 Redo.dat delete mode 100644 Undo.dat diff --git a/Chemical Simulator GUI.exe b/Chemical Simulator GUI.exe index c615efb..3ca8fd0 100644 Binary files a/Chemical Simulator GUI.exe and b/Chemical Simulator GUI.exe differ diff --git a/Container.py b/Container.py index 7a845a8..8de7b95 100644 --- a/Container.py +++ b/Container.py @@ -45,7 +45,7 @@ class Container(): self.unit_operations.append(obj) data = self.unit_operations[:] data.append(compound_selected) - push('Undo', data) + #push('Undo', data) self.msg.append("["+str(self.current_time())+"] "+obj.name+" is instantiated .""") ''' @@ -87,10 +87,10 @@ class Container(): del item.obj del item - clean_file('Redo') + #clean_file('Redo') data = self.unit_operations[:] data.append(compound_selected) - push('Undo', data) + #push('Undo', data) def fetch_object(self,name): for i in self.unit_operations: diff --git a/Graphics.py b/Graphics.py index 16a4189..4779a12 100644 --- a/Graphics.py +++ b/Graphics.py @@ -396,19 +396,19 @@ class NodeSocket(QtWidgets.QGraphicsItem): del self.new_line super(NodeSocket, self).mouseReleaseEvent(event) - try: - data = get_last_list('Undo') - comp_selected = data[-1] - data.remove(comp_selected) - for i in range(len(data)): - if data[i].name == self.new_line.source.parent.obj.name: - data[i] = self.new_line.source.parent.obj - elif data[i].name == self.new_line.target.parent.obj.name: - data[i] = self.new_line.target.parent.obj - data.append(comp_selected) - push('Undo', data) - except Exception as e: - print(e) + # try: + # data = get_last_list('Undo') + # comp_selected = data[-1] + # data.remove(comp_selected) + # for i in range(len(data)): + # if data[i].name == self.new_line.source.parent.obj.name: + # data[i] = self.new_line.source.parent.obj + # elif data[i].name == self.new_line.target.parent.obj.name: + # data[i] = self.new_line.target.parent.obj + # data.append(comp_selected) + # push('Undo', data) + # except Exception as e: + # print(e) def get_center(self): rect = self.boundingRect() diff --git a/Redo.dat b/Redo.dat deleted file mode 100644 index e69de29..0000000 diff --git a/Undo.dat b/Undo.dat deleted file mode 100644 index e69de29..0000000 diff --git a/mainApp.py b/mainApp.py index 7c9b55f..e83d4c3 100644 --- a/mainApp.py +++ b/mainApp.py @@ -82,10 +82,10 @@ class MainApp(QMainWindow,ui): self.actionSequentialMode.setShortcut('Ctrl+M') self.actionEquationOriented.triggered.connect(partial(self.simulate,'EQN')) self.actionEquationOriented.setShortcut('Ctrl+E') - self.actionUndo.triggered.connect(self.undo) - self.actionUndo.setShortcut('Ctrl+Z') - self.actionRedo.triggered.connect(self.redo) - self.actionRedo.setShortcut('Ctrl+Y') + #self.actionUndo.triggered.connect(self.undo) + # self.actionUndo.setShortcut('Ctrl+Z') + # #self.actionRedo.triggered.connect(self.redo) + # self.actionRedo.setShortcut('Ctrl+Y') self.actionSave.triggered.connect(self.save) self.actionSave.setShortcut('Ctrl+S') self.actionOpen.triggered.connect(self.open) @@ -232,7 +232,7 @@ class MainApp(QMainWindow,ui): ''' def new(self): self.setWindowTitle('Untitled - Chemical Simulator GUI') - self.undo_redo_helper() + #self.undo_redo_helper() self.comp = ComponentSelector(self) self.textBrowser.append("[" + str(self.current_time()) + "] New flowsheet is created ... ") dock_widget_lst.clear() @@ -248,61 +248,61 @@ class MainApp(QMainWindow,ui): except Exception as e: print(e) - ''' - It helps by clearing screen and loading the objects by undo redo methods - ''' - def undo_redo_helper(self): - for i in self.container.unit_operations: - type(i).counter = 1 - self.container = None - for i in dock_widget_lst: - i.hide() - del i - lst.clear() - self.container = Container(self.textBrowser, self.graphicsView) - - compound_selected.clear() - self.scene = self.container.graphics.get_scene() - self.graphicsView.setScene(self.scene) - self.graphicsView.setMouseTracking(True) - self.graphicsView.keyPressEvent=self.delete_call - - ''' - Function for undo - ''' - def undo(self): - redo_data = pop('Undo') - if redo_data is not None: - push('Redo', redo_data) - undo_data = get_last_list('Undo') - messages = self.textBrowser.toPlainText() - try: - self.undo_redo_helper() - self.container.graphics.load_canvas(undo_data, self.container) - self.textBrowser.setText(messages) - except Exception as e: - print(e) - self.textBrowser.append(messages) - else: - messages = self.textBrowser.toPlainText() - self.textBrowser.setText(messages) - self.textBrowser.append("[" + str(self.current_time()) + "] No more undo can be done!... ") - - ''' - Function for redo - ''' - def redo(self): - redo_data = pop('Redo') - if redo_data is not None: - push('Undo', redo_data) - messages = self.textBrowser.toPlainText() - self.undo_redo_helper() - self.container.graphics.load_canvas(redo_data, self.container) - self.textBrowser.setText(messages) - else: - messages = self.textBrowser.toPlainText() - self.textBrowser.setText(messages) - self.textBrowser.append("[" + str(self.current_time()) + "] No more redo can be done!... ") + # ''' + # It helps by clearing screen and loading the objects by undo redo methods + # ''' + # def undo_redo_helper(self): + # for i in self.container.unit_operations: + # type(i).counter = 1 + # self.container = None + # for i in dock_widget_lst: + # i.hide() + # del i + # lst.clear() + # self.container = Container(self.textBrowser, self.graphicsView) + + # compound_selected.clear() + # self.scene = self.container.graphics.get_scene() + # self.graphicsView.setScene(self.scene) + # self.graphicsView.setMouseTracking(True) + # self.graphicsView.keyPressEvent=self.delete_call + + # ''' + # Function for undo + # ''' + # def undo(self): + # redo_data = pop('Undo') + # if redo_data is not None: + # push('Redo', redo_data) + # undo_data = get_last_list('Undo') + # messages = self.textBrowser.toPlainText() + # try: + # self.undo_redo_helper() + # self.container.graphics.load_canvas(undo_data, self.container) + # self.textBrowser.setText(messages) + # except Exception as e: + # print(e) + # self.textBrowser.append(messages) + # else: + # messages = self.textBrowser.toPlainText() + # self.textBrowser.setText(messages) + # self.textBrowser.append("[" + str(self.current_time()) + "] No more undo can be done!... ") + + # ''' + # Function for redo + # ''' + # def redo(self): + # redo_data = pop('Redo') + # if redo_data is not None: + # push('Undo', redo_data) + # messages = self.textBrowser.toPlainText() + # self.undo_redo_helper() + # self.container.graphics.load_canvas(redo_data, self.container) + # self.textBrowser.setText(messages) + # else: + # messages = self.textBrowser.toPlainText() + # self.textBrowser.setText(messages) + # self.textBrowser.append("[" + str(self.current_time()) + "] No more redo can be done!... ") ''' Function for saving the current canvas items and compound_selected @@ -343,7 +343,7 @@ class MainApp(QMainWindow,ui): fileName = file_name.split('/')[-1].split('.')[0] self.setWindowTitle(fileName+' - Chemical Simulator GUI') - self.undo_redo_helper() + #self.undo_redo_helper() with open(file_name, 'rb') as f: obj = pickle.load(f) @@ -396,8 +396,8 @@ class MainApp(QMainWindow,ui): def main(): - clean_file('Undo') - clean_file('Redo') + # clean_file('Undo') + # clean_file('Redo') app = QApplication(sys.argv) window = MainApp() -- cgit