Exemplo n.º 1
0
    def DoCreateWidgets(self):
        global data_model
        self._main_wid = QtGui.QWidget()
        data_model = self.wsa.capture_history
        self._plt = PersistencePlotWidget(self, data_model=data_model)
        self._plt.setXRange(self.wsa._start_MHz, self.wsa._stop_MHz, padding=0)

        self._plt.showGrid(True, True)

        if self._using_mock_wsa:
            self._plt.setYRange(-50, 0)
        else:
            self._plt.setYRange(-120, -40)

        self._gradient_editor = self._plt.gradient_editor
Exemplo n.º 2
0
    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)