def test_init(self, init_prog): prog = init_prog prog = Viewer1D(None) assert isinstance(prog, Viewer1D) assert prog.viewer_type == 'Data1D' assert prog.title == 'viewer1D' assert prog.parent is not None
def setup_spread_UI(self): self.ui.spread_widget = QtWidgets.QWidget() self.ui.spread_widget.setLayout(QtWidgets.QVBoxLayout()) widget1D = QtWidgets.QWidget() widget2D = QtWidgets.QWidget() self.ui.spread_viewer_1D = Viewer1D(widget1D) self.ui.spread_viewer_2D = Viewer2D(widget2D) self.ui.spread_widget.layout().addWidget(widget1D) self.ui.spread_widget.layout().addWidget(widget2D) # todo: better connection as discussed self.ui.spread_viewer_1D.ui.crosshair.crosshair_dragged.connect(self.get_nav_position) self.ui.spread_viewer_1D.ui.crosshair_pb.click() self.ui.spread_viewer_2D.get_action('autolevels').click() # todo: better connection as discussed self.ui.spread_viewer_2D.crosshair_dragged.connect(self.get_nav_position) self.ui.spread_viewer_2D.get_action('crosshair').trigger() self.ui.spread_widget.show() self.ui.spread_widget.setVisible(False)
def setup_docks(self): for dock in self.detector.viewer_docks: self.detector.dockarea.moveDock(dock, 'right', self.led_control.dock_manual) self.dockarea.moveDock(self.led_control.dock_sequence, 'bottom', self.led_control.dock_manual) self.dockarea.moveDock(self.steps_sequencer.dock, 'bottom', self.led_control.dock_manual) self.dockarea.moveDock(self.manual_actuation.dock, 'right', self.led_control.dock_manual) self.show_dashboard(False) QtWidgets.QApplication.processEvents() self.steps_sequencer.dock.resize(QtCore.QSize(350, 100)) self.scan_live_dock = Dock('Live Scan Plot') widget = QtWidgets.QWidget() self.scan_live_viewer = Viewer1D(widget) self.scan_live_dock.addWidget(widget) self.dockarea.addDock(self.scan_live_dock, 'bottom', self.detector.viewer_docks[0]) self.scan_live_dock.setVisible(False)
def set_GUI(self): """ Create the graphic interface of the h5 file analyser, including: * *h5 file dock* : QtreeWidget (custom instance of Tree_layout) showing the contents of the h5 file * *status bar* : the top_down information bar * *tree_dock* : The QTree viewer * *1D viewer dock* : the preview window of 1D data * *2D viewer dock* : the preview window of 2D data * *Navigator viewer dock* : the global navigator graphic interface """ # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # h5 file dock V_splitter = QtWidgets.QSplitter(Qt.Vertical) H_splitter = QtWidgets.QSplitter(Qt.Horizontal) Form = QtWidgets.QWidget() self.ui.h5file_tree = Tree_layout(Form, col_counts=2, labels=["Node", 'Pixmap']) self.ui.h5file_tree.ui.Tree.setMinimumWidth(250) self.ui.h5file_tree.ui.Tree.itemClicked.connect(self.show_h5_attributes) self.ui.h5file_tree.ui.Tree.itemDoubleClicked.connect(self.show_h5_data) V_splitter.addWidget(Form) self.ui.attributes_table = pymodaq_ptypes.Table_custom() V_splitter.addWidget(self.ui.attributes_table) H_splitter.addWidget(V_splitter) self.ui.settings_tree = ParameterTree() self.ui.settings_tree.setMinimumWidth(300) H_splitter.addWidget(self.ui.settings_tree) self.ui.menubar = self.mainwindow.menuBar() self.create_menu(self.ui.menubar) # %%create status bar self.ui.statusbar = QtWidgets.QStatusBar() self.ui.statusbar.setMaximumHeight(25) # %% create tree dock file_dock = Dock("File data", size=(1, 1), autoOrientation=False) # give this dock the minimum possible size file_dock.setOrientation('vertical') file_dock.addWidget(H_splitter) file_dock.addWidget(self.ui.statusbar) self.settings = Parameter.create(name='Param', type='group') self.ui.settings_tree.setParameters(self.settings, showTop=False) # #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # #% 1D viewer Dock viewer1D_widget = QtWidgets.QWidget() self.ui.viewer1D = Viewer1D(viewer1D_widget) dock1D = Dock('Viewer1D') dock1D.addWidget(viewer1D_widget) # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # % 2D viewer Dock viewer2D_widget = QtWidgets.QWidget() self.ui.viewer2D = Viewer2D(viewer2D_widget) dock2D = Dock('Viewer2D') dock2D.addWidget(viewer2D_widget) # #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # #% Navigator viewer Dock navigator1D_widget = QtWidgets.QWidget() self.ui.navigator1D = Viewer1D(navigator1D_widget) self.ui.navigator1D.ui.crosshair.crosshair_dragged.connect(self.update_viewer_data) self.ui.navigator1D.ui.crosshair_pb.click() navigator2D_widget = QtWidgets.QWidget() self.ui.navigator2D = Viewer2D(navigator2D_widget) self.ui.navigator2D.crosshair_dragged.connect( self.update_viewer_data) # export scaled position in conjonction with 2D scaled axes self.ui.navigator2D.ui.crosshair_pb.click() dock_nav = Dock('Navigator') dock_nav.addWidget(navigator1D_widget) dock_nav.addWidget(navigator2D_widget, 1, 0) self.dockarea.addDock(file_dock, 'top') self.dockarea.addDock(dock2D, 'right', file_dock) self.dockarea.addDock(dock1D, 'bottom', dock2D) self.dockarea.addDock(dock_nav, 'right', dock2D)
def show_positions(self): widget = QtWidgets.QWidget() viewer = Viewer1D(widget) viewer.show_data([self.update_steps_calculation()]) dialog('Positions to be send to Tabular Scan', '', widget)
label = QtWidgets.QLabel(message) label.setAlignment(QtCore.Qt.AlignCenter) dlg.layout().addWidget(label) dlg.layout().addWidget(widget) button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) dlg.layout().addWidget(button_box) button_box.accepted.connect(dlg.accept) button_box.rejected.connect(dlg.reject) ret = dlg.exec() return ret def show_message(message="blabla", title="Error"): DeprecationWarning( 'Using show_message is deprecated, please use messagebox in daq_utils.messenger module' ) messagebox('Warning', title=title, text=message) if __name__ == '__main__': import sys from pymodaq.daq_utils.plotting.data_viewers.viewer1D import Viewer1D app = QtWidgets.QApplication([]) widget = QtWidgets.QWidget() viewer = Viewer1D(widget) ret = dialog('my dialog', 'this is a dialog do you want to proceed', widget) print(ret) sys.exit(app.exec_())
def init_prog(qtbot): form = QtWidgets.QWidget() prog = Viewer1D(form) qtbot.addWidget(prog) yield prog form.close()
def set_GUI(self): """ """ # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # main_layout = QtWidgets.QGridLayout() # self.area.setLayout(main_layout) # vsplitter = QtWidgets.QSplitter(Qt.Vertical) # Hsplitter=QtWidgets.QSplitter(Qt.Horizontal) params = [ {'title': 'Set data 4D', 'name': 'set_data_4D', 'type': 'action', 'visible': False}, {'title': 'Set data 3D', 'name': 'set_data_3D', 'type': 'action', 'visible': False}, {'title': 'Set data 2D', 'name': 'set_data_2D', 'type': 'action', 'visible': False}, {'title': 'Set data 1D', 'name': 'set_data_1D', 'type': 'action', 'visible': False}, {'title': 'Signal shape', 'name': 'data_shape_settings', 'type': 'group', 'children': [ {'title': 'Initial Data shape:', 'name': 'data_shape_init', 'type': 'str', 'value': "", 'readonly': True}, {'title': 'Axes shape:', 'name': 'nav_axes_shapes', 'type': 'group', 'children': [], 'readonly': True}, {'title': 'Data shape:', 'name': 'data_shape', 'type': 'str', 'value': "", 'readonly': True}, {'title': 'Navigator axes:', 'name': 'navigator_axes', 'type': 'itemselect'}, {'title': 'Set Nav axes:', 'name': 'set_nav_axes', 'type': 'action', 'visible': True}, ]}, ] self.settings = Parameter.create(name='Param', type='group', children=params) # #self.signal_axes_selection() # connecting from tree self.settings.sigTreeStateChanged.connect(self.parameter_tree_changed) # any changes on the settings self.settings.child(('set_data_1D')).sigActivated.connect(lambda: self.set_data_test('1D')) self.settings.child(('set_data_2D')).sigActivated.connect(lambda: self.set_data_test('2D')) self.settings.child(('set_data_3D')).sigActivated.connect(lambda: self.set_data_test('3D')) self.settings.child(('set_data_4D')).sigActivated.connect(lambda: self.set_data_test('4D')) self.settings.child('data_shape_settings', 'set_nav_axes').sigActivated.connect(self.update_data) # #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # #% 1D signalviewer viewer1D_widget = QtWidgets.QWidget() self.ui.viewer1D = Viewer1D(viewer1D_widget) self.ROI1D = LinearRegionItem() self.ui.viewer1D.viewer.plotwidget.plotItem.addItem(self.ROI1D) self.ui.combomath = QtWidgets.QComboBox() self.ui.combomath.addItems(['Sum', 'Mean', 'Half-life']) self.ui.viewer1D.ui.button_widget.addWidget(self.ui.combomath) self.ui.combomath.currentIndexChanged.connect(self.update_Navigator) self.ROI1D.sigRegionChangeFinished.connect(self.update_Navigator) # % 2D viewer Dock viewer2D_widget = QtWidgets.QWidget() self.ui.viewer2D = Viewer2D(viewer2D_widget) self.ui.viewer2D.set_action_visible('flip_ud', False) self.ui.viewer2D.set_action_visible('flip_lr', False) self.ui.viewer2D.set_action_visible('rotate', False) self.ui.viewer2D.get_action('autolevels').trigger() self.ui.viewer2D.get_action('ROIselect').trigger() self.ROI2D = self.ui.viewer2D.ROIselect self.ui.viewer2D.ROI_select_signal.connect(self.update_Navigator) Dock_signal = Dock('Signal') Dock_signal.addWidget(viewer1D_widget) Dock_signal.addWidget(viewer2D_widget) # #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # #% Navigator viewer Dock navigator1D_widget = QtWidgets.QWidget() self.ui.navigator1D = Viewer1D(navigator1D_widget) self.ui.navigator1D.ui.crosshair.crosshair_dragged.connect(self.update_viewer_data) self.ui.navigator1D.ui.crosshair_pb.click() self.ui.navigator1D.data_to_export_signal.connect(self.export_data) navigator2D_widget = QtWidgets.QWidget() self.ui.navigator2D = Viewer2D(navigator2D_widget) self.ui.navigator2D.get_action('autolevels').trigger() self.ui.navigator2D.crosshair_dragged.connect( self.update_viewer_data) # export scaled position in conjonction with 2D scaled axes self.ui.navigator2D.get_action('crosshair').trigger() self.ui.navigator2D.data_to_export_signal.connect(self.export_data) self.ui.navigation_widget = QtWidgets.QWidget() # vlayout_navigation = QtWidgets.QVBoxLayout() # self.navigator_label = QtWidgets.QLabel('Navigation View') # self.navigator_label.setMaximumHeight(15) # layout_navigation.addWidget(self.navigator_label) self.ui.nav_axes_widget = QtWidgets.QWidget() self.ui.nav_axes_widget.setLayout(QtWidgets.QVBoxLayout()) # vlayout_navigation.addWidget(navigator2D_widget) # vlayout_navigation.addWidget(self.ui.nav_axes_widget) self.ui.nav_axes_widget.setVisible(False) # vlayout_navigation.addWidget(navigator1D_widget) # self.ui.navigation_widget.setLayout(vlayout_navigation) # vsplitter.insertWidget(0, self.ui.navigation_widget) Dock_navigation = Dock('Navigation') Dock_navigation.addWidget(navigator1D_widget) Dock_navigation.addWidget(navigator2D_widget) self.area.addDock(Dock_navigation) self.area.addDock(Dock_signal, 'right', Dock_navigation) # self.ui.signal_widget = QtWidgets.QWidget() # VLayout1 = QtWidgets.QVBoxLayout() # self.viewer_label = QtWidgets.QLabel('Data View') # self.viewer_label.setMaximumHeight(15) # VLayout1.addWidget(self.viewer_label) # VLayout1.addWidget(viewer1D_widget) # VLayout1.addWidget(viewer2D_widget) # self.ui.signal_widget.setLayout(VLayout1) # vsplitter.insertWidget(1, self.ui.signal_widget) self.ui.set_signals_pb_1D = addaction('', icon_name='cartesian', checkable=True, tip='Change navigation/signal axes') self.ui.set_signals_pb_1D_bis = addaction('', icon_name='cartesian', checkable=True, tip='Change navigation/signal axes') self.ui.set_signals_pb_2D = addaction('', icon_name='cartesian', checkable=True, tip='Change navigation/signal axes') self.ui.set_signals_pb_2D_bis = addaction('', icon_name='cartesian', checkable=True, tip='Change navigation/signal axes') self.ui.navigator1D.ui.button_widget.addAction(self.ui.set_signals_pb_1D) self.ui.navigator2D.toolbar.addAction(self.ui.set_signals_pb_2D) self.ui.viewer1D.ui.button_widget.addAction(self.ui.set_signals_pb_1D_bis) self.ui.viewer2D.toolbar.addAction(self.ui.set_signals_pb_2D_bis) # main_layout.addWidget(vsplitter) self.ui.set_signals_pb_1D.clicked.connect(self.signal_axes_selection) self.ui.set_signals_pb_2D.clicked.connect(self.signal_axes_selection) self.ui.set_signals_pb_1D_bis.clicked.connect(self.signal_axes_selection) self.ui.set_signals_pb_2D_bis.clicked.connect(self.signal_axes_selection) # to start: display as default a 2D navigator and a 1D viewer self.ui.navigator1D.parent.setVisible(False) self.ui.viewer2D.parent.setVisible(True)