def init_colorbar(self): """ Create the colorbar """ self.my_colors = ColorScaleInferno() self._color_map = ColorScaleMagma() self._cb = ColorBar(self.my_colors.cmap_normed, width=100, cb_min=self._cb_min, cb_max=self._cb_max) self.colorbar.addItem(self._cb) self.colorbar.hideAxis('bottom') self.colorbar.setLabel('left', 'Intensity', units=self.unit) self.colorbar.setMouseEnabled(x=False, y=False)
def __init_roi_scan_image(self): # Get the color scheme my_colors = ColorScaleInferno() # Setting up display of ROI xy scan image self.roi_image = ScanImageItem(axisOrder='row-major', lut=my_colors.lut) self._mw.roi_map_ViewWidget.addItem(self.roi_image) self._mw.roi_map_ViewWidget.setLabel('bottom', 'X position', units='m') self._mw.roi_map_ViewWidget.setLabel('left', 'Y position', units='m') self._mw.roi_map_ViewWidget.setAspectLocked(lock=True, ratio=1.0) # Set up color bar self.roi_cb = ColorBar(my_colors.cmap_normed, 100, 0, 100000) self._mw.roi_cb_ViewWidget.addItem(self.roi_cb) self._mw.roi_cb_ViewWidget.hideAxis('bottom') self._mw.roi_cb_ViewWidget.setLabel('left', 'Fluorescence', units='c/s') self._mw.roi_cb_ViewWidget.setMouseEnabled(x=False, y=False) # Get scan image from logic and update initialize plot self._update_scan_image(self.poimanagerlogic().roi_scan_image, self.poimanagerlogic().roi_scan_image_extent) return
def initMainUI(self): """ Definition, configuration and initialisation of the POI Manager GUI. This init connects all the graphic modules, which were created in the *.ui file and configures the event handling between the modules. """ # Use the inherited class 'Ui_PoiManagerGuiTemplate' to create now the # GUI element: self._mw = PoiManagerMainWindow() ##################### # Configuring the dock widgets ##################### # All our gui elements are dockable, and so there should be no "central" widget. self._mw.centralwidget.hide() self._mw.setDockNestingEnabled(True) ##################### # Setting up display of ROI map xy image ##################### # Get the image for the display from the logic: self.roi_xy_image_data = self._poi_manager_logic.roi_map_data[:, :, 3] # Load the image in the display: self.roi_map_image = pg.ImageItem(image=self.roi_xy_image_data, axisOrder='row-major') self.roi_map_image.setRect( QtCore.QRectF( self._confocal_logic.image_x_range[0], self._confocal_logic.image_y_range[0], self._confocal_logic.image_x_range[1] - self._confocal_logic.image_x_range[0], self._confocal_logic.image_y_range[1] - self._confocal_logic.image_y_range[0])) # Add the display item to the roi map ViewWidget defined in the UI file self._mw.roi_map_ViewWidget.addItem(self.roi_map_image) self._mw.roi_map_ViewWidget.setLabel('bottom', 'X position', units='m') self._mw.roi_map_ViewWidget.setLabel('left', 'Y position', units='m') # Set to fixed 1.0 aspect ratio, since the metaphor is a "map" of the sample self._mw.roi_map_ViewWidget.setAspectLocked(lock=True, ratio=1.0) # Get the colorscales and set LUT my_colors = ColorScaleInferno() self.roi_map_image.setLookupTable(my_colors.lut) # Add color bar: self.roi_cb = ColorBar(my_colors.cmap_normed, 100, 0, 100000) self._mw.roi_cb_ViewWidget.addItem(self.roi_cb) self._mw.roi_cb_ViewWidget.hideAxis('bottom') self._mw.roi_cb_ViewWidget.setLabel('left', 'Fluorescence', units='c/s') self._mw.roi_cb_ViewWidget.setMouseEnabled(x=False, y=False) ##################### # Setting up display of sample shift plot ##################### # Load image in the display self.x_shift_plot = pg.PlotDataItem([0], [0], pen=pg.mkPen( palette.c1, style=QtCore.Qt.DotLine), symbol='o', symbolPen=palette.c1, symbolBrush=palette.c1, symbolSize=5, name='x') self.y_shift_plot = pg.PlotDataItem([0], [0], pen=pg.mkPen( palette.c2, style=QtCore.Qt.DotLine), symbol='s', symbolPen=palette.c2, symbolBrush=palette.c2, symbolSize=5, name='y') self.z_shift_plot = pg.PlotDataItem([0], [0], pen=pg.mkPen( palette.c3, style=QtCore.Qt.DotLine), symbol='t', symbolPen=palette.c3, symbolBrush=palette.c3, symbolSize=5, name='z') self._mw.sample_shift_ViewWidget.addLegend() # Add the plot to the ViewWidget defined in the UI file self._mw.sample_shift_ViewWidget.addItem(self.x_shift_plot) self._mw.sample_shift_ViewWidget.addItem(self.y_shift_plot) self._mw.sample_shift_ViewWidget.addItem(self.z_shift_plot) # Label axes self._mw.sample_shift_ViewWidget.setLabel('bottom', 'Time', units='s') self._mw.sample_shift_ViewWidget.setLabel('left', 'Sample shift', units='m') ##################### # Connect signals ##################### # Distance Measurement: # Introducing a SignalProxy will limit the rate of signals that get fired. # Otherwise we will run into a heap of unhandled function calls. proxy = pg.SignalProxy(self.roi_map_image.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved) # Connecting a Mouse Signal to trace to mouse movement function. self.roi_map_image.scene().sigMouseMoved.connect(self.mouseMoved) # Toolbar actions self._mw.new_roi_Action.triggered.connect(self.make_new_roi) self._mw.save_roi_Action.triggered.connect(self.save_roi) self._mw.load_roi_Action.triggered.connect(self.load_roi) self._mw.reorient_roi_Action.triggered.connect( self.open_reorient_roi_dialog) self._mw.autofind_pois_Action.triggered.connect( self.do_autofind_poi_procedure) self._mw.optimize_roi_Action.triggered.connect(self.optimize_roi) self._mw.new_poi_Action.triggered.connect(self.set_new_poi) self._mw.goto_poi_Action.triggered.connect(self.goto_poi) self._mw.refind_poi_Action.triggered.connect(self.update_poi_pos) self._mw.track_poi_Action.triggered.connect(self.toggle_tracking) # Interface controls self._mw.get_confocal_image_PushButton.clicked.connect( self.get_confocal_image) self._mw.set_poi_PushButton.clicked.connect(self.set_new_poi) self._mw.delete_last_pos_Button.clicked.connect(self.delete_last_point) self._mw.manual_update_poi_PushButton.clicked.connect( self.manual_update_poi) self._mw.move_poi_PushButton.clicked.connect(self.move_poi) self._mw.poi_name_LineEdit.returnPressed.connect(self.change_poi_name) self._mw.roi_name_LineEdit.editingFinished.connect(self.set_roi_name) self._mw.delete_poi_PushButton.clicked.connect(self.delete_poi) self._mw.goto_poi_after_update_checkBox.toggled.connect( self.toggle_follow) # This needs to be activated so that it only listens to user input, and ignores # algorithmic index changes self._mw.active_poi_ComboBox.activated.connect( self.handle_active_poi_ComboBox_index_change) self._mw.refind_method_ComboBox.currentIndexChanged.connect( self.change_refind_method) # Connect the buttons and inputs for the colorbar self._mw.roi_cb_centiles_RadioButton.toggled.connect( self.refresh_roi_colorscale) self._mw.roi_cb_manual_RadioButton.toggled.connect( self.refresh_roi_colorscale) self._mw.roi_cb_min_SpinBox.valueChanged.connect( self.shortcut_to_roi_cb_manual) self._mw.roi_cb_max_SpinBox.valueChanged.connect( self.shortcut_to_roi_cb_manual) self._mw.roi_cb_low_percentile_DoubleSpinBox.valueChanged.connect( self.shortcut_to_roi_cb_centiles) self._mw.roi_cb_high_percentile_DoubleSpinBox.valueChanged.connect( self.shortcut_to_roi_cb_centiles) self._mw.display_shift_vs_duration_RadioButton.toggled.connect( self._redraw_sample_shift) self._mw.display_shift_vs_clocktime_RadioButton.toggled.connect( self._redraw_sample_shift) self._markers = dict() # Signal at end of refocus self._poi_manager_logic.signal_timer_updated.connect( self._update_timer, QtCore.Qt.QueuedConnection) self._poi_manager_logic.signal_poi_updated.connect( self._redraw_sample_shift, QtCore.Qt.QueuedConnection) self._poi_manager_logic.signal_poi_updated.connect( self.populate_poi_list, QtCore.Qt.QueuedConnection) self._poi_manager_logic.signal_poi_updated.connect( self._redraw_poi_markers, QtCore.Qt.QueuedConnection) self._poi_manager_logic.signal_poi_deleted.connect( self._remove_poi_marker) self._poi_manager_logic.signal_confocal_image_updated.connect( self._redraw_roi_image) self._poi_manager_logic.signal_periodic_opt_duration_changed.connect( self._track_period_changed) self._poi_manager_logic.signal_periodic_opt_started.connect( self._tracking_started) self._poi_manager_logic.signal_periodic_opt_stopped.connect( self._tracking_stopped) # Connect track period after setting the GUI value from the logic initial_period = self._poi_manager_logic.timer_duration self._mw.track_period_SpinBox.setValue(initial_period) self._mw.time_till_next_update_ProgressBar.setMaximum(initial_period) self._mw.time_till_next_update_ProgressBar.setValue(initial_period) self._mw.track_period_SpinBox.valueChanged.connect( self.set_track_period) # Redraw the sample_shift axes if the range changes self._mw.sample_shift_ViewWidget.plotItem.sigRangeChanged.connect( self._redraw_sample_shift) self._mw.show()
def on_activate(self): """ Initializes all needed UI files and establishes the connectors. """ self._logic = self.camera_logic() self._save_logic = self.savelogic() # Windows self._mw = CameraWindow() self._mw.centralwidget.hide() self._mw.setDockNestingEnabled(True) self.initSettingsUI() self._mw.start_video_Action.setEnabled(True) self._mw.start_video_Action.setChecked(self._logic.enabled) self._mw.start_video_Action.triggered.connect(self.start_video_clicked) self._mw.start_image_Action.setEnabled(True) self._mw.start_image_Action.setChecked(self._logic.enabled) self._mw.start_image_Action.triggered.connect(self.start_image_clicked) self._logic.sigUpdateDisplay.connect(self.update_data) self._logic.sigAcquisitionFinished.connect(self.acquisition_finished) self._logic.sigVideoFinished.connect(self.enable_start_image_action) # starting the physical measurement self.sigVideoStart.connect(self._logic.start_loop) self.sigVideoStop.connect(self._logic.stop_loop) self.sigImageStart.connect(self._logic.start_single_acquistion) # connect Settings action under Options menu self._mw.actionSettings.triggered.connect(self.menu_settings) # connect save action to save function self._mw.actionSave_XY_Scan.triggered.connect(self.save_xy_scan_data) raw_data_image = self._logic.get_last_image() self._image = pg.ImageItem(image=raw_data_image, axisOrder='row-major') self._mw.image_PlotWidget.addItem(self._image) self._mw.image_PlotWidget.setAspectLocked(True) # Get the colorscale and set the LUTs self.my_colors = ColorScaleInferno() self._image.setLookupTable(self.my_colors.lut) # Connect the buttons and inputs for the colorbar self._mw.xy_cb_manual_RadioButton.clicked.connect(self.update_xy_cb_range) self._mw.xy_cb_centiles_RadioButton.clicked.connect(self.update_xy_cb_range) self._mw.xy_cb_min_DoubleSpinBox.valueChanged.connect(self.shortcut_to_xy_cb_manual) self._mw.xy_cb_max_DoubleSpinBox.valueChanged.connect(self.shortcut_to_xy_cb_manual) self._mw.xy_cb_low_percentile_DoubleSpinBox.valueChanged.connect(self.shortcut_to_xy_cb_centiles) self._mw.xy_cb_high_percentile_DoubleSpinBox.valueChanged.connect(self.shortcut_to_xy_cb_centiles) # create color bar self.xy_cb = ColorBar(self.my_colors.cmap_normed, width=100, cb_min=0, cb_max=100) self.depth_cb = ColorBar(self.my_colors.cmap_normed, width=100, cb_min=0, cb_max=100) self._mw.xy_cb_ViewWidget.addItem(self.xy_cb) self._mw.xy_cb_ViewWidget.hideAxis('bottom') self._mw.xy_cb_ViewWidget.setLabel('left', 'Fluorescence', units='c') self._mw.xy_cb_ViewWidget.setMouseEnabled(x=False, y=False)
def on_activate(self): """ Initializes all needed UI files and establishes the connectors. """ self._logic = self.camera_logic() self._save_logic = self.savelogic() # Windows self._mw = CameraWindow() self._mw.centralwidget.hide() self._mw.setDockNestingEnabled(True) self.initSettingsUI() self._sd.exposureDSpinBox.setDecimals(5) self._mw.start_video_Action.setEnabled(True) self._mw.start_video_Action.setChecked(self._logic.enabled) self._mw.start_video_Action.triggered.connect(self.start_video_clicked) self._mw.start_image_Action.setEnabled(True) self._mw.start_image_Action.setChecked(self._logic.enabled) self._mw.start_image_Action.triggered.connect(self.start_image_clicked) self._mw.action_toggle_cooling.toggled.connect(self.toggle_fan) self._logic.sigUpdateDisplay.connect(self.update_data) self._logic.sigAcquisitionFinished.connect(self.acquisition_finished) self._logic.sigVideoFinished.connect(self.enable_start_image_action) # starting the physical measurement self.sigVideoStart.connect(self._logic.start_loop) self.sigVideoStop.connect(self._logic.stop_loop) self.sigImageStart.connect(self._logic.start_single_acquistion) # connect Settings action under Options menu self._mw.actionSettings.triggered.connect(self.menu_settings) # connect save action to save function self._mw.actionSave_XY_Scan.triggered.connect(self.save_xy_scan_data) raw_data_image = self._logic.get_last_image() # This allows the camera GUI to take care of a 3darray of images if the cam GUI is initialized after # and ODMR measuremnt. try: if raw_data_image.ndim > 2: raw_data_image = np.zeros(self._logic.get_sensor()) except BaseException: pass self._image = pg.ImageItem(image=raw_data_image, axisOrder='row-major') self._mw.image_PlotWidget.addItem(self._image) # Set ROI widget with default sensor size, snapping true and invisible color until and image is clicked. # Extra scale handles are added as well. # It has not been added to main window yet, so as to give a clean look when an image has not yet been # clicked. self.roi_p1 = self.roi_p2 = 0 self.roi_s1, self.roi_s2 = self._logic.get_sensor() self.roi = pg.RectROI([self.roi_p1, self.roi_p2], [self.roi_s1, self.roi_s2], pen=(0, 0, 0, 0), scaleSnap=True, translateSnap=True, maxBounds=QtCore.QRectF(self.roi_p1, self.roi_p2, self.roi_s1, self.roi_s2), movable=False) self.roi.handleSize = 12 self.roi.addScaleHandle((0, 1), (1, 0)) self.roi.addScaleHandle((0, 0), (1, 1)) self.roi.addScaleHandle((1, 0), (0, 1)) self.roi.addTranslateHandle((1, 1), (0, 0)) # self._mw.image_PlotWidget.addItem(self.roi) self._mw.image_PlotWidget.setAspectLocked(True) self.sigROISet.connect(self._logic.set_image_roi) # ROI button actions self._mw.DefaultRoi.clicked.connect(self.default_roi) self._mw.SetRoi.clicked.connect(self.set_roi) self._mw.DefaultRoi.setEnabled(False) self._mw.SetRoi.setEnabled(False) self._mw.image_PlotWidget.addItem(self.roi) self.cross = pg.CrosshairROI(pos=(self.roi_s1 / 2, self.roi_s2 / 2), size=(40, 40), translateSnap=True, rotateSnap=True, maxBounds=QtCore.QRectF(0, 0, 1200, 1200)) self.cross.sigRegionChanged.connect(self.print_counts) self._mw.image_PlotWidget.addItem(self.cross) self.scaleBar = pg.LineSegmentROI(([0, 0], [100, 0]), pen={ 'color': "#E0D8D8", 'width': 3 }) self._mw.image_PlotWidget.addItem(self.scaleBar) self.scaleBar.sigRegionChanged.connect(self.print_scale) # Get the colorscale and set the LUTs self.my_colors = ColorScaleInferno() self._image.setLookupTable(self.my_colors.lut) # Connect the buttons and inputs for the colorbar self._mw.xy_cb_manual_RadioButton.clicked.connect( self.update_xy_cb_range) self._mw.xy_cb_centiles_RadioButton.clicked.connect( self.update_xy_cb_range) self._mw.xy_cb_min_DoubleSpinBox.valueChanged.connect( self.shortcut_to_xy_cb_manual) self._mw.xy_cb_max_DoubleSpinBox.valueChanged.connect( self.shortcut_to_xy_cb_manual) self._mw.xy_cb_low_percentile_DoubleSpinBox.valueChanged.connect( self.shortcut_to_xy_cb_centiles) self._mw.xy_cb_high_percentile_DoubleSpinBox.valueChanged.connect( self.shortcut_to_xy_cb_centiles) # create color bar self.xy_cb = ColorBar(self.my_colors.cmap_normed, width=100, cb_min=0, cb_max=100) self.depth_cb = ColorBar(self.my_colors.cmap_normed, width=100, cb_min=0, cb_max=100) self._mw.xy_cb_ViewWidget.addItem(self.xy_cb) self._mw.xy_cb_ViewWidget.hideAxis('bottom') self._mw.xy_cb_ViewWidget.setLabel('left', 'Fluorescence', units='c') self._mw.xy_cb_ViewWidget.setMouseEnabled(x=False, y=False)
def on_activate(self): """ Definition, configuration and initialisation of the ODMR GUI. This init connects all the graphic modules, which were created in the *.ui file and configures the event handling between the modules. """ self._odmr_logic = self.odmrlogic1() # Use the inherited class 'Ui_ODMRGuiUI' to create now the GUI element: self._mw = ODMRMainWindow() self._sd = ODMRSettingDialog() # Create a QSettings object for the mainwindow and store the actual GUI layout self.mwsettings = QtCore.QSettings("QUDI", "ODMR") self.mwsettings.setValue("geometry", self._mw.saveGeometry()) self.mwsettings.setValue("windowState", self._mw.saveState()) # Get hardware constraints to set limits for input widgets constraints = self._odmr_logic.get_hw_constraints() # Adjust range of scientific spinboxes above what is possible in Qt Designer self._mw.cw_frequency_DoubleSpinBox.setMaximum( constraints.max_frequency) self._mw.cw_frequency_DoubleSpinBox.setMinimum( constraints.min_frequency) self._mw.start_freq_DoubleSpinBox.setMaximum(constraints.max_frequency) self._mw.start_freq_DoubleSpinBox.setMinimum(constraints.min_frequency) self._mw.step_freq_DoubleSpinBox.setMaximum(100e9) self._mw.stop_freq_DoubleSpinBox.setMaximum(constraints.max_frequency) self._mw.stop_freq_DoubleSpinBox.setMinimum(constraints.min_frequency) self._mw.cw_power_DoubleSpinBox.setMaximum(constraints.max_power) self._mw.cw_power_DoubleSpinBox.setMinimum(constraints.min_power) self._mw.sweep_power_DoubleSpinBox.setMaximum(constraints.max_power) self._mw.sweep_power_DoubleSpinBox.setMinimum(constraints.min_power) # Add save file tag input box self._mw.save_tag_LineEdit = QtWidgets.QLineEdit(self._mw) self._mw.save_tag_LineEdit.setMaximumWidth(500) self._mw.save_tag_LineEdit.setMinimumWidth(200) self._mw.save_tag_LineEdit.setToolTip('Enter a nametag which will be\n' 'added to the filename.') self._mw.save_ToolBar.addWidget(self._mw.save_tag_LineEdit) # add a clear button to clear the ODMR plots: self._mw.clear_odmr_PushButton = QtWidgets.QPushButton(self._mw) self._mw.clear_odmr_PushButton.setText('Clear ODMR') self._mw.clear_odmr_PushButton.setToolTip('Clear the data of the\n' 'current ODMR measurements.') self._mw.clear_odmr_PushButton.setEnabled(False) self._mw.toolBar.addWidget(self._mw.clear_odmr_PushButton) # Set up and connect channel combobox self.display_channel = 0 odmr_channels = self._odmr_logic.get_odmr_channels() for n, ch in enumerate(odmr_channels): self._mw.odmr_channel_ComboBox.addItem(str(ch), n) self._mw.odmr_channel_ComboBox.activated.connect(self.update_channel) # Get the image from the logic self.odmr_matrix_image = pg.ImageItem( self._odmr_logic.odmr_plot_xy[:, self.display_channel], axisOrder='row-major') self.odmr_matrix_image.setRect( QtCore.QRectF(self._odmr_logic.mw_start, 0, self._odmr_logic.mw_stop - self._odmr_logic.mw_start, self._odmr_logic.number_of_lines)) self.odmr_image = pg.PlotDataItem( self._odmr_logic.odmr_plot_x, self._odmr_logic.odmr_plot_y[self.display_channel], pen=pg.mkPen(palette.c1, style=QtCore.Qt.DotLine), symbol='o', symbolPen=palette.c1, symbolBrush=palette.c1, symbolSize=7) self.odmr_fit_image = pg.PlotDataItem(self._odmr_logic.odmr_fit_x, self._odmr_logic.odmr_fit_y, pen=pg.mkPen(palette.c2)) # Add the display item to the xy and xz ViewWidget, which was defined in the UI file. self._mw.odmr_PlotWidget.addItem(self.odmr_image) self._mw.odmr_PlotWidget.setLabel(axis='left', text='Counts', units='Counts/s') self._mw.odmr_PlotWidget.setLabel(axis='bottom', text='Frequency', units='Hz') self._mw.odmr_PlotWidget.showGrid(x=True, y=True, alpha=0.8) self._mw.odmr_matrix_PlotWidget.addItem(self.odmr_matrix_image) self._mw.odmr_matrix_PlotWidget.setLabel(axis='left', text='Matrix Lines', units='#') self._mw.odmr_matrix_PlotWidget.setLabel(axis='bottom', text='Frequency', units='Hz') # Get the colorscales at set LUT my_colors = ColorScaleInferno() self.odmr_matrix_image.setLookupTable(my_colors.lut) ######################################################################## # Configuration of the Colorbar # ######################################################################## self.odmr_cb = ColorBar(my_colors.cmap_normed, 100, 0, 100000) # adding colorbar to ViewWidget self._mw.odmr_cb_PlotWidget.addItem(self.odmr_cb) self._mw.odmr_cb_PlotWidget.hideAxis('bottom') self._mw.odmr_cb_PlotWidget.hideAxis('left') self._mw.odmr_cb_PlotWidget.setLabel('right', 'Fluorescence', units='counts/s') ######################################################################## # Configuration of the various display Widgets # ######################################################################## # Take the default values from logic: self._mw.cw_frequency_DoubleSpinBox.setValue( self._odmr_logic.cw_mw_frequency) self._mw.start_freq_DoubleSpinBox.setValue(self._odmr_logic.mw_start) self._mw.stop_freq_DoubleSpinBox.setValue(self._odmr_logic.mw_stop) self._mw.step_freq_DoubleSpinBox.setValue(self._odmr_logic.mw_step) self._mw.cw_power_DoubleSpinBox.setValue(self._odmr_logic.cw_mw_power) self._mw.sweep_power_DoubleSpinBox.setValue( self._odmr_logic.sweep_mw_power) self._mw.runtime_DoubleSpinBox.setValue(self._odmr_logic.run_time) self._mw.elapsed_time_DisplayWidget.display( int(np.rint(self._odmr_logic.elapsed_time))) self._mw.elapsed_sweeps_DisplayWidget.display( self._odmr_logic.elapsed_sweeps) self._mw.average_level_SpinBox.setValue( self._odmr_logic.lines_to_average) self._sd.matrix_lines_SpinBox.setValue( self._odmr_logic.number_of_lines) self._sd.clock_frequency_DoubleSpinBox.setValue( self._odmr_logic.clock_frequency) self._sd.oversampling_SpinBox.setValue(self._odmr_logic.oversampling) self._sd.lock_in_CheckBox.setChecked(self._odmr_logic.lock_in) # fit settings self._fsd = FitSettingsDialog(self._odmr_logic.fc) self._fsd.sigFitsUpdated.connect( self._mw.fit_methods_ComboBox.setFitFunctions) self._fsd.applySettings() self._mw.action_FitSettings.triggered.connect(self._fsd.show) ######################################################################## # Connect signals # ######################################################################## # Internal user input changed signals self._mw.cw_frequency_DoubleSpinBox.editingFinished.connect( self.change_cw_params) self._mw.start_freq_DoubleSpinBox.editingFinished.connect( self.change_sweep_params) self._mw.step_freq_DoubleSpinBox.editingFinished.connect( self.change_sweep_params) self._mw.stop_freq_DoubleSpinBox.editingFinished.connect( self.change_sweep_params) self._mw.sweep_power_DoubleSpinBox.editingFinished.connect( self.change_sweep_params) self._mw.cw_power_DoubleSpinBox.editingFinished.connect( self.change_cw_params) self._mw.runtime_DoubleSpinBox.editingFinished.connect( self.change_runtime) self._mw.odmr_cb_max_DoubleSpinBox.valueChanged.connect( self.colorscale_changed) self._mw.odmr_cb_min_DoubleSpinBox.valueChanged.connect( self.colorscale_changed) self._mw.odmr_cb_high_percentile_DoubleSpinBox.valueChanged.connect( self.colorscale_changed) self._mw.odmr_cb_low_percentile_DoubleSpinBox.valueChanged.connect( self.colorscale_changed) self._mw.average_level_SpinBox.valueChanged.connect( self.average_level_changed) # Internal trigger signals self._mw.odmr_cb_manual_RadioButton.clicked.connect( self.colorscale_changed) self._mw.odmr_cb_centiles_RadioButton.clicked.connect( self.colorscale_changed) self._mw.clear_odmr_PushButton.clicked.connect(self.clear_odmr_data) self._mw.action_run_stop.triggered.connect(self.run_stop_odmr) self._mw.action_resume_odmr.triggered.connect(self.resume_odmr) self._mw.action_toggle_cw.triggered.connect(self.toggle_cw_mode) self._mw.action_Save.triggered.connect(self.save_data) self._mw.action_RestoreDefault.triggered.connect( self.restore_defaultview) self._mw.do_fit_PushButton.clicked.connect(self.do_fit) # Control/values-changed signals to logic self.sigCwMwOn.connect(self._odmr_logic.mw_cw_on, QtCore.Qt.QueuedConnection) self.sigMwOff.connect(self._odmr_logic.mw_off, QtCore.Qt.QueuedConnection) self.sigClearData.connect(self._odmr_logic.clear_odmr_data, QtCore.Qt.QueuedConnection) self.sigStartOdmrScan.connect(self._odmr_logic.start_odmr_scan, QtCore.Qt.QueuedConnection) self.sigStopOdmrScan.connect(self._odmr_logic.stop_odmr_scan, QtCore.Qt.QueuedConnection) self.sigContinueOdmrScan.connect(self._odmr_logic.continue_odmr_scan, QtCore.Qt.QueuedConnection) self.sigDoFit.connect(self._odmr_logic.do_fit, QtCore.Qt.QueuedConnection) self.sigMwCwParamsChanged.connect(self._odmr_logic.set_cw_parameters, QtCore.Qt.QueuedConnection) self.sigMwSweepParamsChanged.connect( self._odmr_logic.set_sweep_parameters, QtCore.Qt.QueuedConnection) self.sigRuntimeChanged.connect(self._odmr_logic.set_runtime, QtCore.Qt.QueuedConnection) self.sigNumberOfLinesChanged.connect( self._odmr_logic.set_matrix_line_number, QtCore.Qt.QueuedConnection) self.sigClockFreqChanged.connect(self._odmr_logic.set_clock_frequency, QtCore.Qt.QueuedConnection) self.sigOversamplingChanged.connect(self._odmr_logic.set_oversampling, QtCore.Qt.QueuedConnection) self.sigLockInChanged.connect(self._odmr_logic.set_lock_in, QtCore.Qt.QueuedConnection) self.sigSaveMeasurement.connect(self._odmr_logic.save_odmr_data, QtCore.Qt.QueuedConnection) self.sigAverageLinesChanged.connect( self._odmr_logic.set_average_length, QtCore.Qt.QueuedConnection) # Update signals coming from logic: self._odmr_logic.sigParameterUpdated.connect( self.update_parameter, QtCore.Qt.QueuedConnection) self._odmr_logic.sigOutputStateUpdated.connect( self.update_status, QtCore.Qt.QueuedConnection) self._odmr_logic.sigOdmrPlotsUpdated.connect( self.update_plots, QtCore.Qt.QueuedConnection) self._odmr_logic.sigOdmrFitUpdated.connect(self.update_fit, QtCore.Qt.QueuedConnection) self._odmr_logic.sigOdmrElapsedTimeUpdated.connect( self.update_elapsedtime, QtCore.Qt.QueuedConnection) # connect settings signals self._mw.action_Settings.triggered.connect(self._menu_settings) self._sd.accepted.connect(self.update_settings) self._sd.rejected.connect(self.reject_settings) self._sd.buttonBox.button( QtWidgets.QDialogButtonBox.Apply).clicked.connect( self.update_settings) self.reject_settings() # Show the Main ODMR GUI: self.show()
def on_activate(self): """ """ self._voltscan_logic = self.get_connector('voltagescannerlogic1') self._savelogic = self.get_connector('savelogic') # Use the inherited class 'Ui_VoltagescannerGuiUI' to create now the # GUI element: self._mw = VoltScanMainWindow() # Add save file tag input box self._mw.save_tag_LineEdit = QtWidgets.QLineEdit(self._mw) self._mw.save_tag_LineEdit.setMaximumWidth(500) self._mw.save_tag_LineEdit.setMinimumWidth(200) self._mw.save_tag_LineEdit.setToolTip('Enter a nametag which will be\n' 'added to the filename.') self._mw.toolBar.addWidget(self._mw.save_tag_LineEdit) # Get the image from the logic self.scan_matrix_image = pg.ImageItem( self._voltscan_logic.scan_matrix, axisOrder='row-major') self.scan_matrix_image.setRect( QtCore.QRectF( self._voltscan_logic.scan_range[0], 0, self._voltscan_logic.scan_range[1] - self._voltscan_logic.scan_range[0], self._voltscan_logic.number_of_repeats) ) self.scan_matrix_image2 = pg.ImageItem( self._voltscan_logic.scan_matrix2, axisOrder='row-major') self.scan_matrix_image2.setRect( QtCore.QRectF( self._voltscan_logic.scan_range[0], 0, self._voltscan_logic.scan_range[1] - self._voltscan_logic.scan_range[0], self._voltscan_logic.number_of_repeats) ) self.scan_image = pg.PlotDataItem( self._voltscan_logic.plot_x, self._voltscan_logic.plot_y) self.scan_image2 = pg.PlotDataItem( self._voltscan_logic.plot_x, self._voltscan_logic.plot_y2) self.scan_fit_image = pg.PlotDataItem( self._voltscan_logic.fit_x, self._voltscan_logic.fit_y, pen=QtGui.QPen(QtGui.QColor(255, 255, 255, 255))) # Add the display item to the xy and xz VieWidget, which was defined in # the UI file. self._mw.voltscan_ViewWidget.addItem(self.scan_image) #self._mw.voltscan_ViewWidget.addItem(self.scan_fit_image) self._mw.voltscan_ViewWidget.showGrid(x=True, y=True, alpha=0.8) self._mw.voltscan_matrix_ViewWidget.addItem(self.scan_matrix_image) self._mw.voltscan2_ViewWidget.addItem(self.scan_image2) #self._mw.voltscan2_ViewWidget.addItem(self.scan_fit_image) self._mw.voltscan2_ViewWidget.showGrid(x=True, y=True, alpha=0.8) self._mw.voltscan_matrix2_ViewWidget.addItem(self.scan_matrix_image2) # Get the colorscales at set LUT my_colors = ColorScaleInferno() self.scan_matrix_image.setLookupTable(my_colors.lut) self.scan_matrix_image2.setLookupTable(my_colors.lut) # Configuration of the Colorbar self.scan_cb = ColorBar(my_colors.cmap_normed, 100, 0, 100000) #adding colorbar to ViewWidget self._mw.voltscan_cb_ViewWidget.addItem(self.scan_cb) self._mw.voltscan_cb_ViewWidget.hideAxis('bottom') self._mw.voltscan_cb_ViewWidget.hideAxis('left') self._mw.voltscan_cb_ViewWidget.setLabel('right', 'Fluorescence', units='c/s') # Connect the buttons and inputs for colorbar self._mw.voltscan_cb_manual_RadioButton.clicked.connect(self.refresh_matrix) self._mw.voltscan_cb_centiles_RadioButton.clicked.connect(self.refresh_matrix) # set initial values self._mw.startDoubleSpinBox.setValue(self._voltscan_logic.scan_range[0]) self._mw.speedDoubleSpinBox.setValue(self._voltscan_logic._scan_speed) self._mw.stopDoubleSpinBox.setValue(self._voltscan_logic.scan_range[1]) self._mw.constDoubleSpinBox.setValue(self._voltscan_logic._static_v) self._mw.resolutionSpinBox.setValue(self._voltscan_logic.resolution) self._mw.linesSpinBox.setValue(self._voltscan_logic.number_of_repeats) # Update the inputed/displayed numbers if the cursor has left the field: self._mw.startDoubleSpinBox.editingFinished.connect(self.change_start_volt) self._mw.speedDoubleSpinBox.editingFinished.connect(self.change_speed) self._mw.stopDoubleSpinBox.editingFinished.connect(self.change_stop_volt) self._mw.resolutionSpinBox.editingFinished.connect(self.change_resolution) self._mw.linesSpinBox.editingFinished.connect(self.change_lines) self._mw.constDoubleSpinBox.editingFinished.connect(self.change_voltage) # self._mw.voltscan_cb_max_InputWidget.valueChanged.connect(self.refresh_matrix) self._mw.voltscan_cb_min_InputWidget.valueChanged.connect(self.refresh_matrix) self._mw.voltscan_cb_high_centile_InputWidget.valueChanged.connect(self.refresh_matrix) self._mw.voltscan_cb_low_centile_InputWidget.valueChanged.connect(self.refresh_matrix) # Connect signals self._voltscan_logic.sigUpdatePlots.connect(self.refresh_matrix) self._voltscan_logic.sigUpdatePlots.connect(self.refresh_plot) self._voltscan_logic.sigUpdatePlots.connect(self.refresh_lines) self._voltscan_logic.sigScanFinished.connect(self.scan_stopped) self._voltscan_logic.sigScanStarted.connect(self.scan_started) self.sigStartScan.connect(self._voltscan_logic.start_scanning) self.sigStopScan.connect(self._voltscan_logic.stop_scanning) self.sigChangeVoltage.connect(self._voltscan_logic.set_voltage) self.sigChangeRange.connect(self._voltscan_logic.set_scan_range) self.sigChangeSpeed.connect(self._voltscan_logic.set_scan_speed) self.sigChangeLines.connect(self._voltscan_logic.set_scan_lines) self.sigChangeResolution.connect(self._voltscan_logic.set_resolution) self.sigSaveMeasurement.connect(self._voltscan_logic.save_data) self._mw.action_run_stop.triggered.connect(self.run_stop) self._mw.action_Save.triggered.connect(self.save_data) self._mw.show()
def on_activate(self, e=None): """ Definition, configuration and initialisation of the ODMR GUI. @param object e: Fysom.event object from Fysom class. An object created by the state machine module Fysom, which is connected to a specific event (have a look in the Base Class). This object contains the passed event, the state before the event happened and the destination of the state which should be reached after the event had happened. This init connects all the graphic modules, which were created in the *.ui file and configures the event handling between the modules. """ self._odmr_logic = self.get_in_connector('odmrlogic1') self._save_logic = self.get_in_connector('savelogic') # Use the inherited class 'Ui_ODMRGuiUI' to create now the # GUI element: self._mw = ODMRMainWindow() self._sd = ODMRSettingDialog() # Create a QSettings object for the mainwindow and store the actual GUI layout self.mwsettings = QtCore.QSettings("QUDI", "ODMR") self.mwsettings.setValue("geometry", self._mw.saveGeometry()) self.mwsettings.setValue("windowState", self._mw.saveState()) # Adjust range of scientific spinboxes above what is possible in Qt Designer self._mw.frequency_DoubleSpinBox.setMaximum( self._odmr_logic.limits.max_frequency) self._mw.frequency_DoubleSpinBox.setMinimum( self._odmr_logic.limits.min_frequency) self._mw.start_freq_DoubleSpinBox.setMaximum( self._odmr_logic.limits.max_frequency) self._mw.start_freq_DoubleSpinBox.setMinimum( self._odmr_logic.limits.min_frequency) self._mw.step_freq_DoubleSpinBox.setMaximum(100e9) self._mw.stop_freq_DoubleSpinBox.setMaximum( self._odmr_logic.limits.max_frequency) self._mw.stop_freq_DoubleSpinBox.setMinimum( self._odmr_logic.limits.min_frequency) self._mw.power_DoubleSpinBox.setMaximum( self._odmr_logic.limits.max_power) self._mw.power_DoubleSpinBox.setMinimum( self._odmr_logic.limits.min_power) # Add save file tag input box self._mw.save_tag_LineEdit = QtWidgets.QLineEdit(self._mw) self._mw.save_tag_LineEdit.setMaximumWidth(200) self._mw.save_tag_LineEdit.setToolTip( 'Enter a nametag which will be\nadded to the filename.') self._mw.save_ToolBar.addWidget(self._mw.save_tag_LineEdit) # add a clear button to clear the ODMR plots: self._mw.clear_odmr_PushButton = QtWidgets.QPushButton(self._mw) self._mw.clear_odmr_PushButton.setText('Clear ODMR') self._mw.clear_odmr_PushButton.setToolTip( 'Clear the plots of the\ncurrent ODMR measurements.') self._mw.clear_odmr_PushButton.setEnabled(False) self._mw.save_ToolBar.addWidget(self._mw.clear_odmr_PushButton) self.sigClearPlots.connect(self._odmr_logic.clear_odmr_plots) # Get the image from the logic self.odmr_matrix_image = pg.ImageItem( self._odmr_logic.ODMR_plot_xy.transpose()) self.odmr_matrix_image.setRect( QtCore.QRectF(self._odmr_logic.mw_start, 0, self._odmr_logic.mw_stop - self._odmr_logic.mw_start, self._odmr_logic.number_of_lines)) self.odmr_image = pg.PlotDataItem(self._odmr_logic.ODMR_plot_x, self._odmr_logic.ODMR_plot_y, pen=pg.mkPen( palette.c1, style=QtCore.Qt.DotLine), symbol='o', symbolPen=palette.c1, symbolBrush=palette.c1, symbolSize=7) self.odmr_fit_image = pg.PlotDataItem(self._odmr_logic.ODMR_fit_x, self._odmr_logic.ODMR_fit_y, pen=pg.mkPen(palette.c2)) # Add the display item to the xy and xz VieWidget, which was defined in # the UI file. self._mw.odmr_PlotWidget.addItem(self.odmr_image) self._mw.odmr_PlotWidget.setLabel(axis='left', text='Counts', units='Counts/s') self._mw.odmr_PlotWidget.setLabel(axis='bottom', text='Frequency', units='Hz') self._mw.odmr_matrix_PlotWidget.addItem(self.odmr_matrix_image) self._mw.odmr_matrix_PlotWidget.setLabel(axis='left', text='Matrix Lines', units='#') self._mw.odmr_matrix_PlotWidget.setLabel(axis='bottom', text='Frequency', units='Hz') self._mw.odmr_PlotWidget.showGrid(x=True, y=True, alpha=0.8) # Get the colorscales at set LUT my_colors = ColorScaleInferno() self.odmr_matrix_image.setLookupTable(my_colors.lut) # Configuration of the comboWidget self._mw.mode_ComboBox.addItem('Off') self._mw.mode_ComboBox.addItem('CW') fit_functions = self._odmr_logic.get_fit_functions() self._mw.fit_methods_ComboBox.clear() self._mw.fit_methods_ComboBox.addItems(fit_functions) ######################################################################## # Configuration of the Colorbar # ######################################################################## self.odmr_cb = ColorBar(my_colors.cmap_normed, 100, 0, 100000) # adding colorbar to ViewWidget self._mw.odmr_cb_PlotWidget.addItem(self.odmr_cb) self._mw.odmr_cb_PlotWidget.hideAxis('bottom') self._mw.odmr_cb_PlotWidget.hideAxis('left') self._mw.odmr_cb_PlotWidget.setLabel('right', 'Fluorescence', units='counts/s') # Connect the buttons and inputs for the odmr colorbar self._mw.odmr_cb_manual_RadioButton.clicked.connect( self.refresh_matrix) self._mw.odmr_cb_centiles_RadioButton.clicked.connect( self.refresh_matrix) ######################################################################## # Configuration of the various display Widgets # ######################################################################## # Take the default values from logic: self._mw.frequency_DoubleSpinBox.setValue( self._odmr_logic.mw_frequency) self._mw.start_freq_DoubleSpinBox.setValue(self._odmr_logic.mw_start) self._mw.step_freq_DoubleSpinBox.setValue(self._odmr_logic.mw_step) self._mw.step_freq_DoubleSpinBox.setOpts( minStep=1.0) # set the minimal step to 1Hz. self._mw.stop_freq_DoubleSpinBox.setValue(self._odmr_logic.mw_stop) self._mw.power_DoubleSpinBox.setValue(self._odmr_logic.mw_power) self._mw.power_DoubleSpinBox.setOpts(minStep=0.1) self._mw.runtime_DoubleSpinBox.setValue(self._odmr_logic.run_time) self._mw.elapsed_time_DisplayWidget.display( int(self._odmr_logic.elapsed_time)) self._sd.matrix_lines_SpinBox.setValue( self._odmr_logic.number_of_lines) self._sd.clock_frequency_DoubleSpinBox.setValue( self._odmr_logic._clock_frequency) self._sd.fit_tabs = {} for name, model in self._odmr_logic.fit_models.items(): try: self._sd.fit_tabs[name] = FitSettingsWidget(model[1]) except: self.log.warning('Could not load fitmodel {0}'.format(name)) else: self._sd.tabWidget.addTab(self._sd.fit_tabs[name], name) # Update the inputed/displayed numbers if return key is hit: # If the attribute setKeyboardTracking is set in a SpinBox or # DoubleSpinBox the valueChanged method will actually hold on the signal # until the return key is pressed which is pretty useful ;) # self._mw.frequency_DoubleSpinBox.setKeyboardTracking(False) # Update the inputed/displayed numbers if the cursor has left the field: self._mw.frequency_DoubleSpinBox.editingFinished.connect( self.change_frequency) self._mw.start_freq_DoubleSpinBox.editingFinished.connect( self.change_start_freq) self._mw.step_freq_DoubleSpinBox.editingFinished.connect( self.change_step_freq) self._mw.stop_freq_DoubleSpinBox.editingFinished.connect( self.change_stop_freq) self._mw.power_DoubleSpinBox.editingFinished.connect(self.change_power) self._mw.runtime_DoubleSpinBox.editingFinished.connect( self.change_runtime) self._mw.odmr_cb_max_DoubleSpinBox.valueChanged.connect( self.refresh_matrix) self._mw.odmr_cb_min_DoubleSpinBox.valueChanged.connect( self.refresh_matrix) self._mw.odmr_cb_high_percentile_DoubleSpinBox.valueChanged.connect( self.refresh_matrix) self._mw.odmr_cb_low_percentile_DoubleSpinBox.valueChanged.connect( self.refresh_matrix) ######################################################################## # Connect signals # ######################################################################## # Connect the RadioButtons and connect to the events if they are clicked: self._mw.action_run_stop.triggered.connect(self.run_stop) self._mw.action_resume_odmr.triggered.connect(self.resume_odmr) self._mw.action_Save.triggered.connect(self.save_data) self._mw.action_RestoreDefault.triggered.connect( self.restore_defaultview) self.sigStartODMRScan.connect(self._odmr_logic.start_odmr_scan) self.sigStopODMRScan.connect(self._odmr_logic.stop_odmr_scan) self.sigContinueODMRScan.connect(self._odmr_logic.continue_odmr_scan) self.sigMWOn.connect(self._odmr_logic.MW_on) self.sigMWOff.connect(self._odmr_logic.MW_off) self.sigMWFreqChanged.connect(self._odmr_logic.set_frequency) self.sigMWPowerChanged.connect(self._odmr_logic.set_power) # react on an axis change in the logic by adapting the display: self._odmr_logic.sigODMRMatrixAxesChanged.connect( self.update_matrix_axes) # connect the clear button: self._mw.clear_odmr_PushButton.clicked.connect( self.clear_odmr_plots_clicked) self._odmr_logic.sigOdmrPlotUpdated.connect(self.refresh_plot) self._odmr_logic.sigOdmrFitUpdated.connect(self.refresh_plot_fit) self._odmr_logic.sigOdmrMatrixUpdated.connect(self.refresh_matrix) self._odmr_logic.sigOdmrElapsedTimeChanged.connect( self.refresh_elapsedtime) # connect settings signals self._mw.action_Settings.triggered.connect(self.menu_settings) self._sd.accepted.connect(self.update_settings) self._sd.rejected.connect(self.reject_settings) self._sd.buttonBox.button( QtWidgets.QDialogButtonBox.Apply).clicked.connect( self.update_settings) self.reject_settings() # Connect stop odmr self._odmr_logic.sigOdmrStarted.connect(self.odmr_started) self._odmr_logic.sigOdmrStopped.connect(self.odmr_stopped) # Combo Widget self._mw.mode_ComboBox.activated[str].connect(self.mw_stop) self._mw.fit_methods_ComboBox.activated[str].connect( self.update_fit_variable) # Push Buttons self._mw.do_fit_PushButton.clicked.connect(self.update_fit) # let the gui react on the signals from the GUI self._odmr_logic.sigMicrowaveCWModeChanged.connect( self.update_cw_display) self._odmr_logic.sigMicrowaveListModeChanged.connect( self.update_run_stop_display) # Show the Main ODMR GUI: self._mw.show()
def initMainUI(self): """ Definition, configuration and initialisation of the confocal GUI. This init connects all the graphic modules, which were created in the *.ui file and configures the event handling between the modules. Moreover it sets default values. """ self._mainwindow = SnvmWindow() # All our gui elements are dockable, and so there should be no "central" widget. self._mainwindow.centralwidget.hide() self._mainwindow.setDockNestingEnabled(True) self.photon_colormap = ColorScaleInferno() self.afm_cmap = BlackAndWhite() self._crosshair_maxrange = None #Set up the SNVM image and colorbar self.snvm_image = ScanImageItem(axisOrder='row-major') self.snvm_image.setLookupTable(self.photon_colormap.lut) self._mainwindow.multiFreqPlotView.addItem(self.snvm_image) self._mainwindow.multiFreqPlotView.setLabel('bottom', 'X (nm)') self._mainwindow.multiFreqPlotView.setLabel('left', 'Y (nm)') self._mainwindow.multiFreqPlotView.toggle_crosshair(True, movable=True) self._mainwindow.multiFreqPlotView.set_crosshair_size((1, 1)) self._mainwindow.multiFreqPlotView.sigCrosshairDraggedPosChanged.connect( self.move_afm_crosshair) snvm_im_vb = self.get_image_viewbox(self.snvm_image) snvm_im_vb.setAspectLocked(True) snvm_im_vb.toggle_selection(True) snvm_im_vb.toggle_zoom_by_selection(True) self.multifreq_cb = ColorBar(self.photon_colormap.cmap_normed, width=100, cb_min=0, cb_max=1) self._mainwindow.multiFreqCbarView.addItem(self.multifreq_cb) self._mainwindow.multiFreqCbarView.hideAxis('bottom') self._mainwindow.multiFreqCbarView.setMouseEnabled(x=False, y=False) #Set up the AFM image and colorbar self.afm_image = ScanImageItem(axisOrder='row-major') self._mainwindow.afmPlotView.addItem(self.afm_image) self._mainwindow.afmPlotView.setLabel('bottom', 'X (nm)') self._mainwindow.afmPlotView.setLabel('left', 'Y (nm)') self._mainwindow.afmPlotView.toggle_crosshair(True, movable=True) self._mainwindow.afmPlotView.set_crosshair_size((1, 1)) self._mainwindow.afmPlotView.sigCrosshairDraggedPosChanged.connect( self.move_multifreq_crosshair) afm_im_vb = self.get_image_viewbox(self.afm_image) afm_im_vb.setAspectLocked(True) afm_im_vb.toggle_selection(True) afm_im_vb.toggle_zoom_by_selection(True) self.afm_cb = ColorBar(self.afm_cmap.cmap_normed, width=100, cb_min=0, cb_max=1) self._mainwindow.afmCbarView.addItem(self.afm_cb) # Set up the confocal image and colorbar self.cfc_image = ScanImageItem(axisOrder='row-major') self.cfc_image.setLookupTable(self.photon_colormap.lut) self._mainwindow.confocalScannerView.addItem(self.cfc_image) self._mainwindow.confocalScannerView.setLabel('bottom', 'X (nm)') self._mainwindow.confocalScannerView.setLabel('left', 'Y (nm)') self._mainwindow.confocalScannerView.toggle_crosshair(True, movable=True) self._mainwindow.confocalScannerView.set_crosshair_size((1, 1)) cfc_im_vb = self.get_image_viewbox(self.cfc_image) cfc_im_vb.setAspectLocked(True) cfc_im_vb.toggle_selection(True) cfc_im_vb.toggle_zoom_by_selection(True) self.cfc_cb = ColorBar(self.photon_colormap.cmap_normed, width=100, cb_min=0, cb_max=1) self._mainwindow.confocalCbarView.addItem(self.cfc_cb) # Set up the optimizer image and colorbar self.optimizer_image = ScanImageItem(axisOrder='row-major') self.optimizer_image.setLookupTable(self.photon_colormap.lut) self._mainwindow.optimizerView.addItem(self.optimizer_image) self._mainwindow.optimizerView.setLabel('bottom', 'X (nm)') self._mainwindow.optimizerView.setLabel('left', 'Y (nm)') opt_im_vb = self.get_image_viewbox(self.optimizer_image) opt_im_vb.setAspectLocked(True) self.opt_cb = ColorBar(self.photon_colormap.cmap_normed, width=100, cb_min=0, cb_max=1) self._mainwindow.optimizerCbarView.addItem(self.opt_cb) #Set up the ODMR plot self.curr_odmr_trace = pg.PlotDataItem(skipFiniteCheck=False, connect='finite', pen=pg.mkPen(color='w')) self.average_odmr_trace = pg.PlotDataItem(skipFiniteCheck=True, pen=pg.mkPen(color='r')) self._mainwindow.odmrPlotWidget.addItem(self.curr_odmr_trace) self._mainwindow.odmrPlotWidget.addItem(self.average_odmr_trace) self._mainwindow.odmrPlotWidget.setLabel('bottom', 'Frequency (GHz)') self._mainwindow.odmrPlotWidget.setLabel('left', 'Counts (GHz)') #Quick settings for the spinbox to view the frequency slices self._mainwindow.frequencySliceSelector.lineEdit().setReadOnly(True) self._viewIndex = 0 #Variable used to scroll through the SNVM images.Gets updated when clicking the frequency selector ######## # AFM scanning settings ######## #Put all the settings in a dictionary, for ease of access self._afm_widgets = dict() self._afm_widgets[self._mainwindow.xResolution.objectName( )] = self._mainwindow.xResolution self._afm_widgets[self._mainwindow.yResolution.objectName( )] = self._mainwindow.yResolution self._afm_widgets[self._mainwindow.xMinRange.objectName( )] = self._mainwindow.xMinRange self._afm_widgets[self._mainwindow.xMaxRange.objectName( )] = self._mainwindow.xMaxRange self._afm_widgets[self._mainwindow.yMinRange.objectName( )] = self._mainwindow.yMinRange self._afm_widgets[self._mainwindow.yMaxRange.objectName( )] = self._mainwindow.yMaxRange self._afm_widgets[ self._mainwindow.fwpxTime.objectName()] = self._mainwindow.fwpxTime self._afm_widgets[self._mainwindow.storeRetrace.objectName( )] = self._mainwindow.storeRetrace ######### self._afm_widgets['xResolution'].setValue( self._scanning_logic.scanning_x_resolution) self._afm_widgets['yResolution'].setValue( self._scanning_logic.scanning_y_resolution) self._afm_widgets['xMinRange'].setValue( self._scanning_logic.scanning_x_range[0] / self.xy_range_multiplier) self._afm_widgets['yMinRange'].setValue( self._scanning_logic.scanning_y_range[0] / self.xy_range_multiplier) self._afm_widgets['xMaxRange'].setValue( self._scanning_logic.scanning_x_range[1] / self.xy_range_multiplier) self._afm_widgets['yMaxRange'].setValue( self._scanning_logic.scanning_y_range[1] / self.xy_range_multiplier) self._afm_widgets['fwpxTime'].setValue(self._scanning_logic.px_time / self.px_time_multiplier) self._afm_widgets['storeRetrace'].setChecked( self._scanning_logic.store_retrace) ######### ####### # ODMR scanning settings ###### #Also here, store in a dictionary if the widgets need to be accessed in for loops self._odmr_widgets = dict() self._odmr_widgets[ self._mainwindow.mwStart.objectName()] = self._mainwindow.mwStart self._odmr_widgets[ self._mainwindow.mwEnd.objectName()] = self._mainwindow.mwEnd self._odmr_widgets[ self._mainwindow.mwStep.objectName()] = self._mainwindow.mwStep self._odmr_widgets[ self._mainwindow.mwPower.objectName()] = self._mainwindow.mwPower self._odmr_widgets[self._mainwindow.mwAverages.objectName( )] = self._mainwindow.mwAverages #TODO: maybe turn the freq resolution of the GUI into a settable value self._mainwindow.mwStart.setDecimals(6) self._mainwindow.mwEnd.setDecimals(6) self._mainwindow.mwStep.setDecimals(6) ######### self._odmr_widgets['mwStart'].setValue( self._scanning_logic.start_freq / self.startstopFreq_multiplier) self._odmr_widgets['mwEnd'].setValue(self._scanning_logic.stop_freq / self.startstopFreq_multiplier) self._odmr_widgets['mwStep'].setValue( self._scanning_logic.freq_resolution / self.stepFreq_multiplier) self._odmr_widgets['mwPower'].setValue(self._scanning_logic.mw_power) self._odmr_widgets['mwAverages'].setValue( self._scanning_logic.odmr_averages) ######### #Connect the signals self.sigStartOptimizer.connect(self.optimize_counts, QtCore.Qt.QueuedConnection) self.sigStartScanning.connect(self.start_scanning, QtCore.Qt.QueuedConnection) self.sigGoTo.connect(self.go_to_point, QtCore.Qt.QueuedConnection) self._odmr_widgets['mwStart'].valueChanged.connect( self.accept_frequency_ranges) self._odmr_widgets['mwEnd'].valueChanged.connect( self.accept_frequency_ranges) self._odmr_widgets['mwStep'].valueChanged.connect( self.accept_frequency_ranges) self._scanning_logic.signal_scan_finished.connect( self.snvm_confocal_finished) self._scanning_logic.signal_freq_px_acquired.connect( self.refresh_odmr_plot) self._scanning_logic.signal_snvm_image_updated.connect( self.refresh_snvm_image) self._scanning_logic.signal_snvm_image_updated.connect( self.refresh_afm_image) self._scanning_logic.signal_xy_image_updated.connect( self.refresh_confocal_image) self._scanning_logic.signal_snvm_initialized.connect( self.set_snvm_im_range) self._scanning_logic.signal_confocal_initialized.connect( self.set_confocal_im_range) self._scanning_logic.signal_moved_to_point.connect(self.go_to_finished) self._optimizer_logic.sigImageUpdated.connect( self.refresh_optimizer_image) self._optimizer_logic.sigRefocusStarted.connect( self.set_optimizer_im_range) self._optimizer_logic.sigRefocusFinished.connect( self._optimization_complete) self._mainwindow.frequencySliceSelector.stepClicked.connect( self.frequency_selector_clicked) self._mainwindow.sampleTraceViewSpinBox.valueChanged.connect( self.refresh_snvm_image) self._mainwindow.sampleTraceViewSpinBox.valueChanged.connect( self.refresh_afm_image) self._mainwindow.tipTraceViewSpinBox.valueChanged.connect( self.refresh_confocal_image) ############## # Connect the actions to their slots ############## self._mainwindow.actionStart_snvmscan.triggered.connect( self.scanning_action_clicked) self._mainwindow.actionStart_conf_scan.triggered.connect( self.scanning_action_clicked) self._mainwindow.actionStop_scan.triggered.connect( self.stop_scanning_request) self._mainwindow.actionOptimize.triggered.connect( self.scanning_action_clicked) self._mainwindow.actionOptimizer_settings.triggered.connect( self.menu_optimizer_settings) self._mainwindow.actionSnvm_settings.triggered.connect( self.menu_snvm_settings) self._mainwindow.action_snvm_goToPoint.triggered.connect( self.scanning_action_clicked) self._mainwindow.action_cfc_goToPoint.triggered.connect( self.scanning_action_clicked) self._mainwindow.actionSave_snvm.triggered.connect(self.save_snvm_data) self._mainwindow.actionSave_confocal.triggered.connect( self.save_confocal_data) self._mainwindow.actionStop_scan.setEnabled(False) self.show()
def _activate_image_tab(self): """ Initialization method for the image tab """ camera_width = self.spectrumlogic().camera_constraints.width camera_height = self.spectrumlogic().camera_constraints.height for read_mode in self.spectrumlogic().camera_constraints.read_modes: if read_mode.name[:5] == "IMAGE": self._image_tab.read_modes.addItem(read_mode.name, read_mode.name) if read_mode == self._image_read_mode: self._image_tab.read_modes.setCurrentText(read_mode.name) for acquisition_mode in AcquisitionMode.__members__: if acquisition_mode != "MULTI_SCAN": self._image_tab.acquisition_modes.addItem( acquisition_mode, acquisition_mode) if acquisition_mode == self._image_acquisition_mode: self._image_tab.acquisition_modes.setCurrentText( acquisition_mode) self.image_exposure_time_widget = ScienDSpinBox() self.image_exposure_time_widget.setMinimum(0) self.image_exposure_time_widget.setValue(self._image_exposure_time) self.image_exposure_time_widget.setSuffix('s') self._image_tab.exposure_time_layout.addWidget( self.image_exposure_time_widget) for readout_speed in self.spectrumlogic( ).camera_constraints.readout_speeds: self._image_tab.readout_speed.addItem( "{:.2r}Hz".format(ScaledFloat(readout_speed)), readout_speed) if readout_speed == self._image_readout_speed: self._image_tab.readout_speed.setCurrentText("{:.2r}Hz".format( ScaledFloat(readout_speed))) self._image_tab.save.clicked.connect(partial(self.save_data, 0)) self._save_data_buttons.append(self._image_tab.save) self._image_tab.acquire_dark.clicked.connect( partial(self.start_dark_acquisition, 0)) self._acquire_dark_buttons.append(self._image_tab.acquire_dark) self._image_tab.start_acquisition.clicked.connect( partial(self.start_acquisition, 0)) self._start_acquisition_buttons.append( self._image_tab.start_acquisition) self._image_tab.stop_acquisition.clicked.connect(self.stop_acquisition) self._stop_acquisition_buttons.append(self._image_tab.stop_acquisition) self._image_tab.remove_dark.clicked.connect( partial(self.remove_dark, 0)) self.my_colors = ColorScaleInferno() self._image = pg.ImageItem(image=self._image_data, axisOrder='row-major') self._image.setLookupTable(self.my_colors.lut) self._image_tab.graph.addItem(self._image) self._colorbar = ColorbarWidget(self._image) self._image_tab.colorbar.addWidget(self._colorbar) self.track_colors = np.array( [palette.c5, palette.c2, palette.c6, palette.c4]) self.plot_colors = self.track_colors height = self.spectrumlogic().camera_constraints.height for i in range(4): self._track_buttons[i].setCheckable(True) self._track_buttons[i].clicked.connect( partial(self._manage_track_buttons, i)) tracks = self.spectrumlogic().active_tracks if 2 * i < len(tracks): top_pos = tracks[2 * i] bottom_pos = tracks[2 * i + 1] else: top_pos = 0 bottom_pos = 10 color = self.track_colors[i].getRgb() track_color = pg.mkBrush(color[0], color[1], color[2], 100) track = pg.LinearRegionItem( values=[top_pos, bottom_pos], orientation=pg.LinearRegionItem.Horizontal, brush=track_color) track.setBounds([0, height]) track.hide() self._track_selector.append(track) self._image_tab.graph.addItem(track) self._image_tab.image_advanced.setCheckable(True) self._image_tab.image_advanced.clicked.connect( self._manage_image_advanced_button) self._image_advanced_widget = pg.ROI( [0, 0], [camera_width, camera_height], maxBounds=QRectF(QPoint(0, 0), QPoint(camera_width, camera_height))) self._image_advanced_widget.addScaleHandle((1, 0), (0, 1)) self._image_advanced_widget.addScaleHandle((0, 1), (1, 0)) self._image_advanced_widget.hide() self._image_tab.graph.addItem(self._image_advanced_widget) self._image_tab.horizontal_binning.setRange(1, camera_width - 1) self._image_tab.vertical_binning.setRange(1, camera_height - 1) self._image_tab.horizontal_binning.editingFinished.connect( self.set_image_params) self._image_tab.vertical_binning.editingFinished.connect( self.set_image_params) self._image_tab.read_modes.currentTextChanged.connect( self.set_image_params) self._image_tab.acquisition_modes.currentTextChanged.connect( self.set_image_params) self.image_exposure_time_widget.editingFinished.connect( self.set_image_params) self._image_tab.readout_speed.currentTextChanged.connect( self.set_image_params)
def on_activate(self, e=None): """ Definition, configuration and initialisation of the ODMR GUI. @param class e: event class from Fysom This init connects all the graphic modules, which were created in the *.ui file and configures the event handling between the modules. """ self._voltscan_logic = self.get_in_connector('odmrlogic1') print("ODMR logic is", self._odmr_logic) # Use the inherited class 'Ui_VoltagescannerGuiUI' to create now the # GUI element: self._mw = VoltScanMainWindow() # Get the image from the logic self.odmr_matrix_image = pg.ImageItem(self._odmr_logic.ODMR_plot_xy.transpose()) self.odmr_matrix_image.setRect(QtCore.QRectF(self._odmr_logic.mw_start,0,self._odmr_logic.mw_stop-self._odmr_logic.mw_start,self._odmr_logic.number_of_lines)) self.odmr_image = pg.PlotDataItem(self._odmr_logic.ODMR_plot_x,self._odmr_logic.ODMR_plot_y) self.odmr_fit_image = pg.PlotDataItem(self._odmr_logic.ODMR_fit_x,self._odmr_logic.ODMR_fit_y, pen=QtGui.QPen(QtGui.QColor(255,255,255,255))) # Add the display item to the xy and xz VieWidget, which was defined in # the UI file. self._mw.voltscan_ViewWidget.addItem(self.odmr_image) self._mw.voltscan_ViewWidget.addItem(self.odmr_fit_image) self._mw.voltscan_matrix_ViewWidget.addItem(self.odmr_matrix_image) self._mw.vonsoltscan_ViewWidget.showGrid(x=True, y=True, alpha=0.8) # Get the colorscales at set LUT my_colors = ColorScaleInferno() self.odmr_matrix_image.setLookupTable(my_colors.lut) # Set the state button as ready button as default setting. # self._mw.idle_StateWidget.click() # Configuration of the comboWidget self._mw.mode_ComboWidget.addItem('Off') self._mw.mode_ComboWidget.addItem('CW') self._mw.fit_methods_ComboWidget.addItem('No Fit') self._mw.fit_methods_ComboWidget.addItem('Lorentzian') self._mw.fit_methods_ComboWidget.addItem('Double Lorentzian') self._mw.fit_methods_ComboWidget.addItem('Double Lorentzian with fixed splitting') self._mw.fit_methods_ComboWidget.addItem('N14') self._mw.fit_methods_ComboWidget.addItem('N15') ####################################################################### ## Configuration of the Colorbar ## ####################################################################### self.odmr_cb = ColorBar(my_colors.cmap_normed, 100, 0, 100000) #adding colorbar to ViewWidget self._mw.odmr_cb_ViewWidget.addItem(self.odmr_cb) self._mw.odmr_cb_ViewWidget.hideAxis('bottom') self._mw.odmr_cb_ViewWidget.hideAxis('left') self._mw.odmr_cb_ViewWidget.setLabel('right', 'Fluorescence', units='c/s') # Connect the buttons and inputs for the odmr colorbar self._mw.odmr_cb_manual_RadioButton.clicked.connect(self.refresh_matrix) self._mw.odmr_cb_centiles_RadioButton.clicked.connect(self.refresh_matrix) ####################################################################### ## Configuration of the InputWidgets ## ####################################################################### # Add Validators to InputWidgets validator = QtGui.QDoubleValidator() validator2 = QtGui.QIntValidator() self._mw.frequency_InputWidget.setValidator(validator) self._mw.start_freq_InputWidget.setValidator(validator) self._mw.step_freq_InputWidget.setValidator(validator) self._mw.stop_freq_InputWidget.setValidator(validator) self._mw.power_InputWidget.setValidator(validator) self._mw.runtime_InputWidget.setValidator(validator2) self._sd.matrix_lines_InputWidget.setValidator(validator) self._sd.clock_frequency_InputWidget.setValidator(validator2) # Take the default values from logic: self._mw.frequency_InputWidget.setText(str(self._odmr_logic.mw_frequency)) self._mw.start_freq_InputWidget.setText(str(self._odmr_logic.mw_start)) self._mw.step_freq_InputWidget.setText(str(self._odmr_logic.mw_step)) self._mw.stop_freq_InputWidget.setText(str(self._odmr_logic.mw_stop)) self._mw.power_InputWidget.setText(str(self._odmr_logic.mw_power)) self._mw.runtime_InputWidget.setText(str(self._odmr_logic.run_time)) self._mw.elapsed_time_DisplayWidget.display(int(self._odmr_logic.ElapsedTime)) self._sd.matrix_lines_InputWidget.setText(str(self._odmr_logic.number_of_lines)) self._sd.clock_frequency_InputWidget.setText(str(self._odmr_logic._clock_frequency)) # Update the inputed/displayed numbers if return key is hit: self._mw.frequency_InputWidget.returnPressed.connect(self.change_frequency) self._mw.start_freq_InputWidget.returnPressed.connect(self.change_start_freq) self._mw.step_freq_InputWidget.returnPressed.connect(self.change_step_freq) self._mw.stop_freq_InputWidget.returnPressed.connect(self.change_stop_freq) self._mw.power_InputWidget.returnPressed.connect(self.change_power) self._mw.runtime_InputWidget.returnPressed.connect(self.change_runtime) # Update the inputed/displayed numbers if the cursor has left the field: self._mw.frequency_InputWidget.editingFinished.connect(self.change_frequency) self._mw.start_freq_InputWidget.editingFinished.connect(self.change_start_freq) self._mw.step_freq_InputWidget.editingFinished.connect(self.change_step_freq) self._mw.stop_freq_InputWidget.editingFinished.connect(self.change_stop_freq) self._mw.power_InputWidget.editingFinished.connect(self.change_power) self._mw.runtime_InputWidget.editingFinished.connect(self.change_runtime) # self._mw.odmr_cb_max_InputWidget.valueChanged.connect(self.refresh_matrix) self._mw.odmr_cb_min_InputWidget.valueChanged.connect(self.refresh_matrix) self._mw.odmr_cb_high_centile_InputWidget.valueChanged.connect(self.refresh_matrix) self._mw.odmr_cb_low_centile_InputWidget.valueChanged.connect(self.refresh_matrix) ####################################################################### ## Connect signals ## ####################################################################### # Connect the RadioButtons and connect to the events if they are clicked: # self._mw.idle_StateWidget.toggled.connect(self.idle_clicked) # self._mw.run_StateWidget.toggled.connect(self.run_clicked) self._mw.action_run_stop.toggled.connect(self.run_stop) self._mw.action_Save.triggered.connect(self._odmr_logic.save_ODMR_Data) self._odmr_logic.sigOdmrPlotUpdated.connect(self.refresh_plot) self._odmr_logic.sigOdmrPlotUpdated.connect(self.refresh_matrix) self._odmr_logic.sigOdmrElapsedTimeChanged.connect(self.refresh_elapsedtime) # connect settings signals self._mw.action_Settings.triggered.connect(self.menue_settings) self._sd.accepted.connect(self.update_settings) self._sd.rejected.connect(self.reject_settings) self._sd.buttonBox.button(QtWidgets.QDialogButtonBox.Apply).clicked.connect(self.update_settings) self.reject_settings() # Connect stop odmr # self._odmr_logic.sigOdmrFinished.connect(self._mw.idle_StateWidget.click) self._odmr_logic.sigOdmrFinished.connect(self.odmr_stopped) # Combo Widget self._mw.mode_ComboWidget.activated[str].connect(self.mw_stop) self._mw.fit_methods_ComboWidget.activated[str].connect(self.update_fit_variable) # Push Buttons self._mw.do_fit_PushButton.clicked.connect(self.update_fit) # Show the Main ODMR GUI: self._mw.show()