def test_menu(simple_workflow, qtbot): manager.qt_is_safe = True manager.initialize_types() manager.collect_plugins() workflow_editor = WorkflowEditor(simple_workflow) workflow_editor.show() qtbot.addWidget(workflow_editor)
def ir_stxm_data(): plugin_manager.collect_plugins() required_task = next(filter(lambda task: task.name == 'application/x-hdf5', plugin_manager._tasks)) plugin_manager._load_plugin(required_task) plugin_manager._instantiate_plugin(required_task) catalog = load_header([ 'C:\\Users\\LBL\\PycharmProjects\\merged-repo\\ir_stxm.h5']) data = project_nxstxm(catalog) return data
def arpes_data(): plugin_manager.collect_plugins() required_task = next(filter(lambda task: task.name=='application/x-fits', plugin_manager._tasks)) plugin_manager._load_plugin(required_task) plugin_manager._instantiate_plugin(required_task) # FIXME: don't rely on absolute file path here! catalog = load_header(['C:\\Users\\LBL\\PycharmProjects\\merged-repo\\Xi-cam.spectral\\xicam\\spectral\\ingestors\\20161214_00034.fits']) data = project_arpes(catalog) return data
def test_menu(qtbot): workflow_editor = WorkflowEditor(Workflow()) workflow_editor.show() qtbot.addWidget(workflow_editor) manager.qt_is_safe = True manager.initialize_types() manager.collect_plugins() qtbot.wait(10000)
def cosmic_data(): plugin_manager.collect_plugins() required_task = next(filter(lambda task: task.name == 'application/x-cxi', plugin_manager._tasks)) plugin_manager._load_plugin(required_task) plugin_manager._instantiate_plugin(required_task) catalog = load_header([ 'C:\\Users\\LBL\\PycharmProjects\\merged-repo\\NS_200805056.cxi']) intents = project_nxCXI_ptycho(catalog) data = intents[0].image return data.transpose('y (nm)', 'x (nm)', 'E (eV)')
def custom_parameter_workflow(qfit): from xicam.core.execution.workflow import Workflow from xicam.core.execution.daskexecutor import DaskExecutor from xicam.plugins import manager manager.collect_plugins() executor = DaskExecutor() wf = Workflow() qfit = qfit() wf.add_operation(qfit) return wf
def __init__(self): super(XicamMainWindow, self).__init__() # Set icon self.setWindowIcon(QIcon(QPixmap(str(path("icons/xicam.gif"))))) # Set size and position self.setGeometry(0, 0, 1000, 600) frameGm = self.frameGeometry() screen = QApplication.desktop().screenNumber( QApplication.desktop().cursor().pos()) centerPoint = QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) # Init child widgets to None self.topwidget = (self.leftwidget) = (self.rightwidget) = ( self.bottomwidget ) = self.lefttopwidget = self.righttopwidget = self.leftbottomwidget = self.rightbottomwidget = None # Setup appearance self.setWindowTitle("Xi-cam") self.load_style() # Attach an object to restore config when loaded self._config_restorer = ConfigRestorer() # Load plugins pluginmanager.qt_is_safe = True pluginmanager.initialize_types() pluginmanager.collect_plugins() pluginmanager.collect_user_plugins() # Setup center/toolbar/statusbar/progressbar self.pluginmodewidget = pluginModeWidget() self.pluginmodewidget.sigSetStage.connect(self.setStage) self.pluginmodewidget.sigSetGUIPlugin.connect(self.setGUIPlugin) self.addToolBar(self.pluginmodewidget) self.setStatusBar(QStatusBar(self)) msg.progressbar = QProgressBar(self) msg.progressbar.hide() msg.statusbar = self.statusBar() self.statusBar().addPermanentWidget(msg.progressbar) self.setCentralWidget(QStackedWidget()) # NOTE: CentralWidgets are force-deleted when replaced, even if the object is still referenced; # To avoid this, a QStackedWidget is used for the central widget. # Setup menubar menubar = DebuggableMenuBar() self.setMenuBar(menubar) file = QMenu("&File", parent=menubar) plugins = QMenu("&Plugins", parent=menubar) menubar.addMenu(file) file.addAction("Se&ttings", self.showSettings, shortcut=QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_S)) file.addAction("E&xit", self.close) menubar.addMenu(plugins) plugins.addAction("Open User &Plugin Directory", self.openUserPluginDir, shortcut=QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_P)) # Set up help help = QMenu("&Help", parent=menubar) documentation_link = QUrl("https://xi-cam.readthedocs.io/en/latest/") help.addAction("Xi-CAM &Help", lambda: QDesktopServices.openUrl(documentation_link)) slack_link = QUrl("https://nikea.slack.com") help.addAction("Chat on &Slack", lambda: QDesktopServices.openUrl(slack_link)) help.addSeparator() about_title = "About Xi-CAM" version_text = f"""Version: <strong>{version.get_versions()['version']}</strong>""" copyright_text = f"""<small>Copyright (c) 2016, The Regents of the University of California, \ through Lawrence Berkeley National Laboratory \ (subject to receipt of any required approvals from the U.S. Dept. of Energy). \ All rights reserved.</small>""" funding_text = f"""Funding for this research was provided by: \ Lawrence Berkeley National Laboratory (grant No. TReXS LDRD to AH); \ US Department of Energy (award No. Early Career Award to AH; \ contract No. DE-SC0012704; contract No. DE-AC02-06CH11357; \ contract No. DE-AC02-76SF00515; contract No. DE-AC02-05CH11231); \ Center for Advanced Mathematics in Energy Research Applications; \ Light Source Directors Data Solution Task Force Pilot Project.""" about_text = version_text + "<br><br>" + funding_text + "<br><hr>" + copyright_text about_box = QMessageBox(QMessageBox.NoIcon, about_title, about_text) about_box.setTextFormat(Qt.RichText) about_box.setWindowModality(Qt.NonModal) help.addAction("&About Xi-CAM", lambda: about_box.show()) help.addSeparator() help.addAction(QWhatsThis.createAction(help)) menubar.addMenu(help) # Initialize layout with first plugin self._currentGUIPlugin = None self.build_layout() # self._currentGUIPlugin = pluginmanager.getPluginsOfCategory("GUIPlugin")[0] self.populate_layout() # Make F key bindings fkeys = [ Qt.Key_F1, Qt.Key_F2, Qt.Key_F3, Qt.Key_F4, Qt.Key_F5, Qt.Key_F6, Qt.Key_F7, Qt.Key_F8, Qt.Key_F9, Qt.Key_F10, Qt.Key_F11, Qt.Key_F12, ] self.Fshortcuts = [QShortcut(QKeySequence(key), self) for key in fkeys] for i in range(12): self.Fshortcuts[i].activated.connect(partial(self.setStage, i)) self.readSettings() # Wireup default widgets get_default_stage()["left"].sigOpen.connect(self.open) get_default_stage()["left"].sigOpen.connect(print) get_default_stage()["left"].sigPreview.connect( get_default_stage()["lefttop"].preview)
def __init__(self): super(XicamMainWindow, self).__init__() # Set icon self.setWindowIcon(QIcon(QPixmap(str(path("icons/xicam.gif"))))) # Set size and position self.setGeometry(0, 0, 1000, 600) frameGm = self.frameGeometry() screen = QApplication.desktop().screenNumber( QApplication.desktop().cursor().pos()) centerPoint = QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) # Init child widgets to None self.topwidget = (self.leftwidget) = (self.rightwidget) = ( self.bottomwidget ) = self.lefttopwidget = self.righttopwidget = self.leftbottomwidget = self.rightbottomwidget = None # Setup appearance self.setWindowTitle("Xi-cam") self._configdialog = ConfigDialog() # Load plugins pluginmanager.collect_plugins() # Setup center/toolbar/statusbar/progressbar self.pluginmodewidget = pluginModeWidget() self.pluginmodewidget.sigSetStage.connect(self.setStage) self.pluginmodewidget.sigSetGUIPlugin.connect(self.setGUIPlugin) self.addToolBar(self.pluginmodewidget) self.setStatusBar(QStatusBar(self)) msg.progressbar = QProgressBar(self) msg.progressbar.hide() msg.statusbar = self.statusBar() self.statusBar().addPermanentWidget(msg.progressbar) self.setCentralWidget(QStackedWidget()) # NOTE: CentralWidgets are force-deleted when replaced, even if the object is still referenced; # To avoid this, a QStackedWidget is used for the central widget. # Setup menubar menubar = DebuggableMenuBar() self.setMenuBar(menubar) file = QMenu("&File", parent=menubar) menubar.addMenu(file) file.addAction("Se&ttings", self.showSettings, shortcut=QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_S)) file.addAction("E&xit", self.close) help = QMenu("&Help", parent=menubar) menubar.addMenu(help) # Initialize layout with first plugin self._currentGUIPlugin = None self.build_layout() # self._currentGUIPlugin = pluginmanager.getPluginsOfCategory("GUIPlugin")[0] self.populate_layout() # Make F key bindings fkeys = [ Qt.Key_F1, Qt.Key_F2, Qt.Key_F3, Qt.Key_F4, Qt.Key_F5, Qt.Key_F6, Qt.Key_F7, Qt.Key_F8, Qt.Key_F9, Qt.Key_F10, Qt.Key_F11, Qt.Key_F12, ] self.Fshortcuts = [QShortcut(QKeySequence(key), self) for key in fkeys] for i in range(12): self.Fshortcuts[i].activated.connect(partial(self.setStage, i)) self.readSettings() # Wireup default widgets defaultstage["left"].sigOpen.connect(self.open) defaultstage["left"].sigOpen.connect(print) defaultstage["left"].sigPreview.connect( defaultstage["lefttop"].preview)
def test_view(simple_workflow_with_intents, qtbot): # Tests ingesting an internally run workflow, projecting it, storing it in a model # and using a CanvasView to display it plugin_manager.qt_is_safe = True plugin_manager.initialize_types() plugin_manager.collect_plugins() pc = next( filter(lambda task: task.name == 'plot_canvas', plugin_manager._tasks)) plugin_manager._load_plugin(pc) plugin_manager._instantiate_plugin(pc) ic = next( filter(lambda task: task.name == 'image_canvas', plugin_manager._tasks)) plugin_manager._load_plugin(ic) plugin_manager._instantiate_plugin(ic) plot_intent_task = next( filter(lambda task: task.name == 'PlotIntent', plugin_manager._tasks)) plugin_manager._load_plugin(plot_intent_task) plugin_manager._instantiate_plugin(plot_intent_task) image_intent_task = next( filter(lambda task: task.name == 'ImageIntent', plugin_manager._tasks)) plugin_manager._load_plugin(image_intent_task) plugin_manager._instantiate_plugin(image_intent_task) execution.executor = LocalExecutor() ensemble_model = EnsembleModel() intents_model = IntentsModel() intents_model.setSourceModel(ensemble_model) data_selector_view = DataSelectorView() data_selector_view.setModel(ensemble_model) stacked_canvas_view = StackedCanvasView() stacked_canvas_view.setModel(intents_model) widget = QWidget() layout = QHBoxLayout() layout.addWidget(stacked_canvas_view) layout.addWidget(data_selector_view) widget.setLayout(layout) def showResult(*result): ensemble = Ensemble() doc_generator = ingest_result_set(simple_workflow_with_intents, result) documents = list(doc_generator) catalog = BlueskyInMemoryCatalog() catalog.upsert(documents[0][1], documents[-1][1], ingest_result_set, [simple_workflow_with_intents, result], {}) catalog = catalog[-1] ensemble.append_catalog(catalog) ensemble_model.add_ensemble(ensemble, project_intents) qtbot.wait(1000) root = ensemble_model.index(0, 0, QModelIndex()) ensemble_model.setData(root.child(0, 0), True, Qt.CheckStateRole) widget.setMinimumSize(800, 600) widget.show() qtbot.addWidget(widget) workflow_editor = WorkflowEditor(simple_workflow_with_intents, callback_slot=showResult) workflow_editor.run_workflow() qtbot.wait(7000)