def on_actionTS_triggered(self, checked=None): if checked is None: return if not hasattr(self, "local_connect_explorer"): self.local_connect_explorer = ConnectExplorerDialog(self.system, self.app, parent=self) self.local_connect_explorer.show() self.local_connect_explorer.set_nebrunner(self.nebrunner)
class NEBExplorer(QtGui.QMainWindow): def __init__(self, parent=None, system=None, app=None): QtGui.QMainWindow.__init__(self, parent=parent) self.ui = UI() self.ui.setupUi(self) self.system = system self.app = app self.mdi = QtGui.QMdiArea(self) self.setCentralWidget(self.mdi) self.nebrunner = NEBRunner(app, system) self.nebrunner.on_update_gui.connect(self.update) self.nebrunner.on_run_started.connect(self.run_started) self.nebrunner.on_run_finished.connect(self.run_finished) # from dlg_params import EditParamsWidget # w = QtGui.QDockWidget("NEB parameters", self) # w.setWidget(EditParamsWidget(self, # self.system.params.double_ended_connect.local_connect_params.NEBparams)) # self.addDockWidget(QtCore.Qt.RightDockWidgetArea, w) # # self.editparams = w # self.energies = NEBEnergyWidget() self.view_energies = self.new_view("Energies", self.energies, QtCore.Qt.TopDockWidgetArea) self.view_distances = self.new_view("Distances", NEBDistanceWidget(), QtCore.Qt.TopDockWidgetArea) self.view_k = self.new_view("k", NEBTimeseries(attrname="k"), QtCore.Qt.BottomDockWidgetArea) self.view_nimages = self.new_view("nimages", NEBTimeseries(attrname="nimages"), QtCore.Qt.BottomDockWidgetArea) self.view_rms = self.new_view( "rms", NEBTimeseries(attrname="rms", yscale='log'), QtCore.Qt.BottomDockWidgetArea) self.show3d = Show3DWithSlider() self.view_3d = QtGui.QDockWidget("NEB parameters", self) self.view_3d.setWidget(self.show3d) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.view_3d) # self.view_3d.setFloating(True) self.view_3d.hide() self.show3d.setSystem(self.system) self.show3d.on_frame_updated.connect(self.set_current_frame) self.centralWidget().hide() def run_started(self): self.ui.actionRun.setEnabled(False) self.ui.actionReset.setEnabled(False) self.ui.actionTS.setEnabled(False) def run_finished(self): self.ui.actionRun.setEnabled(True) self.ui.actionReset.setEnabled(True) self.ui.actionTS.setEnabled(True) def set_current_frame(self, index, sender=None): self.energies.highlight_frame(index) def new_view(self, title, widget, pos=QtCore.Qt.RightDockWidgetArea): child = QtGui.QDockWidget(title, self) child.setWidget(widget) self.addDockWidget(pos, child) self.nebrunner.on_update_gui.connect(widget.update_gui) return child def new_neb(self, coords1, coords2, path=None, run=True): self.coords1 = coords1.copy() self.coords2 = coords2.copy() self.initial_path = path self.nebrunner.run(coords1, coords2, path=path, run=run) def toggle_view(self, view, show): if show: view.show() else: view.hide() def update(self, nebrunner): self.show3d.setCoordsPath(nebrunner.path) def on_actionRun_triggered(self, checked=None): if checked is None: return self.nebrunner.continue_run() def on_actionReset_triggered(self, checked=None): if checked is None: return self.nebrunner.run(self.coords1, self.coords2, run=False, path=self.initial_path) def on_actionParams_triggered(self, checked=None): if checked is None: return if not hasattr(self, "paramsdlg"): self.paramsdlg = DlgParams(self.system.params.double_ended_connect. local_connect_params.NEBparams, parent=self) self.paramsdlg.show() def on_actionSave_triggered(self, checked=None): if checked is None: return dialog = QtGui.QFileDialog(self) dialog.setFileMode(QtGui.QFileDialog.AnyFile) dialog.selectFile("path.pickle") dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) if not dialog.exec_(): return filename = dialog.selectedFiles()[0] pickle.dump(self.nebrunner.path, open(filename, "w")) def on_actionLoad_triggered(self, checked=None): if checked is None: return dialog = QtGui.QFileDialog(self) dialog.setFileMode(QtGui.QFileDialog.AnyFile) dialog.setAcceptMode(QtGui.QFileDialog.AcceptOpen) if not dialog.exec_(): return filename = dialog.selectedFiles()[0] self.initial_path = pickle.load(open(filename)) self.nebrunner.run(self.coords1, self.coords2, run=False, path=self.initial_path) def on_actionRms_toggled(self, checked): self.toggle_view(self.view_rms, checked) def on_actionE_toggled(self, checked): self.toggle_view(self.view_energies, checked) def on_actionS_toggled(self, checked): self.toggle_view(self.view_distances, checked) def on_actionK_toggled(self, checked): self.toggle_view(self.view_k, checked) def on_actionNimages_toggled(self, checked): self.toggle_view(self.view_nimages, checked) def on_action3D_toggled(self, checked): self.toggle_view(self.view_3d, checked) def on_actionTS_triggered(self, checked=None): if checked is None: return if not hasattr(self, "local_connect_explorer"): self.local_connect_explorer = ConnectExplorerDialog(self.system, self.app, parent=self) self.local_connect_explorer.show() self.local_connect_explorer.set_nebrunner(self.nebrunner)
class NEBExplorer(QtGui.QMainWindow): def __init__(self, parent=None, system=None, app=None): QtGui.QMainWindow.__init__(self, parent=parent) self.ui = UI() self.ui.setupUi(self) self.system = system self.app = app self.mdi = QtGui.QMdiArea(self) self.setCentralWidget(self.mdi) self.nebrunner = NEBRunner(app, system) self.nebrunner.on_update_gui.connect(self.update) self.nebrunner.on_run_started.connect(self.run_started) self.nebrunner.on_run_finished.connect(self.run_finished) # from dlg_params import EditParamsWidget # w = QtGui.QDockWidget("NEB parameters", self) # w.setWidget(EditParamsWidget(self, # self.system.params.double_ended_connect.local_connect_params.NEBparams)) # self.addDockWidget(QtCore.Qt.RightDockWidgetArea, w) # # self.editparams = w # self.energies = NEBEnergyWidget() self.view_energies = self.new_view("Energies", self.energies, QtCore.Qt.TopDockWidgetArea) self.view_distances = self.new_view("Distances", NEBDistanceWidget(), QtCore.Qt.TopDockWidgetArea) self.view_k = self.new_view("k", NEBTimeseries(attrname="k"), QtCore.Qt.BottomDockWidgetArea) self.view_nimages = self.new_view("nimages", NEBTimeseries(attrname="nimages"), QtCore.Qt.BottomDockWidgetArea) self.view_rms = self.new_view("rms", NEBTimeseries(attrname="rms", yscale='log'), QtCore.Qt.BottomDockWidgetArea) self.show3d = Show3DWithSlider() self.view_3d = QtGui.QDockWidget("NEB parameters", self) self.view_3d.setWidget(self.show3d) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.view_3d) #self.view_3d.setFloating(True) self.view_3d.hide() self.show3d.setSystem(self.system) self.show3d.on_frame_updated.connect(self.set_current_frame) self.centralWidget().hide() def run_started(self): self.ui.actionRun.setEnabled(False) self.ui.actionReset.setEnabled(False) self.ui.actionTS.setEnabled(False) def run_finished(self): self.ui.actionRun.setEnabled(True) self.ui.actionReset.setEnabled(True) self.ui.actionTS.setEnabled(True) def set_current_frame(self, index, sender=None): self.energies.highlight_frame(index) def new_view(self, title, widget, pos=QtCore.Qt.RightDockWidgetArea): child = QtGui.QDockWidget(title, self) child.setWidget(widget) self.addDockWidget(pos, child) self.nebrunner.on_update_gui.connect(widget.update_gui) return child def new_neb(self, coords1, coords2, path=None, run=True): self.coords1 = coords1.copy() self.coords2 = coords2.copy() self.initial_path=path self.nebrunner.run(coords1, coords2, path=path, run=run) def toggle_view(self, view, show): if show: view.show() else: view.hide() def update(self, nebrunner): self.show3d.setCoordsPath(nebrunner.path) def on_actionRun_triggered(self, checked=None): if checked is None: return self.nebrunner.continue_run() def on_actionReset_triggered(self, checked=None): if checked is None: return self.nebrunner.run(self.coords1, self.coords2, run=False, path=self.initial_path) def on_actionParams_triggered(self, checked=None): if checked is None: return if not hasattr(self, "paramsdlg"): self.paramsdlg = DlgParams(self.system.params.double_ended_connect.local_connect_params.NEBparams, parent=self) self.paramsdlg.show() def on_actionSave_triggered(self, checked=None): if checked is None: return dialog = QtGui.QFileDialog(self) dialog.setFileMode(QtGui.QFileDialog.AnyFile) dialog.selectFile("path.pickle") dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave); if(not dialog.exec_()): return filename = dialog.selectedFiles()[0] pickle.dump(self.nebrunner.path, open(filename, "w")) def on_actionLoad_triggered(self, checked=None): if checked is None: return dialog = QtGui.QFileDialog(self) dialog.setFileMode(QtGui.QFileDialog.AnyFile) dialog.setAcceptMode(QtGui.QFileDialog.AcceptOpen); if(not dialog.exec_()): return filename = dialog.selectedFiles()[0] self.initial_path = pickle.load(open(filename)) self.nebrunner.run(self.coords1, self.coords2, run=False, path=self.initial_path) def on_actionRms_toggled(self, checked): self.toggle_view(self.view_rms, checked) def on_actionE_toggled(self, checked): self.toggle_view(self.view_energies, checked) def on_actionS_toggled(self, checked): self.toggle_view(self.view_distances, checked) def on_actionK_toggled(self, checked): self.toggle_view(self.view_k, checked) def on_actionNimages_toggled(self, checked): self.toggle_view(self.view_nimages, checked) def on_action3D_toggled(self, checked): self.toggle_view(self.view_3d, checked) def on_actionTS_triggered(self, checked=None): if checked is None: return if not hasattr(self, "local_connect_explorer"): self.local_connect_explorer = ConnectExplorerDialog(self.system, self.app, parent=self) self.local_connect_explorer.show() self.local_connect_explorer.set_nebrunner(self.nebrunner)