diff options
Diffstat (limited to 'gr-qtgui')
40 files changed, 756 insertions, 454 deletions
diff --git a/gr-qtgui/CMakeLists.txt b/gr-qtgui/CMakeLists.txt new file mode 100644 index 000000000..9caea38c7 --- /dev/null +++ b/gr-qtgui/CMakeLists.txt @@ -0,0 +1,119 @@ +# Copyright 2010-2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Setup dependencies +######################################################################## +include(GrBoost) + +find_package(Qt4 4.2.0 COMPONENTS QtCore QtGui) +include(${QT_USE_FILE}) #sets up the environment + +find_package(Qwt) + +find_package(PythonLibs) + +include(GrPython) +GR_PYTHON_CHECK_MODULE("PyQt4" PyQt4 True PYQT4_FOUND) + +######################################################################## +# Register component +######################################################################## +include(GrComponent) +GR_REGISTER_COMPONENT("gr-qtgui" ENABLE_GR_QTGUI + Boost_FOUND + QT4_FOUND + QWT_FOUND + ENABLE_GR_CORE + PYTHONLIBS_FOUND + PYQT4_FOUND +) + +GR_SET_GLOBAL(GR_QTGUI_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/lib + ${CMAKE_CURRENT_BINARY_DIR}/lib +) + +######################################################################## +# Begin conditional configuration +######################################################################## +if(ENABLE_GR_QTGUI) + +######################################################################## +# Setup CPack components +######################################################################## +include(GrPackage) +CPACK_SET(CPACK_COMPONENT_GROUP_QTGUI_DESCRIPTION "GNU Radio QtGUI Blocks") + +CPACK_COMPONENT("qtgui_runtime" + GROUP "QtGUI" + DISPLAY_NAME "Runtime" + DESCRIPTION "Runtime" + DEPENDS "core_runtime" +) + +CPACK_COMPONENT("qtgui_devel" + GROUP "QtGUI" + DISPLAY_NAME "Development" + DESCRIPTION "C++ headers, package config, import libraries" + DEPENDS "core_devel" +) + +CPACK_COMPONENT("qtgui_python" + GROUP "QtGUI" + DISPLAY_NAME "Python" + DESCRIPTION "Python modules for runtime; GRC xml files" + DEPENDS "core_python;qtgui_runtime" +) + +CPACK_COMPONENT("qtgui_swig" + GROUP "QtGUI" + DISPLAY_NAME "SWIG" + DESCRIPTION "SWIG development .i files" + DEPENDS "core_swig;qtgui_python;qtgui_devel" +) + +######################################################################## +# Add subdirectories +######################################################################## +add_subdirectory(include) +add_subdirectory(lib) +add_subdirectory(doc) +if(ENABLE_PYTHON) + add_subdirectory(grc) + add_subdirectory(swig) + add_subdirectory(python) +endif(ENABLE_PYTHON) + +######################################################################## +# Create Pkg Config File +######################################################################## +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-qtgui.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-qtgui.pc +@ONLY) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-qtgui.pc + DESTINATION ${GR_LIBRARY_DIR}/pkgconfig + COMPONENT "qtgui_devel" +) + +endif(ENABLE_GR_QTGUI) diff --git a/gr-qtgui/Makefile.am b/gr-qtgui/Makefile.am index cc194e4c0..e850567cc 100644 --- a/gr-qtgui/Makefile.am +++ b/gr-qtgui/Makefile.am @@ -21,10 +21,10 @@ include $(top_srcdir)/Makefile.common -SUBDIRS = lib +SUBDIRS = include lib doc if PYTHON -SUBDIRS += swig python apps grc +SUBDIRS += swig python apps grc examples endif pkgconfigdir = $(libdir)/pkgconfig diff --git a/gr-qtgui/apps/Makefile.am b/gr-qtgui/apps/Makefile.am index 7b35d949e..4d0c550a1 100644 --- a/gr-qtgui/apps/Makefile.am +++ b/gr-qtgui/apps/Makefile.am @@ -28,13 +28,9 @@ nodist_bin_SCRIPTS = \ usrp_display_qtgui.ui noinst_PYTHON = \ - pyqt_example_f.py \ - pyqt_example_c.py \ - pyqt_time_c.py \ qt_digital.py \ qt_digital_window.py \ - usrp2_display.py \ - usrp_display.py \ + uhd_display.py \ qt_digital_window.py \ usrp_display_qtgui.py diff --git a/gr-qtgui/apps/usrp2_display.py b/gr-qtgui/apps/uhd_display.py index 497bcc00e..806914797 100755 --- a/gr-qtgui/apps/usrp2_display.py +++ b/gr-qtgui/apps/uhd_display.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2009,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr -from gnuradio import usrp2 +from gnuradio import uhd from gnuradio import eng_notation from gnuradio.eng_option import eng_option from gnuradio.qtgui import qtgui @@ -163,53 +163,40 @@ class main_window(QtGui.QMainWindow): class my_top_block(gr.top_block): - def __init__(self): + def __init__(self, options): gr.top_block.__init__(self) - parser = OptionParser(option_class=eng_option) - parser.add_option("-e", "--interface", type="string", default="eth0", - help="select Ethernet interface, default is eth0") - parser.add_option("-m", "--mac-addr", type="string", default="", - help="select USRP by MAC address, default is auto-select") - parser.add_option("-W", "--bw", type="eng_float", default=1e6, - help="set bandwidth of receiver [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=2412e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("--fft-size", type="int", default=2048, - help="Set number of FFT bins [default=%default]") - (options, args) = parser.parse_args() - - if len(args) != 0: - parser.print_help() - sys.exit(1) - self.options = options + self.options = options self.show_debug_info = True self.qapp = QtGui.QApplication(sys.argv) - self.u = usrp2.source_32fc(options.interface, options.mac_addr) - self._adc_rate = self.u.adc_rate() - self.set_bandwidth(options.bw) + self.u = uhd.usrp_source(device_addr=options.address, + io_type=uhd.io_type.COMPLEX_FLOAT32, + num_channels=1) + self.set_bandwidth(options.samp_rate) if options.gain is None: # if no gain was specified, use the mid-point in dB - g = self.u.gain_range() - options.gain = float(g[0]+g[1])/2 + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2 self.set_gain(options.gain) if options.freq is None: - # if no frequency was specified, use the mid-point of the subdev - f = self.u.freq_range() - options.freq = float(f[0]+f[1])/2 + # if no freq was specified, use the mid-point + r = self.u.get_freq_range() + options.freq = float(r.start()+r.stop())/2 self.set_frequency(options.freq) + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + self._fftsize = options.fft_size - self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, + self.snk = qtgui.sink_c(options.fft_size, + gr.firdes.WIN_BLACKMAN_hARRIS, self._freq, self._bandwidth, - "USRP2 Display", + "UHD Display", True, True, True, False) # Set up internal amplifier @@ -225,9 +212,9 @@ class my_top_block(gr.top_block): self.connect(self.u, self.amp, self.snk) if self.show_debug_info: - print "Decimation rate: ", self._decim - print "Bandwidth: ", self._bandwidth - print "D'board: ", self.u.daughterboard_id() + print "Bandwidth: ", self.u.get_samp_rate() + print "Center Freq: ", self.u.get_center_freq() + print "Freq Range: ", self.u.get_freq_range() # Get the reference pointer to the SpectrumDisplayForm QWidget # Wrap the pointer as a PyQt SIP object @@ -268,8 +255,7 @@ class my_top_block(gr.top_block): def set_bandwidth(self, bw): self._bandwidth = bw - self._decim = int(self._adc_rate / self._bandwidth) - self.u.set_decim(self._decim) + self.u.set_samp_rate(self._bandwidth) try: self.snk.set_frequency_range(self._freq, self._bandwidth) @@ -301,7 +287,26 @@ class my_top_block(gr.top_block): self.unlock() def main (): - tb = my_top_block() + parser = OptionParser(option_class=eng_option) + parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", + help="Address of UHD device, [default=%default]") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, + help="set sample rate (bandwidth) [default=%default]") + parser.add_option("-f", "--freq", type="eng_float", default=2412e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("--fft-size", type="int", default=2048, + help="Set number of FFT bins [default=%default]") + (options, args) = parser.parse_args() + + if len(args) != 0: + parser.print_help() + sys.exit(1) + + tb = my_top_block(options) tb.start() tb.snk.exec_(); diff --git a/gr-qtgui/apps/usrp_display.py b/gr-qtgui/apps/usrp_display.py deleted file mode 100755 index 888bb6338..000000000 --- a/gr-qtgui/apps/usrp_display.py +++ /dev/null @@ -1,299 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr -from gnuradio import usrp -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.qtgui import qtgui -from optparse import OptionParser -import sys - -try: - from gnuradio.qtgui import qtgui - from PyQt4 import QtGui, QtCore - import sip -except ImportError: - print "Error: Program requires PyQt4 and gr-qtgui." - sys.exit(1) - -try: - from usrp_display_qtgui import Ui_MainWindow -except ImportError: - print "Error: could not find usrp_display_qtgui.py:" - print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\"" - sys.exit(1) - - - -# //////////////////////////////////////////////////////////////////// -# Define the QT Interface and Control Dialog -# //////////////////////////////////////////////////////////////////// - - -class main_window(QtGui.QMainWindow): - def __init__(self, snk, fg, parent=None): - - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_MainWindow() - self.gui.setupUi(self) - - self.fg = fg - - # Add the qtsnk widgets to the layout box - self.gui.sinkLayout.addWidget(snk) - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), - self.frequencyEditText) - self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), - self.gainEditText) - self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), - self.bandwidthEditText) - self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), - self.amplifierEditText) - - self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), - self.saveData) - self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.gui.pauseButton.setText("Pause") - - - # Functions to set the values in the GUI - def set_frequency(self, freq): - self.freq = freq - sfreq = eng_notation.num_to_str(self.freq) - self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) - - def set_gain(self, gain): - self.gain = gain - self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) - - def set_bandwidth(self, bw): - self.bw = bw - sbw = eng_notation.num_to_str(self.bw) - self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) - - def set_amplifier(self, amp): - self.amp = amp - self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) - - - # Functions called when signals are triggered in the GUI - def frequencyEditText(self): - try: - freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) - self.fg.set_frequency(freq) - self.freq = freq - except RuntimeError: - pass - - def gainEditText(self): - try: - gain = float(self.gui.gainEdit.text()) - self.fg.set_gain(gain) - self.gain = gain - except ValueError: - pass - - def bandwidthEditText(self): - try: - bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) - self.fg.set_bandwidth(bw) - self.bw = bw - except ValueError: - pass - - def amplifierEditText(self): - try: - amp = float(self.gui.amplifierEdit.text()) - self.fg.set_amplifier_gain(amp) - self.amp = amp - except ValueError: - pass - - def saveData(self): - fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); - if(len(fileName)): - self.fg.save_to_file(str(fileName)) - - -def pick_subdevice(u): - """ - The user didn't specify a subdevice on the command line. - If there's a daughterboard on A, select A. - If there's a daughterboard on B, select B. - Otherwise, select A. - """ - if u.db(0, 0).dbid() >= 0: # dbid is < 0 if there's no d'board or a problem - return (0, 0) - if u.db(0, 0).dbid() >= 0: - return (1, 0) - return (0, 0) - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-w", "--which", type="int", default=0, - help="select which USRP (0, 1, ...) default is %default", - metavar="NUM") - parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B (default=first one with a daughterboard)") - parser.add_option("-A", "--antenna", default=None, - help="select Rx Antenna (only on RFX-series boards)") - parser.add_option("-W", "--bw", type="float", default=1e6, - help="set bandwidth of receiver [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=None, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB [default is midpoint]") - parser.add_option("-8", "--width-8", action="store_true", default=False, - help="Enable 8-bit samples across USB") - parser.add_option( "--no-hb", action="store_true", default=False, - help="don't use halfband filter in usrp") - parser.add_option("-S", "--oscilloscope", action="store_true", default=False, - help="Enable oscilloscope display") - parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1, - help="Set fftsink averaging factor, [default=%default]") - parser.add_option("", "--ref-scale", type="eng_float", default=13490.0, - help="Set dBFS=0dB input value, [default=%default]") - parser.add_option("", "--fft-size", type="int", default=2048, - help="Set FFT frame size, [default=%default]"); - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - self.options = options - self.show_debug_info = True - - # Call this before creating the Qt sink - self.qapp = QtGui.QApplication(sys.argv) - - self._fftsize = options.fft_size - - self.u = usrp.source_c(which=options.which) - self._adc_rate = self.u.converter_rate() - self.set_bandwidth(options.bw) - - if options.rx_subdev_spec is None: - options.rx_subdev_spec = pick_subdevice(self.u) - self._rx_subdev_spec = options.rx_subdev_spec - self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec)) - self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) - - self._gain_range = self.subdev.gain_range() - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self._gain_range - options.gain = float(g[0]+g[1])/2 - self.set_gain(options.gain) - - if options.freq is None: - # if no frequency was specified, use the mid-point of the subdev - f = self.subdev.freq_range() - options.freq = float(f[0]+f[1])/2 - self.set_frequency(options.freq) - - self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - self._freq, self._bandwidth, - "USRP Display", - True, True, True, False) - - # Set up internal amplifier - self.amp = gr.multiply_const_cc(0.0) - self.set_amplifier_gain(0.001) - - # Connect the flow graph - self.connect(self.u, self.amp, self.snk) - - - # Get the reference pointer to the SpectrumDisplayForm QWidget - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) - - self.main_win = main_window(self.pysink, self) - - self.main_win.set_frequency(self._freq) - self.main_win.set_gain(self._gain) - self.main_win.set_bandwidth(self._bandwidth) - self.main_win.set_amplifier(self._amp_value) - - self.main_win.show() - - def save_to_file(self, name): - # Pause the flow graph - self.stop() - self.wait() - - # Add file sink to save data - self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) - self.connect(self.amp, self.file_sink) - - # Restart flow graph - self.start() - - def set_gain(self, gain): - self._gain = gain - self.subdev.set_gain(self._gain) - - def set_frequency(self, freq): - self._freq = freq - self.u.tune(0, self.subdev, self._freq) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_bandwidth(self, bw): - self._bandwidth = bw - self._decim = int(self._adc_rate / self._bandwidth) - self.u.set_decim_rate(self._decim) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_amplifier_gain(self, amp): - self._amp_value = amp - self.amp.set_k(self._amp_value) - - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() diff --git a/gr-qtgui/doc/.gitignore b/gr-qtgui/doc/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-qtgui/doc/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-qtgui/doc/CMakeLists.txt b/gr-qtgui/doc/CMakeLists.txt new file mode 100644 index 000000000..e6d01b8b0 --- /dev/null +++ b/gr-qtgui/doc/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +install( + FILES README.qtgui + DESTINATION ${GR_PKG_DOC_DIR} +) diff --git a/gr-qtgui/doc/Makefile.am b/gr-qtgui/doc/Makefile.am new file mode 100644 index 000000000..b65eb062f --- /dev/null +++ b/gr-qtgui/doc/Makefile.am @@ -0,0 +1,27 @@ +# +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = + +dist_gr_doc_DATA = \ + README.qtgui diff --git a/gr-qtgui/doc/README.qtgui b/gr-qtgui/doc/README.qtgui new file mode 100644 index 000000000..e54c3d907 --- /dev/null +++ b/gr-qtgui/doc/README.qtgui @@ -0,0 +1,12 @@ +This is the gr-qtgui package. It contains various QT-based graphical +user interface blocks that add graphical sinks to a GNU Radio +flowgraph. The Python namespaces is in gnuradio.qtgui, which would be normally +imported as: + + from gnuradio import qtgui + +See the Doxygen documentation for details about the blocks available +in this package. A quick listing of the details can be found in Python +after importing by using: + + help(qtgui) diff --git a/gr-qtgui/doc/qtgui.dox b/gr-qtgui/doc/qtgui.dox new file mode 100644 index 000000000..c7f4b7146 --- /dev/null +++ b/gr-qtgui/doc/qtgui.dox @@ -0,0 +1,77 @@ +/*! \page page_qtgui QT Graphical User Interface + +\section Introduction + +This is the gr-qtgui package. It contains various QT-based graphical +user interface blocks that add graphical sinks to a GNU Radio +flowgraph. The Python namespaces is in gnuradio.qtgui, which would be normally +imported as: + +\code + from gnuradio import qtgui +\endcode + +See the Doxygen documentation for details about the blocks available +in this package. The relevant blocks are listed in the \ref +qtgui_blk group. + +A quick listing of the details can be found in Python after importing +by using: + +\code + help(qtgui) +\endcode + + +\section Dependencies + +The QT GUI blocks require the following dependencies. + +\li QtCore (version >= 4.4) +\li QtGui (version >= 4.4) +\li QtOpenGL (version >= 4.4) +\li PyQt4 for Qt4 (version >= 4.4) +\li Qwt (version >= 5.2) +\li PyQwt5 for Qt4 (version >= 5.2) + +\section Usage + +To use the qtgui interface, a bit of boiler-plate lines must be +included. First, the sink is defined, then it must be exposed from C++ +into Python using the "sip.wrapinstance" command, and finally, the +"show" method is run on the new Python object. This sets up the QT +environment to show the widget, but the qApplication must also be +launched. + +In the "main" function of the code, the qApp is retrieved. Then, after +the GNU Radio top block is started (remember that start() is a +non-blocking call to launch the main thread of the flowgraph), the +qapp's "exec_()" function is called. This function is a blocking call +while the GUI is alive. + +\code +from PyQt4 import Qt +from gnuradio.qtgui import qtgui +import sys, sip + +class grclass(gr.top_block): + .... + + self.snk = qtgui.sink_c(1024, #fftsize + samp_rate, #bw + "QT GUI Plot") #name + + self.snk_win = sip.wrapinstance(self.snk.pyqwidget(), Qt.QWidget) + self.snk_win.show() + +def main(): + qapp = Qt.QApplication(sys.argv) + tb = grclass() + tb.start() + qapp.exec_() + tb.stop() + + +\endcode + +*/ diff --git a/gr-qtgui/examples/.gitignore b/gr-qtgui/examples/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-qtgui/examples/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-qtgui/examples/Makefile.am b/gr-qtgui/examples/Makefile.am new file mode 100644 index 000000000..a204d1fcc --- /dev/null +++ b/gr-qtgui/examples/Makefile.am @@ -0,0 +1,34 @@ +# +# Copyright 2008-2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +if PYTHON +ourdatadir = $(exampledir)/qt-gui + +dist_ourdata_SCRIPTS = \ + pyqt_example_c.py \ + pyqt_example_f.py \ + pyqt_time_c.py \ + pyqt_time_f.py +endif + +EXTRA_DIST += diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/examples/pyqt_example_c.py index 553d346c9..553d346c9 100755 --- a/gr-qtgui/apps/pyqt_example_c.py +++ b/gr-qtgui/examples/pyqt_example_c.py diff --git a/gr-qtgui/apps/pyqt_example_f.py b/gr-qtgui/examples/pyqt_example_f.py index 5e432fe78..5e432fe78 100755 --- a/gr-qtgui/apps/pyqt_example_f.py +++ b/gr-qtgui/examples/pyqt_example_f.py diff --git a/gr-qtgui/apps/pyqt_time_c.py b/gr-qtgui/examples/pyqt_time_c.py index a47302d19..a47302d19 100755 --- a/gr-qtgui/apps/pyqt_time_c.py +++ b/gr-qtgui/examples/pyqt_time_c.py diff --git a/gr-qtgui/apps/pyqt_time_f.py b/gr-qtgui/examples/pyqt_time_f.py index 835b42a75..835b42a75 100755 --- a/gr-qtgui/apps/pyqt_time_f.py +++ b/gr-qtgui/examples/pyqt_time_f.py diff --git a/gr-qtgui/grc/CMakeLists.txt b/gr-qtgui/grc/CMakeLists.txt new file mode 100644 index 000000000..370a71725 --- /dev/null +++ b/gr-qtgui/grc/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +file(GLOB xml_files "*.xml") +install(FILES ${xml_files} DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "qtgui_python") diff --git a/gr-qtgui/grc/qtgui_sink_x.xml b/gr-qtgui/grc/qtgui_sink_x.xml index 8c470a1a5..83d6ec287 100644 --- a/gr-qtgui/grc/qtgui_sink_x.xml +++ b/gr-qtgui/grc/qtgui_sink_x.xml @@ -57,6 +57,26 @@ $(gui_hint()($win))</make> <name>Blackman-harris</name> <key>firdes.WIN_BLACKMAN_hARRIS</key> </option> + <option> + <name>Hamming</name> + <key>firdes.WIN_HAMMING</key> + </option> + <option> + <name>Hann</name> + <key>firdes.WIN_HANN</key> + </option> + <option> + <name>Blackman</name> + <key>firdes.WIN_BLACKMAN</key> + </option> + <option> + <name>Rectangular</name> + <key>firdes.WIN_RECTANGULAR</key> + </option> + <option> + <name>Kaiser</name> + <key>firdes.WIN_KAISER</key> + </option> </param> <param> <name>Center Frequency (Hz)</name> diff --git a/gr-qtgui/include/.gitignore b/gr-qtgui/include/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-qtgui/include/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-qtgui/include/CMakeLists.txt b/gr-qtgui/include/CMakeLists.txt new file mode 100644 index 000000000..ef4cb1175 --- /dev/null +++ b/gr-qtgui/include/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright 2010-2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Install the header files +######################################################################## +install(FILES + gr_qtgui_api.h + qtgui_time_sink_c.h + qtgui_time_sink_f.h + qtgui_sink_c.h + qtgui_sink_f.h + qtgui_util.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "qtgui_devel" +) diff --git a/gr-qtgui/include/Makefile.am b/gr-qtgui/include/Makefile.am new file mode 100644 index 000000000..59a030854 --- /dev/null +++ b/gr-qtgui/include/Makefile.am @@ -0,0 +1,33 @@ +# +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +# These headers get installed in ${prefix}/include/gnuradio +grinclude_HEADERS = \ + gr_qtgui_api.h \ + qtgui_time_sink_c.h \ + qtgui_time_sink_f.h \ + qtgui_sink_c.h \ + qtgui_sink_f.h \ + qtgui_util.h + +libgnuradio_digital_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) diff --git a/gr-qtgui/lib/gr_qtgui_api.h b/gr-qtgui/include/gr_qtgui_api.h index 65033a093..65033a093 100644 --- a/gr-qtgui/lib/gr_qtgui_api.h +++ b/gr-qtgui/include/gr_qtgui_api.h diff --git a/gr-qtgui/lib/qtgui_sink_c.h b/gr-qtgui/include/qtgui_sink_c.h index b0946885c..b04706b14 100644 --- a/gr-qtgui/lib/qtgui_sink_c.h +++ b/gr-qtgui/include/qtgui_sink_c.h @@ -41,6 +41,17 @@ GR_QTGUI_API qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, bool plottime=true, bool plotconst=true, QWidget *parent=NULL); +/*! + * \brief A graphical sink to display freq, spec, time, and const plots. + * \ingroup qtgui_blk + * + * This is a QT-based graphical sink the takes a complex stream and + * plots it. The default action is to plot the signal as a PSD (FFT), + * spectrogram (waterfall), time domain I&Q, and constellation (I + * vs. Q) plots. The plots may be turned off by setting the + * appropriate boolean value in the constructor to False. + */ + class GR_QTGUI_API qtgui_sink_c : public gr_block { private: diff --git a/gr-qtgui/lib/qtgui_sink_f.h b/gr-qtgui/include/qtgui_sink_f.h index 6d43f18dd..2d79b5eef 100644 --- a/gr-qtgui/lib/qtgui_sink_f.h +++ b/gr-qtgui/include/qtgui_sink_f.h @@ -38,9 +38,20 @@ GR_QTGUI_API qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, double fc=0, double bw=1.0, const std::string &name="Spectrum Display", bool plotfreq=true, bool plotwaterfall=true, - bool plottime=true, bool plotconst=true, + bool plottime=true, bool plotconst=false, QWidget *parent=NULL); +/*! + * \brief A graphical sink to display freq, spec, and time. + * \ingroup qtgui_blk + * + * This is a QT-based graphical sink the takes a float stream and + * plots it. The default action is to plot the signal as a PSD (FFT), + * spectrogram (waterfall), and time domain plots. The plots may be + * turned off by setting the appropriate boolean value in the + * constructor to False. + */ + class GR_QTGUI_API qtgui_sink_f : public gr_block { private: diff --git a/gr-qtgui/lib/qtgui_time_sink_c.h b/gr-qtgui/include/qtgui_time_sink_c.h index 459423c40..ec7cc490b 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.h +++ b/gr-qtgui/include/qtgui_time_sink_c.h @@ -25,7 +25,7 @@ #include <Python.h> #include <gr_qtgui_api.h> -#include <gr_block.h> +#include <gr_sync_block.h> #include <gr_firdes.h> #include <gri_fft.h> #include <qapplication.h> @@ -35,24 +35,33 @@ class qtgui_time_sink_c; typedef boost::shared_ptr<qtgui_time_sink_c> qtgui_time_sink_c_sptr; GR_QTGUI_API qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, - const std::string &name, - int nconnectons=1, - QWidget *parent=NULL); - -class GR_QTGUI_API qtgui_time_sink_c : public gr_block + const std::string &name, + int nconnectons=1, + QWidget *parent=NULL); + +/*! + * \brief A graphical sink to display multiple signals in time. + * \ingroup qtgui_blk + * + * This is a QT-based graphical sink the takes set of a complex + * streams and plots them in the time domain. For each signal, both + * the signal's I and Q parts are plotted, and they are all plotted + * with a different color, and the \a set_title and \a set_color + * functions can be used to change the lable and color for a given + * input number. + */ +class GR_QTGUI_API qtgui_time_sink_c : public gr_sync_block { private: friend GR_QTGUI_API qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, - const std::string &name, - int nconnections, - QWidget *parent); + const std::string &name, + int nconnections, + QWidget *parent); qtgui_time_sink_c(int size, double bw, const std::string &name, int nconnections, QWidget *parent=NULL); - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - void initialize(); int d_size; @@ -84,10 +93,9 @@ public: QApplication *d_qApplication; - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); }; #endif /* INCLUDED_QTGUI_TIME_SINK_C_H */ diff --git a/gr-qtgui/lib/qtgui_time_sink_f.h b/gr-qtgui/include/qtgui_time_sink_f.h index 632246c6e..ff17f8a1b 100644 --- a/gr-qtgui/lib/qtgui_time_sink_f.h +++ b/gr-qtgui/include/qtgui_time_sink_f.h @@ -25,7 +25,7 @@ #include <Python.h> #include <gr_qtgui_api.h> -#include <gr_block.h> +#include <gr_sync_block.h> #include <gr_firdes.h> #include <gri_fft.h> #include <qapplication.h> @@ -39,7 +39,16 @@ GR_QTGUI_API qtgui_time_sink_f_sptr qtgui_make_time_sink_f(int size, double bw, int nconnectons=1, QWidget *parent=NULL); -class GR_QTGUI_API qtgui_time_sink_f : public gr_block +/*! + * \brief A graphical sink to display multiple signals in time. + * \ingroup qtgui_blk + * + * This is a QT-based graphical sink the takes set of a float streams + * and plots them in the time domain. Each signal is plotted with a + * different color, and the \a set_title and \a set_color functions + * can be used to change the lable and color for a given input number. + */ +class GR_QTGUI_API qtgui_time_sink_f : public gr_sync_block { private: friend GR_QTGUI_API qtgui_time_sink_f_sptr qtgui_make_time_sink_f(int size, double bw, @@ -51,8 +60,6 @@ private: int nconnections, QWidget *parent=NULL); - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - void initialize(); int d_size; @@ -84,10 +91,9 @@ public: QApplication *d_qApplication; - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); }; #endif /* INCLUDED_QTGUI_TIME_SINK_F_H */ diff --git a/gr-qtgui/lib/qtgui_util.h b/gr-qtgui/include/qtgui_util.h index 7b3692e75..7b3692e75 100644 --- a/gr-qtgui/lib/qtgui_util.h +++ b/gr-qtgui/include/qtgui_util.h diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt new file mode 100644 index 000000000..ab6fedcf8 --- /dev/null +++ b/gr-qtgui/lib/CMakeLists.txt @@ -0,0 +1,115 @@ +# Copyright 2010-2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Setup the QT file generations stuff +######################################################################## +set(qtgui_moc_hdrs + spectrumdisplayform.h + timedisplayform.h + FrequencyDisplayPlot.h + TimeDomainDisplayPlot.h + WaterfallDisplayPlot.h + ConstellationDisplayPlot.h +) +QT4_WRAP_CPP(qtgui_moc_srcs ${qtgui_moc_hdrs}) +QT4_WRAP_UI(qtgui_ui_hdrs spectrumdisplayform.ui) + +#FIXME the sources expect <foo>.ui.h, but the macros generate ui_foo.h +#avoid changing the sources by generating the header with the include +set(spectrum_ui_hdr ${CMAKE_CURRENT_BINARY_DIR}/spectrumdisplayform.ui.h) +if(NOT EXISTS ${spectrum_ui_hdr}) + file(WRITE ${spectrum_ui_hdr} "#include <ui_spectrumdisplayform.h>\n") +endif(NOT EXISTS ${spectrum_ui_hdr}) + +set(qtgui_srcs + ${qtgui_moc_srcs} + ${qtgui_ui_hdrs} + FrequencyDisplayPlot.cc + TimeDomainDisplayPlot.cc + WaterfallDisplayPlot.cc + waterfallGlobalData.cc + ConstellationDisplayPlot.cc + spectrumdisplayform.cc + timedisplayform.cc + SpectrumGUIClass.cc + spectrumUpdateEvents.cc + plot_waterfall.cc + qtgui_sink_c.cc + qtgui_sink_f.cc + qtgui_time_sink_c.cc + qtgui_time_sink_f.cc + qtgui_util.cc +) + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GR_QTGUI_INCLUDE_DIRS} +) + +include_directories(${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + +include_directories(${QWT_INCLUDE_DIRS}) +link_directories(${QWT_LIBRARY_DIRS}) + +include_directories(${PYTHON_INCLUDE_DIRS}) + +######################################################################## +# Setup library +######################################################################## +list(APPEND qtgui_libs + gnuradio-core + ${QT_LIBRARIES} + ${QWT_LIBRARIES} + ${PYTHON_LIBRARIES} +) + +add_definitions(-DQWT_DLL) #setup QWT library linkage +add_library(gnuradio-qtgui SHARED ${qtgui_srcs}) +target_link_libraries(gnuradio-qtgui ${qtgui_libs}) +set_target_properties(gnuradio-qtgui PROPERTIES DEFINE_SYMBOL "libgnuradio_qtgui_EXPORTS") +set_target_properties(gnuradio-qtgui PROPERTIES SOVERSION ${LIBVER}) + +install(TARGETS gnuradio-qtgui + LIBRARY DESTINATION ${GR_LIBRARY_DIR} COMPONENT "qtgui_runtime" # .so/.dylib file + ARCHIVE DESTINATION ${GR_LIBRARY_DIR} COMPONENT "qtgui_devel" # .lib file + RUNTIME DESTINATION ${GR_RUNTIME_DIR} COMPONENT "qtgui_runtime" # .dll file +) + +######################################################################## +# Install the header files +######################################################################## +install(FILES + FrequencyDisplayPlot.h + TimeDomainDisplayPlot.h + WaterfallDisplayPlot.h + waterfallGlobalData.h + ConstellationDisplayPlot.h + plot_waterfall.h + spectrumdisplayform.h + timedisplayform.h + SpectrumGUIClass.h + spectrumUpdateEvents.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "qtgui_devel" +) diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index 3257c3aae..aba311297 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -24,8 +24,8 @@ include $(top_srcdir)/Makefile.common EXTRA_DIST += spectrumdisplayform.ui AM_CPPFLAGS = -I. $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ - $(QT_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES) \ - -Dlibgnuradio_qtgui_EXPORTS + $(QT_INCLUDES) $(BOOST_CPPFLAGS) $(GR_QTGUI_INCLUDES) \ + $(WITH_INCLUDES) -Dlibgnuradio_qtgui_EXPORTS # Only include these files in the build if qtgui passes configure checks # This is mostly to help make distcheck pass @@ -73,14 +73,8 @@ grinclude_HEADERS = \ spectrumdisplayform.h \ timedisplayform.h \ SpectrumGUIClass.h \ - spectrumUpdateEvents.h \ plot_waterfall.h \ - gr_qtgui_api.h \ - qtgui_sink_c.h \ - qtgui_sink_f.h \ - qtgui_time_sink_c.h \ - qtgui_time_sink_f.h \ - qtgui_util.h + spectrumUpdateEvents.h #QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB diff --git a/gr-qtgui/lib/highResTimeFunctions.h b/gr-qtgui/lib/highResTimeFunctions.h deleted file mode 100644 index 6b3844901..000000000 --- a/gr-qtgui/lib/highResTimeFunctions.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef HIGH_RES_TIME_FUNCTIONS_H -#define HIGH_RES_TIME_FUNCTIONS_H - -#include <gruel/high_res_timer.h> - -typedef gruel::high_res_timer_type highres_timespec; - -static inline highres_timespec -get_highres_clock() -{ - return gruel::high_res_timer_now(); -} - -#endif /* HIGH_RES_TIME_FUNCTIONS_H */ diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index 3d38419b2..207d4a924 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -44,9 +44,9 @@ qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, const std::string &name, int nconnections, QWidget *parent) - : gr_block ("time_sink_c", - gr_make_io_signature (nconnections, nconnections, sizeof(gr_complex)), - gr_make_io_signature (0, 0, 0)), + : gr_sync_block ("time_sink_c", + gr_make_io_signature (nconnections, nconnections, sizeof(gr_complex)), + gr_make_io_signature (0, 0, 0)), d_size(size), d_bandwidth(bw), d_name(name), d_nconnections(2*nconnections), d_parent(parent) { @@ -59,6 +59,7 @@ qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, } initialize(); + set_output_multiple(d_size); } qtgui_time_sink_c::~qtgui_time_sink_c() @@ -70,15 +71,6 @@ qtgui_time_sink_c::~qtgui_time_sink_c() } void -qtgui_time_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned int ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = std::min(d_size, 8191); - } -} - -void qtgui_time_sink_c::initialize() { if(qApp != NULL) { @@ -144,10 +136,9 @@ qtgui_time_sink_c::set_color(int which, const std::string &color) } int -qtgui_time_sink_c::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +qtgui_time_sink_c::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { int n=0, j=0, idx=0; const gr_complex *in = (const gr_complex*)input_items[idx]; @@ -181,7 +172,9 @@ qtgui_time_sink_c::general_work (int noutput_items, j += resid; } // Otherwise, copy what we received into the residbufs for next time + // because we set the output_multiple, this should never need to be called else { + assert(0); for(n = 0; n < d_nconnections; n+=2) { in = (const gr_complex*)input_items[idx++]; for(unsigned int k = 0; k < resid; k++) { @@ -193,7 +186,6 @@ qtgui_time_sink_c::general_work (int noutput_items, j += datasize; } } - - consume_each(j); - return j; + + return noutput_items; } diff --git a/gr-qtgui/lib/qtgui_time_sink_f.cc b/gr-qtgui/lib/qtgui_time_sink_f.cc index 58cc7a38a..2fe99f43c 100644 --- a/gr-qtgui/lib/qtgui_time_sink_f.cc +++ b/gr-qtgui/lib/qtgui_time_sink_f.cc @@ -44,9 +44,9 @@ qtgui_time_sink_f::qtgui_time_sink_f (int size, double bw, const std::string &name, int nconnections, QWidget *parent) - : gr_block ("time_sink_f", - gr_make_io_signature (nconnections, nconnections, sizeof(float)), - gr_make_io_signature (0, 0, 0)), + : gr_sync_block ("time_sink_f", + gr_make_io_signature (nconnections, nconnections, sizeof(float)), + gr_make_io_signature (0, 0, 0)), d_size(size), d_bandwidth(bw), d_name(name), d_nconnections(nconnections), d_parent(parent) { @@ -59,6 +59,7 @@ qtgui_time_sink_f::qtgui_time_sink_f (int size, double bw, } initialize(); + set_output_multiple(d_size); } qtgui_time_sink_f::~qtgui_time_sink_f() @@ -70,15 +71,6 @@ qtgui_time_sink_f::~qtgui_time_sink_f() } void -qtgui_time_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned int ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = std::min(d_size, 8191); - } -} - -void qtgui_time_sink_f::initialize() { if(qApp != NULL) { @@ -144,10 +136,9 @@ qtgui_time_sink_f::set_color(int which, const std::string &color) } int -qtgui_time_sink_f::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +qtgui_time_sink_f::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { int n=0, j=0, idx=0; const float *in = (const float*)input_items[idx]; @@ -180,7 +171,9 @@ qtgui_time_sink_f::general_work (int noutput_items, j += resid; } // Otherwise, copy what we received into the residbufs for next time + // because we set the output_multiple, this should never need to be called else { + assert(0); for(n = 0; n < d_nconnections; n++) { in = (const float*)input_items[idx++]; for(unsigned int k = 0; k < resid; k++) { @@ -192,6 +185,5 @@ qtgui_time_sink_f::general_work (int noutput_items, } } - consume_each(j); - return j; + return noutput_items; } diff --git a/gr-qtgui/python/CMakeLists.txt b/gr-qtgui/python/CMakeLists.txt new file mode 100644 index 000000000..e61b54f08 --- /dev/null +++ b/gr-qtgui/python/CMakeLists.txt @@ -0,0 +1,46 @@ +# Copyright 2010-2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +include(GrPython) + +GR_PYTHON_INSTALL( + FILES __init__.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/qtgui + COMPONENT "qtgui_python" +) + +######################################################################## +# Handle the unit tests +######################################################################## +if(ENABLE_TESTING) +include(GrTest) +file(GLOB py_qa_test_files "qa_*.py") +foreach(py_qa_test_file ${py_qa_test_files}) + get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) + set(GR_TEST_PYTHON_DIRS + ${CMAKE_BINARY_DIR}/gnuradio-core/src/python + ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig + ${CMAKE_BINARY_DIR}/gr-qtgui/python + ${CMAKE_BINARY_DIR}/gr-qtgui/swig + ) + set(GR_TEST_TARGET_DEPS gruel gnuradio-core gnuradio-qtgui) + GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${py_qa_test_file}) +endforeach(py_qa_test_file) +endif(ENABLE_TESTING) diff --git a/gr-qtgui/python/__init__.py b/gr-qtgui/python/__init__.py index db113bbd3..236f211b1 100644 --- a/gr-qtgui/python/__init__.py +++ b/gr-qtgui/python/__init__.py @@ -19,6 +19,11 @@ # Boston, MA 02110-1301, USA. # +''' +This is the gr-qtgui package. This package includes QT-based graphical +sinks. +''' + # The presence of this file turns this directory into a Python package from qtgui_swig import * diff --git a/gr-qtgui/swig/CMakeLists.txt b/gr-qtgui/swig/CMakeLists.txt new file mode 100644 index 000000000..34b40fb7e --- /dev/null +++ b/gr-qtgui/swig/CMakeLists.txt @@ -0,0 +1,50 @@ +# Copyright 2010-2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Setup swig generation +######################################################################## +include(GrPython) +include(GrSwig) + +set(GR_SWIG_INCLUDE_DIRS + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${GR_QTGUI_INCLUDE_DIRS} + ${QWT_INCLUDE_DIRS} +) + +set(GR_SWIG_LIBRARIES gnuradio-qtgui) + +GR_SWIG_MAKE(qtgui_swig qtgui_swig.i) + +GR_SWIG_INSTALL( + TARGETS qtgui_swig + DESTINATION ${GR_PYTHON_DIR}/gnuradio/qtgui + COMPONENT "qtgui_python" +) + +install(FILES + qtgui_swig.i + qtgui_sink_c.i + qtgui_sink_f.i + qtgui_time_sink_c.i + qtgui_time_sink_f.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "qtgui_swig" +) diff --git a/gr-qtgui/swig/Makefile.am b/gr-qtgui/swig/Makefile.am index 1d8319987..ad6f49e00 100644 --- a/gr-qtgui/swig/Makefile.am +++ b/gr-qtgui/swig/Makefile.am @@ -31,6 +31,7 @@ AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ $(QT_INCLUDES) \ + $(GR_QTGUI_INCLUDES) \ $(WITH_INCLUDES) ############################## diff --git a/gr-qtgui/swig/Makefile.swig.gen b/gr-qtgui/swig/Makefile.swig.gen index 3659601c3..e343db374 100644 --- a/gr-qtgui/swig/Makefile.swig.gen +++ b/gr-qtgui/swig/Makefile.swig.gen @@ -105,7 +105,7 @@ _qtgui_swig_la_CXXFLAGS = \ $(qtgui_swig_la_swig_cxxflags) python/qtgui_swig.cc: qtgui_swig.py -qtgui_swig.py: qtgui_swig.i +qtgui_swig.py: qtgui_swig.i # Include the python dependencies for this file -include python/qtgui_swig.d diff --git a/gr-qtgui/swig/qtgui_sink_f.i b/gr-qtgui/swig/qtgui_sink_f.i index c5eb656b9..a34420461 100644 --- a/gr-qtgui/swig/qtgui_sink_f.i +++ b/gr-qtgui/swig/qtgui_sink_f.i @@ -32,7 +32,7 @@ qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, double fc=0, double bw=0.0, const std::string &name="Display", bool plotfreq=true, bool plotwaterfall=true, - bool plottime=true, bool plotconst=true, + bool plottime=true, bool plotconst=false, QWidget *parent=NULL); class qtgui_sink_f : public gr_block diff --git a/gr-qtgui/swig/qtgui_time_sink_c.i b/gr-qtgui/swig/qtgui_time_sink_c.i index 8f5c9f4f0..e7240aa69 100644 --- a/gr-qtgui/swig/qtgui_time_sink_c.i +++ b/gr-qtgui/swig/qtgui_time_sink_c.i @@ -33,7 +33,7 @@ qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, int nconnections=1, QWidget *parent=NULL); -class qtgui_time_sink_c : public gr_block +class qtgui_time_sink_c : public gr_sync_block { private: friend qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, diff --git a/gr-qtgui/swig/qtgui_time_sink_f.i b/gr-qtgui/swig/qtgui_time_sink_f.i index b92efe7be..06af42da3 100644 --- a/gr-qtgui/swig/qtgui_time_sink_f.i +++ b/gr-qtgui/swig/qtgui_time_sink_f.i @@ -33,7 +33,7 @@ qtgui_time_sink_f_sptr qtgui_make_time_sink_f(int size, double bw, int nconnections=1, QWidget *parent=NULL); -class qtgui_time_sink_f : public gr_block +class qtgui_time_sink_f : public gr_sync_block { private: friend qtgui_time_sink_f_sptr qtgui_make_time_sink_f(int size, double bw, |