def DoCreateWidgets(self): self._main_wid = QtGui.QWidget() self._waterfall = ThreadedWaterfallPlotWidget( self.wsa.capture_history, scale_limits=(-140, -50), max_frame_rate_fps=40, parent=self._main_wid, ) self._live_plot = pg.PlotWidget(self._main_wid) self._live_plot.setLabel('bottom', text='Frequency', units='Hz') self._live_plot.setYRange(-160, 20) self._live_plot.setLabel('left', text='Power', units='dBm') self._live_curve = self._live_plot.plot(pen='b') self._vslice_plot = pg.PlotWidget(self._main_wid) self._vslice_plot.setLabel('bottom', text='Time', units='s') self._vslice_plot.setLabel('left', text='Power', units='dBm') self._vslice_curve = self._vslice_plot.plot(pen='r') self._hslice_plot = pg.PlotWidget(self._main_wid) self._hslice_plot.setLabel('bottom', text='Frequency', units='Hz') self._hslice_plot.setLabel('left', text='Power', units='dBm') self._hslice_curve = self._hslice_plot.plot(pen='r') self._start_but = QtGui.QPushButton("Pause capture")
def __init__(self, controller, layout): super(Plot, self).__init__() self.controller = controller controller.device_change.connect(self.device_changed) controller.state_change.connect(self.state_changed) controller.plot_change.connect(self.plot_changed) self.plot_state = {} # initialize main fft window self.spectral_window = SpectralWidget(controller) self.window = self.spectral_window.window self.window.setMenuEnabled(False) def widget_range_changed(widget, ranges): if hasattr(self, 'gui_state') and hasattr(self, 'plot_state'): # HDR mode has a tuning resolution almost the same as its usable bandwidth, making the tuning mouse tuning annoying to use if self.gui_state.mode == 'HDR' or not self.plot_state[ 'mouse_tune']: return if not hasattr(ranges, '__getitem__'): return # we're not intereted in QRectF updates self.user_xrange_change.emit(ranges[0][0], ranges[0][1]) self.window.sigRangeChanged.connect(widget_range_changed) self.view_box = self.window.plotItem.getViewBox() # initialize the y-axis of the plot self.window.setYRange(PLOT_BOTTOM, PLOT_TOP) labelStyle = fonts.AXIS_LABEL_FONT self.window.setLabel('left', 'Power', 'dBm', **labelStyle) self.window.setLabel('top') self.window.setLabel('bottom', 'Frequency', 'Hz', **labelStyle) # horizontal cursor line cursor_pen = pg.mkPen(color=colors.YELLOW_NUM, width=2) self.cursor_line = pg.InfiniteLine(pos=-100, angle=0, movable=True, pen=cursor_pen) self.channel_power_region = pg.LinearRegionItem() self._trig_enable = False self.grid(True) # IQ constellation window self.const_window = pg.PlotWidget(name='const_plot') self.const_plot = pg.ScatterPlotItem(pen='y') self.const_window.setMenuEnabled(False) self.const_window.addItem(self.const_plot) self.const_window.setYRange(IQ_PLOT_YMIN, IQ_PLOT_YMAX) self.const_window.setXRange(IQ_PLOT_YMIN, IQ_PLOT_YMAX) # IQ time domain window self.iq_window = pg.PlotWidget(name='const_plot') self.iq_window.setYRange(IQ_PLOT_YMIN, IQ_PLOT_YMAX) self.iq_window.setMenuEnabled(False) self.update_iq_range = True self.i_curve = self.iq_window.plot(pen='g') self.q_curve = self.iq_window.plot(pen='r') # add traces self.traces = [] first_trace = labels.TRACES[0] for trace_name, trace_color in zip(labels.TRACES, colors.TRACE_COLORS): trace = Trace(self, trace_name, trace_color, blank=True, write=False) self.traces.append(trace) self.traces[0].blank = False self.traces[0].write = True self.markers = [] for name in labels.MARKERS: self.markers.append( Marker(self, name, colors.WHITE_NUM, self.controller)) self.waterfall_data = WaterfallModel(max_len=600) self.waterfall_window = ThreadedWaterfallPlotWidget( self.waterfall_data, scale_limits=(PLOT_YMIN, PLOT_YMAX), max_frame_rate_fps=30, mouse_move_crosshair=False, ) self.persistence_window = PersistencePlotWidget( decay_fn=decay_fn_EXPONENTIAL, data_model=self.waterfall_data) self.persistence_window.getAxis('bottom').setScale(1e-9) self.persistence_window.showGrid(True, True) self.trigger_control = triggerControl() self.connect_plot_controls() self.update_waterfall_levels(PLOT_BOTTOM, PLOT_TOP)