diff options
author | brenda-br | 2023-03-04 11:32:02 +0530 |
---|---|---|
committer | brenda-br | 2023-03-04 11:32:02 +0530 |
commit | 7cf8eca28f9ca77e6195aa43e3bd9ae319518b66 (patch) | |
tree | c00e283eaa3f67c64f66c828f518bb74abe55752 | |
parent | c9cf87cd94d97c2166e3acdaec8f638c11d4a779 (diff) | |
download | Chemical-Simulator-GUI-7cf8eca28f9ca77e6195aa43e3bd9ae319518b66.tar.gz Chemical-Simulator-GUI-7cf8eca28f9ca77e6195aa43e3bd9ae319518b66.tar.bz2 Chemical-Simulator-GUI-7cf8eca28f9ca77e6195aa43e3bd9ae319518b66.zip |
Revert "Commenting Undo and Redo Functions"
This reverts commit c9cf87cd94d97c2166e3acdaec8f638c11d4a779.
-rw-r--r-- | Chemical Simulator GUI.exe | bin | 57148865 -> 57150217 bytes | |||
-rw-r--r-- | Container.py | 6 | ||||
-rw-r--r-- | Graphics.py | 26 | ||||
-rw-r--r-- | Redo.dat | 0 | ||||
-rw-r--r-- | Undo.dat | 0 | ||||
-rw-r--r-- | mainApp.py | 126 |
6 files changed, 79 insertions, 79 deletions
diff --git a/Chemical Simulator GUI.exe b/Chemical Simulator GUI.exe Binary files differindex 3ca8fd0..c615efb 100644 --- a/Chemical Simulator GUI.exe +++ b/Chemical Simulator GUI.exe diff --git a/Container.py b/Container.py index 8de7b95..7a845a8 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("<span style=\"color:blue\">["+str(self.current_time())+"]<b> "+obj.name+" </b>is instantiated .""</span>") ''' @@ -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 4779a12..16a4189 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 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Redo.dat diff --git a/Undo.dat b/Undo.dat new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Undo.dat @@ -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("<span>[" + str(self.current_time()) + "] <b>New</b> flowsheet is created ... </span>") 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("<span>[" + str(self.current_time()) + "] <b>No more undo can be done!</b>... </span>") - - # ''' - # 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("<span>[" + str(self.current_time()) + "] <b>No more redo can be done!</b>... </span>") + ''' + 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("<span>[" + str(self.current_time()) + "] <b>No more undo can be done!</b>... </span>") + + ''' + 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("<span>[" + str(self.current_time()) + "] <b>No more redo can be done!</b>... </span>") ''' 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() |