예제 #1
0
    def __init__(self, fg, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        self.gui = Ui_MainWindow()
        self.gui.setupUi(self)

        self.fg = fg
        self.first_run = 0

        # Set up plot
        self.gui.plot.setTitle("Spectrum Estimate")
        self.gui.plot.setAxisTitle(Qwt.QwtPlot.xBottom, "Frequency (MHz)")
        self.gui.plot.setAxisTitle(Qwt.QwtPlot.yLeft, "Spectral Power Density (dB)")
        # Grid
        grid = Qwt.QwtPlotGrid()
        pen = Qt.QPen(Qt.Qt.DotLine)
        pen.setColor(Qt.Qt.black)
        pen.setWidth(0)
        grid.setPen(pen)
        grid.attach(self.gui.plot)
        #Curve
        pen_curve = Qt.QPen(Qt.Qt.SolidLine)
        pen_curve.setColor(Qt.Qt.blue)
        pen_curve.setWidth(1)
        self.curve = Qwt.QwtPlotCurve("Power Density")
        self.curve.attach(self.gui.plot)
        self.curve.setPen(pen_curve)

        # Set data in UI
        # General Settings
        self.set_input_selector(self.fg.input_selector())
        self.set_input_tab(self.fg.input_selector())
        self.set_method_selector(self.fg.method_selector())
        self.set_method_tab(self.fg.method_selector())
        self.set_center_f(self.fg.center_frequency())
        self.set_scale(self.fg.get_scale())
        # File Input Settings
        self.set_file_rec_samp_rate(self.fg.file_rec_samp_rate())
        self.set_file_file_to_open(self.fg.file_file_to_open())
        self.set_file_samp_type(self.fg.file_samp_type())
        # UHD Input Settings
        self.set_uhd_samp_type(self.fg.uhd_samp_type())
        self.set_uhd_board_num(self.fg.uhd_board_num())
        self.set_uhd_samp_rate(self.fg.uhd_samp_rate())
        self.set_uhd_gain(self.fg.uhd_gain())
        self.set_uhd_ant(self.fg.uhd_ant())
        self.set_uhd_subdev_spec(self.fg.uhd_subdev_spec())

        # Connect control signals
        self.connect(self.gui.pause_button, QtCore.SIGNAL("clicked()"),
                                 self.pause_flow_graph)
        self.connect(self.gui.run_button, QtCore.SIGNAL("clicked()"),
                                 self.run_flow_graph)
        self.connect(self.gui.close_button, QtCore.SIGNAL("clicked()"),
                                 self.stop_flow_graph)
        # Connect general signals
        self.connect(self.gui.input_selector, QtCore.SIGNAL("currentIndexChanged(int)"),
                                 self.input_selector_text)
        self.connect(self.gui.tabWidget_2, QtCore.SIGNAL("currentChanged(int)"),
                                 self.input_tab_text)
        self.connect(self.gui.method_selector, QtCore.SIGNAL("currentIndexChanged(int)"),
                                 self.method_selector_text)
        self.connect(self.gui.tabWidget, QtCore.SIGNAL("currentChanged(int)"),
                                 self.method_tab_text)
        self.connect(self.gui.center_f, QtCore.SIGNAL("valueChanged(double)"),
                                 self.center_f_text)
        self.connect(self.gui.scale, QtCore.SIGNAL("currentIndexChanged(int)"),
                                 self.scale_text)
        # File Input Signals
        self.connect(self.gui.file_rec_samp_rate, QtCore.SIGNAL("editingFinished()"),
                     self.file_rec_samp_rate_text)
        self.connect(self.gui.file_file_to_open, QtCore.SIGNAL("editingFinished()"),
                     self.file_file_to_open_text)
        self.connect(self.gui.file_samp_type, QtCore.SIGNAL("currentIndexChanged(int)"),
                     self.file_samp_type_text)
        # UHD Input Signals
        self.connect(self.gui.uhd_samp_type, QtCore.SIGNAL("currentIndexChanged(int)"),
                     self.uhd_samp_type_text)
        self.connect(self.gui.uhd_gain, QtCore.SIGNAL("editingFinished()"),
                     self.uhd_gain_text)
        self.connect(self.gui.uhd_samp_rate, QtCore.SIGNAL("editingFinished()"),
                     self.uhd_samp_rate_text)
        self.connect(self.gui.uhd_board_num, QtCore.SIGNAL("editingFinished()"),
                     self.uhd_board_num_text)
        self.connect(self.gui.uhd_ant, QtCore.SIGNAL("editingFinished()"),
                     self.uhd_ant_text)
        self.connect(self.gui.uhd_subdev_spec, QtCore.SIGNAL("editingFinished()"),
                     self.uhd_subdev_spec_text)
        for estimator_name in estimators:
            estimators[estimator_name].connect_gui(self)
        self.__initTracking()
        self.__initZooming()