summaryrefslogtreecommitdiff
path: root/gr-qtgui
diff options
context:
space:
mode:
Diffstat (limited to 'gr-qtgui')
-rw-r--r--gr-qtgui/CMakeLists.txt131
-rw-r--r--gr-qtgui/apps/grc_qt_example.grc441
-rwxr-xr-xgr-qtgui/apps/qt_digital.py308
-rw-r--r--gr-qtgui/apps/qt_digital_window.py161
-rw-r--r--gr-qtgui/apps/qt_digital_window.ui342
-rwxr-xr-xgr-qtgui/apps/uhd_display.py317
-rw-r--r--gr-qtgui/apps/usrp_display_qtgui.py191
-rw-r--r--gr-qtgui/apps/usrp_display_qtgui.ui375
-rw-r--r--gr-qtgui/doc/CMakeLists.txt23
-rw-r--r--gr-qtgui/doc/README.qtgui12
-rw-r--r--gr-qtgui/doc/qtgui.dox77
-rw-r--r--gr-qtgui/examples/CMakeLists.txt29
-rwxr-xr-xgr-qtgui/examples/pyqt_example_c.py176
-rwxr-xr-xgr-qtgui/examples/pyqt_example_f.py178
-rwxr-xr-xgr-qtgui/examples/pyqt_time_c.py189
-rwxr-xr-xgr-qtgui/examples/pyqt_time_f.py189
-rw-r--r--gr-qtgui/gnuradio-qtgui.pc.in11
-rw-r--r--gr-qtgui/grc/CMakeLists.txt22
-rw-r--r--gr-qtgui/grc/qtgui_check_box.xml83
-rw-r--r--gr-qtgui/grc/qtgui_chooser.xml251
-rw-r--r--gr-qtgui/grc/qtgui_entry.xml68
-rw-r--r--gr-qtgui/grc/qtgui_label.xml66
-rw-r--r--gr-qtgui/grc/qtgui_range.xml211
-rw-r--r--gr-qtgui/grc/qtgui_sink_x.xml153
-rw-r--r--gr-qtgui/grc/qtgui_tab_widget.xml84
-rw-r--r--gr-qtgui/grc/qtgui_time_sink_x.xml78
-rw-r--r--gr-qtgui/include/CMakeLists.txt32
-rw-r--r--gr-qtgui/include/gr_qtgui_api.h33
-rw-r--r--gr-qtgui/include/qtgui_sink_c.h128
-rw-r--r--gr-qtgui/include/qtgui_sink_f.h125
-rw-r--r--gr-qtgui/include/qtgui_time_sink_c.h101
-rw-r--r--gr-qtgui/include/qtgui_time_sink_f.h99
-rw-r--r--gr-qtgui/include/qtgui_util.h57
-rw-r--r--gr-qtgui/lib/CMakeLists.txt112
-rw-r--r--gr-qtgui/lib/ConstellationDisplayPlot.cc255
-rw-r--r--gr-qtgui/lib/ConstellationDisplayPlot.h101
-rw-r--r--gr-qtgui/lib/FrequencyDisplayPlot.cc560
-rw-r--r--gr-qtgui/lib/FrequencyDisplayPlot.h139
-rw-r--r--gr-qtgui/lib/SpectrumGUIClass.cc478
-rw-r--r--gr-qtgui/lib/SpectrumGUIClass.h130
-rw-r--r--gr-qtgui/lib/TimeDomainDisplayPlot.cc345
-rw-r--r--gr-qtgui/lib/TimeDomainDisplayPlot.h102
-rw-r--r--gr-qtgui/lib/WaterfallDisplayPlot.cc695
-rw-r--r--gr-qtgui/lib/WaterfallDisplayPlot.h127
-rw-r--r--gr-qtgui/lib/plot_waterfall.cc310
-rw-r--r--gr-qtgui/lib/plot_waterfall.h67
-rw-r--r--gr-qtgui/lib/qtgui_sink_c.cc310
-rw-r--r--gr-qtgui/lib/qtgui_sink_f.cc294
-rw-r--r--gr-qtgui/lib/qtgui_time_sink_c.cc192
-rw-r--r--gr-qtgui/lib/qtgui_time_sink_f.cc190
-rw-r--r--gr-qtgui/lib/qtgui_util.cc103
-rw-r--r--gr-qtgui/lib/spectrumUpdateEvents.cc223
-rw-r--r--gr-qtgui/lib/spectrumUpdateEvents.h115
-rw-r--r--gr-qtgui/lib/spectrumdisplayform.cc754
-rw-r--r--gr-qtgui/lib/spectrumdisplayform.h139
-rw-r--r--gr-qtgui/lib/spectrumdisplayform.ui756
-rw-r--r--gr-qtgui/lib/timedisplayform.cc177
-rw-r--r--gr-qtgui/lib/timedisplayform.h85
-rw-r--r--gr-qtgui/lib/waterfallGlobalData.cc230
-rw-r--r--gr-qtgui/lib/waterfallGlobalData.h59
-rw-r--r--gr-qtgui/python/CMakeLists.txt46
-rw-r--r--gr-qtgui/python/__init__.py30
-rwxr-xr-xgr-qtgui/python/qa_qtgui.py48
-rw-r--r--gr-qtgui/swig/CMakeLists.txt57
-rw-r--r--gr-qtgui/swig/__init__.py24
-rw-r--r--gr-qtgui/swig/qtgui_sink_c.i66
-rw-r--r--gr-qtgui/swig/qtgui_sink_f.i66
-rw-r--r--gr-qtgui/swig/qtgui_swig.i38
-rw-r--r--gr-qtgui/swig/qtgui_time_sink_c.i56
-rw-r--r--gr-qtgui/swig/qtgui_time_sink_f.i56
70 files changed, 12276 insertions, 0 deletions
diff --git a/gr-qtgui/CMakeLists.txt b/gr-qtgui/CMakeLists.txt
new file mode 100644
index 000000000..d7d889e93
--- /dev/null
+++ b/gr-qtgui/CMakeLists.txt
@@ -0,0 +1,131 @@
+# Copyright 2010-2011,2013 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)
+
+find_package(Qwt)
+
+find_package(PythonLibs)
+
+include(GrPython)
+GR_PYTHON_CHECK_MODULE("PyQt4" PyQt4 True PYQT4_FOUND)
+
+########################################################################
+# Register component
+########################################################################
+include(GrComponent)
+if(NOT CMAKE_CROSSCOMPILING)
+ set(qt_gui_python_deps
+ PYQT4_FOUND
+ #we could check for pyqwt, but its not strictly required
+ )
+endif(NOT CMAKE_CROSSCOMPILING)
+
+GR_REGISTER_COMPONENT("gr-qtgui" ENABLE_GR_QTGUI
+ Boost_FOUND
+ QT4_FOUND
+ QWT_FOUND
+ ENABLE_GR_CORE
+ PYTHONLIBS_FOUND
+ ${qt_gui_python_deps}
+)
+
+GR_SET_GLOBAL(GR_QTGUI_INCLUDE_DIRS
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ ${CMAKE_CURRENT_BINARY_DIR}/lib
+)
+
+SET(GR_PKG_QTGUI_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/qt-gui)
+
+########################################################################
+# Begin conditional configuration
+########################################################################
+if(ENABLE_GR_QTGUI)
+
+# populate the environment with QT variables
+include(GrSetupQt4)
+
+########################################################################
+# 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)
+ add_subdirectory(examples)
+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/apps/grc_qt_example.grc b/gr-qtgui/apps/grc_qt_example.grc
new file mode 100644
index 000000000..170cd546a
--- /dev/null
+++ b/gr-qtgui/apps/grc_qt_example.grc
@@ -0,0 +1,441 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+ <timestamp>Sun Apr 10 16:49:13 2011</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>grc_qt_example</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value></value>
+ </param>
+ <param>
+ <key>author</key>
+ <value></value>
+ </param>
+ <param>
+ <key>description</key>
+ <value></value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1280, 1024</value>
+ </param>
+ <param>
+ <key>generate_options</key>
+ <value>qt_gui</value>
+ </param>
+ <param>
+ <key>category</key>
+ <value>Custom</value>
+ </param>
+ <param>
+ <key>run_options</key>
+ <value>prompt</value>
+ </param>
+ <param>
+ <key>run</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>realtime_scheduling</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(10, 10)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>32000</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(10, 170)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_throttle</key>
+ <param>
+ <key>id</key>
+ <value>gr_throttle_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>samples_per_second</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(511, 96)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable_qtgui_range</key>
+ <param>
+ <key>id</key>
+ <value>freq</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>label</key>
+ <value>Signal Frequency</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>1000</value>
+ </param>
+ <param>
+ <key>start</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>stop</key>
+ <value>samp_rate/2.0</value>
+ </param>
+ <param>
+ <key>step</key>
+ <value>samp_rate/100.0</value>
+ </param>
+ <param>
+ <key>widget</key>
+ <value>counter_slider</value>
+ </param>
+ <param>
+ <key>orient</key>
+ <value>Qt.Horizontal</value>
+ </param>
+ <param>
+ <key>min_len</key>
+ <value>200</value>
+ </param>
+ <param>
+ <key>gui_hint</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(169, 187)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_sig_source_x</key>
+ <param>
+ <key>id</key>
+ <value>gr_sig_source_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>waveform</key>
+ <value>gr.GR_COS_WAVE</value>
+ </param>
+ <param>
+ <key>freq</key>
+ <value>freq</value>
+ </param>
+ <param>
+ <key>amp</key>
+ <value>amp</value>
+ </param>
+ <param>
+ <key>offset</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(295, 64)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable_qtgui_range</key>
+ <param>
+ <key>id</key>
+ <value>amp</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>label</key>
+ <value>Signal Amplitude</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>start</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>stop</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>step</key>
+ <value>0.01</value>
+ </param>
+ <param>
+ <key>widget</key>
+ <value>counter_slider</value>
+ </param>
+ <param>
+ <key>orient</key>
+ <value>Qt.Horizontal</value>
+ </param>
+ <param>
+ <key>min_len</key>
+ <value>200</value>
+ </param>
+ <param>
+ <key>gui_hint</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(311, 187)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable_qtgui_range</key>
+ <param>
+ <key>id</key>
+ <value>noise</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>label</key>
+ <value>Noise Amplitude</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>0.01</value>
+ </param>
+ <param>
+ <key>start</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>stop</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>step</key>
+ <value>0.01</value>
+ </param>
+ <param>
+ <key>widget</key>
+ <value>counter_slider</value>
+ </param>
+ <param>
+ <key>orient</key>
+ <value>Qt.Horizontal</value>
+ </param>
+ <param>
+ <key>min_len</key>
+ <value>200</value>
+ </param>
+ <param>
+ <key>gui_hint</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(723, 191)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_channel_model</key>
+ <param>
+ <key>id</key>
+ <value>gr_channel_model_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>noise_voltage</key>
+ <value>noise</value>
+ </param>
+ <param>
+ <key>freq_offset</key>
+ <value>0.0</value>
+ </param>
+ <param>
+ <key>epsilon</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>taps</key>
+ <value>1.0 + 0.0j</value>
+ </param>
+ <param>
+ <key>seed</key>
+ <value>42</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(727, 64)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>qtgui_sink_x</key>
+ <param>
+ <key>id</key>
+ <value>qtgui_sink_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>name</key>
+ <value>QT GUI Plot</value>
+ </param>
+ <param>
+ <key>fftsize</key>
+ <value>1024</value>
+ </param>
+ <param>
+ <key>wintype</key>
+ <value>firdes.WIN_BLACKMAN_hARRIS</value>
+ </param>
+ <param>
+ <key>fc</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>bw</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>plotfreq</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>plotwaterfall</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>plottime</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>plotconst</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>gui_hint</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(958, 72)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <connection>
+ <source_block_id>gr_sig_source_x_0</source_block_id>
+ <sink_block_id>gr_throttle_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_throttle_0</source_block_id>
+ <sink_block_id>gr_channel_model_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_channel_model_0</source_block_id>
+ <sink_block_id>qtgui_sink_x_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+</flow_graph>
diff --git a/gr-qtgui/apps/qt_digital.py b/gr-qtgui/apps/qt_digital.py
new file mode 100755
index 000000000..2bc039a31
--- /dev/null
+++ b/gr-qtgui/apps/qt_digital.py
@@ -0,0 +1,308 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+from gnuradio import gr, blks2
+from gnuradio import eng_notation
+import sys
+
+try:
+ from gnuradio import qtgui
+ from PyQt4 import QtGui, QtCore
+ import sip
+except ImportError:
+ print "Error: Program requires PyQt4 and gr-qtgui."
+ sys.exit(1)
+
+try:
+ import scipy
+except ImportError:
+ print "Error: Program requires scipy (see: www.scipy.org)."
+ sys.exit(1)
+
+try:
+ from qt_digital_window import Ui_DigitalWindow
+except ImportError:
+ print "Error: could not find qt_digital_window.py:"
+ print "\t\"Please run: pyuic4 qt_digital_window.ui -o qt_digital_window.py\""
+ sys.exit(1)
+
+class dialog_box(QtGui.QMainWindow):
+ def __init__(self, snkTx, snkRx, fg, parent=None):
+ QtGui.QWidget.__init__(self, parent)
+ self.gui = Ui_DigitalWindow()
+ self.gui.setupUi(self)
+
+ self.fg = fg
+
+ self.set_sample_rate(self.fg.sample_rate())
+
+ self.set_snr(self.fg.snr())
+ self.set_frequency(self.fg.frequency_offset())
+ self.set_time_offset(self.fg.timing_offset())
+
+ self.set_gain_mu(self.fg.rx_gain_mu())
+ self.set_alpha(self.fg.rx_alpha())
+
+ # Add the qtsnk widgets to the hlayout box
+ self.gui.sinkLayout.addWidget(snkTx)
+ self.gui.sinkLayout.addWidget(snkRx)
+
+
+ # Connect up some signals
+ self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"),
+ self.pauseFg)
+
+ self.connect(self.gui.sampleRateEdit, QtCore.SIGNAL("editingFinished()"),
+ self.sampleRateEditText)
+
+ self.connect(self.gui.snrEdit, QtCore.SIGNAL("editingFinished()"),
+ self.snrEditText)
+ self.connect(self.gui.freqEdit, QtCore.SIGNAL("editingFinished()"),
+ self.freqEditText)
+ self.connect(self.gui.timeEdit, QtCore.SIGNAL("editingFinished()"),
+ self.timeEditText)
+
+ self.connect(self.gui.gainMuEdit, QtCore.SIGNAL("editingFinished()"),
+ self.gainMuEditText)
+ self.connect(self.gui.alphaEdit, QtCore.SIGNAL("editingFinished()"),
+ self.alphaEditText)
+
+
+ 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")
+
+ # Accessor functions for Gui to manipulate system parameters
+ def set_sample_rate(self, sr):
+ ssr = eng_notation.num_to_str(sr)
+ self.gui.sampleRateEdit.setText(QtCore.QString("%1").arg(ssr))
+
+ def sampleRateEditText(self):
+ try:
+ rate = self.gui.sampleRateEdit.text().toAscii()
+ srate = eng_notation.str_to_num(rate)
+ self.fg.set_sample_rate(srate)
+ except RuntimeError:
+ pass
+
+
+ # Accessor functions for Gui to manipulate channel model
+ def set_snr(self, snr):
+ self.gui.snrEdit.setText(QtCore.QString("%1").arg(snr))
+
+ def set_frequency(self, fo):
+ self.gui.freqEdit.setText(QtCore.QString("%1").arg(fo))
+
+ def set_time_offset(self, to):
+ self.gui.timeEdit.setText(QtCore.QString("%1").arg(to))
+
+ def snrEditText(self):
+ try:
+ snr = self.gui.snrEdit.text().toDouble()[0]
+ self.fg.set_snr(snr)
+ except RuntimeError:
+ pass
+
+ def freqEditText(self):
+ try:
+ freq = self.gui.freqEdit.text().toDouble()[0]
+ self.fg.set_frequency_offset(freq)
+ except RuntimeError:
+ pass
+
+ def timeEditText(self):
+ try:
+ to = self.gui.timeEdit.text().toDouble()[0]
+ self.fg.set_timing_offset(to)
+ except RuntimeError:
+ pass
+
+
+ # Accessor functions for Gui to manipulate receiver parameters
+ def set_gain_mu(self, gain):
+ self.gui.gainMuEdit.setText(QtCore.QString("%1").arg(gain))
+
+ def set_alpha(self, alpha):
+ self.gui.alphaEdit.setText(QtCore.QString("%1").arg(alpha))
+
+ def alphaEditText(self):
+ try:
+ alpha = self.gui.alphaEdit.text().toDouble()[0]
+ self.fg.set_rx_alpha(alpha)
+ except RuntimeError:
+ pass
+
+ def gainMuEditText(self):
+ try:
+ gain = self.gui.gainMuEdit.text().toDouble()[0]
+ self.fg.set_rx_gain_mu(gain)
+ except RuntimeError:
+ pass
+
+
+class my_top_block(gr.top_block):
+ def __init__(self):
+ gr.top_block.__init__(self)
+
+ self.qapp = QtGui.QApplication(sys.argv)
+
+ self._sample_rate = 2000e3
+
+ self.sps = 2
+ self.excess_bw = 0.35
+ self.gray_code = True
+
+ fftsize = 2048
+
+ self.data = scipy.random.randint(0, 255, 1000)
+ self.src = gr.vector_source_b(self.data.tolist(), True)
+ self.mod = blks2.dqpsk_mod(self.sps, self.excess_bw, self.gray_code, False, False)
+
+ self.rrctaps = gr.firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 21)
+ self.rx_rrc = gr.fir_filter_ccf(1, self.rrctaps)
+
+
+ # Set up the carrier & clock recovery parameters
+ self.arity = 4
+ self.mu = 0.5
+ self.gain_mu = 0.05
+ self.omega = self.sps
+ self.gain_omega = .25 * self.gain_mu * self.gain_mu
+ self.omega_rel_lim = 0.05
+
+ self.alpha = 0.15
+ self.beta = 0.25 * self.alpha * self.alpha
+ self.fmin = -1000/self.sample_rate()
+ self.fmax = 1000/self.sample_rate()
+
+ self.receiver = gr.mpsk_receiver_cc(self.arity, 0,
+ self.alpha, self.beta,
+ self.fmin, self.fmax,
+ self.mu, self.gain_mu,
+ self.omega, self.gain_omega,
+ self.omega_rel_lim)
+
+
+ self.snr_dB = 15
+ noise = self.get_noise_voltage(self.snr_dB)
+ self.fo = 100/self.sample_rate()
+ self.to = 1.0
+ self.channel = gr.channel_model(noise, self.fo, self.to)
+
+ self.thr = gr.throttle(gr.sizeof_char, self._sample_rate)
+ self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
+ 0, self._sample_rate*self.sps,
+ "Tx", True, True, True, True)
+
+ self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
+ 0, self._sample_rate,
+ "Rx", True, True, True, True)
+
+ self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx)
+ self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx)
+
+ pyTxQt = self.snk_tx.pyqwidget()
+ pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget)
+
+ pyRxQt = self.snk_rx.pyqwidget()
+ pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget)
+
+ self.main_box = dialog_box(pyTx, pyRx, self);
+ self.main_box.show()
+
+
+ def get_noise_voltage(self, SNR):
+ S = 0 # dBm, assuming signal power normalized
+ N = S - SNR # dBm
+ npwr = pow(10.0, N/10.0) # ratio
+ nv = scipy.sqrt(npwr * self.sps) # convert the noise voltage
+ return nv
+
+
+ # System Parameters
+ def sample_rate(self):
+ return self._sample_rate
+
+ def set_sample_rate(self, sr):
+ self._sample_rate = sr
+
+
+ # Channel Model Parameters
+ def snr(self):
+ return self.snr_dB
+
+ def set_snr(self, snr):
+ self.snr_dB = snr
+ noise = self.get_noise_voltage(self.snr_dB)
+ self.channel.set_noise_voltage(noise)
+
+ def frequency_offset(self):
+ return self.fo * self.sample_rate()
+
+ def set_frequency_offset(self, fo):
+ self.fo = fo / self.sample_rate()
+ self.channel.set_frequency_offset(self.fo)
+
+ def timing_offset(self):
+ return self.to
+
+ def set_timing_offset(self, to):
+ self.to = to
+ self.channel.set_timing_offset(self.to)
+
+
+ # Receiver Parameters
+ def rx_gain_mu(self):
+ return self.gain_mu
+
+ def rx_gain_omega(self):
+ return self.gain_omega
+
+ def set_rx_gain_mu(self, gain):
+ self.gain_mu = gain
+ self.gain_omega = .25 * self.gain_mu * self.gain_mu
+ self.receiver.set_gain_mu(self.gain_mu)
+ self.receiver.set_gain_omega(self.gain_omega)
+
+ def rx_alpha(self):
+ return self.alpha
+
+ def rx_beta(self):
+ return self.beta
+
+ def set_rx_alpha(self, alpha):
+ self.alpha = alpha
+ self.beta = .25 * self.alpha * self.alpha
+ self.receiver.set_alpha(self.alpha)
+ self.receiver.set_beta(self.beta)
+
+
+if __name__ == "__main__":
+ tb = my_top_block();
+ tb.start()
+ tb.qapp.exec_()
+ tb.stop()
diff --git a/gr-qtgui/apps/qt_digital_window.py b/gr-qtgui/apps/qt_digital_window.py
new file mode 100644
index 000000000..50dd53a92
--- /dev/null
+++ b/gr-qtgui/apps/qt_digital_window.py
@@ -0,0 +1,161 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'qt_digital_window.ui'
+#
+# Created: Sat May 1 20:14:02 2010
+# by: PyQt4 UI code generator 4.6.1
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_DigitalWindow(object):
+ def setupUi(self, DigitalWindow):
+ DigitalWindow.setObjectName("DigitalWindow")
+ DigitalWindow.resize(1236, 741)
+ self.centralwidget = QtGui.QWidget(DigitalWindow)
+ self.centralwidget.setObjectName("centralwidget")
+ self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.sinkFrame = QtGui.QFrame(self.centralwidget)
+ self.sinkFrame.setMinimumSize(QtCore.QSize(0, 550))
+ self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel)
+ self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised)
+ self.sinkFrame.setObjectName("sinkFrame")
+ self.horizontalLayout_2 = QtGui.QHBoxLayout(self.sinkFrame)
+ self.horizontalLayout_2.setObjectName("horizontalLayout_2")
+ self.sinkLayout = QtGui.QHBoxLayout()
+ self.sinkLayout.setObjectName("sinkLayout")
+ self.horizontalLayout_2.addLayout(self.sinkLayout)
+ self.verticalLayout.addWidget(self.sinkFrame)
+ self.horizontalLayout = QtGui.QHBoxLayout()
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.sysBox = QtGui.QGroupBox(self.centralwidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth())
+ self.sysBox.setSizePolicy(sizePolicy)
+ self.sysBox.setMinimumSize(QtCore.QSize(0, 0))
+ self.sysBox.setMaximumSize(QtCore.QSize(16777215, 120))
+ self.sysBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
+ self.sysBox.setObjectName("sysBox")
+ self.gridLayout_2 = QtGui.QGridLayout(self.sysBox)
+ self.gridLayout_2.setObjectName("gridLayout_2")
+ self.sampleRateEdit = QtGui.QLineEdit(self.sysBox)
+ self.sampleRateEdit.setMaximumSize(QtCore.QSize(100, 16777215))
+ self.sampleRateEdit.setObjectName("sampleRateEdit")
+ self.gridLayout_2.addWidget(self.sampleRateEdit, 0, 3, 1, 1)
+ self.sampleRateLabel = QtGui.QLabel(self.sysBox)
+ self.sampleRateLabel.setObjectName("sampleRateLabel")
+ self.gridLayout_2.addWidget(self.sampleRateLabel, 0, 2, 1, 1)
+ self.horizontalLayout.addWidget(self.sysBox)
+ self.rxBox = QtGui.QGroupBox(self.centralwidget)
+ self.rxBox.setMaximumSize(QtCore.QSize(16777215, 120))
+ self.rxBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
+ self.rxBox.setObjectName("rxBox")
+ self.gridLayout_3 = QtGui.QGridLayout(self.rxBox)
+ self.gridLayout_3.setObjectName("gridLayout_3")
+ self.alphaLabel = QtGui.QLabel(self.rxBox)
+ self.alphaLabel.setObjectName("alphaLabel")
+ self.gridLayout_3.addWidget(self.alphaLabel, 1, 0, 1, 1)
+ self.alphaEdit = QtGui.QLineEdit(self.rxBox)
+ self.alphaEdit.setMaximumSize(QtCore.QSize(100, 16777215))
+ self.alphaEdit.setObjectName("alphaEdit")
+ self.gridLayout_3.addWidget(self.alphaEdit, 1, 1, 1, 1)
+ self.gainMuLabel = QtGui.QLabel(self.rxBox)
+ self.gainMuLabel.setObjectName("gainMuLabel")
+ self.gridLayout_3.addWidget(self.gainMuLabel, 0, 0, 1, 1)
+ self.gainMuEdit = QtGui.QLineEdit(self.rxBox)
+ self.gainMuEdit.setMaximumSize(QtCore.QSize(100, 16777215))
+ self.gainMuEdit.setObjectName("gainMuEdit")
+ self.gridLayout_3.addWidget(self.gainMuEdit, 0, 1, 1, 1)
+ self.horizontalLayout.addWidget(self.rxBox)
+ self.channelModeBox = QtGui.QGroupBox(self.centralwidget)
+ self.channelModeBox.setMaximumSize(QtCore.QSize(16777215, 120))
+ self.channelModeBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
+ self.channelModeBox.setObjectName("channelModeBox")
+ self.gridLayout = QtGui.QGridLayout(self.channelModeBox)
+ self.gridLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
+ self.gridLayout.setObjectName("gridLayout")
+ self.snrLabel = QtGui.QLabel(self.channelModeBox)
+ self.snrLabel.setObjectName("snrLabel")
+ self.gridLayout.addWidget(self.snrLabel, 0, 1, 1, 1)
+ self.snrEdit = QtGui.QLineEdit(self.channelModeBox)
+ self.snrEdit.setMaximumSize(QtCore.QSize(100, 16777215))
+ self.snrEdit.setObjectName("snrEdit")
+ self.gridLayout.addWidget(self.snrEdit, 0, 2, 1, 1)
+ self.freqLabel = QtGui.QLabel(self.channelModeBox)
+ self.freqLabel.setObjectName("freqLabel")
+ self.gridLayout.addWidget(self.freqLabel, 1, 1, 1, 1)
+ self.freqEdit = QtGui.QLineEdit(self.channelModeBox)
+ self.freqEdit.setMaximumSize(QtCore.QSize(100, 16777215))
+ self.freqEdit.setObjectName("freqEdit")
+ self.gridLayout.addWidget(self.freqEdit, 1, 2, 1, 1)
+ self.timeLabel = QtGui.QLabel(self.channelModeBox)
+ self.timeLabel.setObjectName("timeLabel")
+ self.gridLayout.addWidget(self.timeLabel, 2, 1, 1, 1)
+ self.timeEdit = QtGui.QLineEdit(self.channelModeBox)
+ self.timeEdit.setMaximumSize(QtCore.QSize(100, 16777215))
+ self.timeEdit.setObjectName("timeEdit")
+ self.gridLayout.addWidget(self.timeEdit, 2, 2, 1, 1)
+ self.horizontalLayout.addWidget(self.channelModeBox)
+ spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+ self.horizontalLayout.addItem(spacerItem)
+ self.verticalLayout_2 = QtGui.QVBoxLayout()
+ self.verticalLayout_2.setObjectName("verticalLayout_2")
+ spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.verticalLayout_2.addItem(spacerItem1)
+ self.pauseButton = QtGui.QPushButton(self.centralwidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth())
+ self.pauseButton.setSizePolicy(sizePolicy)
+ self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215))
+ self.pauseButton.setObjectName("pauseButton")
+ self.verticalLayout_2.addWidget(self.pauseButton)
+ self.closeButton = QtGui.QPushButton(self.centralwidget)
+ self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215))
+ self.closeButton.setObjectName("closeButton")
+ self.verticalLayout_2.addWidget(self.closeButton)
+ self.horizontalLayout.addLayout(self.verticalLayout_2)
+ self.verticalLayout.addLayout(self.horizontalLayout)
+ DigitalWindow.setCentralWidget(self.centralwidget)
+ self.menubar = QtGui.QMenuBar(DigitalWindow)
+ self.menubar.setGeometry(QtCore.QRect(0, 0, 1236, 23))
+ self.menubar.setObjectName("menubar")
+ self.menuFile = QtGui.QMenu(self.menubar)
+ self.menuFile.setObjectName("menuFile")
+ DigitalWindow.setMenuBar(self.menubar)
+ self.statusbar = QtGui.QStatusBar(DigitalWindow)
+ self.statusbar.setObjectName("statusbar")
+ DigitalWindow.setStatusBar(self.statusbar)
+ self.actionExit = QtGui.QAction(DigitalWindow)
+ self.actionExit.setObjectName("actionExit")
+ self.menuFile.addAction(self.actionExit)
+ self.menubar.addAction(self.menuFile.menuAction())
+
+ self.retranslateUi(DigitalWindow)
+ QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), DigitalWindow.close)
+ QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), DigitalWindow.close)
+ QtCore.QMetaObject.connectSlotsByName(DigitalWindow)
+ DigitalWindow.setTabOrder(self.snrEdit, self.freqEdit)
+ DigitalWindow.setTabOrder(self.freqEdit, self.timeEdit)
+
+ def retranslateUi(self, DigitalWindow):
+ DigitalWindow.setWindowTitle(QtGui.QApplication.translate("DigitalWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
+ self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8))
+ self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8))
+ self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8))
+ self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8))
+ self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8))
+ self.channelModeBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Channel Model Parameters", None, QtGui.QApplication.UnicodeUTF8))
+ self.snrLabel.setText(QtGui.QApplication.translate("DigitalWindow", "SNR (dB)", None, QtGui.QApplication.UnicodeUTF8))
+ self.freqLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Frequency Offset (Hz)", None, QtGui.QApplication.UnicodeUTF8))
+ self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8))
+ self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8))
+ self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8))
+ self.menuFile.setTitle(QtGui.QApplication.translate("DigitalWindow", "&File", None, QtGui.QApplication.UnicodeUTF8))
+ self.actionExit.setText(QtGui.QApplication.translate("DigitalWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8))
+
diff --git a/gr-qtgui/apps/qt_digital_window.ui b/gr-qtgui/apps/qt_digital_window.ui
new file mode 100644
index 000000000..967252181
--- /dev/null
+++ b/gr-qtgui/apps/qt_digital_window.ui
@@ -0,0 +1,342 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DigitalWindow</class>
+ <widget class="QMainWindow" name="DigitalWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1236</width>
+ <height>741</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QFrame" name="sinkFrame">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>550</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="sinkLayout"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QGroupBox" name="sysBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>120</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>System Parameters</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="3">
+ <widget class="QLineEdit" name="sampleRateEdit">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="sampleRateLabel">
+ <property name="text">
+ <string>Sample Rate (sps)</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="rxBox">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>120</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Receiver Parameters</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="1" column="0">
+ <widget class="QLabel" name="alphaLabel">
+ <property name="text">
+ <string>Alpha</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="alphaEdit">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="gainMuLabel">
+ <property name="text">
+ <string>Gain mu</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="gainMuEdit">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="channelModeBox">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>120</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Channel Model Parameters</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
+ <item row="0" column="1">
+ <widget class="QLabel" name="snrLabel">
+ <property name="text">
+ <string>SNR (dB)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLineEdit" name="snrEdit">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="freqLabel">
+ <property name="text">
+ <string>Frequency Offset (Hz)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLineEdit" name="freqEdit">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="timeLabel">
+ <property name="text">
+ <string>Timing Offset</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLineEdit" name="timeEdit">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pauseButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>80</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Pause</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeButton">
+ <property name="maximumSize">
+ <size>
+ <width>80</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1236</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>&amp;File</string>
+ </property>
+ <addaction name="actionExit"/>
+ </widget>
+ <addaction name="menuFile"/>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ <action name="actionExit">
+ <property name="text">
+ <string>E&amp;xit</string>
+ </property>
+ </action>
+ </widget>
+ <tabstops>
+ <tabstop>snrEdit</tabstop>
+ <tabstop>freqEdit</tabstop>
+ <tabstop>timeEdit</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>closeButton</sender>
+ <signal>clicked()</signal>
+ <receiver>DigitalWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>322</x>
+ <y>623</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>66</x>
+ <y>561</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionExit</sender>
+ <signal>triggered()</signal>
+ <receiver>DigitalWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>617</x>
+ <y>327</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/gr-qtgui/apps/uhd_display.py b/gr-qtgui/apps/uhd_display.py
new file mode 100755
index 000000000..d02fbad9e
--- /dev/null
+++ b/gr-qtgui/apps/uhd_display.py
@@ -0,0 +1,317 @@
+#!/usr/bin/env python
+#
+# Copyright 2009,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.
+#
+
+from gnuradio import gr
+from gnuradio import uhd
+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)
+
+ self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001))
+
+ # 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)
+
+ self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"),
+ self.dcGainEditText)
+ self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"),
+ self.dcCancelClicked)
+
+ 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 dcGainEditText(self):
+ gain = float(self.gui.dcGainEdit.text())
+ self.fg.set_dc_gain(gain)
+
+ def dcCancelClicked(self, state):
+ self.dcGainEditText()
+ self.fg.cancel_dc(state)
+
+
+
+class my_top_block(gr.top_block):
+ def __init__(self, options):
+ gr.top_block.__init__(self)
+
+ self.options = options
+ self.show_debug_info = True
+
+ self.qapp = QtGui.QApplication(sys.argv)
+
+ self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32'))
+
+ if(options.antenna):
+ self.u.set_antenna(options.antenna, 0)
+
+ 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.get_gain_range()
+ options.gain = float(g.start()+g.stop())/2
+ self.set_gain(options.gain)
+
+ if options.freq is None:
+ # 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)
+
+ self._fftsize = options.fft_size
+
+ self.snk = qtgui.sink_c(options.fft_size,
+ gr.firdes.WIN_BLACKMAN_hARRIS,
+ self._freq, self._bandwidth,
+ "UHD Display",
+ True, True, True, False)
+
+ # Set up internal amplifier
+ self.amp = gr.multiply_const_cc(0.0)
+ self.set_amplifier_gain(100)
+
+ # Create a single-pole IIR filter to remove DC
+ # but don't connect it yet
+ self.dc_gain = 0.001
+ self.dc = gr.single_pole_iir_filter_cc(self.dc_gain)
+ self.dc_sub = gr.sub_cc()
+
+ self.connect(self.u, self.amp, self.snk)
+
+ if self.show_debug_info:
+ 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
+ # 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):
+ self.lock()
+
+ # Add file sink to save data
+ self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name)
+ self.connect(self.amp, self.file_sink)
+
+ self.unlock()
+
+ def set_gain(self, gain):
+ self._gain = gain
+ self.u.set_gain(self._gain)
+
+ def set_frequency(self, freq):
+ self._freq = freq
+ r = self.u.set_center_freq(freq)
+
+ try:
+ self.snk.set_frequency_range(self._freq, self._bandwidth)
+ except:
+ pass
+
+ def set_bandwidth(self, bw):
+ self._bandwidth = bw
+ self.u.set_samp_rate(self._bandwidth)
+
+ 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)
+
+ def set_dc_gain(self, gain):
+ self.dc.set_taps(gain)
+
+ def cancel_dc(self, state):
+ self.lock()
+
+ if(state):
+ self.disconnect(self.u, self.amp)
+ self.connect(self.u, (self.dc_sub,0))
+ self.connect(self.u, self.dc, (self.dc_sub,1))
+ self.connect(self.dc_sub, self.amp)
+ else:
+ self.disconnect(self.dc_sub, self.amp)
+ self.disconnect(self.dc, (self.dc_sub,1))
+ self.disconnect(self.u, self.dc)
+ self.disconnect(self.u, (self.dc_sub,0))
+ self.connect(self.u, self.amp)
+
+ self.unlock()
+
+def main ():
+ 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_();
+
+if __name__ == '__main__':
+ try:
+ main ()
+ except KeyboardInterrupt:
+ pass
+
diff --git a/gr-qtgui/apps/usrp_display_qtgui.py b/gr-qtgui/apps/usrp_display_qtgui.py
new file mode 100644
index 000000000..4c9de3a53
--- /dev/null
+++ b/gr-qtgui/apps/usrp_display_qtgui.py
@@ -0,0 +1,191 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'usrp_display_qtgui.ui'
+#
+# Created: Thu Jul 16 22:06:24 2009
+# by: PyQt4 UI code generator 4.4.3
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_MainWindow(object):
+ def setupUi(self, MainWindow):
+ MainWindow.setObjectName("MainWindow")
+ MainWindow.resize(820, 774)
+ self.centralwidget = QtGui.QWidget(MainWindow)
+ self.centralwidget.setObjectName("centralwidget")
+ self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget)
+ self.gridLayout_2.setObjectName("gridLayout_2")
+ self.horizontalLayout_2 = QtGui.QHBoxLayout()
+ self.horizontalLayout_2.setObjectName("horizontalLayout_2")
+ self.groupBox = QtGui.QGroupBox(self.centralwidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
+ self.groupBox.setSizePolicy(sizePolicy)
+ self.groupBox.setMinimumSize(QtCore.QSize(240, 150))
+ self.groupBox.setMaximumSize(QtCore.QSize(240, 16777215))
+ self.groupBox.setObjectName("groupBox")
+ self.formLayoutWidget = QtGui.QWidget(self.groupBox)
+ self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 221, 124))
+ self.formLayoutWidget.setObjectName("formLayoutWidget")
+ self.formLayout = QtGui.QFormLayout(self.formLayoutWidget)
+ self.formLayout.setObjectName("formLayout")
+ self.frequencyLabel = QtGui.QLabel(self.formLayoutWidget)
+ self.frequencyLabel.setObjectName("frequencyLabel")
+ self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.frequencyLabel)
+ self.gainLabel = QtGui.QLabel(self.formLayoutWidget)
+ self.gainLabel.setObjectName("gainLabel")
+ self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.gainLabel)
+ self.bandwidthLabel = QtGui.QLabel(self.formLayoutWidget)
+ self.bandwidthLabel.setObjectName("bandwidthLabel")
+ self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.bandwidthLabel)
+ self.frequencyEdit = QtGui.QLineEdit(self.formLayoutWidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.frequencyEdit.sizePolicy().hasHeightForWidth())
+ self.frequencyEdit.setSizePolicy(sizePolicy)
+ self.frequencyEdit.setMinimumSize(QtCore.QSize(120, 26))
+ self.frequencyEdit.setObjectName("frequencyEdit")
+ self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.frequencyEdit)
+ self.gainEdit = QtGui.QLineEdit(self.formLayoutWidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.gainEdit.sizePolicy().hasHeightForWidth())
+ self.gainEdit.setSizePolicy(sizePolicy)
+ self.gainEdit.setMinimumSize(QtCore.QSize(120, 26))
+ self.gainEdit.setObjectName("gainEdit")
+ self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.gainEdit)
+ self.bandwidthEdit = QtGui.QLineEdit(self.formLayoutWidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.bandwidthEdit.sizePolicy().hasHeightForWidth())
+ self.bandwidthEdit.setSizePolicy(sizePolicy)
+ self.bandwidthEdit.setMinimumSize(QtCore.QSize(120, 26))
+ self.bandwidthEdit.setObjectName("bandwidthEdit")
+ self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.bandwidthEdit)
+ self.amplifierLabel = QtGui.QLabel(self.formLayoutWidget)
+ self.amplifierLabel.setObjectName("amplifierLabel")
+ self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.amplifierLabel)
+ self.amplifierEdit = QtGui.QLineEdit(self.formLayoutWidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.amplifierEdit.sizePolicy().hasHeightForWidth())
+ self.amplifierEdit.setSizePolicy(sizePolicy)
+ self.amplifierEdit.setMinimumSize(QtCore.QSize(120, 26))
+ self.amplifierEdit.setObjectName("amplifierEdit")
+ self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.amplifierEdit)
+ self.horizontalLayout_2.addWidget(self.groupBox)
+ self.frame_2 = QtGui.QFrame(self.centralwidget)
+ self.frame_2.setMinimumSize(QtCore.QSize(200, 0))
+ self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel)
+ self.frame_2.setFrameShadow(QtGui.QFrame.Raised)
+ self.frame_2.setObjectName("frame_2")
+ self.verticalLayoutWidget = QtGui.QWidget(self.frame_2)
+ self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, -1, 191, 151))
+ self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
+ self.verticalLayout_3 = QtGui.QVBoxLayout(self.verticalLayoutWidget)
+ self.verticalLayout_3.setObjectName("verticalLayout_3")
+ self.dcCancelCheckBox = QtGui.QCheckBox(self.verticalLayoutWidget)
+ self.dcCancelCheckBox.setObjectName("dcCancelCheckBox")
+ self.verticalLayout_3.addWidget(self.dcCancelCheckBox)
+ self.horizontalLayout = QtGui.QHBoxLayout()
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.dcGainLabel = QtGui.QLabel(self.verticalLayoutWidget)
+ self.dcGainLabel.setObjectName("dcGainLabel")
+ self.horizontalLayout.addWidget(self.dcGainLabel)
+ self.dcGainEdit = QtGui.QLineEdit(self.verticalLayoutWidget)
+ self.dcGainEdit.setObjectName("dcGainEdit")
+ self.horizontalLayout.addWidget(self.dcGainEdit)
+ self.verticalLayout_3.addLayout(self.horizontalLayout)
+ spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.verticalLayout_3.addItem(spacerItem)
+ self.horizontalLayout_2.addWidget(self.frame_2)
+ spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+ self.horizontalLayout_2.addItem(spacerItem1)
+ self.verticalLayout = QtGui.QVBoxLayout()
+ self.verticalLayout.setObjectName("verticalLayout")
+ spacerItem2 = QtGui.QSpacerItem(20, 80, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
+ self.verticalLayout.addItem(spacerItem2)
+ self.pauseButton = QtGui.QPushButton(self.centralwidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth())
+ self.pauseButton.setSizePolicy(sizePolicy)
+ self.pauseButton.setObjectName("pauseButton")
+ self.verticalLayout.addWidget(self.pauseButton)
+ self.closeButton = QtGui.QPushButton(self.centralwidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.closeButton.sizePolicy().hasHeightForWidth())
+ self.closeButton.setSizePolicy(sizePolicy)
+ self.closeButton.setMinimumSize(QtCore.QSize(75, 0))
+ self.closeButton.setObjectName("closeButton")
+ self.verticalLayout.addWidget(self.closeButton)
+ self.horizontalLayout_2.addLayout(self.verticalLayout)
+ self.gridLayout_2.addLayout(self.horizontalLayout_2, 1, 0, 1, 1)
+ self.verticalLayout_2 = QtGui.QVBoxLayout()
+ self.verticalLayout_2.setObjectName("verticalLayout_2")
+ self.frame = QtGui.QFrame(self.centralwidget)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(1)
+ sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth())
+ self.frame.setSizePolicy(sizePolicy)
+ self.frame.setMinimumSize(QtCore.QSize(800, 550))
+ self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
+ self.frame.setFrameShadow(QtGui.QFrame.Raised)
+ self.frame.setObjectName("frame")
+ self.gridLayout = QtGui.QGridLayout(self.frame)
+ self.gridLayout.setObjectName("gridLayout")
+ self.sinkLayout = QtGui.QHBoxLayout()
+ self.sinkLayout.setObjectName("sinkLayout")
+ self.gridLayout.addLayout(self.sinkLayout, 0, 0, 1, 1)
+ self.verticalLayout_2.addWidget(self.frame)
+ self.gridLayout_2.addLayout(self.verticalLayout_2, 0, 0, 1, 1)
+ MainWindow.setCentralWidget(self.centralwidget)
+ self.menubar = QtGui.QMenuBar(MainWindow)
+ self.menubar.setGeometry(QtCore.QRect(0, 0, 820, 24))
+ self.menubar.setObjectName("menubar")
+ self.menuFile = QtGui.QMenu(self.menubar)
+ self.menuFile.setObjectName("menuFile")
+ MainWindow.setMenuBar(self.menubar)
+ self.statusbar = QtGui.QStatusBar(MainWindow)
+ self.statusbar.setObjectName("statusbar")
+ MainWindow.setStatusBar(self.statusbar)
+ self.actionExit = QtGui.QAction(MainWindow)
+ self.actionExit.setObjectName("actionExit")
+ self.actionSaveData = QtGui.QAction(MainWindow)
+ self.actionSaveData.setObjectName("actionSaveData")
+ self.menuFile.addAction(self.actionSaveData)
+ self.menuFile.addAction(self.actionExit)
+ self.menubar.addAction(self.menuFile.menuAction())
+
+ self.retranslateUi(MainWindow)
+ QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), MainWindow.close)
+ QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), MainWindow.close)
+ QtCore.QMetaObject.connectSlotsByName(MainWindow)
+
+ def retranslateUi(self, MainWindow):
+ MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "USRP Display", None, QtGui.QApplication.UnicodeUTF8))
+ self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8))
+ self.frequencyLabel.setText(QtGui.QApplication.translate("MainWindow", "Frequency (Hz)", None, QtGui.QApplication.UnicodeUTF8))
+ self.gainLabel.setText(QtGui.QApplication.translate("MainWindow", "RF Gain", None, QtGui.QApplication.UnicodeUTF8))
+ self.bandwidthLabel.setText(QtGui.QApplication.translate("MainWindow", "Bandwidth", None, QtGui.QApplication.UnicodeUTF8))
+ self.amplifierLabel.setText(QtGui.QApplication.translate("MainWindow", "Amplifier", None, QtGui.QApplication.UnicodeUTF8))
+ self.dcCancelCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Cancel DC", None, QtGui.QApplication.UnicodeUTF8))
+ self.dcGainLabel.setText(QtGui.QApplication.translate("MainWindow", "DC Canceller Gain", None, QtGui.QApplication.UnicodeUTF8))
+ self.pauseButton.setText(QtGui.QApplication.translate("MainWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8))
+ self.closeButton.setText(QtGui.QApplication.translate("MainWindow", "Close", None, QtGui.QApplication.UnicodeUTF8))
+ self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8))
+ self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8))
+ self.actionSaveData.setText(QtGui.QApplication.translate("MainWindow", "&Save Data", None, QtGui.QApplication.UnicodeUTF8))
+
diff --git a/gr-qtgui/apps/usrp_display_qtgui.ui b/gr-qtgui/apps/usrp_display_qtgui.ui
new file mode 100644
index 000000000..e88ca9dce
--- /dev/null
+++ b/gr-qtgui/apps/usrp_display_qtgui.ui
@@ -0,0 +1,375 @@
+<ui version="4.0" >
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>820</width>
+ <height>774</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>USRP Display</string>
+ </property>
+ <widget class="QWidget" name="centralwidget" >
+ <layout class="QGridLayout" name="gridLayout_2" >
+ <item row="1" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>240</width>
+ <height>150</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>240</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="title" >
+ <string>Receiver Parameters</string>
+ </property>
+ <widget class="QWidget" name="formLayoutWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>221</width>
+ <height>124</height>
+ </rect>
+ </property>
+ <layout class="QFormLayout" name="formLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="frequencyLabel" >
+ <property name="text" >
+ <string>Frequency (Hz)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="gainLabel" >
+ <property name="text" >
+ <string>RF Gain</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="bandwidthLabel" >
+ <property name="text" >
+ <string>Bandwidth</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="frequencyEdit" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>120</width>
+ <height>26</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLineEdit" name="gainEdit" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>120</width>
+ <height>26</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QLineEdit" name="bandwidthEdit" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>120</width>
+ <height>26</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="amplifierLabel" >
+ <property name="text" >
+ <string>Amplifier</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QLineEdit" name="amplifierEdit" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>120</width>
+ <height>26</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QFrame" name="frame_2" >
+ <property name="minimumSize" >
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QWidget" name="verticalLayoutWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>-1</y>
+ <width>191</width>
+ <height>151</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3" >
+ <item>
+ <widget class="QCheckBox" name="dcCancelCheckBox" >
+ <property name="text" >
+ <string>Cancel DC</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QLabel" name="dcGainLabel" >
+ <property name="text" >
+ <string>DC Canceller Gain</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="dcGainEdit" />
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>80</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pauseButton" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Pause</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeButton" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>75</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0" >
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QFrame" name="frame" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>800</width>
+ <height>550</height>
+ </size>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" name="sinkLayout" />
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>820</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile" >
+ <property name="title" >
+ <string>&amp;File</string>
+ </property>
+ <addaction name="actionSaveData" />
+ <addaction name="actionExit" />
+ </widget>
+ <addaction name="menuFile" />
+ </widget>
+ <widget class="QStatusBar" name="statusbar" />
+ <action name="actionExit" >
+ <property name="text" >
+ <string>E&amp;xit</string>
+ </property>
+ </action>
+ <action name="actionSaveData" >
+ <property name="text" >
+ <string>&amp;Save Data</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>closeButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>808</x>
+ <y>739</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>66</x>
+ <y>561</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionExit</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>617</x>
+ <y>327</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/gr-qtgui/doc/CMakeLists.txt b/gr-qtgui/doc/CMakeLists.txt
new file mode 100644
index 000000000..668ed59f5
--- /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/README.qtgui b/gr-qtgui/doc/README.qtgui
new file mode 100644
index 000000000..b5b523bf6
--- /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..8664af163
--- /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/CMakeLists.txt b/gr-qtgui/examples/CMakeLists.txt
new file mode 100644
index 000000000..998d17bd9
--- /dev/null
+++ b/gr-qtgui/examples/CMakeLists.txt
@@ -0,0 +1,29 @@
+# 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(GrPython)
+
+GR_PYTHON_INSTALL(PROGRAMS
+ pyqt_example_c.py
+ pyqt_example_f.py
+ pyqt_time_c.py
+ pyqt_time_f.py
+ DESTINATION ${GR_PKG_QTGUI_EXAMPLES_DIR}
+ COMPONENT "qtgui_python"
+)
diff --git a/gr-qtgui/examples/pyqt_example_c.py b/gr-qtgui/examples/pyqt_example_c.py
new file mode 100755
index 000000000..0b43fce0e
--- /dev/null
+++ b/gr-qtgui/examples/pyqt_example_c.py
@@ -0,0 +1,176 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+from gnuradio import gr
+import sys
+
+try:
+ from gnuradio import qtgui
+ from PyQt4 import QtGui, QtCore
+ import sip
+except ImportError:
+ print "Error: Program requires PyQt4 and gr-qtgui."
+ sys.exit(1)
+
+class dialog_box(QtGui.QWidget):
+ def __init__(self, display, control):
+ QtGui.QWidget.__init__(self, None)
+ self.setWindowTitle('PyQt Test GUI')
+
+ self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
+ self.boxlayout.addWidget(display, 1)
+ self.boxlayout.addWidget(control)
+
+ self.resize(800, 500)
+
+class control_box(QtGui.QWidget):
+ def __init__(self, parent=None):
+ QtGui.QWidget.__init__(self, parent)
+ self.setWindowTitle('Control Panel')
+
+ self.setToolTip('Control the signals')
+ QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
+
+ self.layout = QtGui.QFormLayout(self)
+
+ # Control the first signal
+ self.freq1Edit = QtGui.QLineEdit(self)
+ self.freq1Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 1 Frequency:", self.freq1Edit)
+ self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"),
+ self.freq1EditText)
+
+ self.amp1Edit = QtGui.QLineEdit(self)
+ self.amp1Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit)
+ self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"),
+ self.amp1EditText)
+
+
+ # Control the second signal
+ self.freq2Edit = QtGui.QLineEdit(self)
+ self.freq2Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 2 Frequency:", self.freq2Edit)
+ self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"),
+ self.freq2EditText)
+
+
+ self.amp2Edit = QtGui.QLineEdit(self)
+ self.amp2Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit)
+ self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"),
+ self.amp2EditText)
+
+ self.quit = QtGui.QPushButton('Close', self)
+ self.quit.setMinimumWidth(100)
+ self.layout.addWidget(self.quit)
+
+ self.connect(self.quit, QtCore.SIGNAL('clicked()'),
+ QtGui.qApp, QtCore.SLOT('quit()'))
+
+ def attach_signal1(self, signal):
+ self.signal1 = signal
+ self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency()))
+ self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude()))
+
+ def attach_signal2(self, signal):
+ self.signal2 = signal
+ self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency()))
+ self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude()))
+
+ def freq1EditText(self):
+ try:
+ newfreq = float(self.freq1Edit.text())
+ self.signal1.set_frequency(newfreq)
+ except ValueError:
+ print "Bad frequency value entered"
+
+ def amp1EditText(self):
+ try:
+ newamp = float(self.amp1Edit.text())
+ self.signal1.set_amplitude(newamp)
+ except ValueError:
+ print "Bad amplitude value entered"
+
+
+ def freq2EditText(self):
+ try:
+ newfreq = float(self.freq2Edit.text())
+ self.signal2.set_frequency(newfreq)
+ except ValueError:
+ print "Bad frequency value entered"
+
+ def amp2EditText(self):
+ try:
+ newamp = float(self.amp2Edit.text())
+ self.signal2.set_amplitude(newamp)
+ except ValueError:
+ print "Bad amplitude value entered"
+
+
+class my_top_block(gr.top_block):
+ def __init__(self):
+ gr.top_block.__init__(self)
+
+ Rs = 8000
+ f1 = 1000
+ f2 = 2000
+
+ fftsize = 2048
+
+ self.qapp = QtGui.QApplication(sys.argv)
+
+ src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
+ src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
+ src = gr.add_cc()
+ channel = gr.channel_model(0.001)
+ thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize)
+ self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
+ 0, Rs,
+ "Complex Signal Example",
+ True, True, True, False)
+
+ self.connect(src1, (src,0))
+ self.connect(src2, (src,1))
+ self.connect(src, channel, thr, self.snk1)
+
+ self.ctrl_win = control_box()
+ self.ctrl_win.attach_signal1(src1)
+ self.ctrl_win.attach_signal2(src2)
+
+ # Get the reference pointer to the SpectrumDisplayForm QWidget
+ pyQt = self.snk1.pyqwidget()
+
+ # Wrap the pointer as a PyQt SIP object
+ # This can now be manipulated as a PyQt4.QtGui.QWidget
+ pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
+
+ self.main_box = dialog_box(pyWin, self.ctrl_win)
+
+ self.main_box.show()
+
+if __name__ == "__main__":
+ tb = my_top_block();
+ tb.start()
+ tb.qapp.exec_()
+ tb.stop()
+
diff --git a/gr-qtgui/examples/pyqt_example_f.py b/gr-qtgui/examples/pyqt_example_f.py
new file mode 100755
index 000000000..d00011f40
--- /dev/null
+++ b/gr-qtgui/examples/pyqt_example_f.py
@@ -0,0 +1,178 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+from gnuradio import gr
+import sys
+
+try:
+ from gnuradio import qtgui
+ from PyQt4 import QtGui, QtCore
+ import sip
+except ImportError:
+ print "Error: Program requires PyQt4 and gr-qtgui."
+ sys.exit(1)
+
+class dialog_box(QtGui.QWidget):
+ def __init__(self, display, control):
+ QtGui.QWidget.__init__(self, None)
+ self.setWindowTitle('PyQt Test GUI')
+
+ self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
+ self.boxlayout.addWidget(display, 1)
+ self.boxlayout.addWidget(control)
+
+ self.resize(800, 500)
+
+class control_box(QtGui.QWidget):
+ def __init__(self, parent=None):
+ QtGui.QWidget.__init__(self, parent)
+ self.setWindowTitle('Control Panel')
+
+ self.setToolTip('Control the signals')
+ QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
+
+ self.layout = QtGui.QFormLayout(self)
+
+ # Control the first signal
+ self.freq1Edit = QtGui.QLineEdit(self)
+ self.freq1Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 1 Frequency:", self.freq1Edit)
+ self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"),
+ self.freq1EditText)
+
+ self.amp1Edit = QtGui.QLineEdit(self)
+ self.amp1Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit)
+ self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"),
+ self.amp1EditText)
+
+
+ # Control the second signal
+ self.freq2Edit = QtGui.QLineEdit(self)
+ self.freq2Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 2 Frequency:", self.freq2Edit)
+ self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"),
+ self.freq2EditText)
+
+
+ self.amp2Edit = QtGui.QLineEdit(self)
+ self.amp2Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit)
+ self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"),
+ self.amp2EditText)
+
+ self.quit = QtGui.QPushButton('Close', self)
+ self.quit.setMinimumWidth(100)
+ self.layout.addWidget(self.quit)
+
+ self.connect(self.quit, QtCore.SIGNAL('clicked()'),
+ QtGui.qApp, QtCore.SLOT('quit()'))
+
+ def attach_signal1(self, signal):
+ self.signal1 = signal
+ self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency()))
+ self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude()))
+
+ def attach_signal2(self, signal):
+ self.signal2 = signal
+ self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency()))
+ self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude()))
+
+ def freq1EditText(self):
+ try:
+ newfreq = float(self.freq1Edit.text())
+ self.signal1.set_frequency(newfreq)
+ except ValueError:
+ print "Bad frequency value entered"
+
+ def amp1EditText(self):
+ try:
+ newamp = float(self.amp1Edit.text())
+ self.signal1.set_amplitude(newamp)
+ except ValueError:
+ print "Bad amplitude value entered"
+
+
+ def freq2EditText(self):
+ try:
+ newfreq = float(self.freq2Edit.text())
+ self.signal2.set_frequency(newfreq)
+ except ValueError:
+ print "Bad frequency value entered"
+
+ def amp2EditText(self):
+ try:
+ newamp = float(self.amp2Edit.text())
+ self.signal2.set_amplitude(newamp)
+ except ValueError:
+ print "Bad amplitude value entered"
+
+
+class my_top_block(gr.top_block):
+ def __init__(self):
+ gr.top_block.__init__(self)
+
+ Rs = 8000
+ f1 = 1000
+ f2 = 2000
+
+ fftsize = 2048
+
+ self.qapp = QtGui.QApplication(sys.argv)
+
+ src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
+ src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
+ src = gr.add_ff()
+ thr = gr.throttle(gr.sizeof_float, 100*fftsize)
+ noise = gr.noise_source_f(gr.GR_GAUSSIAN, 0.001)
+ add = gr.add_ff()
+ self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
+ 0, Rs,
+ "Float Signal Example",
+ True, True, True, False)
+
+ self.connect(src1, (src,0))
+ self.connect(src2, (src,1))
+ self.connect(src, thr, (add,0))
+ self.connect(noise, (add,1))
+ self.connect(add, self.snk1)
+
+ self.ctrl_win = control_box()
+ self.ctrl_win.attach_signal1(src1)
+ self.ctrl_win.attach_signal2(src2)
+
+ # Get the reference pointer to the SpectrumDisplayForm QWidget
+ pyQt = self.snk1.pyqwidget()
+
+ # Wrap the pointer as a PyQt SIP object
+ # This can now be manipulated as a PyQt4.QtGui.QWidget
+ pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
+
+ self.main_box = dialog_box(pyWin, self.ctrl_win)
+
+ self.main_box.show()
+
+if __name__ == "__main__":
+ tb = my_top_block();
+ tb.start()
+ tb.qapp.exec_()
+ tb.stop()
diff --git a/gr-qtgui/examples/pyqt_time_c.py b/gr-qtgui/examples/pyqt_time_c.py
new file mode 100755
index 000000000..04425e11f
--- /dev/null
+++ b/gr-qtgui/examples/pyqt_time_c.py
@@ -0,0 +1,189 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+from gnuradio import gr
+import sys
+
+try:
+ from gnuradio import qtgui
+ from PyQt4 import QtGui, QtCore
+ import sip
+except ImportError:
+ print "Error: Program requires PyQt4 and gr-qtgui."
+ sys.exit(1)
+
+class dialog_box(QtGui.QWidget):
+ def __init__(self, display, control):
+ QtGui.QWidget.__init__(self, None)
+ self.setWindowTitle('PyQt Test GUI')
+
+ self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
+ self.boxlayout.addWidget(display, 1)
+ self.boxlayout.addWidget(control)
+
+ self.resize(800, 500)
+
+class control_box(QtGui.QWidget):
+ def __init__(self, parent=None):
+ QtGui.QWidget.__init__(self, parent)
+ self.setWindowTitle('Control Panel')
+
+ self.setToolTip('Control the signals')
+ QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
+
+ self.layout = QtGui.QFormLayout(self)
+
+ # Control the first signal
+ self.freq1Edit = QtGui.QLineEdit(self)
+ self.freq1Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 1 Frequency:", self.freq1Edit)
+ self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"),
+ self.freq1EditText)
+
+ self.amp1Edit = QtGui.QLineEdit(self)
+ self.amp1Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit)
+ self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"),
+ self.amp1EditText)
+
+
+ # Control the second signal
+ self.freq2Edit = QtGui.QLineEdit(self)
+ self.freq2Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 2 Frequency:", self.freq2Edit)
+ self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"),
+ self.freq2EditText)
+
+
+ self.amp2Edit = QtGui.QLineEdit(self)
+ self.amp2Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit)
+ self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"),
+ self.amp2EditText)
+
+ self.quit = QtGui.QPushButton('Close', self)
+ self.quit.setMinimumWidth(100)
+ self.layout.addWidget(self.quit)
+
+ self.connect(self.quit, QtCore.SIGNAL('clicked()'),
+ QtGui.qApp, QtCore.SLOT('quit()'))
+
+ def attach_signal1(self, signal):
+ self.signal1 = signal
+ self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency()))
+ self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude()))
+
+ def attach_signal2(self, signal):
+ self.signal2 = signal
+ self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency()))
+ self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude()))
+
+ def freq1EditText(self):
+ try:
+ newfreq = float(self.freq1Edit.text())
+ self.signal1.set_frequency(newfreq)
+ except ValueError:
+ print "Bad frequency value entered"
+
+ def amp1EditText(self):
+ try:
+ newamp = float(self.amp1Edit.text())
+ self.signal1.set_amplitude(newamp)
+ except ValueError:
+ print "Bad amplitude value entered"
+
+
+ def freq2EditText(self):
+ try:
+ newfreq = float(self.freq2Edit.text())
+ self.signal2.set_frequency(newfreq)
+ except ValueError:
+ print "Bad frequency value entered"
+
+ def amp2EditText(self):
+ try:
+ newamp = float(self.amp2Edit.text())
+ self.signal2.set_amplitude(newamp)
+ except ValueError:
+ print "Bad amplitude value entered"
+
+
+class my_top_block(gr.top_block):
+ def __init__(self):
+ gr.top_block.__init__(self)
+
+ Rs = 8000
+ f1 = 100
+ f2 = 200
+
+ npts = 2048
+
+ self.qapp = QtGui.QApplication(sys.argv)
+
+ src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
+ src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
+ src = gr.add_cc()
+ channel = gr.channel_model(0.01)
+ thr = gr.throttle(gr.sizeof_gr_complex, 100*npts)
+ self.snk1 = qtgui.time_sink_c(npts, Rs,
+ "Complex Time Example", 3)
+
+ self.connect(src1, (src,0))
+ self.connect(src2, (src,1))
+ self.connect(src, channel, thr, (self.snk1, 0))
+ self.connect(src1, (self.snk1, 1))
+ self.connect(src2, (self.snk1, 2))
+
+ self.ctrl_win = control_box()
+ self.ctrl_win.attach_signal1(src1)
+ self.ctrl_win.attach_signal2(src2)
+
+ # Get the reference pointer to the SpectrumDisplayForm QWidget
+ pyQt = self.snk1.pyqwidget()
+
+ # Wrap the pointer as a PyQt SIP object
+ # This can now be manipulated as a PyQt4.QtGui.QWidget
+ pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
+
+ # Example of using signal/slot to set the title of a curve
+ pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"),
+ pyWin, QtCore.SLOT("setTitle(int, QString)"))
+ pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "Re{sum}")
+ self.snk1.set_title(1, "Im{Sum}")
+ self.snk1.set_title(2, "Re{src1}")
+ self.snk1.set_title(3, "Im{src1}")
+ self.snk1.set_title(4, "Re{src2}")
+ self.snk1.set_title(5, "Im{src2}")
+
+ # Can also set the color of a curve
+ #self.snk1.set_color(5, "blue")
+
+ #pyWin.show()
+ self.main_box = dialog_box(pyWin, self.ctrl_win)
+ self.main_box.show()
+
+if __name__ == "__main__":
+ tb = my_top_block();
+ tb.start()
+ tb.qapp.exec_()
+ tb.stop()
+
diff --git a/gr-qtgui/examples/pyqt_time_f.py b/gr-qtgui/examples/pyqt_time_f.py
new file mode 100755
index 000000000..464d8939b
--- /dev/null
+++ b/gr-qtgui/examples/pyqt_time_f.py
@@ -0,0 +1,189 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+from gnuradio import gr
+import sys
+
+try:
+ from gnuradio import qtgui
+ from PyQt4 import QtGui, QtCore
+ import sip
+except ImportError:
+ print "Error: Program requires PyQt4 and gr-qtgui."
+ sys.exit(1)
+
+class dialog_box(QtGui.QWidget):
+ def __init__(self, display, control):
+ QtGui.QWidget.__init__(self, None)
+ self.setWindowTitle('PyQt Test GUI')
+
+ self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
+ self.boxlayout.addWidget(display, 1)
+ self.boxlayout.addWidget(control)
+
+ self.resize(800, 500)
+
+class control_box(QtGui.QWidget):
+ def __init__(self, parent=None):
+ QtGui.QWidget.__init__(self, parent)
+ self.setWindowTitle('Control Panel')
+
+ self.setToolTip('Control the signals')
+ QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
+
+ self.layout = QtGui.QFormLayout(self)
+
+ # Control the first signal
+ self.freq1Edit = QtGui.QLineEdit(self)
+ self.freq1Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 1 Frequency:", self.freq1Edit)
+ self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"),
+ self.freq1EditText)
+
+ self.amp1Edit = QtGui.QLineEdit(self)
+ self.amp1Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit)
+ self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"),
+ self.amp1EditText)
+
+
+ # Control the second signal
+ self.freq2Edit = QtGui.QLineEdit(self)
+ self.freq2Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 2 Frequency:", self.freq2Edit)
+ self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"),
+ self.freq2EditText)
+
+
+ self.amp2Edit = QtGui.QLineEdit(self)
+ self.amp2Edit.setMinimumWidth(100)
+ self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit)
+ self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"),
+ self.amp2EditText)
+
+ self.quit = QtGui.QPushButton('Close', self)
+ self.quit.setMinimumWidth(100)
+ self.layout.addWidget(self.quit)
+
+ self.connect(self.quit, QtCore.SIGNAL('clicked()'),
+ QtGui.qApp, QtCore.SLOT('quit()'))
+
+ def attach_signal1(self, signal):
+ self.signal1 = signal
+ self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency()))
+ self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude()))
+
+ def attach_signal2(self, signal):
+ self.signal2 = signal
+ self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency()))
+ self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude()))
+
+ def freq1EditText(self):
+ try:
+ newfreq = float(self.freq1Edit.text())
+ self.signal1.set_frequency(newfreq)
+ except ValueError:
+ print "Bad frequency value entered"
+
+ def amp1EditText(self):
+ try:
+ newamp = float(self.amp1Edit.text())
+ self.signal1.set_amplitude(newamp)
+ except ValueError:
+ print "Bad amplitude value entered"
+
+
+ def freq2EditText(self):
+ try:
+ newfreq = float(self.freq2Edit.text())
+ self.signal2.set_frequency(newfreq)
+ except ValueError:
+ print "Bad frequency value entered"
+
+ def amp2EditText(self):
+ try:
+ newamp = float(self.amp2Edit.text())
+ self.signal2.set_amplitude(newamp)
+ except ValueError:
+ print "Bad amplitude value entered"
+
+
+class my_top_block(gr.top_block):
+ def __init__(self):
+ gr.top_block.__init__(self)
+
+ Rs = 8000
+ f1 = 100
+ f2 = 200
+
+ npts = 2048
+
+ self.qapp = QtGui.QApplication(sys.argv)
+
+ src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
+ src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
+ src = gr.add_ff()
+ thr = gr.throttle(gr.sizeof_float, 100*npts)
+ noise = gr.noise_source_f(gr.GR_GAUSSIAN, 0.001)
+ add = gr.add_ff()
+ self.snk1 = qtgui.time_sink_f(npts, Rs,
+ "Complex Time Example", 3)
+
+ self.connect(src1, (src,0))
+ self.connect(src2, (src,1))
+ self.connect(src, thr, (add,0))
+ self.connect(noise, (add,1))
+ self.connect(add, self.snk1)
+ self.connect(src1, (self.snk1, 1))
+ self.connect(src2, (self.snk1, 2))
+
+ self.ctrl_win = control_box()
+ self.ctrl_win.attach_signal1(src1)
+ self.ctrl_win.attach_signal2(src2)
+
+ # Get the reference pointer to the SpectrumDisplayForm QWidget
+ pyQt = self.snk1.pyqwidget()
+
+ # Wrap the pointer as a PyQt SIP object
+ # This can now be manipulated as a PyQt4.QtGui.QWidget
+ pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
+
+ # Example of using signal/slot to set the title of a curve
+ pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"),
+ pyWin, QtCore.SLOT("setTitle(int, QString)"))
+ pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "sum")
+ self.snk1.set_title(1, "src1")
+ self.snk1.set_title(2, "src2")
+
+ # Can also set the color of a curve
+ #self.snk1.set_color(5, "blue")
+
+ #pyWin.show()
+ self.main_box = dialog_box(pyWin, self.ctrl_win)
+ self.main_box.show()
+
+if __name__ == "__main__":
+ tb = my_top_block();
+ tb.start()
+ tb.qapp.exec_()
+ tb.stop()
+
diff --git a/gr-qtgui/gnuradio-qtgui.pc.in b/gr-qtgui/gnuradio-qtgui.pc.in
new file mode 100644
index 000000000..27b6a21bf
--- /dev/null
+++ b/gr-qtgui/gnuradio-qtgui.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: gnuradio-qtgui
+Description: GNU Radio blocks for QT GUI
+Requires: gnuradio-core
+Version: @LIBVER@
+Libs: -L${libdir} -lgnuradio-qtgui
+Cflags: -I${includedir}
diff --git a/gr-qtgui/grc/CMakeLists.txt b/gr-qtgui/grc/CMakeLists.txt
new file mode 100644
index 000000000..d56158ac7
--- /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_check_box.xml b/gr-qtgui/grc/qtgui_check_box.xml
new file mode 100644
index 000000000..95f4f968a
--- /dev/null
+++ b/gr-qtgui/grc/qtgui_check_box.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Variable Check Box:
+## a gui check box form
+###################################################
+ -->
+<block>
+ <name>QT GUI Check Box</name>
+ <key>variable_qtgui_check_box</key>
+ <category>QT GUI Widgets</category>
+ <import>from PyQt4 import Qt</import>
+ <var_make>self.$(id) = $(id) = $value</var_make>
+ <make>#set $win = '_%s_check_box'%$id
+#if not $label()
+ #set $label = '"%s"'%$id
+#end if
+$win = Qt.QCheckBox($label)
+self._$(id)_choices = {True: $true, False: $false}
+self._$(id)_choices_inv = dict((v,k) for k,v in self._$(id)_choices.iteritems())
+self._$(id)_callback = lambda i: $(win).setChecked(self._$(id)_choices_inv[i])
+self._$(id)_callback(self.$id)
+$(win).stateChanged.connect(lambda i: self.set_$(id)(self._$(id)_choices[bool(i)]))
+$(gui_hint()($win))</make>
+ <callback>self.set_$(id)($value)</callback>
+ <callback>self._$(id)_callback($id)</callback>
+ <param>
+ <name>Label</name>
+ <key>label</key>
+ <value></value>
+ <type>string</type>
+ <hide>#if $label() then 'none' else 'part'#</hide>
+ </param>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <value>int</value>
+ <type>enum</type>
+ <hide>part</hide>
+ <option><name>Float</name><key>real</key><opt>conv:float</opt></option>
+ <option><name>Integer</name><key>int</key><opt>conv:int</opt></option>
+ <option><name>String</name><key>string</key><opt>conv:str</opt></option>
+ <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt></option>
+ <option><name>Any</name><key>raw</key><opt>conv:eval</opt></option>
+ </param>
+ <param>
+ <name>Default Value</name>
+ <key>value</key>
+ <value>True</value>
+ <type>$type</type>
+ </param>
+ <param>
+ <name>True</name>
+ <key>true</key>
+ <value>True</value>
+ <type>$type</type>
+ </param>
+ <param>
+ <name>False</name>
+ <key>false</key>
+ <value>False</value>
+ <type>$type</type>
+ </param>
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+ <check>$value in ($true, $false)</check>
+ <doc>
+This block creates a variable check box. \
+Leave the label blank to use the variable id as the label.
+
+A check box selects between two values of similar type. \
+Te values do not necessarily need to be of boolean type.
+
+The GUI hint can be used to position the widget within the application. \
+The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \
+Both the tab specification and the grid position are optional.
+ </doc>
+</block>
diff --git a/gr-qtgui/grc/qtgui_chooser.xml b/gr-qtgui/grc/qtgui_chooser.xml
new file mode 100644
index 000000000..cb5090289
--- /dev/null
+++ b/gr-qtgui/grc/qtgui_chooser.xml
@@ -0,0 +1,251 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Variable Chooser:
+## A chooser, radio buttons
+###################################################
+ -->
+<block>
+ <name>QT GUI Chooser</name>
+ <key>variable_qtgui_chooser</key>
+ <category>QT GUI Widgets</category>
+ <import>from PyQt4 import Qt</import>
+ <var_make>self.$(id) = $(id) = $value</var_make>
+ <make>#slurp
+#set $all_options = [$option0, $option1, $option2, $option3, $option4][:int($num_opts())]
+#set $all_labels = [$label0, $label1, $label2, $label3, $label4][:int($num_opts())]
+#if not $label()
+ #set $label = '"%s"'%$id
+#end if
+########################################################################
+## Create the options list
+########################################################################
+#if int($num_opts())
+self._$(id)_options = (#slurp
+ #for $ch in $all_options
+$ch, #slurp
+ #end for
+)
+#else
+self._$(id)_options = $options
+#end if
+########################################################################
+## Create the labels list
+########################################################################
+#if int($num_opts())
+self._$(id)_labels = (#slurp
+ #for i, $lbl in enumerate($all_labels)
+ #if $lbl()
+$lbl, #slurp
+ #else
+str(self._$(id)_options[$i]), #slurp
+ #end if
+ #end for
+)
+#elif $labels()
+self._$(id)_labels = $labels
+#else
+self._$(id)_labels = map(str, self._$(id)_options)
+#end if
+########################################################################
+## Create the combo box
+########################################################################
+#if $widget() == 'combo_box'
+#set $win = 'self._%s_tool_bar'%$id
+$win = Qt.QToolBar(self)
+$(win).addWidget(Qt.QLabel($label+": "))
+self._$(id)_combo_box = Qt.QComboBox()
+$(win).addWidget(self._$(id)_combo_box)
+for label in self._$(id)_labels: self._$(id)_combo_box.addItem(label)
+self._$(id)_callback = lambda i: self._$(id)_combo_box.setCurrentIndex(self._$(id)_options.index(i))
+self._$(id)_callback(self.$id)
+self._$(id)_combo_box.currentIndexChanged.connect(
+ lambda i: self.set_$(id)(self._$(id)_options[i]))
+#end if
+########################################################################
+## Create the radio buttons
+########################################################################
+#if $widget() == 'radio_buttons'
+#set $win = 'self._%s_group_box'%$id
+$win = Qt.QGroupBox($label)
+self._$(id)_box = $(orient)()
+self._$(id)_button_group = Qt.QButtonGroup()
+$(win).setLayout(self._$(id)_box)
+for i, label in enumerate(self._$(id)_labels):
+ radio_button = Qt.QRadioButton(label)
+ self._$(id)_box.addWidget(radio_button)
+ self._$(id)_button_group.addButton(radio_button, i)
+self._$(id)_callback = lambda i: self._$(id)_button_group.button(self._$(id)_options.index(i)).setChecked(True)
+self._$(id)_callback(self.$id)
+self._$(id)_button_group.buttonClicked[int].connect(
+ lambda i: self.set_$(id)(self._$(id)_options[i]))
+#end if
+$(gui_hint()($win))</make>
+ <callback>self.set_$(id)($value)</callback>
+ <callback>self._$(id)_callback($id)</callback>
+ <param>
+ <name>Label</name>
+ <key>label</key>
+ <value></value>
+ <type>string</type>
+ <hide>#if $label() then 'none' else 'part'#</hide>
+ </param>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <value>int</value>
+ <type>enum</type>
+ <hide>part</hide>
+ <option><name>Float</name><key>real</key></option>
+ <option><name>Integer</name><key>int</key></option>
+ <option><name>String</name><key>string</key></option>
+ <option><name>Any</name><key>raw</key></option>
+ </param>
+ <param>
+ <name>Num Options</name>
+ <key>num_opts</key>
+ <value>3</value>
+ <type>enum</type>
+ <option><name>List</name><key>0</key></option>
+ <option><name>1</name><key>1</key></option>
+ <option><name>2</name><key>2</key></option>
+ <option><name>3</name><key>3</key></option>
+ <option><name>4</name><key>4</key></option>
+ <option><name>5</name><key>5</key></option>
+ </param>
+ <param>
+ <name>Default Value</name>
+ <key>value</key>
+ <value>0</value>
+ <type>$type</type>
+ </param>
+ <param>
+ <name>Options</name>
+ <key>options</key>
+ <value>[0, 1, 2]</value>
+ <type>raw</type>
+ <hide>#if int($num_opts()) then 'all' else 'none'#</hide>
+ </param>
+ <param>
+ <name>Labels</name>
+ <key>labels</key>
+ <value>[]</value>
+ <type>raw</type>
+ <hide>#if int($num_opts()) then 'all' else 'none'#</hide>
+ </param>
+ <param>
+ <name>Option 0</name>
+ <key>option0</key>
+ <value>0</value>
+ <type>$type</type>
+ <hide>#if int($num_opts()) > 0 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 0</name>
+ <key>label0</key>
+ <value></value>
+ <type>string</type>
+ <hide>$((int($num_opts()) > 0) and ($label0() and 'none' or 'part') or 'all')</hide>
+ </param>
+ <param>
+ <name>Option 1</name>
+ <key>option1</key>
+ <value>1</value>
+ <type>$type</type>
+ <hide>#if int($num_opts()) > 1 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 1</name>
+ <key>label1</key>
+ <value></value>
+ <type>string</type>
+ <hide>$((int($num_opts()) > 1) and ($label1() and 'none' or 'part') or 'all')</hide>
+ </param>
+ <param>
+ <name>Option 2</name>
+ <key>option2</key>
+ <value>2</value>
+ <type>$type</type>
+ <hide>#if int($num_opts()) > 2 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 2</name>
+ <key>label2</key>
+ <value></value>
+ <type>string</type>
+ <hide>$((int($num_opts()) > 2) and ($label2() and 'none' or 'part') or 'all')</hide>
+ </param>
+ <param>
+ <name>Option 3</name>
+ <key>option3</key>
+ <value>3</value>
+ <type>$type</type>
+ <hide>#if int($num_opts()) > 3 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 3</name>
+ <key>label3</key>
+ <value></value>
+ <type>string</type>
+ <hide>$((int($num_opts()) > 3) and ($label3() and 'none' or 'part') or 'all')</hide>
+ </param>
+ <param>
+ <name>Option 4</name>
+ <key>option4</key>
+ <value>4</value>
+ <type>$type</type>
+ <hide>#if int($num_opts()) > 4 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 4</name>
+ <key>label4</key>
+ <value></value>
+ <type>string</type>
+ <hide>$((int($num_opts()) > 4) and ($label4() and 'none' or 'part') or 'all')</hide>
+ </param>
+ <param>
+ <name>Widget</name>
+ <key>widget</key>
+ <value>combo_box</value>
+ <type>enum</type>
+ <hide>part</hide>
+ <option><name>Combo Box</name><key>combo_box</key></option>
+ <option><name>Radio Buttons</name><key>radio_buttons</key></option>
+ </param>
+ <param>
+ <name>Orientation</name>
+ <key>orient</key>
+ <value>Qt.QVBoxLayout</value>
+ <type>enum</type>
+ <hide>#if $widget() == 'radio_buttons' then 'part' else 'all'#</hide>
+ <option>
+ <name>Horizontal</name>
+ <key>Qt.QHBoxLayout</key>
+ </option>
+ <option>
+ <name>Vertical</name>
+ <key>Qt.QVBoxLayout</key>
+ </option>
+ </param>
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+ <doc>
+This block creates a variable with enumerated options. \
+The gui widget is implemented as a combo box or radio button group. \
+Leave the label blank to use the variable id as the label.
+
+Choose the number of options available to your chooser. \
+When the label is left blank, the option will be used as the label. \
+Set the number of options to "list" to enter a single list of options and labels. \
+When the labels is an empty list, the options will be used as the label.
+
+The GUI hint can be used to position the widget within the application. \
+The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \
+Both the tab specification and the grid position are optional.
+ </doc>
+</block>
diff --git a/gr-qtgui/grc/qtgui_entry.xml b/gr-qtgui/grc/qtgui_entry.xml
new file mode 100644
index 000000000..1a98402a0
--- /dev/null
+++ b/gr-qtgui/grc/qtgui_entry.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Variable Text Entry:
+## a gui text box form
+###################################################
+ -->
+<block>
+ <name>QT GUI Entry</name>
+ <key>variable_qtgui_entry</key>
+ <category>QT GUI Widgets</category>
+ <import>from PyQt4 import Qt</import>
+ <import>from gnuradio import eng_notation</import>
+ <var_make>self.$(id) = $(id) = $value</var_make>
+ <make>#set $win = 'self._%s_tool_bar'%$id
+$win = Qt.QToolBar(self)
+#if not $label()
+ #set $label = '"%s"'%$id
+#end if
+$(win).addWidget(Qt.QLabel($label+": "))
+self._$(id)_line_edit = Qt.QLineEdit(str(self.$id))
+self._$(id)_tool_bar.addWidget(self._$(id)_line_edit)
+self._$(id)_line_edit.returnPressed.connect(
+ lambda: self.set_$(id)($(type.conv)(self._$(id)_line_edit.text().toAscii())))
+$(gui_hint()($win))</make>
+ <callback>self.set_$(id)($value)</callback>
+ <callback>self._$(id)_line_edit.setText($(type.str)($id))</callback>
+ <param>
+ <name>Label</name>
+ <key>label</key>
+ <value></value>
+ <type>string</type>
+ <hide>#if $label() then 'none' else 'part'#</hide>
+ </param>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <value>int</value>
+ <type>enum</type>
+ <hide>part</hide>
+ <option><name>Float</name><key>real</key><opt>conv:eng_notation.str_to_num</opt><opt>str:eng_notation.num_to_str</opt></option>
+ <option><name>Integer</name><key>int</key><opt>conv:int</opt><opt>str:str</opt></option>
+ <option><name>String</name><key>string</key><opt>conv:str</opt><opt>str:str</opt></option>
+ <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt><opt>str:str</opt></option>
+ <option><name>Any</name><key>raw</key><opt>conv:eval</opt><opt>str:repr</opt></option>
+ </param>
+ <param>
+ <name>Default Value</name>
+ <key>value</key>
+ <value>0</value>
+ <type>$type</type>
+ </param>
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+ <doc>
+This block creates a variable with a text entry box. \
+Leave the label blank to use the variable id as the label.
+
+The GUI hint can be used to position the widget within the application. \
+The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \
+Both the tab specification and the grid position are optional.
+ </doc>
+</block>
diff --git a/gr-qtgui/grc/qtgui_label.xml b/gr-qtgui/grc/qtgui_label.xml
new file mode 100644
index 000000000..5049118c4
--- /dev/null
+++ b/gr-qtgui/grc/qtgui_label.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Variable Label Text:
+## a gui static text form
+###################################################
+ -->
+<block>
+ <name>QT GUI Label</name>
+ <key>variable_qtgui_label</key>
+ <category>QT GUI Widgets</category>
+ <import>from PyQt4 import Qt</import>
+ <import>from gnuradio import eng_notation</import>
+ <var_make>self.$(id) = $(id) = $value</var_make>
+ <make>#set $win = 'self._%s_tool_bar'%$id
+$win = Qt.QToolBar(self)
+#if not $label()
+ #set $label = '"%s"'%$id
+#end if
+$(win).addWidget(Qt.QLabel($label+": "))
+self._$(id)_label = Qt.QLabel(str(self.$id))
+self._$(id)_tool_bar.addWidget(self._$(id)_label)
+$(gui_hint()($win))</make>
+ <callback>self.set_$(id)($value)</callback>
+ <callback>self._$(id)_label.setText($(type.str)($id))</callback>
+ <param>
+ <name>Label</name>
+ <key>label</key>
+ <value></value>
+ <type>string</type>
+ <hide>#if $label() then 'none' else 'part'#</hide>
+ </param>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <value>int</value>
+ <type>enum</type>
+ <hide>part</hide>
+ <option><name>Float</name><key>real</key><opt>conv:eng_notation.str_to_num</opt><opt>str:eng_notation.num_to_str</opt></option>
+ <option><name>Integer</name><key>int</key><opt>conv:int</opt><opt>str:str</opt></option>
+ <option><name>String</name><key>string</key><opt>conv:str</opt><opt>str:str</opt></option>
+ <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt><opt>str:str</opt></option>
+ <option><name>Any</name><key>raw</key><opt>conv:eval</opt><opt>str:repr</opt></option>
+ </param>
+ <param>
+ <name>Default Value</name>
+ <key>value</key>
+ <value>0</value>
+ <type>$type</type>
+ </param>
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+ <doc>
+This block creates a variable with a label widget for text. \
+Leave the label blank to use the variable id as the label.
+
+The GUI hint can be used to position the widget within the application. \
+The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \
+Both the tab specification and the grid position are optional.
+ </doc>
+</block>
diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml
new file mode 100644
index 000000000..6b0555f98
--- /dev/null
+++ b/gr-qtgui/grc/qtgui_range.xml
@@ -0,0 +1,211 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Variable Range:
+## ranged widgets like a slider or a knob
+###################################################
+ -->
+<block>
+ <name>QT GUI Range</name>
+ <key>variable_qtgui_range</key>
+ <category>QT GUI Widgets</category>
+ <import>from PyQt4 import Qt</import>
+ <import>import PyQt4.Qwt5 as Qwt</import>
+ <var_make>self.$(id) = $(id) = $value</var_make>
+ <make>#set $win = 'self._%s_layout'%$id
+#if not $label()
+ #set $label = '"%s"'%$id
+#end if
+########################################################################
+#if $widget() == "knob"
+########################################################################
+$win = Qt.QVBoxLayout()
+self._$(id)_knob = Qwt.QwtKnob()
+self._$(id)_knob.setRange($start, $stop, $step)
+self._$(id)_knob.setValue(self.$id)
+self._$(id)_knob.valueChanged.connect(self.set_$(id))
+$(win).addWidget(self._$(id)_knob)
+self._$(id)_label = Qt.QLabel($label)
+self._$(id)_label.setAlignment(Qt.Qt.AlignTop | Qt.Qt.AlignHCenter)
+$(win).addWidget(self._$(id)_label)
+#end if
+########################################################################
+#if $widget() == "thermo"
+########################################################################
+$win = Qt.QVBoxLayout()
+self._$(id)_label = Qt.QLabel($label)
+self._$(id)_thermo = Qwt.QwtThermo()
+self._$(id)_thermo.setScalePosition(Qwt.QwtThermo.$orient.scalepos)
+self._$(id)_thermo.setRange($start, $stop)
+self._$(id)_thermo.setValue(self.$id)
+self._$(id)_thermo.$(orient.minfcn)($min_len)
+#if 'horizontal' in $orient().lower()
+self._$(id)_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
+$(win).addWidget(self._$(id)_label)
+$(win).addWidget(self._$(id)_thermo)
+#elif 'vertical' in $orient().lower()
+self._$(id)_label.setAlignment(Qt.Qt.AlignTop)
+$(win).addWidget(self._$(id)_thermo)
+$(win).addWidget(self._$(id)_label)
+#end if
+#end if
+########################################################################
+#if $widget() == "counter"
+########################################################################
+$win = Qt.QHBoxLayout()
+$(win).addWidget(Qt.QLabel($label+": "))
+self._$(id)_counter = Qwt.QwtCounter()
+self._$(id)_counter.setRange($start, $stop, $step)
+self._$(id)_counter.setNumButtons(2)
+self._$(id)_counter.setMinimumWidth($min_len)
+self._$(id)_counter.setValue(self.$id)
+$(win).addWidget(self._$(id)_counter)
+self._$(id)_counter.valueChanged.connect(self.set_$(id))
+#end if
+########################################################################
+#if $widget() == "slider"
+########################################################################
+$win = Qt.QVBoxLayout()
+self._$(id)_label = Qt.QLabel($label)
+self._$(id)_slider = Qwt.QwtSlider(None, Qt.$orient, Qwt.QwtSlider.$orient.scalepos, Qwt.QwtSlider.BgSlot)
+self._$(id)_slider.setRange($start, $stop, $step)
+self._$(id)_slider.setValue(self.$id)
+self._$(id)_slider.$(orient.minfcn)($min_len)
+self._$(id)_slider.valueChanged.connect(self.set_$(id))
+#if 'horizontal' in $orient().lower()
+self._$(id)_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
+$(win).addWidget(self._$(id)_label)
+$(win).addWidget(self._$(id)_slider)
+#elif 'vertical' in $orient().lower()
+self._$(id)_label.setAlignment(Qt.Qt.AlignTop)
+$(win).addWidget(self._$(id)_slider)
+$(win).addWidget(self._$(id)_label)
+#end if
+#end if
+########################################################################
+#if $widget() == "counter_slider"
+########################################################################
+$win = Qt.QVBoxLayout()
+self._$(id)_tool_bar = Qt.QToolBar(self)
+$(win).addWidget(self._$(id)_tool_bar)
+self._$(id)_tool_bar.addWidget(Qt.QLabel($label+": "))
+self._$(id)_counter = Qwt.QwtCounter()
+self._$(id)_counter.setRange($start, $stop, $step)
+self._$(id)_counter.setNumButtons(2)
+self._$(id)_counter.setValue(self.$id)
+self._$(id)_tool_bar.addWidget(self._$(id)_counter)
+self._$(id)_counter.valueChanged.connect(self.set_$(id))
+self._$(id)_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
+self._$(id)_slider.setRange($start, $stop, $step)
+self._$(id)_slider.setValue(self.$id)
+self._$(id)_slider.setMinimumWidth($min_len)
+self._$(id)_slider.valueChanged.connect(self.set_$(id))
+$(win).addWidget(self._$(id)_slider)
+#end if
+$(gui_hint()($win))</make>
+ <callback>self.set_$(id)($value)</callback>
+ <callback>#if $widget() == "knob"
+self._$(id)_knob.setValue($id)
+#end if
+#if $widget() == "thermo"
+self._$(id)_thermo.setValue($id)
+#end if
+#if $widget() == "counter"
+self._$(id)_counter.setValue($id)
+#end if
+#if $widget() == "slider"
+self._$(id)_slider.setValue($id)
+#end if
+#if $widget() == "counter_slider"
+self._$(id)_counter.setValue($id)
+self._$(id)_slider.setValue($id)
+#end if</callback>
+ <param>
+ <name>Label</name>
+ <key>label</key>
+ <value></value>
+ <type>string</type>
+ <hide>#if $label() then 'none' else 'part'#</hide>
+ </param>
+ <param>
+ <name>Default Value</name>
+ <key>value</key>
+ <value>50</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Start</name>
+ <key>start</key>
+ <value>0</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Stop</name>
+ <key>stop</key>
+ <value>100</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Step</name>
+ <key>step</key>
+ <value>1</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Widget</name>
+ <key>widget</key>
+ <value>counter_slider</value>
+ <type>enum</type>
+ <hide>part</hide>
+ <option><name>Counter + Slider</name><key>counter_slider</key></option>
+ <option><name>Counter</name><key>counter</key></option>
+ <option><name>Slider</name><key>slider</key></option>
+ <option><name>Knob</name><key>knob</key></option>
+ <option><name>Thermo</name><key>thermo</key></option>
+ </param>
+ <param>
+ <name>Orientation</name>
+ <key>orient</key>
+ <value>Qt.Horizontal</value>
+ <type>enum</type>
+ <hide>#if $widget() in ("slider", "thermo") then 'part' else 'all'#</hide>
+ <option>
+ <name>Horizontal</name>
+ <key>Qt.Horizontal</key>
+ <opt>scalepos:BottomScale</opt>
+ <opt>minfcn:setMinimumWidth</opt>
+ </option>
+ <option>
+ <name>Vertical</name>
+ <key>Qt.Vertical</key>
+ <opt>scalepos:LeftScale</opt>
+ <opt>minfcn:setMinimumHeight</opt>
+ </option>
+ </param>
+ <param>
+ <name>Minimum Length</name>
+ <key>min_len</key>
+ <value>200</value>
+ <type>int</type>
+ <hide>#if $widget().split('_')[0] in ("slider", "counter", "thermo") then 'part' else 'all'#</hide>
+ </param>
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+ <check>$start &lt;= $value &lt;= $stop</check>
+ <check>$start &lt; $stop</check>
+ <doc>
+This block creates a variable with a slider. \
+Leave the label blank to use the variable id as the label. \
+The value must be a real number. \
+The value must be between the start and the stop.
+
+The GUI hint can be used to position the widget within the application. \
+The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \
+Both the tab specification and the grid position are optional.
+ </doc>
+</block>
diff --git a/gr-qtgui/grc/qtgui_sink_x.xml b/gr-qtgui/grc/qtgui_sink_x.xml
new file mode 100644
index 000000000..6488ac04c
--- /dev/null
+++ b/gr-qtgui/grc/qtgui_sink_x.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##QT GUI Sink
+###################################################
+ -->
+<block>
+ <name>QT GUI Sink</name>
+ <key>qtgui_sink_x</key>
+ <category>QT GUI Widgets</category>
+ <import>from PyQt4 import Qt</import>
+ <import>from gnuradio.qtgui import qtgui</import>
+ <import>from gnuradio.gr import firdes</import>
+ <import>import sip</import>
+ <make>#set $win = 'self._%s_win'%$id
+qtgui.$(type.fcn)(
+ $fftsize, \#fftsize
+ $wintype, \#wintype
+ $fc, \#fc
+ $bw, \#bw
+ $name, \#name
+ $plotfreq, \#plotfreq
+ $plotwaterfall, \#plotwaterfall
+ $plottime, \#plottime
+ $plotconst, \#plotconst
+)
+self.$(id).set_update_time(1.0 / $rate)
+self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget)
+$(gui_hint()($win))</make>
+ <callback>set_frequency_range($fc, $bw)</callback>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <value>complex</value>
+ <type>enum</type>
+ <option><name>Complex</name><key>complex</key><opt>fcn:sink_c</opt></option>
+ <option><name>Float</name><key>float</key><opt>fcn:sink_f</opt></option>
+ </param>
+ <param>
+ <name>Name</name>
+ <key>name</key>
+ <value>QT GUI Plot</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>FFT Size</name>
+ <key>fftsize</key>
+ <value>1024</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Window Type</name>
+ <key>wintype</key>
+ <value>firdes.WIN_BLACKMAN_hARRIS</value>
+ <type>int</type>
+ <hide>part</hide>
+ <option>
+ <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>
+ <key>fc</key>
+ <value>0</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Bandwidth (Hz)</name>
+ <key>bw</key>
+ <value>samp_rate</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Plot Frequency</name>
+ <key>plotfreq</key>
+ <value>True</value>
+ <type>bool</type>
+ <hide>part</hide>
+ <option><name>On</name><key>True</key></option>
+ <option><name>Off</name><key>False</key></option>
+ </param>
+ <param>
+ <name>Plot Waterfall</name>
+ <key>plotwaterfall</key>
+ <value>True</value>
+ <type>bool</type>
+ <hide>part</hide>
+ <option><name>On</name><key>True</key></option>
+ <option><name>Off</name><key>False</key></option>
+ </param>
+ <param>
+ <name>Plot Time</name>
+ <key>plottime</key>
+ <value>True</value>
+ <type>bool</type>
+ <hide>part</hide>
+ <option><name>On</name><key>True</key></option>
+ <option><name>Off</name><key>False</key></option>
+ </param>
+ <param>
+ <name>Plot Const</name>
+ <key>plotconst</key>
+ <value>True</value>
+ <type>bool</type>
+ <hide>part</hide>
+ <option><name>On</name><key>True</key></option>
+ <option><name>Off</name><key>False</key></option>
+ </param>
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+ <param>
+ <name>Update Rate</name>
+ <key>rate</key>
+ <value>10</value>
+ <type>real</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <nports>$num_inputs</nports>
+ </sink>
+ <doc>
+The GUI hint can be used to position the widget within the application. \
+The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \
+Both the tab specification and the grid position are optional.
+ </doc>
+</block>
diff --git a/gr-qtgui/grc/qtgui_tab_widget.xml b/gr-qtgui/grc/qtgui_tab_widget.xml
new file mode 100644
index 000000000..f90054109
--- /dev/null
+++ b/gr-qtgui/grc/qtgui_tab_widget.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##WX GUI Notebook
+###################################################
+ -->
+<block>
+ <name>QT GUI Tab Widget</name>
+ <key>qtgui_tab_widget</key>
+ <category>QT GUI Widgets</category>
+ <import>from PyQt4 import Qt</import>
+ <make>#set $win = 'self.%s'%$id
+Qt.QTabWidget()
+#set $all_labels = [$label0, $label1, $label2, $label3, $label4][:int($num_tabs())]
+#for i, label in enumerate($all_labels)
+self.$(id)_widget_$(i) = Qt.QWidget()
+self.$(id)_layout_$(i) = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.$(id)_widget_$(i))
+self.$(id)_grid_layout_$(i) = Qt.QGridLayout()
+self.$(id)_layout_$(i).addLayout(self.$(id)_grid_layout_$(i))
+$(win).addTab(self.$(id)_widget_$(i), $label)
+#end for
+$(gui_hint()($win))</make>
+ <param>
+ <name>Num Tabs</name>
+ <key>num_tabs</key>
+ <value>1</value>
+ <type>enum</type>
+ <option><name>1</name><key>1</key></option>
+ <option><name>2</name><key>2</key></option>
+ <option><name>3</name><key>3</key></option>
+ <option><name>4</name><key>4</key></option>
+ <option><name>5</name><key>5</key></option>
+ </param>
+ <param>
+ <name>Label 0</name>
+ <key>label0</key>
+ <value>Tab 0</value>
+ <type>string</type>
+ <hide>#if int($num_tabs()) > 0 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 1</name>
+ <key>label1</key>
+ <value>Tab 1</value>
+ <type>string</type>
+ <hide>#if int($num_tabs()) > 1 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 2</name>
+ <key>label2</key>
+ <value>Tab 2</value>
+ <type>string</type>
+ <hide>#if int($num_tabs()) > 2 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 3</name>
+ <key>label3</key>
+ <value>Tab 3</value>
+ <type>string</type>
+ <hide>#if int($num_tabs()) > 3 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Label 4</name>
+ <key>label4</key>
+ <value>Tab 4</value>
+ <type>string</type>
+ <hide>#if int($num_tabs()) > 4 then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+ <doc>
+This block creates a tabbed widget to organize other widgets. \
+The ID of this block can be used as the tab_id in the GUI hints of other widgets.
+
+The GUI hint can be used to position the widget within the application. \
+The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \
+Both the tab specification and the grid position are optional.
+ </doc>
+</block>
diff --git a/gr-qtgui/grc/qtgui_time_sink_x.xml b/gr-qtgui/grc/qtgui_time_sink_x.xml
new file mode 100644
index 000000000..9c8da6fbc
--- /dev/null
+++ b/gr-qtgui/grc/qtgui_time_sink_x.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##QT GUI Sink
+###################################################
+ -->
+<block>
+ <name>QT GUI Time Sink</name>
+ <key>qtgui_time_sink_x</key>
+ <category>QT GUI Widgets</category>
+ <import>from PyQt4 import Qt</import>
+ <import>from gnuradio.qtgui import qtgui</import>
+ <import>from gnuradio.gr import firdes</import>
+ <import>import sip</import>
+ <make>#set $win = 'self._%s_win'%$id
+qtgui.$(type.fcn)(
+ $size, \#size
+ $bw, \#bw
+ $name, \#name
+ $nconnections \#number of inputs
+)
+self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget)
+$(gui_hint()($win))</make>
+ <callback>set_time_domain_axis($min, $max)</callback>
+ <callback>set_update_time($t)</callback>
+ <callback>set_title($which, $title)</callback>
+ <callback>set_color($which, $color)</callback>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <value>complex</value>
+ <type>enum</type>
+ <option><name>Complex</name><key>complex</key><opt>fcn:time_sink_c</opt></option>
+ <option><name>Float</name><key>float</key><opt>fcn:time_sink_f</opt></option>
+ </param>
+ <param>
+ <name>Name</name>
+ <key>name</key>
+ <value>QT GUI Plot</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Number of Points</name>
+ <key>size</key>
+ <value>1024</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Bandwidth (Hz)</name>
+ <key>bw</key>
+ <value>samp_rate</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Number of Inputs</name>
+ <key>nconnections</key>
+ <value>1</value>
+ <type>int</type>
+ <hide>part</hide>
+ </param>
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <nports>$nconnections</nports>
+ </sink>
+ <doc>
+The GUI hint can be used to position the widget within the application. \
+The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \
+Both the tab specification and the grid position are optional.
+ </doc>
+</block>
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/gr_qtgui_api.h b/gr-qtgui/include/gr_qtgui_api.h
new file mode 100644
index 000000000..c39add1e8
--- /dev/null
+++ b/gr-qtgui/include/gr_qtgui_api.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 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 INCLUDED_GR_QTGUI_API_H
+#define INCLUDED_GR_QTGUI_API_H
+
+#include <gruel/attributes.h>
+
+#ifdef gnuradio_qtgui_EXPORTS
+# define GR_QTGUI_API __GR_ATTR_EXPORT
+#else
+# define GR_QTGUI_API __GR_ATTR_IMPORT
+#endif
+
+#endif /* INCLUDED_GR_QTGUI_API_H */
diff --git a/gr-qtgui/include/qtgui_sink_c.h b/gr-qtgui/include/qtgui_sink_c.h
new file mode 100644
index 000000000..68fff368a
--- /dev/null
+++ b/gr-qtgui/include/qtgui_sink_c.h
@@ -0,0 +1,128 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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 INCLUDED_QTGUI_SINK_C_H
+#define INCLUDED_QTGUI_SINK_C_H
+
+#include <Python.h>
+#include <gr_qtgui_api.h>
+#include <gr_block.h>
+#include <gr_firdes.h>
+#include <gri_fft.h>
+#include <qapplication.h>
+#include <gruel/high_res_timer.h>
+#include "SpectrumGUIClass.h"
+
+class qtgui_sink_c;
+typedef boost::shared_ptr<qtgui_sink_c> qtgui_sink_c_sptr;
+
+GR_QTGUI_API qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
+ double fc=0, double bandwidth=1.0,
+ const std::string &name="Spectrum Display",
+ bool plotfreq=true, bool plotwaterfall=true,
+ 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:
+ friend GR_QTGUI_API qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent);
+ qtgui_sink_c (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent);
+
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ void initialize();
+
+ int d_fftsize;
+ gr_firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ gruel::high_res_timer_type d_last_update;
+ bool d_update_active;
+
+ bool d_shift;
+ gri_fft_complex *d_fft;
+
+ int d_index;
+ gr_complex *d_residbuf;
+
+ bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
+
+ gruel::high_res_timer_type d_update_time;
+
+ QWidget *d_parent;
+ SpectrumGUIClass *d_main_gui;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void fft(const gr_complex *data_in, int size);
+
+public:
+ ~qtgui_sink_c();
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_frequency_range(const double centerfreq,
+ const double bandwidth);
+
+ void set_time_domain_axis(double min, double max);
+ void set_constellation_axis(double xmin, double xmax,
+ double ymin, double ymax);
+ void set_constellation_pen_size(int size);
+ void set_frequency_axis(double min, double max);
+
+ void set_update_time(double t);
+
+ 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);
+};
+
+#endif /* INCLUDED_QTGUI_SINK_C_H */
diff --git a/gr-qtgui/include/qtgui_sink_f.h b/gr-qtgui/include/qtgui_sink_f.h
new file mode 100644
index 000000000..709f02a2f
--- /dev/null
+++ b/gr-qtgui/include/qtgui_sink_f.h
@@ -0,0 +1,125 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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 INCLUDED_QTGUI_SINK_F_H
+#define INCLUDED_QTGUI_SINK_F_H
+
+#include <Python.h>
+#include <gr_qtgui_api.h>
+#include <gr_block.h>
+#include <gr_firdes.h>
+#include <gri_fft.h>
+#include <qapplication.h>
+#include "SpectrumGUIClass.h"
+
+class qtgui_sink_f;
+typedef boost::shared_ptr<qtgui_sink_f> qtgui_sink_f_sptr;
+
+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=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:
+ friend GR_QTGUI_API qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent);
+ qtgui_sink_f (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent);
+
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ void initialize();
+
+ int d_fftsize;
+ gr_firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+
+ bool d_shift;
+ gri_fft_complex *d_fft;
+
+ int d_index;
+ float *d_residbuf;
+
+ bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
+
+ double d_update_time;
+
+ QWidget *d_parent;
+ SpectrumGUIClass *d_main_gui;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void fft(const float *data_in, int size);
+
+public:
+ ~qtgui_sink_f();
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_frequency_range(const double centerfreq,
+ const double bandwidth);
+
+ void set_time_domain_axis(double min, double max);
+ void set_constellation_axis(double xmin, double xmax,
+ double ymin, double ymax);
+ void set_constellation_pen_size(int size);
+ void set_frequency_axis(double min, double max);
+
+ void set_update_time(double t);
+
+ 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);
+};
+
+#endif /* INCLUDED_QTGUI_SINK_F_H */
diff --git a/gr-qtgui/include/qtgui_time_sink_c.h b/gr-qtgui/include/qtgui_time_sink_c.h
new file mode 100644
index 000000000..561d796cf
--- /dev/null
+++ b/gr-qtgui/include/qtgui_time_sink_c.h
@@ -0,0 +1,101 @@
+/* -*- 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 INCLUDED_QTGUI_TIME_SINK_C_H
+#define INCLUDED_QTGUI_TIME_SINK_C_H
+
+#include <Python.h>
+#include <gr_qtgui_api.h>
+#include <gr_sync_block.h>
+#include <gr_firdes.h>
+#include <gri_fft.h>
+#include <qapplication.h>
+#include <timedisplayform.h>
+
+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);
+
+/*!
+ * \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);
+ qtgui_time_sink_c(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+
+ void initialize();
+
+ int d_size;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ int d_index;
+ std::vector<double*> d_residbufs;
+
+ double d_update_time;
+
+ QWidget *d_parent;
+ TimeDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_current_time;
+ gruel::high_res_timer_type d_last_time;
+
+public:
+ ~qtgui_time_sink_c();
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_time_domain_axis(double min, double max);
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+
+ QApplication *d_qApplication;
+
+ 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/include/qtgui_time_sink_f.h b/gr-qtgui/include/qtgui_time_sink_f.h
new file mode 100644
index 000000000..993e0556c
--- /dev/null
+++ b/gr-qtgui/include/qtgui_time_sink_f.h
@@ -0,0 +1,99 @@
+/* -*- 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 INCLUDED_QTGUI_TIME_SINK_F_H
+#define INCLUDED_QTGUI_TIME_SINK_F_H
+
+#include <Python.h>
+#include <gr_qtgui_api.h>
+#include <gr_sync_block.h>
+#include <gr_firdes.h>
+#include <gri_fft.h>
+#include <qapplication.h>
+#include <timedisplayform.h>
+
+class qtgui_time_sink_f;
+typedef boost::shared_ptr<qtgui_time_sink_f> qtgui_time_sink_f_sptr;
+
+GR_QTGUI_API qtgui_time_sink_f_sptr qtgui_make_time_sink_f(int size, double bw,
+ 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 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,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent);
+ qtgui_time_sink_f(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+
+ void initialize();
+
+ int d_size;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ int d_index;
+ std::vector<double*> d_residbufs;
+
+ double d_update_time;
+
+ QWidget *d_parent;
+ TimeDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_current_time;
+ gruel::high_res_timer_type d_last_time;
+
+public:
+ ~qtgui_time_sink_f();
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_time_domain_axis(double min, double max);
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+
+ QApplication *d_qApplication;
+
+ 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/include/qtgui_util.h b/gr-qtgui/include/qtgui_util.h
new file mode 100644
index 000000000..2deaddb94
--- /dev/null
+++ b/gr-qtgui/include/qtgui_util.h
@@ -0,0 +1,57 @@
+/* -*- 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 INCLUDED_QTGUI_UTIL_H
+#define INCLUDED_QTGUI_UTIL_H
+
+#include <qevent.h>
+#include <gr_qtgui_api.h>
+#include <qwt_plot_picker.h>
+#include <qwt_picker_machine.h>
+
+
+class GR_QTGUI_API QwtDblClickPlotPicker: public QwtPlotPicker
+{
+public:
+ QwtDblClickPlotPicker(QwtPlotCanvas *);
+ ~QwtDblClickPlotPicker();
+
+ virtual QwtPickerMachine * stateMachine(int) const;
+};
+
+class GR_QTGUI_API QwtPickerDblClickPointMachine: public QwtPickerMachine
+{
+public:
+ QwtPickerDblClickPointMachine();
+ ~QwtPickerDblClickPointMachine();
+
+#if QWT_VERSION < 0x060000
+ virtual CommandList transition( const QwtEventPattern &eventPattern,
+ const QEvent *e);
+#else
+ virtual QList<QwtPickerMachine::Command>
+ transition( const QwtEventPattern &eventPattern,
+ const QEvent *e);
+#endif
+};
+
+#endif /* INCLUDED_QTGUI_UTIL_H */
diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt
new file mode 100644
index 000000000..49fa525d7
--- /dev/null
+++ b/gr-qtgui/lib/CMakeLists.txt
@@ -0,0 +1,112 @@
+# Copyright 2010-2011,2013 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(
+ ${GR_QTGUI_INCLUDE_DIRS}
+ ${GNURADIO_CORE_INCLUDE_DIRS}
+ ${GRUEL_INCLUDE_DIRS}
+ ${QWT_INCLUDE_DIRS}
+ ${QT_INCLUDE_DIRS}
+ ${Boost_INCLUDE_DIRS}
+ ${PYTHON_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${QWT_LIBRARY_DIRS}
+ ${Boost_LIBRARY_DIRS}
+)
+
+include_directories(${PYTHON_INCLUDE_PATH}) #deprecated for dirs (cmake 2.6)
+
+########################################################################
+# Setup library
+########################################################################
+list(APPEND qtgui_libs
+ gnuradio-core
+ ${QWT_LIBRARIES}
+ ${QT_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})
+GR_LIBRARY_FOO(gnuradio-qtgui RUNTIME_COMPONENT "qtgui_runtime" DEVEL_COMPONENT "qtgui_devel")
+
+########################################################################
+# 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/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc
new file mode 100644
index 000000000..7a595fef4
--- /dev/null
+++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc
@@ -0,0 +1,255 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef CONSTELLATION_DISPLAY_PLOT_C
+#define CONSTELLATION_DISPLAY_PLOT_C
+
+#include <ConstellationDisplayPlot.h>
+
+#include <qwt_scale_draw.h>
+#include <qwt_legend.h>
+#include <iostream>
+
+class ConstellationDisplayZoomer: public QwtPlotZoomer
+{
+public:
+ ConstellationDisplayZoomer(QwtPlotCanvas* canvas):QwtPlotZoomer(canvas)
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
+
+ virtual ~ConstellationDisplayZoomer(){
+
+ }
+
+ virtual void updateTrackerText(){
+ updateDisplay();
+ }
+
+protected:
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText( const QwtDoublePoint& p ) const
+ {
+ QwtText t(QString("(%1, %2)").arg(p.x(), 0, 'f', 4).
+ arg(p.y(), 0, 'f', 4));
+ return t;
+ }
+};
+
+ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent)
+ : QwtPlot(parent)
+{
+ _lastReplot = 0;
+
+ resize(parent->width(), parent->height());
+
+ _numPoints = 1024;
+ _penSize = 5;
+ _realDataPoints = new double[_numPoints];
+ _imagDataPoints = new double[_numPoints];
+
+ // Disable polygon clipping
+#if QWT_VERSION < 0x060000
+ QwtPainter::setDeviceClipping(false);
+#else
+ QwtPainter::setPolylineSplitting(false);
+#endif
+
+#if QWT_VERSION < 0x060000
+ // We don't need the cache here
+ canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
+ canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
+#endif
+
+ QPalette palette;
+ palette.setColor(canvas()->backgroundRole(), QColor("white"));
+ canvas()->setPalette(palette);
+
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
+ set_xaxis(-2.0, 2.0);
+ setAxisTitle(QwtPlot::xBottom, "In-phase");
+
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ set_yaxis(-2.0, 2.0);
+ setAxisTitle(QwtPlot::yLeft, "Quadrature");
+
+ // Automatically deleted when parent is deleted
+ _plot_curve = new QwtPlotCurve("Constellation Points");
+ _plot_curve->attach(this);
+ _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
+ _plot_curve->setStyle(QwtPlotCurve::Dots);
+
+#if QWT_VERSION < 0x060000
+ _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints);
+#else
+ _plot_curve->setRawSamples(_realDataPoints, _imagDataPoints, _numPoints);
+#endif
+
+ memset(_realDataPoints, 0x0, _numPoints*sizeof(double));
+ memset(_imagDataPoints, 0x0, _numPoints*sizeof(double));
+
+ _zoomer = new ConstellationDisplayZoomer(canvas());
+
+#if QWT_VERSION < 0x060000
+ _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+#endif
+
+ _zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
+ Qt::RightButton, Qt::ControlModifier);
+ _zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
+ Qt::RightButton);
+
+ _panner = new QwtPlotPanner(canvas());
+ _panner->setAxisEnabled(QwtPlot::yRight, false);
+ _panner->setMouseButton(Qt::MidButton);
+
+ // Avoid jumping when labels with more/less digits
+ // appear/disappear when scrolling vertically
+
+ const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
+ QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
+ sd->setMinimumExtent( fm.width("100.00") );
+
+ const QColor c(Qt::darkRed);
+ _zoomer->setRubberBandPen(c);
+ _zoomer->setTrackerPen(c);
+
+ // emit the position of clicks on widget
+ _picker = new QwtDblClickPlotPicker(canvas());
+
+#if QWT_VERSION < 0x060000
+ connect(_picker, SIGNAL(selected(const QwtDoublePoint &)),
+ this, SLOT(OnPickerPointSelected(const QwtDoublePoint &)));
+#else
+ connect(_picker, SIGNAL(selected(const QPointF &)),
+ this, SLOT(OnPickerPointSelected6(const QPointF &)));
+#endif
+
+ connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool ) ),
+ this, SLOT(LegendEntryChecked(QwtPlotItem *, bool ) ));
+}
+
+ConstellationDisplayPlot::~ConstellationDisplayPlot()
+{
+ delete[] _realDataPoints;
+ delete[] _imagDataPoints;
+
+ // _fft_plot_curves deleted when parent deleted
+ // _zoomer and _panner deleted when parent deleted
+}
+
+void
+ConstellationDisplayPlot::set_pen_size(int size)
+{
+ if(size > 0 && size < 30){
+ _penSize = size;
+ _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
+ }
+}
+
+
+void
+ConstellationDisplayPlot::set_xaxis(double min, double max)
+{
+ setAxisScale(QwtPlot::xBottom, min, max);
+}
+
+void
+ConstellationDisplayPlot::set_yaxis(double min, double max)
+{
+ setAxisScale(QwtPlot::yLeft, min, max);
+}
+
+void
+ConstellationDisplayPlot::set_axis(double xmin, double xmax,
+ double ymin, double ymax)
+{
+ set_xaxis(xmin, xmax);
+ set_yaxis(ymin, ymax);
+}
+
+void ConstellationDisplayPlot::replot()
+{
+ QwtPlot::replot();
+}
+
+void
+ConstellationDisplayPlot::resizeSlot( QSize *s )
+{
+ resize(s->width(), s->height());
+}
+
+void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints,
+ const double* imagDataPoints,
+ const int64_t numDataPoints,
+ const double timeInterval)
+{
+ if((numDataPoints > 0) &&
+ (gruel::high_res_timer_now() - _lastReplot > timeInterval*gruel::high_res_timer_tps())) {
+
+ if(numDataPoints != _numPoints){
+ _numPoints = numDataPoints;
+
+ delete[] _realDataPoints;
+ delete[] _imagDataPoints;
+ _realDataPoints = new double[_numPoints];
+ _imagDataPoints = new double[_numPoints];
+
+#if QWT_VERSION < 0x060000
+ _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints);
+#else
+ _plot_curve->setRawSamples(_realDataPoints, _imagDataPoints, _numPoints);
+#endif
+ }
+
+ memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double));
+ memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double));
+
+ replot();
+
+ _lastReplot = gruel::high_res_timer_now();
+ }
+}
+
+void
+ConstellationDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on)
+{
+ plotItem->setVisible(!on);
+}
+
+void
+ConstellationDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p)
+{
+ QPointF point = p;
+ //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y());
+ emit plotPointSelected(point);
+}
+
+void
+ConstellationDisplayPlot::OnPickerPointSelected6(const QPointF & p)
+{
+ QPointF point = p;
+ //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y());
+ emit plotPointSelected(point);
+}
+
+#endif /* CONSTELLATION_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.h b/gr-qtgui/lib/ConstellationDisplayPlot.h
new file mode 100644
index 000000000..9e0f6f26a
--- /dev/null
+++ b/gr-qtgui/lib/ConstellationDisplayPlot.h
@@ -0,0 +1,101 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef CONSTELLATION_DISPLAY_PLOT_HPP
+#define CONSTELLATION_DISPLAY_PLOT_HPP
+
+#include <stdint.h>
+#include <cstdio>
+#include <qwt_plot.h>
+#include <qwt_painter.h>
+#include <qwt_plot_canvas.h>
+#include <qwt_plot_curve.h>
+#include <qwt_scale_engine.h>
+#include <qwt_scale_widget.h>
+#include <qwt_plot_zoomer.h>
+#include <qwt_plot_panner.h>
+#include <qwt_plot_marker.h>
+#include <gruel/high_res_timer.h>
+#include <qwt_symbol.h>
+#include <qtgui_util.h>
+
+#if QWT_VERSION >= 0x060000
+#include <qwt_point_3d.h> // doesn't seem necessary, but is...
+#include <qwt_compat.h>
+#endif
+
+class ConstellationDisplayPlot : public QwtPlot
+{
+ Q_OBJECT
+
+public:
+ ConstellationDisplayPlot(QWidget*);
+ virtual ~ConstellationDisplayPlot();
+
+ void PlotNewData(const double* realDataPoints,
+ const double* imagDataPoints,
+ const int64_t numDataPoints,
+ const double timeInterval);
+
+ virtual void replot();
+
+ void set_xaxis(double min, double max);
+ void set_yaxis(double min, double max);
+ void set_axis(double xmin, double xmax,
+ double ymin, double ymax);
+ void set_pen_size(int size);
+
+public slots:
+ void resizeSlot( QSize *s );
+
+ // Because of the preprocessing of slots in QT, these are no
+ // easily separated by the version check. Make one for each
+ // version until it's worked out.
+ void OnPickerPointSelected(const QwtDoublePoint & p);
+ void OnPickerPointSelected6(const QPointF & p);
+
+signals:
+ void plotPointSelected(const QPointF p);
+
+protected slots:
+ void LegendEntryChecked(QwtPlotItem *plotItem, bool on);
+
+protected:
+
+private:
+ QwtPlotCurve* _plot_curve;
+
+ QwtPlotPanner* _panner;
+ QwtPlotZoomer* _zoomer;
+
+ QwtDblClickPlotPicker *_picker;
+
+ double* _realDataPoints;
+ double* _imagDataPoints;
+
+ gruel::high_res_timer_type _lastReplot;
+
+ int64_t _numPoints;
+ int64_t _penSize;
+};
+
+#endif /* CONSTELLATION_DISPLAY_PLOT_HPP */
diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc
new file mode 100644
index 000000000..b74d46015
--- /dev/null
+++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc
@@ -0,0 +1,560 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef FREQUENCY_DISPLAY_PLOT_C
+#define FREQUENCY_DISPLAY_PLOT_C
+
+#include <FrequencyDisplayPlot.h>
+
+#include <qwt_scale_draw.h>
+
+class FreqPrecisionClass
+{
+public:
+ FreqPrecisionClass(const int freqPrecision)
+ {
+ _frequencyPrecision = freqPrecision;
+ }
+
+ virtual ~FreqPrecisionClass()
+ {
+ }
+
+ virtual unsigned int GetFrequencyPrecision() const
+ {
+ return _frequencyPrecision;
+ }
+
+ virtual void SetFrequencyPrecision(const unsigned int newPrecision)
+ {
+ _frequencyPrecision = newPrecision;
+ }
+protected:
+ unsigned int _frequencyPrecision;
+
+private:
+
+};
+
+class FreqDisplayScaleDraw: public QwtScaleDraw, public FreqPrecisionClass
+{
+public:
+ FreqDisplayScaleDraw(const unsigned int precision)
+ : QwtScaleDraw(), FreqPrecisionClass(precision)
+ {
+ }
+
+ virtual ~FreqDisplayScaleDraw()
+ {
+ }
+
+ virtual QwtText label(double value) const
+ {
+ return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision());
+ }
+
+protected:
+
+private:
+
+};
+
+class FreqDisplayZoomer: public QwtPlotZoomer, public FreqPrecisionClass
+{
+public:
+ FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision)
+ : QwtPlotZoomer(canvas),FreqPrecisionClass(freqPrecision)
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
+
+ virtual ~FreqDisplayZoomer(){
+
+ }
+
+ virtual void updateTrackerText(){
+ updateDisplay();
+ }
+
+ void SetUnitType(const std::string &type)
+ {
+ _unitType = type;
+ }
+
+protected:
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText( const QwtDoublePoint& p ) const
+ {
+ QwtText t(QString("%1 %2, %3 dB").
+ arg(p.x(), 0, 'f', GetFrequencyPrecision()).
+ arg(_unitType.c_str()).arg(p.y(), 0, 'f', 2));
+ return t;
+ }
+
+private:
+ std::string _unitType;
+};
+
+FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent)
+ : QwtPlot(parent)
+{
+ _startFrequency = 0;
+ _stopFrequency = 4000;
+
+ _lastReplot = 0;
+
+ resize(parent->width(), parent->height());
+
+ _useCenterFrequencyFlag = false;
+
+ _numPoints = 1024;
+ _dataPoints = new double[_numPoints];
+ _minFFTPoints = new double[_numPoints];
+ _maxFFTPoints = new double[_numPoints];
+ _xAxisPoints = new double[_numPoints];
+
+ // Disable polygon clipping
+#if QWT_VERSION < 0x060000
+ QwtPainter::setDeviceClipping(false);
+#else
+ QwtPainter::setPolylineSplitting(false);
+#endif
+
+#if QWT_VERSION < 0x060000
+ // We don't need the cache here
+ canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
+ canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
+#endif
+
+ QPalette palette;
+ palette.setColor(canvas()->backgroundRole(), QColor("white"));
+ canvas()->setPalette(palette);
+
+ setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
+ setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
+
+ _minYAxis = -120;
+ _maxYAxis = 10;
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis);
+ setAxisTitle(QwtPlot::yLeft, "Power (dB)");
+
+ // Automatically deleted when parent is deleted
+ _fft_plot_curve = new QwtPlotCurve("Power Spectrum");
+ _fft_plot_curve->attach(this);
+ _fft_plot_curve->setPen(QPen(Qt::blue));
+
+#if QWT_VERSION < 0x060000
+ _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints);
+#else
+ _fft_plot_curve->setRawSamples(_xAxisPoints, _dataPoints, _numPoints);
+#endif
+
+ _min_fft_plot_curve = new QwtPlotCurve("Minimum Power");
+ _min_fft_plot_curve->attach(this);
+ _min_fft_plot_curve->setPen(QPen(Qt::magenta));
+
+#if QWT_VERSION < 0x060000
+ _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints);
+#else
+ _min_fft_plot_curve->setRawSamples(_xAxisPoints, _minFFTPoints, _numPoints);
+#endif
+
+ _min_fft_plot_curve->setVisible(false);
+
+ _max_fft_plot_curve = new QwtPlotCurve("Maximum Power");
+ _max_fft_plot_curve->attach(this);
+ _max_fft_plot_curve->setPen(QPen(Qt::darkYellow));
+
+#if QWT_VERSION < 0x060000
+ _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints);
+#else
+ _max_fft_plot_curve->setRawSamples(_xAxisPoints, _maxFFTPoints, _numPoints);
+#endif
+
+ _max_fft_plot_curve->setVisible(false);
+
+ _lower_intensity_marker= new QwtPlotMarker();
+ _lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ _lower_intensity_marker->setLinePen(QPen(Qt::cyan));
+ _lower_intensity_marker->attach(this);
+
+ _upper_intensity_marker = new QwtPlotMarker();
+ _upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ _upper_intensity_marker->setLinePen(QPen(Qt::green, 0, Qt::DotLine));
+ _upper_intensity_marker->attach(this);
+
+ memset(_dataPoints, 0x0, _numPoints*sizeof(double));
+ memset(_xAxisPoints, 0x0, _numPoints*sizeof(double));
+
+ for(int64_t number = 0; number < _numPoints; number++){
+ _minFFTPoints[number] = 200.0;
+ _maxFFTPoints[number] = -280.0;
+ }
+
+ // set up peak marker
+ QwtSymbol symbol;
+
+ _markerPeakAmplitude = new QwtPlotMarker();
+ _markerPeakAmplitude->setLinePen(QPen(Qt::yellow));
+ symbol.setStyle(QwtSymbol::Diamond);
+ symbol.setSize(8);
+ symbol.setPen(QPen(Qt::yellow));
+ symbol.setBrush(QBrush(Qt::yellow));
+
+#if QWT_VERSION < 0x060000
+ _markerPeakAmplitude->setSymbol(symbol);
+#else
+ _markerPeakAmplitude->setSymbol(&symbol);
+#endif
+
+ /// THIS CAUSES A PROBLEM!
+ //_markerPeakAmplitude->attach(this);
+
+ _markerNoiseFloorAmplitude = new QwtPlotMarker();
+ _markerNoiseFloorAmplitude->setLineStyle(QwtPlotMarker::HLine);
+ _markerNoiseFloorAmplitude->setLinePen(QPen(Qt::darkRed, 0, Qt::DotLine));
+ _markerNoiseFloorAmplitude->attach(this);
+
+ _markerCF= new QwtPlotMarker();
+ _markerCF->setLineStyle(QwtPlotMarker::VLine);
+ _markerCF->setLinePen(QPen(Qt::lightGray, 0, Qt::DotLine));
+ _markerCF->attach(this);
+ _markerCF->hide();
+
+ _peakFrequency = 0;
+ _peakAmplitude = -HUGE_VAL;
+
+ _noiseFloorAmplitude = -HUGE_VAL;
+
+ replot();
+
+ // emit the position of clicks on widget
+ _picker = new QwtDblClickPlotPicker(canvas());
+
+#if QWT_VERSION < 0x060000
+ connect(_picker, SIGNAL(selected(const QwtDoublePoint &)),
+ this, SLOT(OnPickerPointSelected(const QwtDoublePoint &)));
+#else
+ connect(_picker, SIGNAL(selected(const QPointF &)),
+ this, SLOT(OnPickerPointSelected6(const QPointF &)));
+#endif
+
+ // Configure magnify on mouse wheel
+ _magnifier = new QwtPlotMagnifier(canvas());
+ _magnifier->setAxisEnabled(QwtPlot::xBottom, false);
+
+ _zoomer = new FreqDisplayZoomer(canvas(), 0);
+
+#if QWT_VERSION < 0x060000
+ _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+#endif
+
+ _zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
+ Qt::RightButton, Qt::ControlModifier);
+ _zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
+ Qt::RightButton);
+
+ _panner = new QwtPlotPanner(canvas());
+ _panner->setAxisEnabled(QwtPlot::yRight, false);
+ _panner->setMouseButton(Qt::MidButton);
+
+ // Avoid jumping when labels with more/less digits
+ // appear/disappear when scrolling vertically
+
+ const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
+ QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
+ sd->setMinimumExtent( fm.width("100.00") );
+
+ const QColor c(Qt::darkRed);
+ _zoomer->setRubberBandPen(c);
+ _zoomer->setTrackerPen(c);
+
+ // Do this after the zoomer has been built
+ _resetXAxisPoints();
+}
+
+FrequencyDisplayPlot::~FrequencyDisplayPlot()
+{
+ delete[] _dataPoints;
+ delete[] _maxFFTPoints;
+ delete[] _minFFTPoints;
+ delete[] _xAxisPoints;
+
+ // _fft_plot_curves deleted when parent deleted
+ // _zoomer and _panner deleted when parent deleted
+}
+
+void
+FrequencyDisplayPlot::set_yaxis(double min, double max)
+{
+ // Get the new max/min values for the plot
+ _minYAxis = min;
+ _maxYAxis = max;
+
+ // Set the axis max/min to the new values
+ setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis);
+
+ // Reset the base zoom level to the new axis scale set here
+ _zoomer->setZoomBase();
+}
+
+void
+FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq,
+ const double constStopFreq,
+ const double constCenterFreq,
+ const bool useCenterFrequencyFlag,
+ const double units, const std::string &strunits)
+{
+ double startFreq = constStartFreq / units;
+ double stopFreq = constStopFreq / units;
+ double centerFreq = constCenterFreq / units;
+
+ _xAxisMultiplier = units;
+ _useCenterFrequencyFlag = useCenterFrequencyFlag;
+
+ if(_useCenterFrequencyFlag){
+ startFreq = (startFreq + centerFreq);
+ stopFreq = (stopFreq + centerFreq);
+ }
+
+ bool reset = false;
+ if((startFreq != _startFrequency) || (stopFreq != _stopFrequency))
+ reset = true;
+
+ if(stopFreq > startFreq) {
+ _startFrequency = startFreq;
+ _stopFrequency = stopFreq;
+
+ if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){
+ double display_units = ceil(log10(units)/2.0);
+ setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units));
+ setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str()));
+
+ if(reset)
+ _resetXAxisPoints();
+
+ ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(display_units);
+ ((FreqDisplayZoomer*)_zoomer)->SetUnitType(strunits);
+ }
+ }
+}
+
+
+double
+FrequencyDisplayPlot::GetStartFrequency() const
+{
+ return _startFrequency;
+}
+
+double
+FrequencyDisplayPlot::GetStopFrequency() const
+{
+ return _stopFrequency;
+}
+
+void
+FrequencyDisplayPlot::replot()
+{
+ _markerNoiseFloorAmplitude->setYValue(_noiseFloorAmplitude);
+
+ // Make sure to take into account the start frequency
+ if(_useCenterFrequencyFlag){
+ _markerPeakAmplitude->setXValue((_peakFrequency/1000.0) + _startFrequency);
+ }
+ else{
+ _markerPeakAmplitude->setXValue(_peakFrequency + _startFrequency);
+ }
+ _markerPeakAmplitude->setYValue(_peakAmplitude);
+
+ QwtPlot::replot();
+}
+
+void
+FrequencyDisplayPlot::resizeSlot( QSize *s )
+{
+ resize(s->width(), s->height());
+}
+
+void
+FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints,
+ const double noiseFloorAmplitude, const double peakFrequency,
+ const double peakAmplitude, const double timeInterval)
+{
+ // Only update plot if there is data and if the time interval has elapsed
+ if((numDataPoints > 0) &&
+ (gruel::high_res_timer_now() - _lastReplot > timeInterval*gruel::high_res_timer_tps())) {
+
+ if(numDataPoints != _numPoints) {
+ _numPoints = numDataPoints;
+
+ delete[] _dataPoints;
+ delete[] _minFFTPoints;
+ delete[] _maxFFTPoints;
+ delete[] _xAxisPoints;
+ _dataPoints = new double[_numPoints];
+ _xAxisPoints = new double[_numPoints];
+ _minFFTPoints = new double[_numPoints];
+ _maxFFTPoints = new double[_numPoints];
+
+#if QWT_VERSION < 0x060000
+ _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints);
+ _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints);
+ _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints);
+#else
+ _fft_plot_curve->setRawSamples(_xAxisPoints, _dataPoints, _numPoints);
+ _min_fft_plot_curve->setRawSamples(_xAxisPoints, _minFFTPoints, _numPoints);
+ _max_fft_plot_curve->setRawSamples(_xAxisPoints, _maxFFTPoints, _numPoints);
+#endif
+
+ _resetXAxisPoints();
+ ClearMaxData();
+ ClearMinData();
+ }
+
+ memcpy(_dataPoints, dataPoints, numDataPoints*sizeof(double));
+ for(int64_t point = 0; point < numDataPoints; point++){
+ if(dataPoints[point] < _minFFTPoints[point]){
+ _minFFTPoints[point] = dataPoints[point];
+ }
+ if(dataPoints[point] > _maxFFTPoints[point]){
+ _maxFFTPoints[point] = dataPoints[point];
+ }
+ }
+
+ _noiseFloorAmplitude = noiseFloorAmplitude;
+ _peakFrequency = peakFrequency;
+ _peakAmplitude = peakAmplitude;
+
+ SetUpperIntensityLevel(_peakAmplitude);
+
+ replot();
+
+ _lastReplot = gruel::high_res_timer_now();
+ }
+}
+
+void
+FrequencyDisplayPlot::ClearMaxData()
+{
+ for(int64_t number = 0; number < _numPoints; number++){
+ _maxFFTPoints[number] = _minYAxis;
+ }
+}
+
+void
+FrequencyDisplayPlot::ClearMinData()
+{
+ for(int64_t number = 0; number < _numPoints; number++){
+ _minFFTPoints[number] = _maxYAxis;
+ }
+}
+
+void
+FrequencyDisplayPlot::SetMaxFFTVisible(const bool visibleFlag)
+{
+ _max_fft_plot_curve->setVisible(visibleFlag);
+}
+
+void
+FrequencyDisplayPlot::SetMinFFTVisible(const bool visibleFlag)
+{
+ _min_fft_plot_curve->setVisible(visibleFlag);
+}
+
+void
+FrequencyDisplayPlot::_resetXAxisPoints()
+{
+ double fft_bin_size = (_stopFrequency-_startFrequency) / static_cast<double>(_numPoints);
+ double freqValue = _startFrequency;
+ for(int64_t loc = 0; loc < _numPoints; loc++){
+ _xAxisPoints[loc] = freqValue;
+ freqValue += fft_bin_size;
+ }
+
+ setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency);
+
+ // Set up zoomer base for maximum unzoom x-axis
+ // and reset to maximum unzoom level
+ QwtDoubleRect zbase = _zoomer->zoomBase();
+ zbase.setLeft(_startFrequency);
+ zbase.setRight(_stopFrequency);
+ _zoomer->zoom(zbase);
+ _zoomer->setZoomBase(zbase);
+ _zoomer->zoom(0);
+}
+
+void
+FrequencyDisplayPlot::SetLowerIntensityLevel(const double lowerIntensityLevel)
+{
+ _lower_intensity_marker->setYValue( lowerIntensityLevel );
+}
+
+void
+FrequencyDisplayPlot::SetUpperIntensityLevel(const double upperIntensityLevel)
+{
+ _upper_intensity_marker->setYValue( upperIntensityLevel );
+}
+
+void
+FrequencyDisplayPlot::SetTraceColour (QColor c)
+{
+ _fft_plot_curve->setPen(QPen(c));
+}
+
+void
+FrequencyDisplayPlot::SetBGColour (QColor c)
+{
+ QPalette palette;
+ palette.setColor(canvas()->backgroundRole(), c);
+ canvas()->setPalette(palette);
+}
+
+void
+FrequencyDisplayPlot::ShowCFMarker (const bool show)
+{
+ if (show)
+ _markerCF->show();
+ else
+ _markerCF->hide();
+}
+
+
+void
+FrequencyDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p)
+{
+ QPointF point = p;
+ //fprintf(stderr,"OnPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier);
+ point.setX(point.x() * _xAxisMultiplier);
+ emit plotPointSelected(point);
+}
+
+void
+FrequencyDisplayPlot::OnPickerPointSelected6(const QPointF & p)
+{
+ QPointF point = p;
+ //fprintf(stderr,"OnPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier);
+ point.setX(point.x() * _xAxisMultiplier);
+ emit plotPointSelected(point);
+}
+
+#endif /* FREQUENCY_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.h b/gr-qtgui/lib/FrequencyDisplayPlot.h
new file mode 100644
index 000000000..5c3ea708c
--- /dev/null
+++ b/gr-qtgui/lib/FrequencyDisplayPlot.h
@@ -0,0 +1,139 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef FREQUENCY_DISPLAY_PLOT_HPP
+#define FREQUENCY_DISPLAY_PLOT_HPP
+
+#include <stdint.h>
+#include <cstdio>
+#include <qwt_plot.h>
+#include <qwt_painter.h>
+#include <qwt_plot_canvas.h>
+#include <qwt_plot_curve.h>
+#include <qwt_scale_engine.h>
+#include <qwt_scale_widget.h>
+#include <qwt_plot_zoomer.h>
+#include <qwt_plot_panner.h>
+#include <qwt_plot_marker.h>
+#include <qwt_plot_magnifier.h>
+#include <gruel/high_res_timer.h>
+#include <qwt_symbol.h>
+#include <qtgui_util.h>
+
+#if QWT_VERSION >= 0x060000
+#include <qwt_compat.h>
+#endif
+
+class FrequencyDisplayPlot:public QwtPlot{
+ Q_OBJECT
+
+public:
+ FrequencyDisplayPlot(QWidget*);
+ virtual ~FrequencyDisplayPlot();
+
+ void SetFrequencyRange(const double, const double,
+ const double, const bool,
+ const double units=1000.0,
+ const std::string &strunits = "kHz");
+ double GetStartFrequency()const;
+ double GetStopFrequency()const;
+
+ void PlotNewData(const double* dataPoints, const int64_t numDataPoints,
+ const double noiseFloorAmplitude, const double peakFrequency,
+ const double peakAmplitude, const double timeInterval);
+
+ void ClearMaxData();
+ void ClearMinData();
+
+ void SetMaxFFTVisible(const bool);
+ void SetMinFFTVisible(const bool);
+
+ virtual void replot();
+
+ void set_yaxis(double min, double max);
+
+ void SetTraceColour (QColor);
+ void SetBGColour (QColor c);
+ void ShowCFMarker (const bool);
+
+public slots:
+ void resizeSlot( QSize *e );
+ void SetLowerIntensityLevel(const double);
+ void SetUpperIntensityLevel(const double);
+
+ // Because of the preprocessing of slots in QT, these are no
+ // easily separated by the version check. Make one for each
+ // version until it's worked out.
+ void OnPickerPointSelected(const QwtDoublePoint & p);
+ void OnPickerPointSelected6(const QPointF & p);
+
+signals:
+ void plotPointSelected(const QPointF p);
+
+protected:
+
+private:
+
+ void _resetXAxisPoints();
+
+ double _startFrequency;
+ double _stopFrequency;
+ double _maxYAxis;
+ double _minYAxis;
+
+ QwtPlotCurve* _fft_plot_curve;
+ QwtPlotCurve* _min_fft_plot_curve;
+ QwtPlotCurve* _max_fft_plot_curve;
+
+ QwtPlotMarker* _lower_intensity_marker;
+ QwtPlotMarker* _upper_intensity_marker;
+
+ QwtPlotPanner* _panner;
+ QwtPlotZoomer* _zoomer;
+
+ QwtPlotMarker *_markerPeakAmplitude;
+ QwtPlotMarker *_markerNoiseFloorAmplitude;
+ QwtPlotMarker *_markerCF;
+
+ QwtDblClickPlotPicker *_picker;
+
+ QwtPlotMagnifier *_magnifier;
+
+ double* _dataPoints;
+ double* _xAxisPoints;
+ int _xAxisMultiplier;
+
+ double* _minFFTPoints;
+ double* _maxFFTPoints;
+ int64_t _numPoints;
+
+ double _peakFrequency;
+ double _peakAmplitude;
+
+ double _noiseFloorAmplitude;
+
+ gruel::high_res_timer_type _lastReplot;
+
+ bool _useCenterFrequencyFlag;
+};
+
+#endif /* FREQUENCY_DISPLAY_PLOT_HPP */
diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc
new file mode 100644
index 000000000..3efba3f40
--- /dev/null
+++ b/gr-qtgui/lib/SpectrumGUIClass.cc
@@ -0,0 +1,478 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef SPECTRUM_GUI_CLASS_CPP
+#define SPECTRUM_GUI_CLASS_CPP
+
+#include <SpectrumGUIClass.h>
+//Added by qt3to4:
+#include <QEvent>
+#include <QCustomEvent>
+
+const long SpectrumGUIClass::MAX_FFT_SIZE = 32768;
+const long SpectrumGUIClass::MIN_FFT_SIZE = 256;
+
+SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize,
+ const uint64_t fftSize,
+ const double newCenterFrequency,
+ const double newStartFrequency,
+ const double newStopFrequency)
+{
+ _dataPoints = maxDataSize;
+ if(_dataPoints < 2){
+ _dataPoints = 2;
+ }
+ _lastDataPointCount = _dataPoints;
+
+ _fftSize = fftSize;
+
+ _pendingGUIUpdateEventsCount = 0;
+ _droppedEntriesCount = 0;
+
+ _centerFrequency = newCenterFrequency;
+ _startFrequency = newStartFrequency;
+ _stopFrequency = newStopFrequency;
+
+ _windowType = 5;
+
+ _lastGUIUpdateTime = 0;
+
+ _windowOpennedFlag = false;
+ _fftBuffersCreatedFlag = false;
+
+ _powerValue = 1;
+}
+
+SpectrumGUIClass::~SpectrumGUIClass()
+{
+ // We don't need to delete this since as a QWidget, it is supposed to be destroyed
+ // with it's parent. Deleting it causes a segmentation fault, and not deleting it
+ // does not leave any extra memory.
+ //if(GetWindowOpenFlag()){
+ //delete _spectrumDisplayForm;
+ //}
+
+ if(_fftBuffersCreatedFlag){
+ delete[] _fftPoints;
+ delete[] _realTimeDomainPoints;
+ delete[] _imagTimeDomainPoints;
+ }
+}
+
+void
+SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent,
+ const bool frequency, const bool waterfall,
+ const bool time, const bool constellation)
+{
+ d_mutex.lock();
+
+ if(!_windowOpennedFlag){
+
+ if(!_fftBuffersCreatedFlag){
+ _fftPoints = new std::complex<float>[_dataPoints];
+ _realTimeDomainPoints = new double[_dataPoints];
+ _imagTimeDomainPoints = new double[_dataPoints];
+ _fftBuffersCreatedFlag = true;
+
+
+ memset(_fftPoints, 0x0, _dataPoints*sizeof(std::complex<float>));
+ memset(_realTimeDomainPoints, 0x0, _dataPoints*sizeof(double));
+ memset(_imagTimeDomainPoints, 0x0, _dataPoints*sizeof(double));
+ }
+
+ // Called from the Event Thread
+ _spectrumDisplayForm = new SpectrumDisplayForm(parent);
+
+ // Toggle Windows on/off
+ _spectrumDisplayForm->ToggleTabFrequency(frequency);
+ _spectrumDisplayForm->ToggleTabWaterfall(waterfall);
+ _spectrumDisplayForm->ToggleTabTime(time);
+ _spectrumDisplayForm->ToggleTabConstellation(constellation);
+
+ _windowOpennedFlag = true;
+
+ _spectrumDisplayForm->setSystem(this, _dataPoints, _fftSize);
+
+ qApp->processEvents();
+ }
+ d_mutex.unlock();
+
+
+ SetDisplayTitle(_title);
+ Reset();
+
+ qApp->postEvent(_spectrumDisplayForm,
+ new QEvent(QEvent::Type(QEvent::User+3)));
+
+ _lastGUIUpdateTime = 0;
+
+ // Draw Blank Display
+ UpdateWindow(false, NULL, 0, NULL, 0, NULL, 0, gruel::high_res_timer_now(), true);
+
+ // Set up the initial frequency axis settings
+ SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
+
+ // GUI Thread only
+ qApp->processEvents();
+
+ // Set the FFT Size combo box to display the right number
+ int idx = _spectrumDisplayForm->FFTSizeComboBox->findText(QString("%1").arg(_fftSize));
+ _spectrumDisplayForm->FFTSizeComboBox->setCurrentIndex(idx);
+}
+
+void
+SpectrumGUIClass::Reset()
+{
+ if(GetWindowOpenFlag()) {
+ qApp->postEvent(_spectrumDisplayForm,
+ new SpectrumFrequencyRangeEvent(_centerFrequency,
+ _startFrequency,
+ _stopFrequency));
+ qApp->postEvent(_spectrumDisplayForm, new SpectrumWindowResetEvent());
+ }
+ _droppedEntriesCount = 0;
+ // Call the following function the the Spectrum Window Reset Event window
+ // ResetPendingGUIUpdateEvents();
+}
+
+void
+SpectrumGUIClass::SetDisplayTitle(const std::string newString)
+{
+ _title.assign(newString);
+
+ if(GetWindowOpenFlag()){
+ qApp->postEvent(_spectrumDisplayForm,
+ new SpectrumWindowCaptionEvent(_title.c_str()));
+ }
+}
+
+bool
+SpectrumGUIClass::GetWindowOpenFlag()
+{
+ gruel::scoped_lock lock(d_mutex);
+ bool returnFlag = false;
+ returnFlag = _windowOpennedFlag;
+ return returnFlag;
+}
+
+
+void
+SpectrumGUIClass::SetWindowOpenFlag(const bool newFlag)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _windowOpennedFlag = newFlag;
+}
+
+void
+SpectrumGUIClass::SetFrequencyRange(const double centerFreq,
+ const double startFreq,
+ const double stopFreq)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _centerFrequency = centerFreq;
+ _startFrequency = startFreq;
+ _stopFrequency = stopFreq;
+
+ _spectrumDisplayForm->SetFrequencyRange(_centerFrequency,
+ _startFrequency,
+ _stopFrequency);
+}
+
+double
+SpectrumGUIClass::GetStartFrequency()
+{
+ gruel::scoped_lock lock(d_mutex);
+ double returnValue = 0.0;
+ returnValue = _startFrequency;
+ return returnValue;
+}
+
+double
+SpectrumGUIClass::GetStopFrequency()
+{
+ gruel::scoped_lock lock(d_mutex);
+ double returnValue = 0.0;
+ returnValue = _stopFrequency;
+ return returnValue;
+}
+
+double
+SpectrumGUIClass::GetCenterFrequency()
+{
+ gruel::scoped_lock lock(d_mutex);
+ double returnValue = 0.0;
+ returnValue = _centerFrequency;
+ return returnValue;
+}
+
+
+void
+SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag,
+ const std::complex<float>* fftBuffer,
+ const uint64_t inputBufferSize,
+ const float* realTimeDomainData,
+ const uint64_t realTimeDomainDataSize,
+ const float* complexTimeDomainData,
+ const uint64_t complexTimeDomainDataSize,
+ const gruel::high_res_timer_type timestamp,
+ const bool lastOfMultipleFFTUpdateFlag)
+{
+ //gruel::scoped_lock lock(d_mutex);
+ int64_t bufferSize = inputBufferSize;
+ bool repeatDataFlag = false;
+ if(bufferSize > _dataPoints){
+ bufferSize = _dataPoints;
+ }
+ int64_t timeDomainBufferSize = 0;
+
+ if(updateDisplayFlag){
+ if((fftBuffer != NULL) && (bufferSize > 0)){
+ memcpy(_fftPoints, fftBuffer, bufferSize * sizeof(std::complex<float>));
+ }
+
+ // Can't do a memcpy since ths is going from float to double data type
+ if((realTimeDomainData != NULL) && (realTimeDomainDataSize > 0)){
+ const float* realTimeDomainDataPtr = realTimeDomainData;
+
+ double* realTimeDomainPointsPtr = _realTimeDomainPoints;
+ timeDomainBufferSize = realTimeDomainDataSize;
+
+ memset( _imagTimeDomainPoints, 0x0, realTimeDomainDataSize*sizeof(double));
+ for( uint64_t number = 0; number < realTimeDomainDataSize; number++){
+ *realTimeDomainPointsPtr++ = *realTimeDomainDataPtr++;
+ }
+ }
+
+ // Can't do a memcpy since ths is going from float to double data type
+ if((complexTimeDomainData != NULL) && (complexTimeDomainDataSize > 0)){
+ const float* complexTimeDomainDataPtr = complexTimeDomainData;
+
+ double* realTimeDomainPointsPtr = _realTimeDomainPoints;
+ double* imagTimeDomainPointsPtr = _imagTimeDomainPoints;
+
+ timeDomainBufferSize = complexTimeDomainDataSize;
+ for( uint64_t number = 0; number < complexTimeDomainDataSize; number++){
+ *realTimeDomainPointsPtr++ = *complexTimeDomainDataPtr++;
+ *imagTimeDomainPointsPtr++ = *complexTimeDomainDataPtr++;
+ }
+ }
+ }
+
+ // If bufferSize is zero, then just update the display by sending over the old data
+ if(bufferSize < 1){
+ bufferSize = _lastDataPointCount;
+ repeatDataFlag = true;
+ }
+ else{
+ // Since there is data this time, update the count
+ _lastDataPointCount = bufferSize;
+ }
+
+ const gruel::high_res_timer_type currentTime = gruel::high_res_timer_now();
+ const gruel::high_res_timer_type lastUpdateGUITime = GetLastGUIUpdateTime();
+
+ if((currentTime - lastUpdateGUITime > (4*_updateTime)*gruel::high_res_timer_tps()) &&
+ (GetPendingGUIUpdateEvents() > 0) && lastUpdateGUITime != 0) {
+ // Do not update the display if too much data is pending to be displayed
+ _droppedEntriesCount++;
+ }
+ else{
+ // Draw the Data
+ IncrementPendingGUIUpdateEvents();
+ qApp->postEvent(_spectrumDisplayForm,
+ new SpectrumUpdateEvent(_fftPoints, bufferSize,
+ _realTimeDomainPoints,
+ _imagTimeDomainPoints,
+ timeDomainBufferSize,
+ timestamp,
+ repeatDataFlag,
+ lastOfMultipleFFTUpdateFlag,
+ currentTime,
+ _droppedEntriesCount));
+
+ // Only reset the dropped entries counter if this is not
+ // repeat data since repeat data is dropped by the display systems
+ if(!repeatDataFlag){
+ _droppedEntriesCount = 0;
+ }
+ }
+}
+
+float
+SpectrumGUIClass::GetPowerValue()
+{
+ gruel::scoped_lock lock(d_mutex);
+ float returnValue = 0;
+ returnValue = _powerValue;
+ return returnValue;
+}
+
+void
+SpectrumGUIClass::SetPowerValue(const float value)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _powerValue = value;
+}
+
+int
+SpectrumGUIClass::GetWindowType()
+{
+ gruel::scoped_lock lock(d_mutex);
+ int returnValue = 0;
+ returnValue = _windowType;
+ return returnValue;
+}
+
+void
+SpectrumGUIClass::SetWindowType(const int newType)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _windowType = newType;
+}
+
+int
+SpectrumGUIClass::GetFFTSize()
+{
+ int returnValue = 0;
+ returnValue = _fftSize;
+ return returnValue;
+}
+
+int
+SpectrumGUIClass::GetFFTSizeIndex()
+{
+ gruel::scoped_lock lock(d_mutex);
+ int fftsize = GetFFTSize();
+ switch(fftsize) {
+ case(1024): return 0; break;
+ case(2048): return 1; break;
+ case(4096): return 2; break;
+ case(8192): return 3; break;
+ case(16384): return 3; break;
+ case(32768): return 3; break;
+ default: return 0;
+ }
+}
+
+void
+SpectrumGUIClass::SetFFTSize(const int newSize)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _fftSize = newSize;
+}
+
+gruel::high_res_timer_type
+SpectrumGUIClass::GetLastGUIUpdateTime()
+{
+ gruel::scoped_lock lock(d_mutex);
+ gruel::high_res_timer_type returnValue;
+ returnValue = _lastGUIUpdateTime;
+ return returnValue;
+}
+
+void
+SpectrumGUIClass::SetLastGUIUpdateTime(const gruel::high_res_timer_type newTime)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _lastGUIUpdateTime = newTime;
+}
+
+unsigned int
+SpectrumGUIClass::GetPendingGUIUpdateEvents()
+{
+ gruel::scoped_lock lock(d_mutex);
+ unsigned int returnValue = 0;
+ returnValue = _pendingGUIUpdateEventsCount;
+ return returnValue;
+}
+
+void
+SpectrumGUIClass::IncrementPendingGUIUpdateEvents()
+{
+ gruel::scoped_lock lock(d_mutex);
+ _pendingGUIUpdateEventsCount++;
+}
+
+void
+SpectrumGUIClass::DecrementPendingGUIUpdateEvents()
+{
+ gruel::scoped_lock lock(d_mutex);
+ if(_pendingGUIUpdateEventsCount > 0){
+ _pendingGUIUpdateEventsCount--;
+ }
+}
+
+void
+SpectrumGUIClass::ResetPendingGUIUpdateEvents()
+{
+ gruel::scoped_lock lock(d_mutex);
+ _pendingGUIUpdateEventsCount = 0;
+}
+
+
+QWidget*
+SpectrumGUIClass::qwidget()
+{
+ gruel::scoped_lock lock(d_mutex);
+ return (QWidget*)_spectrumDisplayForm;
+}
+
+void
+SpectrumGUIClass::SetTimeDomainAxis(double min, double max)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->SetTimeDomainAxis(min, max);
+}
+
+void
+SpectrumGUIClass::SetConstellationAxis(double xmin, double xmax,
+ double ymin, double ymax)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->SetConstellationAxis(xmin, xmax, ymin, ymax);
+}
+
+void
+SpectrumGUIClass::SetConstellationPenSize(int size)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->SetConstellationPenSize(size);
+}
+
+
+void
+SpectrumGUIClass::SetFrequencyAxis(double min, double max)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->SetFrequencyAxis(min, max);
+}
+
+void
+SpectrumGUIClass::SetUpdateTime(double t)
+{
+ gruel::scoped_lock lock(d_mutex);
+ _updateTime = t;
+ _spectrumDisplayForm->SetUpdateTime(_updateTime);
+}
+
+
+#endif /* SPECTRUM_GUI_CLASS_CPP */
diff --git a/gr-qtgui/lib/SpectrumGUIClass.h b/gr-qtgui/lib/SpectrumGUIClass.h
new file mode 100644
index 000000000..e0612413b
--- /dev/null
+++ b/gr-qtgui/lib/SpectrumGUIClass.h
@@ -0,0 +1,130 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef SPECTRUM_GUI_CLASS_HPP
+#define SPECTRUM_GUI_CLASS_HPP
+
+#include <gruel/thread.h>
+#include <qwidget.h>
+#include <qapplication.h>
+#include <qlabel.h>
+#include <qslider.h>
+#include <spectrumUpdateEvents.h>
+
+class SpectrumDisplayForm;
+#include <spectrumdisplayform.h>
+
+#include <cmath>
+
+#include <complex>
+#include <vector>
+#include <string>
+
+class SpectrumGUIClass
+{
+public:
+ SpectrumGUIClass(const uint64_t maxDataSize, const uint64_t fftSize,
+ const double newCenterFrequency,
+ const double newStartFrequency,
+ const double newStopFrequency);
+ ~SpectrumGUIClass();
+ void Reset();
+
+ void OpenSpectrumWindow(QWidget*,
+ const bool frequency=true, const bool waterfall=true,
+ const bool time=true, const bool constellation=true);
+ void SetDisplayTitle(const std::string);
+
+ bool GetWindowOpenFlag();
+ void SetWindowOpenFlag(const bool);
+
+ void SetFrequencyRange(const double, const double, const double);
+ double GetStartFrequency();
+ double GetStopFrequency();
+ double GetCenterFrequency();
+
+ void UpdateWindow(const bool, const std::complex<float>*,
+ const uint64_t, const float*,
+ const uint64_t, const float*,
+ const uint64_t,
+ const gruel::high_res_timer_type, const bool);
+
+ float GetPowerValue();
+ void SetPowerValue(const float);
+
+ int GetWindowType();
+ void SetWindowType(const int);
+
+ int GetFFTSize();
+ int GetFFTSizeIndex();
+ void SetFFTSize(const int);
+
+ gruel::high_res_timer_type GetLastGUIUpdateTime();
+ void SetLastGUIUpdateTime(const gruel::high_res_timer_type);
+
+ unsigned int GetPendingGUIUpdateEvents();
+ void IncrementPendingGUIUpdateEvents();
+ void DecrementPendingGUIUpdateEvents();
+ void ResetPendingGUIUpdateEvents();
+
+ static const long MAX_FFT_SIZE;
+ static const long MIN_FFT_SIZE;
+
+ QWidget* qwidget();
+
+ void SetTimeDomainAxis(double min, double max);
+ void SetConstellationAxis(double xmin, double xmax,
+ double ymin, double ymax);
+ void SetConstellationPenSize(int size);
+ void SetFrequencyAxis(double min, double max);
+
+ void SetUpdateTime(double t);
+
+protected:
+
+private:
+
+ gruel::mutex d_mutex;
+ int64_t _dataPoints;
+ std::string _title;
+ double _centerFrequency;
+ double _startFrequency;
+ double _stopFrequency;
+ float _powerValue;
+ bool _windowOpennedFlag;
+ int _windowType;
+ int64_t _lastDataPointCount;
+ int _fftSize;
+ gruel::high_res_timer_type _lastGUIUpdateTime;
+ unsigned int _pendingGUIUpdateEventsCount;
+ int _droppedEntriesCount;
+ bool _fftBuffersCreatedFlag;
+ double _updateTime;
+
+ SpectrumDisplayForm* _spectrumDisplayForm;
+
+ std::complex<float>* _fftPoints;
+ double* _realTimeDomainPoints;
+ double* _imagTimeDomainPoints;
+};
+
+#endif /* SPECTRUM_GUI_CLASS_HPP */
diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc
new file mode 100644
index 000000000..84b09af90
--- /dev/null
+++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc
@@ -0,0 +1,345 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef TIME_DOMAIN_DISPLAY_PLOT_C
+#define TIME_DOMAIN_DISPLAY_PLOT_C
+
+#include <TimeDomainDisplayPlot.h>
+
+#include <qwt_scale_draw.h>
+#include <qwt_legend.h>
+#include <QColor>
+#include <iostream>
+
+class TimePrecisionClass
+{
+public:
+ TimePrecisionClass(const int timePrecision)
+ {
+ _timePrecision = timePrecision;
+ }
+
+ virtual ~TimePrecisionClass()
+ {
+ }
+
+ virtual unsigned int GetTimePrecision() const
+ {
+ return _timePrecision;
+ }
+
+ virtual void SetTimePrecision(const unsigned int newPrecision)
+ {
+ _timePrecision = newPrecision;
+ }
+protected:
+ unsigned int _timePrecision;
+};
+
+
+class TimeDomainDisplayZoomer: public QwtPlotZoomer, public TimePrecisionClass
+{
+public:
+ TimeDomainDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int timePrecision)
+ : QwtPlotZoomer(canvas),TimePrecisionClass(timePrecision)
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
+
+ virtual ~TimeDomainDisplayZoomer(){
+
+ }
+
+ virtual void updateTrackerText(){
+ updateDisplay();
+ }
+
+ void SetUnitType(const std::string &type)
+ {
+ _unitType = type;
+ }
+
+protected:
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText( const QwtDoublePoint& p ) const
+ {
+ QwtText t(QString("%1 %2, %3 V").arg(p.x(), 0, 'f', GetTimePrecision()).
+ arg(_unitType.c_str()).
+ arg(p.y(), 0, 'f', 4));
+
+ return t;
+ }
+
+private:
+ std::string _unitType;
+};
+
+TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent)
+ : QwtPlot(parent), _nplots(nplots)
+{
+ resize(parent->width(), parent->height());
+
+ _numPoints = 1024;
+ _xAxisPoints = new double[_numPoints];
+ memset(_xAxisPoints, 0x0, _numPoints*sizeof(double));
+
+ _zoomer = new TimeDomainDisplayZoomer(canvas(), 0);
+
+#if QWT_VERSION < 0x060000
+ _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+#endif
+
+ // Disable polygon clipping
+#if QWT_VERSION < 0x060000
+ QwtPainter::setDeviceClipping(false);
+#else
+ QwtPainter::setPolylineSplitting(false);
+#endif
+
+#if QWT_VERSION < 0x060000
+ // We don't need the cache here
+ canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
+ canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
+#endif
+
+ QPalette palette;
+ palette.setColor(canvas()->backgroundRole(), QColor("white"));
+ canvas()->setPalette(palette);
+
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
+ setXaxis(0, _numPoints);
+ setAxisTitle(QwtPlot::xBottom, "Time (sec)");
+
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ setYaxis(-2.0, 2.0);
+ setAxisTitle(QwtPlot::yLeft, "Amplitude");
+
+ QList<QColor> colors;
+ colors << QColor(Qt::blue) << QColor(Qt::red) << QColor(Qt::green)
+ << QColor(Qt::black) << QColor(Qt::cyan) << QColor(Qt::magenta)
+ << QColor(Qt::yellow) << QColor(Qt::gray) << QColor(Qt::darkRed)
+ << QColor(Qt::darkGreen) << QColor(Qt::darkBlue) << QColor(Qt::darkGray);
+
+ // Setup dataPoints and plot vectors
+ // Automatically deleted when parent is deleted
+ for(int i = 0; i < _nplots; i++) {
+ _dataPoints.push_back(new double[_numPoints]);
+ memset(_dataPoints[i], 0x0, _numPoints*sizeof(double));
+
+ _plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
+ _plot_curve[i]->attach(this);
+ _plot_curve[i]->setPen(QPen(colors[i]));
+
+#if QWT_VERSION < 0x060000
+ _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints);
+#else
+ _plot_curve[i]->setRawSamples(_xAxisPoints, _dataPoints[i], _numPoints);
+#endif
+}
+
+ _sampleRate = 1;
+ _resetXAxisPoints();
+
+ _zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
+ Qt::RightButton, Qt::ControlModifier);
+ _zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
+ Qt::RightButton);
+
+ _panner = new QwtPlotPanner(canvas());
+ _panner->setAxisEnabled(QwtPlot::yRight, false);
+ _panner->setMouseButton(Qt::MidButton);
+
+ // emit the position of clicks on widget
+ _picker = new QwtDblClickPlotPicker(canvas());
+
+#if QWT_VERSION < 0x060000
+ connect(_picker, SIGNAL(selected(const QwtDoublePoint &)),
+ this, SLOT(OnPickerPointSelected(const QwtDoublePoint &)));
+#else
+ connect(_picker, SIGNAL(selected(const QPointF &)),
+ this, SLOT(OnPickerPointSelected6(const QPointF &)));
+#endif
+
+ // Configure magnify on mouse wheel
+ _magnifier = new QwtPlotMagnifier(canvas());
+ _magnifier->setAxisEnabled(QwtPlot::xBottom, false);
+
+ // Avoid jumping when labels with more/less digits
+ // appear/disappear when scrolling vertically
+
+ const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
+ QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
+ sd->setMinimumExtent( fm.width("100.00") );
+
+ const QColor c(Qt::darkRed);
+ _zoomer->setRubberBandPen(c);
+ _zoomer->setTrackerPen(c);
+
+ QwtLegend* legendDisplay = new QwtLegend(this);
+ legendDisplay->setItemMode(QwtLegend::CheckableItem);
+ insertLegend(legendDisplay);
+
+ connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ),
+ this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) ));
+}
+
+TimeDomainDisplayPlot::~TimeDomainDisplayPlot()
+{
+ for(int i = 0; i < _nplots; i++)
+ delete [] _dataPoints[i];
+ delete[] _xAxisPoints;
+
+ // _zoomer and _panner deleted when parent deleted
+}
+
+void
+TimeDomainDisplayPlot::setYaxis(double min, double max)
+{
+ setAxisScale(QwtPlot::yLeft, min, max);
+ _zoomer->setZoomBase();
+}
+
+void
+TimeDomainDisplayPlot::setXaxis(double min, double max)
+{
+ setAxisScale(QwtPlot::xBottom, min, max);
+ _zoomer->setZoomBase();
+}
+
+void
+TimeDomainDisplayPlot::setTitle(int which, QString title)
+{
+ _plot_curve[which]->setTitle(title);
+}
+
+void
+TimeDomainDisplayPlot::setColor(int which, QString color)
+{
+ _plot_curve[which]->setPen(QPen(color));
+}
+
+void TimeDomainDisplayPlot::replot()
+{
+ QwtPlot::replot();
+}
+
+void
+TimeDomainDisplayPlot::resizeSlot( QSize *s )
+{
+ // -10 is to spare some room for the legend and x-axis label
+ resize(s->width()-10, s->height()-10);
+}
+
+void TimeDomainDisplayPlot::PlotNewData(const std::vector<double*> dataPoints,
+ const int64_t numDataPoints,
+ const double timeInterval)
+{
+ if((numDataPoints > 0)) {
+ if(numDataPoints != _numPoints){
+ _numPoints = numDataPoints;
+
+ delete[] _xAxisPoints;
+ _xAxisPoints = new double[_numPoints];
+
+ for(int i = 0; i < _nplots; i++) {
+ delete[] _dataPoints[i];
+ _dataPoints[i] = new double[_numPoints];
+
+#if QWT_VERSION < 0x060000
+ _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints);
+#else
+ _plot_curve[i]->setRawSamples(_xAxisPoints, _dataPoints[i], _numPoints);
+#endif
+ }
+
+ setXaxis(0, numDataPoints);
+ _resetXAxisPoints();
+ }
+
+ for(int i = 0; i < _nplots; i++) {
+ memcpy(_dataPoints[i], dataPoints[i], numDataPoints*sizeof(double));
+ }
+
+ replot();
+ }
+}
+
+void TimeDomainDisplayPlot::_resetXAxisPoints()
+{
+ double delt = 1.0/_sampleRate;
+ for(long loc = 0; loc < _numPoints; loc++){
+ _xAxisPoints[loc] = loc*delt;
+ }
+ setAxisScale(QwtPlot::xBottom, 0, _numPoints*delt);
+
+ // Set up zoomer base for maximum unzoom x-axis
+ // and reset to maximum unzoom level
+ QwtDoubleRect zbase = _zoomer->zoomBase();
+ zbase.setLeft(0);
+ zbase.setRight(_numPoints*delt);
+ _zoomer->zoom(zbase);
+ _zoomer->setZoomBase(zbase);
+ _zoomer->zoom(0);
+}
+
+void TimeDomainDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on)
+{
+ plotItem->setVisible(!on);
+}
+
+void
+TimeDomainDisplayPlot::SetSampleRate(double sr, double units,
+ const std::string &strunits)
+{
+ double newsr = sr/units;
+ if(newsr != _sampleRate) {
+ _sampleRate = sr/units;
+ _resetXAxisPoints();
+
+ // While we could change the displayed sigfigs based on the unit being
+ // displayed, I think it looks better by just setting it to 4 regardless.
+ //double display_units = ceil(log10(units)/2.0);
+ double display_units = 4;
+ setAxisTitle(QwtPlot::xBottom, QString("Time (%1)").arg(strunits.c_str()));
+ ((TimeDomainDisplayZoomer*)_zoomer)->SetTimePrecision(display_units);
+ ((TimeDomainDisplayZoomer*)_zoomer)->SetUnitType(strunits);
+ }
+}
+
+
+void
+TimeDomainDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p)
+{
+ QPointF point = p;
+ //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y());
+ emit plotPointSelected(point);
+}
+
+void
+TimeDomainDisplayPlot::OnPickerPointSelected6(const QPointF & p)
+{
+ QPointF point = p;
+ //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y());
+ emit plotPointSelected(point);
+}
+
+#endif /* TIME_DOMAIN_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h
new file mode 100644
index 000000000..356da25ad
--- /dev/null
+++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h
@@ -0,0 +1,102 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef TIME_DOMAIN_DISPLAY_PLOT_HPP
+#define TIME_DOMAIN_DISPLAY_PLOT_HPP
+
+#include <stdint.h>
+#include <cstdio>
+#include <vector>
+#include <qwt_plot.h>
+#include <qwt_painter.h>
+#include <qwt_plot_canvas.h>
+#include <qwt_plot_curve.h>
+#include <qwt_scale_engine.h>
+#include <qwt_scale_widget.h>
+#include <qwt_plot_zoomer.h>
+#include <qwt_plot_panner.h>
+#include <qwt_plot_magnifier.h>
+#include <qwt_plot_marker.h>
+#include <qwt_symbol.h>
+#include <qtgui_util.h>
+
+#if QWT_VERSION >= 0x060000
+#include <qwt_compat.h>
+#endif
+
+class TimeDomainDisplayPlot:public QwtPlot{
+ Q_OBJECT
+
+public:
+ TimeDomainDisplayPlot(int nplots, QWidget*);
+ virtual ~TimeDomainDisplayPlot();
+
+ void PlotNewData(const std::vector<double*> dataPoints,
+ const int64_t numDataPoints, const double timeInterval);
+
+ virtual void replot();
+
+public slots:
+ void setYaxis(double min, double max);
+ void setXaxis(double min, double max);
+ void setTitle(int which, QString title);
+ void setColor(int which, QString color);
+
+ void resizeSlot( QSize *s );
+ void SetSampleRate(double sr, double units,
+ const std::string &strunits);
+
+ // Because of the preprocessing of slots in QT, these are no
+ // easily separated by the version check. Make one for each
+ // version until it's worked out.
+ void OnPickerPointSelected(const QwtDoublePoint & p);
+ void OnPickerPointSelected6(const QPointF & p);
+
+signals:
+ void plotPointSelected(const QPointF p);
+
+protected slots:
+ void LegendEntryChecked(QwtPlotItem *plotItem, bool on);
+
+protected:
+
+private:
+ void _resetXAxisPoints();
+
+ int _nplots;
+ std::vector<QwtPlotCurve*> _plot_curve;
+
+ QwtPlotPanner* _panner;
+ QwtPlotZoomer* _zoomer;
+
+ QwtDblClickPlotPicker *_picker;
+ QwtPlotMagnifier *_magnifier;
+
+ std::vector<double*> _dataPoints;
+ double* _xAxisPoints;
+
+ double _sampleRate;
+
+ int64_t _numPoints;
+};
+
+#endif /* TIME_DOMAIN_DISPLAY_PLOT_HPP */
diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc
new file mode 100644
index 000000000..63eb57ffe
--- /dev/null
+++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc
@@ -0,0 +1,695 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef WATERFALL_DISPLAY_PLOT_C
+#define WATERFALL_DISPLAY_PLOT_C
+
+#include <WaterfallDisplayPlot.h>
+
+#include <qwt_color_map.h>
+#include <qwt_scale_widget.h>
+#include <qwt_scale_draw.h>
+#include <qwt_plot_zoomer.h>
+#include <qwt_plot_panner.h>
+#include <qwt_plot_layout.h>
+
+#include <qapplication.h>
+
+#include <boost/date_time/posix_time/posix_time.hpp>
+namespace pt = boost::posix_time;
+
+class FreqOffsetAndPrecisionClass
+{
+public:
+ FreqOffsetAndPrecisionClass(const int freqPrecision)
+ {
+ _frequencyPrecision = freqPrecision;
+ _centerFrequency = 0;
+ }
+
+ virtual ~FreqOffsetAndPrecisionClass()
+ {
+ }
+
+ virtual unsigned int GetFrequencyPrecision() const
+ {
+ return _frequencyPrecision;
+ }
+
+ virtual void SetFrequencyPrecision(const unsigned int newPrecision)
+ {
+ _frequencyPrecision = newPrecision;
+ }
+
+ virtual double GetCenterFrequency() const
+ {
+ return _centerFrequency;
+ }
+
+ virtual void SetCenterFrequency(const double newFreq)
+ {
+ _centerFrequency = newFreq;
+ }
+
+protected:
+ unsigned int _frequencyPrecision;
+ double _centerFrequency;
+
+private:
+
+};
+
+class WaterfallFreqDisplayScaleDraw: public QwtScaleDraw, public FreqOffsetAndPrecisionClass{
+public:
+ WaterfallFreqDisplayScaleDraw(const unsigned int precision)
+ : QwtScaleDraw(), FreqOffsetAndPrecisionClass(precision)
+ {
+ }
+
+ virtual ~WaterfallFreqDisplayScaleDraw()
+ {
+ }
+
+ QwtText label(double value) const
+ {
+ return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision());
+ }
+
+ virtual void initiateUpdate()
+ {
+ invalidateCache();
+ }
+
+protected:
+
+private:
+
+};
+
+class TimeScaleData
+{
+public:
+ TimeScaleData()
+ {
+ _zeroTime = 0;
+ _secondsPerLine = 1.0;
+ }
+
+ virtual ~TimeScaleData()
+ {
+ }
+
+ virtual gruel::high_res_timer_type GetZeroTime() const
+ {
+ return _zeroTime;
+ }
+
+ virtual void SetZeroTime(const gruel::high_res_timer_type newTime)
+ {
+ _zeroTime = newTime - gruel::high_res_timer_epoch();
+ }
+
+ virtual void SetSecondsPerLine(const double newTime)
+ {
+ _secondsPerLine = newTime;
+ }
+
+ virtual double GetSecondsPerLine() const
+ {
+ return _secondsPerLine;
+ }
+
+
+protected:
+ gruel::high_res_timer_type _zeroTime;
+ double _secondsPerLine;
+
+private:
+
+};
+
+static QString
+make_time_label(double secs)
+{
+ std::string time_str = pt::to_simple_string(pt::from_time_t(time_t(secs)));
+
+ // lops off the YYYY-mmm-DD part of the string
+ size_t ind = time_str.find(" ");
+ if(ind != std::string::npos)
+ time_str = time_str.substr(ind);
+
+ return QString("").sprintf("%s.%03ld", time_str.c_str(), long(std::fmod(secs*1000, 1000)));
+}
+
+class QwtTimeScaleDraw: public QwtScaleDraw, public TimeScaleData
+{
+public:
+ QwtTimeScaleDraw():QwtScaleDraw(),TimeScaleData()
+ {
+ }
+
+ virtual ~QwtTimeScaleDraw()
+ {
+ }
+
+ virtual QwtText label(double value) const
+ {
+ double secs = GetZeroTime()/double(gruel::high_res_timer_tps()) - (value * GetSecondsPerLine());
+ return QwtText(make_time_label(secs));
+ }
+
+ virtual void initiateUpdate()
+ {
+ // Do this in one call rather than when zeroTime and secondsPerLine
+ // updates is to prevent the display from being updated too often...
+ invalidateCache();
+ }
+
+protected:
+
+private:
+
+};
+
+class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData,
+ public FreqOffsetAndPrecisionClass
+{
+public:
+ WaterfallZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision)
+ : QwtPlotZoomer(canvas), TimeScaleData(),
+ FreqOffsetAndPrecisionClass(freqPrecision)
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
+
+ virtual ~WaterfallZoomer()
+ {
+ }
+
+ virtual void updateTrackerText()
+ {
+ updateDisplay();
+ }
+
+ void SetUnitType(const std::string &type)
+ {
+ _unitType = type;
+ }
+
+protected:
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText( const QwtDoublePoint& p ) const
+ {
+ double secs = GetZeroTime()/double(gruel::high_res_timer_tps()) - (p.y() * GetSecondsPerLine());
+ QwtText t(QString("%1 %2, %3").
+ arg(p.x(), 0, 'f', GetFrequencyPrecision()).
+ arg(_unitType.c_str()).arg(make_time_label(secs)));
+ return t;
+ }
+
+private:
+ std::string _unitType;
+};
+
+class ColorMap_MultiColor: public QwtLinearColorMap
+{
+public:
+ ColorMap_MultiColor():
+ QwtLinearColorMap(Qt::darkCyan, Qt::white)
+ {
+ addColorStop(0.25, Qt::cyan);
+ addColorStop(0.5, Qt::yellow);
+ addColorStop(0.75, Qt::red);
+ }
+};
+
+class ColorMap_WhiteHot: public QwtLinearColorMap
+{
+public:
+ ColorMap_WhiteHot():
+ QwtLinearColorMap(Qt::black, Qt::white)
+ {
+ }
+};
+
+class ColorMap_BlackHot: public QwtLinearColorMap
+{
+public:
+ ColorMap_BlackHot():
+ QwtLinearColorMap(Qt::white, Qt::black)
+ {
+ }
+};
+
+class ColorMap_Incandescent: public QwtLinearColorMap
+{
+public:
+ ColorMap_Incandescent():
+ QwtLinearColorMap(Qt::black, Qt::white)
+ {
+ addColorStop(0.5, Qt::darkRed);
+ }
+};
+
+class ColorMap_UserDefined: public QwtLinearColorMap
+{
+public:
+ ColorMap_UserDefined(QColor low, QColor high):
+ QwtLinearColorMap(low, high)
+ {
+ }
+};
+
+/*********************************************************************
+MAIN WATERFALL PLOT WIDGET
+*********************************************************************/
+
+WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent)
+ : QwtPlot(parent)
+{
+ _zoomer = NULL;
+ _startFrequency = 0;
+ _stopFrequency = 4000;
+
+ resize(parent->width(), parent->height());
+ _numPoints = 1024;
+
+ QPalette palette;
+ palette.setColor(canvas()->backgroundRole(), QColor("white"));
+ canvas()->setPalette(palette);
+
+ setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
+ setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(0));
+
+ setAxisTitle(QwtPlot::yLeft, "Time");
+ setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw());
+
+ _lastReplot = 0;
+
+ _intensityColorMapType = INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR;
+
+ d_data = new WaterfallData(_startFrequency, _stopFrequency,
+ _numPoints, 200);
+
+#if QWT_VERSION < 0x060000
+ d_spectrogram = new PlotWaterfall(d_data, "Waterfall Display");
+
+ ColorMap_MultiColor colorMap;
+ d_spectrogram->setColorMap(colorMap);
+
+#else
+ d_spectrogram = new QwtPlotSpectrogram("Spectrogram");
+ d_spectrogram->setData(d_data);
+ d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true);
+ d_spectrogram->setColorMap(new ColorMap_MultiColor());
+#endif
+
+ d_spectrogram->attach(this);
+
+ // LeftButton for the zooming
+ // MidButton for the panning
+ // RightButton: zoom out by 1
+ // Ctrl+RighButton: zoom out to full size
+ _zoomer = new WaterfallZoomer(canvas(), 0);
+#if QWT_VERSION < 0x060000
+ _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+#endif
+ _zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
+ Qt::RightButton, Qt::ControlModifier);
+ _zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
+ Qt::RightButton);
+
+ _panner = new QwtPlotPanner(canvas());
+ _panner->setAxisEnabled(QwtPlot::yRight, false);
+ _panner->setMouseButton(Qt::MidButton);
+
+ // emit the position of clicks on widget
+ _picker = new QwtDblClickPlotPicker(canvas());
+#if QWT_VERSION < 0x060000
+ connect(_picker, SIGNAL(selected(const QwtDoublePoint &)),
+ this, SLOT(OnPickerPointSelected(const QwtDoublePoint &)));
+#else
+ connect(_picker, SIGNAL(selected(const QPointF &)),
+ this, SLOT(OnPickerPointSelected6(const QPointF &)));
+#endif
+
+ // Avoid jumping when labels with more/less digits
+ // appear/disappear when scrolling vertically
+
+ const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
+ QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
+ sd->setMinimumExtent( fm.width("100.00") );
+
+ const QColor c(Qt::black);
+ _zoomer->setRubberBandPen(c);
+ _zoomer->setTrackerPen(c);
+
+ _UpdateIntensityRangeDisplay();
+
+ _xAxisMultiplier = 1;
+}
+
+WaterfallDisplayPlot::~WaterfallDisplayPlot()
+{
+ delete d_data;
+ delete d_spectrogram;
+}
+
+void
+WaterfallDisplayPlot::Reset()
+{
+ d_data->ResizeData(_startFrequency, _stopFrequency, _numPoints);
+ d_data->Reset();
+
+ setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency);
+
+ // Load up the new base zoom settings
+ QwtDoubleRect newSize = _zoomer->zoomBase();
+ newSize.setLeft(_startFrequency);
+ newSize.setWidth(_stopFrequency-_startFrequency);
+ _zoomer->zoom(newSize);
+ _zoomer->setZoomBase(newSize);
+ _zoomer->zoom(0);
+}
+
+void
+WaterfallDisplayPlot::SetFrequencyRange(const double constStartFreq,
+ const double constStopFreq,
+ const double constCenterFreq,
+ const bool useCenterFrequencyFlag,
+ const double units, const std::string &strunits)
+{
+ double startFreq = constStartFreq / units;
+ double stopFreq = constStopFreq / units;
+ double centerFreq = constCenterFreq / units;
+
+ _xAxisMultiplier = units;
+
+ _useCenterFrequencyFlag = useCenterFrequencyFlag;
+
+ if(_useCenterFrequencyFlag){
+ startFreq = (startFreq + centerFreq);
+ stopFreq = (stopFreq + centerFreq);
+ }
+
+ bool reset = false;
+ if((startFreq != _startFrequency) || (stopFreq != _stopFrequency))
+ reset = true;
+
+ if(stopFreq > startFreq) {
+ _startFrequency = startFreq;
+ _stopFrequency = stopFreq;
+
+ if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){
+ double display_units = ceil(log10(units)/2.0);
+ setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(display_units));
+ setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str()));
+
+ if(reset) {
+ Reset();
+ }
+
+ ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision(display_units);
+ ((WaterfallZoomer*)_zoomer)->SetUnitType(strunits);
+ }
+ }
+}
+
+
+double
+WaterfallDisplayPlot::GetStartFrequency() const
+{
+ return _startFrequency;
+}
+
+double
+WaterfallDisplayPlot::GetStopFrequency() const
+{
+ return _stopFrequency;
+}
+
+void
+WaterfallDisplayPlot::PlotNewData(const double* dataPoints,
+ const int64_t numDataPoints,
+ const double timePerFFT,
+ const gruel::high_res_timer_type timestamp,
+ const int droppedFrames)
+{
+ if(numDataPoints > 0){
+ if(numDataPoints != _numPoints){
+ _numPoints = numDataPoints;
+
+ Reset();
+
+ d_spectrogram->invalidateCache();
+ d_spectrogram->itemChanged();
+
+ if(isVisible()){
+ replot();
+ }
+
+ _lastReplot = gruel::high_res_timer_now();
+ }
+
+ if(gruel::high_res_timer_now() - _lastReplot > timePerFFT*gruel::high_res_timer_tps()) {
+ d_data->addFFTData(dataPoints, numDataPoints, droppedFrames);
+ d_data->IncrementNumLinesToUpdate();
+
+ QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
+ timeScale->SetSecondsPerLine(timePerFFT);
+ timeScale->SetZeroTime(timestamp);
+
+ ((WaterfallZoomer*)_zoomer)->SetSecondsPerLine(timePerFFT);
+ ((WaterfallZoomer*)_zoomer)->SetZeroTime(timestamp);
+
+ d_spectrogram->invalidateCache();
+ d_spectrogram->itemChanged();
+
+ replot();
+
+ _lastReplot = gruel::high_res_timer_now();
+ }
+ }
+}
+
+void
+WaterfallDisplayPlot::SetIntensityRange(const double minIntensity,
+ const double maxIntensity)
+{
+#if QWT_VERSION < 0x060000
+ d_data->setRange(QwtDoubleInterval(minIntensity, maxIntensity));
+#else
+ d_data->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity));
+#endif
+
+ emit UpdatedLowerIntensityLevel(minIntensity);
+ emit UpdatedUpperIntensityLevel(maxIntensity);
+
+ _UpdateIntensityRangeDisplay();
+}
+
+void
+WaterfallDisplayPlot::replot()
+{
+ QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
+ timeScale->initiateUpdate();
+
+ WaterfallFreqDisplayScaleDraw* freqScale = \
+ (WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom);
+ freqScale->initiateUpdate();
+
+ // Update the time axis display
+ if(axisWidget(QwtPlot::yLeft) != NULL){
+ axisWidget(QwtPlot::yLeft)->update();
+ }
+
+ // Update the Frequency Offset Display
+ if(axisWidget(QwtPlot::xBottom) != NULL){
+ axisWidget(QwtPlot::xBottom)->update();
+ }
+
+ if(_zoomer != NULL){
+ ((WaterfallZoomer*)_zoomer)->updateTrackerText();
+ }
+
+ QwtPlot::replot();
+}
+
+void
+WaterfallDisplayPlot::resizeSlot( QSize *s )
+{
+ resize(s->width(), s->height());
+}
+
+int
+WaterfallDisplayPlot::GetIntensityColorMapType() const
+{
+ return _intensityColorMapType;
+}
+
+void
+WaterfallDisplayPlot::SetIntensityColorMapType(const int newType,
+ const QColor lowColor,
+ const QColor highColor)
+{
+ if((_intensityColorMapType != newType) ||
+ ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) &&
+ (lowColor.isValid() && highColor.isValid()))){
+ switch(newType){
+ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{
+ _intensityColorMapType = newType;
+#if QWT_VERSION < 0x060000
+ ColorMap_MultiColor colorMap;
+ d_spectrogram->setColorMap(colorMap);
+#else
+ d_spectrogram->setColorMap(new ColorMap_MultiColor());
+#endif
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{
+ _intensityColorMapType = newType;
+#if QWT_VERSION < 0x060000
+ ColorMap_WhiteHot colorMap;
+ d_spectrogram->setColorMap(colorMap);
+#else
+ d_spectrogram->setColorMap(new ColorMap_WhiteHot());
+#endif
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{
+ _intensityColorMapType = newType;
+#if QWT_VERSION < 0x060000
+ ColorMap_BlackHot colorMap;
+ d_spectrogram->setColorMap(colorMap);
+#else
+ d_spectrogram->setColorMap(new ColorMap_BlackHot());
+#endif
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{
+ _intensityColorMapType = newType;
+#if QWT_VERSION < 0x060000
+ ColorMap_Incandescent colorMap;
+ d_spectrogram->setColorMap(colorMap);
+#else
+ d_spectrogram->setColorMap(new ColorMap_Incandescent());
+#endif
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{
+ _userDefinedLowIntensityColor = lowColor;
+ _userDefinedHighIntensityColor = highColor;
+ _intensityColorMapType = newType;
+#if QWT_VERSION < 0x060000
+ ColorMap_UserDefined colorMap(lowColor, highColor);
+ d_spectrogram->setColorMap(colorMap);
+#else
+ d_spectrogram->setColorMap(new ColorMap_UserDefined(lowColor, highColor));
+#endif
+ break;
+ }
+ default: break;
+ }
+
+ _UpdateIntensityRangeDisplay();
+ }
+}
+
+const QColor
+WaterfallDisplayPlot::GetUserDefinedLowIntensityColor() const
+{
+ return _userDefinedLowIntensityColor;
+}
+
+const QColor
+WaterfallDisplayPlot::GetUserDefinedHighIntensityColor() const
+{
+ return _userDefinedHighIntensityColor;
+}
+
+void
+WaterfallDisplayPlot::_UpdateIntensityRangeDisplay()
+{
+ QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
+ rightAxis->setTitle("Intensity (dB)");
+ rightAxis->setColorBarEnabled(true);
+
+#if QWT_VERSION < 0x060000
+ rightAxis->setColorMap(d_spectrogram->data()->range(),
+ d_spectrogram->colorMap());
+ setAxisScale(QwtPlot::yRight,
+ d_spectrogram->data()->range().minValue(),
+ d_spectrogram->data()->range().maxValue());
+#else
+ QwtInterval intv = d_spectrogram->interval(Qt::ZAxis);
+ switch(_intensityColorMapType) {
+ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:
+ rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break;
+ case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:
+ rightAxis->setColorMap(intv, new ColorMap_WhiteHot()); break;
+ case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:
+ rightAxis->setColorMap(intv, new ColorMap_BlackHot()); break;
+ case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:
+ rightAxis->setColorMap(intv, new ColorMap_Incandescent()); break;
+ case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:
+ rightAxis->setColorMap(intv, new ColorMap_UserDefined(_userDefinedLowIntensityColor,
+ _userDefinedHighIntensityColor)); break;
+ default:
+ rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break;
+ }
+ setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue());
+#endif
+
+ enableAxis(QwtPlot::yRight);
+
+ plotLayout()->setAlignCanvasToScales(true);
+
+ // Tell the display to redraw everything
+ d_spectrogram->invalidateCache();
+ d_spectrogram->itemChanged();
+
+ // Draw again
+ replot();
+
+ // Update the last replot timer
+ _lastReplot = gruel::high_res_timer_now();
+}
+
+void
+WaterfallDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p)
+{
+ QPointF point = p;
+ //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y());
+ point.setX(point.x() * _xAxisMultiplier);
+ emit plotPointSelected(point);
+}
+
+void
+WaterfallDisplayPlot::OnPickerPointSelected6(const QPointF & p)
+{
+ QPointF point = p;
+ //fprintf(stderr,"OnPickerPointSelected %f %f\n", point.x(), point.y());
+ point.setX(point.x() * _xAxisMultiplier);
+ emit plotPointSelected(point);
+}
+
+#endif /* WATERFALL_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/lib/WaterfallDisplayPlot.h
new file mode 100644
index 000000000..d189ca2cb
--- /dev/null
+++ b/gr-qtgui/lib/WaterfallDisplayPlot.h
@@ -0,0 +1,127 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef WATERFALL_DISPLAY_PLOT_HPP
+#define WATERFALL_DISPLAY_PLOT_HPP
+
+#include <stdint.h>
+#include <cstdio>
+#include <qwt_plot.h>
+#include <qwt_plot_spectrogram.h>
+#include <qwt_plot_zoomer.h>
+#include <qwt_plot_panner.h>
+#include <qtgui_util.h>
+#include <waterfallGlobalData.h>
+
+#include <gruel/high_res_timer.h>
+
+#if QWT_VERSION < 0x060000
+#include <plot_waterfall.h>
+#else
+#include <qwt_compat.h>
+#endif
+
+class WaterfallDisplayPlot:public QwtPlot{
+ Q_OBJECT
+
+public:
+ WaterfallDisplayPlot(QWidget*);
+ virtual ~WaterfallDisplayPlot();
+
+ void Reset();
+
+ void SetFrequencyRange(const double, const double,
+ const double, const bool,
+ const double units=1000.0,
+ const std::string &strunits = "kHz");
+ double GetStartFrequency()const;
+ double GetStopFrequency()const;
+
+ void PlotNewData(const double* dataPoints, const int64_t numDataPoints,
+ const double timePerFFT, const gruel::high_res_timer_type timestamp,
+ const int droppedFrames);
+
+ void SetIntensityRange(const double minIntensity, const double maxIntensity);
+
+ virtual void replot(void);
+
+ int GetIntensityColorMapType()const;
+ void SetIntensityColorMapType( const int, const QColor, const QColor );
+ const QColor GetUserDefinedLowIntensityColor()const;
+ const QColor GetUserDefinedHighIntensityColor()const;
+
+ enum{
+ INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR = 0,
+ INTENSITY_COLOR_MAP_TYPE_WHITE_HOT = 1,
+ INTENSITY_COLOR_MAP_TYPE_BLACK_HOT = 2,
+ INTENSITY_COLOR_MAP_TYPE_INCANDESCENT = 3,
+ INTENSITY_COLOR_MAP_TYPE_USER_DEFINED = 4
+ };
+
+public slots:
+ void resizeSlot( QSize *s );
+
+ // Because of the preprocessing of slots in QT, these are no
+ // easily separated by the version check. Make one for each
+ // version until it's worked out.
+ void OnPickerPointSelected(const QwtDoublePoint & p);
+ void OnPickerPointSelected6(const QPointF & p);
+
+signals:
+ void UpdatedLowerIntensityLevel(const double);
+ void UpdatedUpperIntensityLevel(const double);
+ void plotPointSelected(const QPointF p);
+
+protected:
+
+private:
+ void _UpdateIntensityRangeDisplay();
+
+ double _startFrequency;
+ double _stopFrequency;
+ int _xAxisMultiplier;
+
+ QwtPlotPanner* _panner;
+ QwtPlotZoomer* _zoomer;
+
+ QwtDblClickPlotPicker *_picker;
+
+ WaterfallData *d_data;
+
+#if QWT_VERSION < 0x060000
+ PlotWaterfall *d_spectrogram;
+#else
+ QwtPlotSpectrogram *d_spectrogram;
+#endif
+
+ gruel::high_res_timer_type _lastReplot;
+
+ bool _useCenterFrequencyFlag;
+
+ int64_t _numPoints;
+
+ int _intensityColorMapType;
+ QColor _userDefinedLowIntensityColor;
+ QColor _userDefinedHighIntensityColor;
+};
+
+#endif /* WATERFALL_DISPLAY_PLOT_HPP */
diff --git a/gr-qtgui/lib/plot_waterfall.cc b/gr-qtgui/lib/plot_waterfall.cc
new file mode 100644
index 000000000..517ec0275
--- /dev/null
+++ b/gr-qtgui/lib/plot_waterfall.cc
@@ -0,0 +1,310 @@
+#include <qimage.h>
+#include <qpen.h>
+#include <qpainter.h>
+#include "qwt_painter.h"
+#include "qwt_scale_map.h"
+#include "qwt_color_map.h"
+#include "plot_waterfall.h"
+
+#if QWT_VERSION < 0x060000
+#include "qwt_double_interval.h"
+#endif
+
+typedef QVector<QRgb> QwtColorTable;
+
+class PlotWaterfallImage: public QImage
+{
+ // This class hides some Qt3/Qt4 API differences
+public:
+ PlotWaterfallImage(const QSize &size, QwtColorMap::Format format):
+ QImage(size, format == QwtColorMap::RGB
+ ? QImage::Format_ARGB32 : QImage::Format_Indexed8 )
+ {
+ }
+
+ PlotWaterfallImage(const QImage &other):
+ QImage(other)
+ {
+ }
+
+ void initColorTable(const QImage& other)
+ {
+ setColorTable(other.colorTable());
+ }
+};
+
+class PlotWaterfall::PrivateData
+{
+public:
+ PrivateData()
+ {
+ data = NULL;
+ colorMap = new QwtLinearColorMap();
+ }
+ ~PrivateData()
+ {
+ delete colorMap;
+ }
+
+ WaterfallData *data;
+ QwtColorMap *colorMap;
+};
+
+/*!
+ Sets the following item attributes:
+ - QwtPlotItem::AutoScale: true
+ - QwtPlotItem::Legend: false
+
+ The z value is initialized by 8.0.
+
+ \param title Title
+
+ \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()
+*/
+PlotWaterfall::PlotWaterfall(WaterfallData* data, const QString &title):
+ QwtPlotRasterItem(title)
+{
+ d_data = new PrivateData();
+ d_data->data = data;
+
+// setCachePolicy(QwtPlotRasterItem::PaintCache);
+
+ setItemAttribute(QwtPlotItem::AutoScale, true);
+ setItemAttribute(QwtPlotItem::Legend, false);
+
+ setZ(8.0);
+}
+
+//! Destructor
+PlotWaterfall::~PlotWaterfall()
+{
+ delete d_data;
+}
+
+const WaterfallData* PlotWaterfall::data()const{
+ return d_data->data;
+}
+
+//! \return QwtPlotItem::Rtti_PlotSpectrogram
+int PlotWaterfall::rtti() const
+{
+ return QwtPlotItem::Rtti_PlotSpectrogram;
+}
+
+/*!
+ Change the color map
+
+ Often it is useful to display the mapping between intensities and
+ colors as an additional plot axis, showing a color bar.
+
+ \param colorMap Color Map
+
+ \sa colorMap(), QwtScaleWidget::setColorBarEnabled(),
+ QwtScaleWidget::setColorMap()
+*/
+void PlotWaterfall::setColorMap(const QwtColorMap &colorMap)
+{
+ delete d_data->colorMap;
+#if QWT_VERSION < 0x060000
+ d_data->colorMap = colorMap.copy();
+#endif
+
+ invalidateCache();
+ itemChanged();
+}
+
+/*!
+ \return Color Map used for mapping the intensity values to colors
+ \sa setColorMap()
+*/
+const QwtColorMap &PlotWaterfall::colorMap() const
+{
+ return *d_data->colorMap;
+}
+
+/*!
+ \return Bounding rect of the data
+ \sa QwtRasterData::boundingRect
+*/
+#if QWT_VERSION < 0x060000
+QwtDoubleRect PlotWaterfall::boundingRect() const
+{
+ return d_data->data->boundingRect();
+}
+#endif
+
+/*!
+ \brief Returns the recommended raster for a given rect.
+
+ F.e the raster hint is used to limit the resolution of
+ the image that is rendered.
+
+ \param rect Rect for the raster hint
+ \return data().rasterHint(rect)
+*/
+#if QWT_VERSION < 0x060000
+QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const
+{
+ return d_data->data->rasterHint(rect);
+}
+#endif
+
+/*!
+ \brief Render an image from the data and color map.
+
+ The area is translated into a rect of the paint device.
+ For each pixel of this rect the intensity is mapped
+ into a color.
+
+ \param xMap X-Scale Map
+ \param yMap Y-Scale Map
+ \param area Area that should be rendered in scale coordinates.
+
+ \return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending
+ on the color map.
+
+ \sa QwtRasterData::intensity(), QwtColorMap::rgb(),
+ QwtColorMap::colorIndex()
+*/
+#if QWT_VERSION < 0x060000
+QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap,
+ const QwtScaleMap &yMap,
+ const QwtDoubleRect &area) const
+#else
+QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap,
+ const QwtScaleMap &yMap,
+ const QRectF &area,
+ const QSize &size) const
+#endif
+{
+ if ( area.isEmpty() )
+ return QImage();
+
+#if QWT_VERSION < 0x060000
+ QRect rect = transform(xMap, yMap, area);
+ const QSize res = d_data->data->rasterHint(area);
+#else
+ QRect rect(0,0,0,0);
+ const QSize res(0,0);
+#endif
+
+ QwtScaleMap xxMap = xMap;
+ QwtScaleMap yyMap = yMap;
+
+ if ( res.isValid() )
+ {
+ /*
+ It is useless to render an image with a higher resolution
+ than the data offers. Of course someone will have to
+ scale this image later into the size of the given rect, but f.e.
+ in case of postscript this will done on the printer.
+ */
+ rect.setSize(rect.size().boundedTo(res));
+
+ int px1 = rect.x();
+ int px2 = rect.x() + rect.width();
+ if ( xMap.p1() > xMap.p2() )
+ qSwap(px1, px2);
+
+ double sx1 = area.x();
+ double sx2 = area.x() + area.width();
+ if ( xMap.s1() > xMap.s2() )
+ qSwap(sx1, sx2);
+
+ int py1 = rect.y();
+ int py2 = rect.y() + rect.height();
+ if ( yMap.p1() > yMap.p2() )
+ qSwap(py1, py2);
+
+ double sy1 = area.y();
+ double sy2 = area.y() + area.height();
+ if ( yMap.s1() > yMap.s2() )
+ qSwap(sy1, sy2);
+
+ xxMap.setPaintInterval(px1, px2);
+ xxMap.setScaleInterval(sx1, sx2);
+ yyMap.setPaintInterval(py1, py2);
+ yyMap.setScaleInterval(sy1, sy2);
+ }
+
+ PlotWaterfallImage image(rect.size(), d_data->colorMap->format());
+
+#if QWT_VERSION < 0x060000
+ const QwtDoubleInterval intensityRange = d_data->data->range();
+#else
+ const QwtInterval intensityRange = d_data->data->interval(Qt::ZAxis);
+#endif
+ if ( !intensityRange.isValid() )
+ return image;
+
+ d_data->data->initRaster(area, rect.size());
+
+ if ( d_data->colorMap->format() == QwtColorMap::RGB )
+ {
+ for ( int y = rect.top(); y <= rect.bottom(); y++ )
+ {
+ const double ty = yyMap.invTransform(y);
+
+ QRgb *line = (QRgb *)image.scanLine(y - rect.top());
+ for ( int x = rect.left(); x <= rect.right(); x++ )
+ {
+ const double tx = xxMap.invTransform(x);
+
+ *line++ = d_data->colorMap->rgb(intensityRange,
+ d_data->data->value(tx, ty));
+ }
+ }
+ }
+ else if ( d_data->colorMap->format() == QwtColorMap::Indexed )
+ {
+ image.setColorTable(d_data->colorMap->colorTable(intensityRange));
+
+ for ( int y = rect.top(); y <= rect.bottom(); y++ )
+ {
+ const double ty = yyMap.invTransform(y);
+
+ unsigned char *line = image.scanLine(y - rect.top());
+ for ( int x = rect.left(); x <= rect.right(); x++ )
+ {
+ const double tx = xxMap.invTransform(x);
+
+ *line++ = d_data->colorMap->colorIndex(intensityRange,
+ d_data->data->value(tx, ty));
+ }
+ }
+ }
+
+ d_data->data->discardRaster();
+
+ // Mirror the image in case of inverted maps
+
+ const bool hInvert = xxMap.p1() > xxMap.p2();
+ const bool vInvert = yyMap.p1() < yyMap.p2();
+ if ( hInvert || vInvert )
+ {
+ image = image.mirrored(hInvert, vInvert);
+ }
+
+ return image;
+}
+
+/*!
+ \brief Draw the spectrogram
+
+ \param painter Painter
+ \param xMap Maps x-values into pixel coordinates.
+ \param yMap Maps y-values into pixel coordinates.
+ \param canvasRect Contents rect of the canvas in painter coordinates
+
+ \sa setDisplayMode, renderImage,
+ QwtPlotRasterItem::draw, drawContourLines
+*/
+
+void PlotWaterfall::draw(QPainter *painter,
+ const QwtScaleMap &xMap,
+ const QwtScaleMap &yMap,
+ const QRect &canvasRect) const
+{
+ QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect);
+}
+
diff --git a/gr-qtgui/lib/plot_waterfall.h b/gr-qtgui/lib/plot_waterfall.h
new file mode 100644
index 000000000..df2537b57
--- /dev/null
+++ b/gr-qtgui/lib/plot_waterfall.h
@@ -0,0 +1,67 @@
+#ifndef PLOT_WATERFALL_H
+#define PLOT_WATERFALL_H
+
+#include <qglobal.h>
+#include <waterfallGlobalData.h>
+#include <qwt_plot_rasteritem.h>
+
+#if QWT_VERSION >= 0x060000
+#include <qwt_point_3d.h> // doesn't seem necessary, but is...
+#include <qwt_compat.h>
+#endif
+
+class QwtColorMap;
+
+/*!
+ \brief A plot item, which displays a waterfall spectrogram
+
+ A waterfall displays threedimenional data, where the 3rd dimension
+ ( the intensity ) is displayed using colors. The colors are calculated
+ from the values using a color map.
+
+ \sa QwtRasterData, QwtColorMap
+*/
+
+class PlotWaterfall: public QwtPlotRasterItem
+{
+public:
+ explicit PlotWaterfall(WaterfallData* data,
+ const QString &title = QString::null);
+ virtual ~PlotWaterfall();
+
+ const WaterfallData* data()const;
+
+ void setColorMap(const QwtColorMap &);
+
+ const QwtColorMap &colorMap() const;
+
+#if QWT_VERSION < 0x060000
+ virtual QwtDoubleRect boundingRect() const;
+ virtual QSize rasterHint(const QwtDoubleRect &) const;
+#endif
+
+ virtual int rtti() const;
+
+ virtual void draw(QPainter *p,
+ const QwtScaleMap &xMap,
+ const QwtScaleMap &yMap,
+ const QRect &rect) const;
+
+protected:
+#if QWT_VERSION < 0x060000
+ QImage renderImage(const QwtScaleMap &xMap,
+ const QwtScaleMap &yMap,
+ const QwtDoubleRect &rect) const;
+#else
+ QImage renderImage(const QwtScaleMap &xMap,
+ const QwtScaleMap &yMap,
+ const QRectF &rect,
+ const QSize &size=QSize(0,0)) const;
+#endif
+
+private:
+ class PrivateData;
+ PrivateData *d_data;
+};
+
+#endif
diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc
new file mode 100644
index 000000000..de730a871
--- /dev/null
+++ b/gr-qtgui/lib/qtgui_sink_c.cc
@@ -0,0 +1,310 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qtgui_sink_c.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+#include <QTimer>
+
+qtgui_sink_c_sptr
+qtgui_make_sink_c (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent)
+{
+ return gnuradio::get_initial_sptr(new qtgui_sink_c (fftsize, wintype,
+ fc, bw, name,
+ plotfreq, plotwaterfall,
+ plottime, plotconst,
+ parent));
+}
+
+qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent)
+ : gr_block ("sink_c",
+ gr_make_io_signature (1, -1, sizeof(gr_complex)),
+ gr_make_io_signature (0, 0, 0)),
+ d_fftsize(fftsize),
+ d_wintype((gr_firdes::win_type)(wintype)),
+ d_center_freq(fc), d_bandwidth(bw), d_name(name),
+ d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall),
+ d_plottime(plottime), d_plotconst(plotconst),
+ d_parent(parent)
+{
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new gri_fft_complex (d_fftsize, true);
+
+ d_index = 0;
+ d_residbuf = new gr_complex[d_fftsize];
+
+ buildwindow();
+
+ initialize();
+}
+
+qtgui_sink_c::~qtgui_sink_c()
+{
+ delete d_main_gui;
+ delete [] d_residbuf;
+ delete d_fft;
+}
+
+void
+qtgui_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_fftsize, 8191);
+ }
+}
+
+void
+qtgui_sink_c::initialize()
+{
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ if(d_center_freq < 0) {
+ throw std::runtime_error("qtgui_sink_c: Received bad center frequency.\n");
+ }
+
+ uint64_t maxBufferSize = 32768;
+ d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize,
+ d_center_freq,
+ -d_bandwidth/2.0,
+ d_bandwidth/2.0);
+
+ d_main_gui->SetDisplayTitle(d_name);
+ d_main_gui->SetFFTSize(d_fftsize);
+ d_main_gui->SetWindowType((int)d_wintype);
+
+ d_main_gui->OpenSpectrumWindow(d_parent,
+ d_plotfreq, d_plotwaterfall,
+ d_plottime, d_plotconst);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.5);
+
+ d_last_update = gruel::high_res_timer_now();
+ d_update_active = false;
+}
+
+
+void
+qtgui_sink_c::exec_()
+{
+ d_qApplication->exec();
+}
+
+QWidget*
+qtgui_sink_c::qwidget()
+{
+ return d_main_gui->qwidget();
+}
+
+PyObject*
+qtgui_sink_c::pyqwidget()
+{
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget());
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+}
+
+void
+qtgui_sink_c::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+{
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ -d_bandwidth/2.0,
+ d_bandwidth/2.0);
+}
+
+void
+qtgui_sink_c::set_time_domain_axis(double min, double max)
+{
+ d_main_gui->SetTimeDomainAxis(min, max);
+}
+
+void
+qtgui_sink_c::set_constellation_axis(double xmin, double xmax,
+ double ymin, double ymax)
+{
+ d_main_gui->SetConstellationAxis(xmin, xmax, ymin, ymax);
+}
+
+void
+qtgui_sink_c::set_constellation_pen_size(int size)
+{
+ d_main_gui->SetConstellationPenSize(size);
+}
+
+
+void
+qtgui_sink_c::set_frequency_axis(double min, double max)
+{
+ d_main_gui->SetFrequencyAxis(min, max);
+}
+
+void
+qtgui_sink_c::set_update_time(double t)
+{
+ d_update_time = t * gruel::high_res_timer_tps();
+ d_main_gui->SetUpdateTime(t);
+}
+
+void
+qtgui_sink_c::fft(const gr_complex *data_in, int size)
+{
+ if (d_window.size()) {
+ gr_complex *dst = d_fft->get_inbuf();
+ int i;
+ for (i = 0; i < size; i++) // apply window
+ dst[i] = data_in[i] * d_window[i];
+ }
+ else {
+ memcpy (d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
+ }
+
+ d_fft->execute (); // compute the fft
+}
+
+void
+qtgui_sink_c::windowreset()
+{
+ gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType();
+ if(d_wintype != newwintype) {
+ d_wintype = newwintype;
+ buildwindow();
+ }
+}
+
+void
+qtgui_sink_c::buildwindow()
+{
+ d_window.clear();
+ if(d_wintype != 0) {
+ d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76);
+ }
+}
+
+void
+qtgui_sink_c::fftresize()
+{
+ int newfftsize = d_main_gui->GetFFTSize();
+
+ if(newfftsize != d_fftsize) {
+
+ // Resize residbuf and replace data
+ delete [] d_residbuf;
+ d_residbuf = new gr_complex[newfftsize];
+
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
+
+ // Reset window to reflect new size
+ buildwindow();
+
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new gri_fft_complex (d_fftsize, true);
+ }
+}
+
+
+int
+qtgui_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)
+{
+ int j=0;
+ const gr_complex *in = (const gr_complex*)input_items[0];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+
+ for(int i=0; i < noutput_items; i+=d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize-d_index;
+
+ if (!d_update_active && (gruel::high_res_timer_now() - d_last_update) < d_update_time) {
+ consume_each(noutput_items);
+ return noutput_items;
+ } else {
+ d_last_update = gruel::high_res_timer_now();
+ d_update_active = true;
+ }
+
+ // If we have enough input for one full FFT, do it
+ if(datasize >= resid) {
+ const gruel::high_res_timer_type currentTime = gruel::high_res_timer_now();
+
+ // Fill up residbuf with d_fftsize number of items
+ memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*resid);
+ d_index = 0;
+
+ j += resid;
+ fft(d_residbuf, d_fftsize);
+
+ d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize,
+ NULL, 0, (float*)d_residbuf, d_fftsize,
+ currentTime, true);
+ d_update_active = false;
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*datasize);
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ consume_each(j);
+ return j;
+}
diff --git a/gr-qtgui/lib/qtgui_sink_f.cc b/gr-qtgui/lib/qtgui_sink_f.cc
new file mode 100644
index 000000000..a02f89d0a
--- /dev/null
+++ b/gr-qtgui/lib/qtgui_sink_f.cc
@@ -0,0 +1,294 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qtgui_sink_f.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+#include <QTimer>
+
+qtgui_sink_f_sptr
+qtgui_make_sink_f (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent)
+{
+ return gnuradio::get_initial_sptr(new qtgui_sink_f (fftsize, wintype,
+ fc, bw, name,
+ plotfreq, plotwaterfall,
+ plottime, plotconst,
+ parent));
+}
+
+qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent)
+ : gr_block ("sink_f",
+ gr_make_io_signature (1, 1, sizeof(float)),
+ gr_make_io_signature (0, 0, 0)),
+ d_fftsize(fftsize),
+ d_wintype((gr_firdes::win_type)(wintype)),
+ d_center_freq(fc), d_bandwidth(bw), d_name(name),
+ d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall),
+ d_plottime(plottime), d_plotconst(plotconst),
+ d_parent(parent)
+{
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new gri_fft_complex (d_fftsize, true);
+
+ d_index = 0;
+ d_residbuf = new float[d_fftsize];
+
+ buildwindow();
+
+ initialize();
+}
+
+qtgui_sink_f::~qtgui_sink_f()
+{
+ delete d_main_gui;
+ delete [] d_residbuf;
+ delete d_fft;
+}
+
+void
+qtgui_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_fftsize, 8191);
+ }
+}
+
+void
+qtgui_sink_f::initialize()
+{
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+
+ uint64_t maxBufferSize = 32768;
+ d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize,
+ d_center_freq,
+ -d_bandwidth/2.0,
+ d_bandwidth/2.0);
+ d_main_gui->SetDisplayTitle(d_name);
+ d_main_gui->SetFFTSize(d_fftsize);
+ d_main_gui->SetWindowType((int)d_wintype);
+
+ d_main_gui->OpenSpectrumWindow(d_parent,
+ d_plotfreq, d_plotwaterfall,
+ d_plottime, d_plotconst);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
+
+void
+qtgui_sink_f::exec_()
+{
+ d_qApplication->exec();
+}
+
+QWidget*
+qtgui_sink_f::qwidget()
+{
+ return d_main_gui->qwidget();
+}
+
+PyObject*
+qtgui_sink_f::pyqwidget()
+{
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget());
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+}
+
+void
+qtgui_sink_f::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+{
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ -d_bandwidth/2.0,
+ d_bandwidth/2.0);
+}
+
+void
+qtgui_sink_f::set_time_domain_axis(double min, double max)
+{
+ d_main_gui->SetTimeDomainAxis(min, max);
+}
+
+void
+qtgui_sink_f::set_constellation_axis(double xmin, double xmax,
+ double ymin, double ymax)
+{
+ d_main_gui->SetConstellationAxis(xmin, xmax, ymin, ymax);
+}
+
+void
+qtgui_sink_f::set_constellation_pen_size(int size)
+{
+ d_main_gui->SetConstellationPenSize(size);
+}
+
+
+void
+qtgui_sink_f::set_frequency_axis(double min, double max)
+{
+ d_main_gui->SetFrequencyAxis(min, max);
+}
+
+void
+qtgui_sink_f::set_update_time(double t)
+{
+ d_update_time = t;
+ d_main_gui->SetUpdateTime(d_update_time);
+}
+
+void
+qtgui_sink_f::fft(const float *data_in, int size)
+{
+ if (d_window.size()) {
+ gr_complex *dst = d_fft->get_inbuf();
+ for (int i = 0; i < size; i++) // apply window
+ dst[i] = data_in[i] * d_window[i];
+ }
+ else {
+ gr_complex *dst = d_fft->get_inbuf();
+ for (int i = 0; i < size; i++) // float to complex conversion
+ dst[i] = data_in[i];
+ }
+
+ d_fft->execute (); // compute the fft
+}
+
+void
+qtgui_sink_f::windowreset()
+{
+ gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType();
+ if(d_wintype != newwintype) {
+ d_wintype = newwintype;
+ buildwindow();
+ }
+}
+
+void
+qtgui_sink_f::buildwindow()
+{
+ d_window.clear();
+ if(d_wintype != 0) {
+ d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76);
+ }
+}
+
+void
+qtgui_sink_f::fftresize()
+{
+ int newfftsize = d_main_gui->GetFFTSize();
+
+ if(newfftsize != d_fftsize) {
+
+ // Resize residbuf and replace data
+ delete [] d_residbuf;
+ d_residbuf = new float[newfftsize];
+
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
+
+ // Reset window to reflect new size
+ buildwindow();
+
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new gri_fft_complex (d_fftsize, true);
+ }
+}
+
+
+int
+qtgui_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)
+{
+ int j=0;
+ const float *in = (const float*)input_items[0];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+
+ for(int i=0; i < noutput_items; i+=d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize-d_index;
+
+ // If we have enough input for one full FFT, do it
+ if(datasize >= resid) {
+ const gruel::high_res_timer_type currentTime = gruel::high_res_timer_now();
+
+ // Fill up residbuf with d_fftsize number of items
+ memcpy(d_residbuf+d_index, &in[j], sizeof(float)*resid);
+ d_index = 0;
+
+ j += resid;
+ fft(d_residbuf, d_fftsize);
+
+ d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize,
+ (float*)d_residbuf, d_fftsize, NULL, 0,
+ currentTime, true);
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ memcpy(d_residbuf+d_index, &in[j], sizeof(float)*datasize);
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ consume_each(j);
+ return j;
+}
diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc
new file mode 100644
index 000000000..773199462
--- /dev/null
+++ b/gr-qtgui/lib/qtgui_time_sink_c.cc
@@ -0,0 +1,192 @@
+/* -*- 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qtgui_time_sink_c.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+#include <QTimer>
+
+qtgui_time_sink_c_sptr
+qtgui_make_time_sink_c (int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+{
+ return gnuradio::get_initial_sptr(new qtgui_time_sink_c (size, bw, name,
+ nconnections, parent));
+}
+
+qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : 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)
+{
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(new double[d_size]);
+ }
+
+ initialize();
+ set_output_multiple(d_size);
+}
+
+qtgui_time_sink_c::~qtgui_time_sink_c()
+{
+ // d_main_gui is a qwidget destroyed with its parent
+ for(int i = 0; i < d_nconnections; i++) {
+ delete [] d_residbufs[i];
+ }
+}
+
+void
+qtgui_time_sink_c::initialize()
+{
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
+ d_main_gui->setFrequencyRange(0, 0, d_bandwidth);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+}
+
+
+void
+qtgui_time_sink_c::exec_()
+{
+ d_qApplication->exec();
+}
+
+QWidget*
+qtgui_time_sink_c::qwidget()
+{
+ return d_main_gui;
+}
+
+PyObject*
+qtgui_time_sink_c::pyqwidget()
+{
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+}
+
+void
+qtgui_time_sink_c::set_time_domain_axis(double min, double max)
+{
+ d_main_gui->setTimeDomainAxis(min, max);
+}
+
+void
+qtgui_time_sink_c::set_update_time(double t)
+{
+ d_update_time = t;
+ d_main_gui->setUpdateTime(d_update_time);
+}
+
+void
+qtgui_time_sink_c::set_title(int which, const std::string &title)
+{
+ d_main_gui->setTitle(which, title.c_str());
+}
+
+void
+qtgui_time_sink_c::set_color(int which, const std::string &color)
+{
+ d_main_gui->setColor(which, color.c_str());
+}
+
+int
+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];
+
+ for(int i=0; i < noutput_items; i+=d_size) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_size-d_index;
+ idx = 0;
+
+ // If we have enough input for one full plot, do it
+ if(datasize >= resid) {
+ d_current_time = gruel::high_res_timer_now();
+
+ // Fill up residbufs with d_size number of items
+ for(n = 0; n < d_nconnections; n+=2) {
+ in = (const gr_complex*)input_items[idx++];
+ for(unsigned int k = 0; k < resid; k++) {
+ d_residbufs[n][d_index+k] = in[j+k].real();
+ d_residbufs[n+1][d_index+k] = in[j+k].imag();
+ }
+ }
+
+ // Update the plot if its time
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = d_current_time;
+ d_qApplication->postEvent(d_main_gui,
+ new TimeUpdateEvent(d_residbufs, d_size));
+ }
+
+ d_index = 0;
+ 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++) {
+ d_residbufs[n][d_index+k] = in[j+k].real();
+ d_residbufs[n+1][d_index+k] = in[j+k].imag();
+ }
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+}
diff --git a/gr-qtgui/lib/qtgui_time_sink_f.cc b/gr-qtgui/lib/qtgui_time_sink_f.cc
new file mode 100644
index 000000000..1a23023b5
--- /dev/null
+++ b/gr-qtgui/lib/qtgui_time_sink_f.cc
@@ -0,0 +1,190 @@
+/* -*- 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qtgui_time_sink_f.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+#include <QTimer>
+
+qtgui_time_sink_f_sptr
+qtgui_make_time_sink_f (int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+{
+ return gnuradio::get_initial_sptr(new qtgui_time_sink_f (size, bw, name,
+ nconnections, parent));
+}
+
+qtgui_time_sink_f::qtgui_time_sink_f (int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : 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)
+{
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(new double[d_size]);
+ }
+
+ initialize();
+ set_output_multiple(d_size);
+}
+
+qtgui_time_sink_f::~qtgui_time_sink_f()
+{
+ // d_main_gui is a qwidget destroyed with its parent
+ for(int i = 0; i < d_nconnections; i++) {
+ delete [] d_residbufs[i];
+ }
+}
+
+void
+qtgui_time_sink_f::initialize()
+{
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
+ d_main_gui->setFrequencyRange(0, 0, d_bandwidth);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+}
+
+
+void
+qtgui_time_sink_f::exec_()
+{
+ d_qApplication->exec();
+}
+
+QWidget*
+qtgui_time_sink_f::qwidget()
+{
+ return d_main_gui;
+}
+
+PyObject*
+qtgui_time_sink_f::pyqwidget()
+{
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+}
+
+void
+qtgui_time_sink_f::set_time_domain_axis(double min, double max)
+{
+ d_main_gui->setTimeDomainAxis(min, max);
+}
+
+void
+qtgui_time_sink_f::set_update_time(double t)
+{
+ d_update_time = t;
+ d_main_gui->setUpdateTime(d_update_time);
+}
+
+void
+qtgui_time_sink_f::set_title(int which, const std::string &title)
+{
+ d_main_gui->setTitle(which, title.c_str());
+}
+
+void
+qtgui_time_sink_f::set_color(int which, const std::string &color)
+{
+ d_main_gui->setColor(which, color.c_str());
+}
+
+int
+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];
+
+ for(int i=0; i < noutput_items; i+=d_size) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_size-d_index;
+ idx = 0;
+
+ // If we have enough input for one full plot, do it
+ if(datasize >= resid) {
+ d_current_time = gruel::high_res_timer_now();
+
+ // Fill up residbufs with d_size number of items
+ for(n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[idx++];
+ for(unsigned int k = 0; k < resid; k++) {
+ d_residbufs[n][d_index+k] = in[j+k];
+ }
+ }
+
+ // Update the plot if its time
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = d_current_time;
+ d_qApplication->postEvent(d_main_gui,
+ new TimeUpdateEvent(d_residbufs, d_size));
+ }
+
+ d_index = 0;
+ 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++) {
+ d_residbufs[n][d_index+k] = in[j+k];
+ }
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+}
diff --git a/gr-qtgui/lib/qtgui_util.cc b/gr-qtgui/lib/qtgui_util.cc
new file mode 100644
index 000000000..543ce1b1c
--- /dev/null
+++ b/gr-qtgui/lib/qtgui_util.cc
@@ -0,0 +1,103 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,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.
+ */
+
+#include <qtgui_util.h>
+
+#if QWT_VERSION < 0x060000
+QwtPickerDblClickPointMachine::QwtPickerDblClickPointMachine()
+ : QwtPickerMachine ()
+{
+}
+#else
+QwtPickerDblClickPointMachine::QwtPickerDblClickPointMachine()
+ : QwtPickerMachine (PointSelection)
+{
+}
+#endif
+
+QwtPickerDblClickPointMachine::~QwtPickerDblClickPointMachine()
+{
+
+}
+
+#if QWT_VERSION < 0x060000
+QwtPickerMachine::CommandList
+QwtPickerDblClickPointMachine::transition(const QwtEventPattern &eventPattern,
+ const QEvent *e)
+{
+ QwtPickerMachine::CommandList cmdList;
+ switch(e->type()) {
+ case QEvent::MouseButtonDblClick:
+ if ( eventPattern.mouseMatch(QwtEventPattern::MouseSelect1,
+ (const QMouseEvent *)e) ) {
+ cmdList += QwtPickerMachine::Begin;
+ cmdList += QwtPickerMachine::Append;
+ cmdList += QwtPickerMachine::End;
+ }
+ break;
+ default:
+ break;
+ }
+ return cmdList;
+}
+
+#else
+
+QList<QwtPickerMachine::Command>
+QwtPickerDblClickPointMachine::transition(const QwtEventPattern &eventPattern,
+ const QEvent *e)
+{
+ QList<QwtPickerMachine::Command> cmdList;
+ switch(e->type()) {
+ case QEvent::MouseButtonDblClick:
+ if ( eventPattern.mouseMatch(QwtEventPattern::MouseSelect1,
+ (const QMouseEvent *)e) ) {
+ cmdList += QwtPickerMachine::Begin;
+ cmdList += QwtPickerMachine::Append;
+ cmdList += QwtPickerMachine::End;
+ }
+ break;
+ default:
+ break;
+ }
+ return cmdList;
+}
+#endif
+
+QwtDblClickPlotPicker::QwtDblClickPlotPicker(QwtPlotCanvas* canvas)
+ : QwtPlotPicker(canvas)
+{
+#if QWT_VERSION < 0x060000
+ setSelectionFlags(QwtPicker::PointSelection);
+#endif
+}
+
+QwtDblClickPlotPicker::~QwtDblClickPlotPicker()
+{
+}
+
+QwtPickerMachine*
+QwtDblClickPlotPicker::stateMachine(int n) const
+{
+ return new QwtPickerDblClickPointMachine;
+}
+
diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc
new file mode 100644
index 000000000..bec39747b
--- /dev/null
+++ b/gr-qtgui/lib/spectrumUpdateEvents.cc
@@ -0,0 +1,223 @@
+#ifndef SPECTRUM_UPDATE_EVENTS_C
+#define SPECTRUM_UPDATE_EVENTS_C
+
+#include <spectrumUpdateEvents.h>
+
+SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex<float>* fftPoints,
+ const uint64_t numFFTDataPoints,
+ const double* realTimeDomainPoints,
+ const double* imagTimeDomainPoints,
+ const uint64_t numTimeDomainDataPoints,
+ const gruel::high_res_timer_type dataTimestamp,
+ const bool repeatDataFlag,
+ const bool lastOfMultipleUpdateFlag,
+ const gruel::high_res_timer_type generatedTimestamp,
+ const int droppedFFTFrames)
+ : QEvent(QEvent::Type(10005))
+{
+ if(numFFTDataPoints < 1) {
+ _numFFTDataPoints = 1;
+ }
+ else {
+ _numFFTDataPoints = numFFTDataPoints;
+ }
+
+ if(numTimeDomainDataPoints < 1) {
+ _numTimeDomainDataPoints = 1;
+ }
+ else {
+ _numTimeDomainDataPoints = numTimeDomainDataPoints;
+ }
+
+ _fftPoints = new std::complex<float>[_numFFTDataPoints];
+ _fftPoints[0] = std::complex<float>(0,0);
+ memcpy(_fftPoints, fftPoints, numFFTDataPoints*sizeof(std::complex<float>));
+
+ _realDataTimeDomainPoints = new double[_numTimeDomainDataPoints];
+ memset(_realDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double));
+ if(numTimeDomainDataPoints > 0) {
+ memcpy(_realDataTimeDomainPoints, realTimeDomainPoints,
+ numTimeDomainDataPoints*sizeof(double));
+ }
+
+ _imagDataTimeDomainPoints = new double[_numTimeDomainDataPoints];
+ memset(_imagDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double));
+ if(numTimeDomainDataPoints > 0) {
+ memcpy(_imagDataTimeDomainPoints, imagTimeDomainPoints,
+ numTimeDomainDataPoints*sizeof(double));
+ }
+ _dataTimestamp = dataTimestamp;
+ _repeatDataFlag = repeatDataFlag;
+ _lastOfMultipleUpdateFlag = lastOfMultipleUpdateFlag;
+ _eventGeneratedTimestamp = generatedTimestamp;
+ _droppedFFTFrames = droppedFFTFrames;
+}
+
+SpectrumUpdateEvent::~SpectrumUpdateEvent()
+{
+ delete[] _fftPoints;
+ delete[] _realDataTimeDomainPoints;
+ delete[] _imagDataTimeDomainPoints;
+}
+
+const std::complex<float>*
+SpectrumUpdateEvent::getFFTPoints() const
+{
+ return _fftPoints;
+}
+
+const double*
+SpectrumUpdateEvent::getRealTimeDomainPoints() const
+{
+ return _realDataTimeDomainPoints;
+}
+
+const double*
+SpectrumUpdateEvent::getImagTimeDomainPoints() const
+{
+ return _imagDataTimeDomainPoints;
+}
+
+uint64_t
+SpectrumUpdateEvent::getNumFFTDataPoints() const
+{
+ return _numFFTDataPoints;
+}
+
+uint64_t
+SpectrumUpdateEvent::getNumTimeDomainDataPoints() const
+{
+ return _numTimeDomainDataPoints;
+}
+
+gruel::high_res_timer_type
+SpectrumUpdateEvent::getDataTimestamp() const
+{
+ return _dataTimestamp;
+}
+
+bool
+SpectrumUpdateEvent::getRepeatDataFlag() const
+{
+ return _repeatDataFlag;
+}
+
+bool
+SpectrumUpdateEvent::getLastOfMultipleUpdateFlag() const
+{
+ return _lastOfMultipleUpdateFlag;
+}
+
+gruel::high_res_timer_type
+SpectrumUpdateEvent::getEventGeneratedTimestamp() const
+{
+ return _eventGeneratedTimestamp;
+}
+
+int
+SpectrumUpdateEvent::getDroppedFFTFrames() const
+{
+ return _droppedFFTFrames;
+}
+
+SpectrumWindowCaptionEvent::SpectrumWindowCaptionEvent(const QString& newLbl)
+ : QEvent(QEvent::Type(10008))
+{
+ _labelString = newLbl;
+}
+
+SpectrumWindowCaptionEvent::~SpectrumWindowCaptionEvent()
+{
+}
+
+QString
+SpectrumWindowCaptionEvent::getLabel()
+{
+ return _labelString;
+}
+
+SpectrumWindowResetEvent::SpectrumWindowResetEvent()
+ : QEvent(QEvent::Type(10009))
+{
+}
+
+SpectrumWindowResetEvent::~SpectrumWindowResetEvent()
+{
+}
+
+SpectrumFrequencyRangeEvent::SpectrumFrequencyRangeEvent(const double centerFreq,
+ const double startFreq,
+ const double stopFreq)
+ : QEvent(QEvent::Type(10010))
+{
+ _centerFrequency = centerFreq;
+ _startFrequency = startFreq;
+ _stopFrequency = stopFreq;
+}
+
+SpectrumFrequencyRangeEvent::~SpectrumFrequencyRangeEvent()
+{
+}
+
+double
+SpectrumFrequencyRangeEvent::GetCenterFrequency() const
+{
+ return _centerFrequency;
+}
+
+double
+SpectrumFrequencyRangeEvent::GetStartFrequency() const
+{
+ return _startFrequency;
+}
+
+double
+SpectrumFrequencyRangeEvent::GetStopFrequency() const
+{
+ return _stopFrequency;
+}
+
+
+/***************************************************************************/
+#include <iostream>
+TimeUpdateEvent::TimeUpdateEvent(const std::vector<double*> timeDomainPoints,
+ const uint64_t numTimeDomainDataPoints)
+ : QEvent(QEvent::Type(10005))
+{
+ if(numTimeDomainDataPoints < 1) {
+ _numTimeDomainDataPoints = 1;
+ }
+ else {
+ _numTimeDomainDataPoints = numTimeDomainDataPoints;
+ }
+
+ _nplots = timeDomainPoints.size();
+ for(size_t i = 0; i < _nplots; i++) {
+ _dataTimeDomainPoints.push_back(new double[_numTimeDomainDataPoints]);
+ if(numTimeDomainDataPoints > 0) {
+ memcpy(_dataTimeDomainPoints[i], timeDomainPoints[i],
+ _numTimeDomainDataPoints*sizeof(double));
+ }
+ }
+}
+
+TimeUpdateEvent::~TimeUpdateEvent()
+{
+ for(size_t i = 0; i < _nplots; i++) {
+ delete[] _dataTimeDomainPoints[i];
+ }
+}
+
+const std::vector<double*>
+TimeUpdateEvent::getTimeDomainPoints() const
+{
+ return _dataTimeDomainPoints;
+}
+
+uint64_t
+TimeUpdateEvent::getNumTimeDomainDataPoints() const
+{
+ return _numTimeDomainDataPoints;
+}
+
+#endif /* SPECTRUM_UPDATE_EVENTS_C */
diff --git a/gr-qtgui/lib/spectrumUpdateEvents.h b/gr-qtgui/lib/spectrumUpdateEvents.h
new file mode 100644
index 000000000..faef0f087
--- /dev/null
+++ b/gr-qtgui/lib/spectrumUpdateEvents.h
@@ -0,0 +1,115 @@
+#ifndef SPECTRUM_UPDATE_EVENTS_H
+#define SPECTRUM_UPDATE_EVENTS_H
+
+#include <stdint.h>
+#include <QEvent>
+#include <QString>
+#include <complex>
+#include <vector>
+#include <gruel/high_res_timer.h>
+
+class SpectrumUpdateEvent:public QEvent{
+
+public:
+ SpectrumUpdateEvent(const std::complex<float>* fftPoints,
+ const uint64_t numFFTDataPoints,
+ const double* realTimeDomainPoints,
+ const double* imagTimeDomainPoints,
+ const uint64_t numTimeDomainDataPoints,
+ const gruel::high_res_timer_type dataTimestamp,
+ const bool repeatDataFlag,
+ const bool lastOfMultipleUpdateFlag,
+ const gruel::high_res_timer_type generatedTimestamp,
+ const int droppedFFTFrames);
+
+ ~SpectrumUpdateEvent();
+
+ const std::complex<float>* getFFTPoints() const;
+ const double* getRealTimeDomainPoints() const;
+ const double* getImagTimeDomainPoints() const;
+ uint64_t getNumFFTDataPoints() const;
+ uint64_t getNumTimeDomainDataPoints() const;
+ gruel::high_res_timer_type getDataTimestamp() const;
+ bool getRepeatDataFlag() const;
+ bool getLastOfMultipleUpdateFlag() const;
+ gruel::high_res_timer_type getEventGeneratedTimestamp() const;
+ int getDroppedFFTFrames() const;
+
+protected:
+
+private:
+ std::complex<float>* _fftPoints;
+ double* _realDataTimeDomainPoints;
+ double* _imagDataTimeDomainPoints;
+ uint64_t _numFFTDataPoints;
+ uint64_t _numTimeDomainDataPoints;
+ gruel::high_res_timer_type _dataTimestamp;
+ bool _repeatDataFlag;
+ bool _lastOfMultipleUpdateFlag;
+ gruel::high_res_timer_type _eventGeneratedTimestamp;
+ int _droppedFFTFrames;
+};
+
+class SpectrumWindowCaptionEvent:public QEvent{
+public:
+ SpectrumWindowCaptionEvent(const QString&);
+ ~SpectrumWindowCaptionEvent();
+ QString getLabel();
+
+protected:
+
+private:
+ QString _labelString;
+};
+
+class SpectrumWindowResetEvent:public QEvent{
+public:
+ SpectrumWindowResetEvent();
+ ~SpectrumWindowResetEvent();
+
+protected:
+
+private:
+
+};
+
+class SpectrumFrequencyRangeEvent:public QEvent{
+public:
+ SpectrumFrequencyRangeEvent(const double, const double, const double);
+ ~SpectrumFrequencyRangeEvent();
+ double GetCenterFrequency()const;
+ double GetStartFrequency()const;
+ double GetStopFrequency()const;
+
+protected:
+
+private:
+ double _centerFrequency;
+ double _startFrequency;
+ double _stopFrequency;
+};
+
+
+class TimeUpdateEvent: public QEvent
+{
+public:
+ TimeUpdateEvent(const std::vector<double*> timeDomainPoints,
+ const uint64_t numTimeDomainDataPoints);
+
+ ~TimeUpdateEvent();
+
+ int which() const;
+ const std::vector<double*> getTimeDomainPoints() const;
+ uint64_t getNumTimeDomainDataPoints() const;
+ bool getRepeatDataFlag() const;
+
+protected:
+
+private:
+ size_t _nplots;
+ std::vector<double*> _dataTimeDomainPoints;
+ uint64_t _numTimeDomainDataPoints;
+};
+
+
+#endif /* SPECTRUM_UPDATE_EVENTS_H */
diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc
new file mode 100644
index 000000000..dd9011dbd
--- /dev/null
+++ b/gr-qtgui/lib/spectrumdisplayform.cc
@@ -0,0 +1,754 @@
+/* -*- c++ -*- */
+/*
+ * 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 <cmath>
+#include <QColorDialog>
+#include <QMessageBox>
+#include <spectrumdisplayform.h>
+
+SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+
+ _systemSpecifiedFlag = false;
+ _intValidator = new QIntValidator(this);
+ _intValidator->setBottom(0);
+ _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame);
+ _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame);
+ _timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame);
+ _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame);
+ _numRealDataPoints = 1024;
+ _realFFTDataPoints = new double[_numRealDataPoints];
+ _averagedValues = new double[_numRealDataPoints];
+ _historyVector = new std::vector<double*>;
+
+ _timeDomainDisplayPlot->setTitle(0, "real");
+ _timeDomainDisplayPlot->setTitle(1, "imag");
+
+ AvgLineEdit->setRange(0, 500); // Set range of Average box value from 0 to 500
+ MinHoldCheckBox_toggled( false );
+ MaxHoldCheckBox_toggled( false );
+
+ WaterfallMaximumIntensityWheel->setRange(-200, 0);
+ WaterfallMaximumIntensityWheel->setTickCnt(50);
+ WaterfallMinimumIntensityWheel->setRange(-200, 0);
+ WaterfallMinimumIntensityWheel->setTickCnt(50);
+ WaterfallMinimumIntensityWheel->setValue(-200);
+
+ _peakFrequency = 0;
+ _peakAmplitude = -HUGE_VAL;
+
+ _noiseFloorAmplitude = -HUGE_VAL;
+
+ connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)),
+ _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double)));
+ connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)),
+ _frequencyDisplayPlot, SLOT(SetUpperIntensityLevel(const double)));
+
+ _frequencyDisplayPlot->SetLowerIntensityLevel(-200);
+ _frequencyDisplayPlot->SetUpperIntensityLevel(-200);
+
+ // Load up the acceptable FFT sizes...
+ FFTSizeComboBox->clear();
+ for(long fftSize = SpectrumGUIClass::MIN_FFT_SIZE; fftSize <= SpectrumGUIClass::MAX_FFT_SIZE; fftSize *= 2){
+ FFTSizeComboBox->insertItem(FFTSizeComboBox->count(), QString("%1").arg(fftSize));
+ }
+ Reset();
+
+ ToggleTabFrequency(false);
+ ToggleTabWaterfall(false);
+ ToggleTabTime(false);
+ ToggleTabConstellation(false);
+
+ _historyEntry = 0;
+ _historyEntryCount = 0;
+
+ // Create a timer to update plots at the specified rate
+ displayTimer = new QTimer(this);
+ connect(displayTimer, SIGNAL(timeout()), this, SLOT(UpdateGuiTimer()));
+
+ // Connect double click signals up
+ connect(_frequencyDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
+ this, SLOT(onFFTPlotPointSelected(const QPointF)));
+
+ connect(_waterfallDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
+ this, SLOT(onWFallPlotPointSelected(const QPointF)));
+
+ connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
+ this, SLOT(onTimePlotPointSelected(const QPointF)));
+
+ connect(_constellationDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
+ this, SLOT(onConstPlotPointSelected(const QPointF)));
+}
+
+SpectrumDisplayForm::~SpectrumDisplayForm()
+{
+ // Qt deletes children when parent is deleted
+
+ // Don't worry about deleting Display Plots - they are deleted when parents are deleted
+ delete _intValidator;
+
+ delete[] _realFFTDataPoints;
+ delete[] _averagedValues;
+
+ for(unsigned int count = 0; count < _historyVector->size(); count++){
+ delete[] _historyVector->operator[](count);
+ }
+
+ delete _historyVector;
+
+ displayTimer->stop();
+ delete displayTimer;
+}
+
+void
+SpectrumDisplayForm::setSystem( SpectrumGUIClass * newSystem,
+ const uint64_t numFFTDataPoints,
+ const uint64_t numTimeDomainDataPoints )
+{
+ ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints);
+
+ if(newSystem != NULL){
+ _system = newSystem;
+ _systemSpecifiedFlag = true;
+ }
+ else{
+ _systemSpecifiedFlag = false;
+ }
+}
+
+void
+SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdateEvent)
+{
+ //_lastSpectrumEvent = (SpectrumUpdateEvent)(*spectrumUpdateEvent);
+ const std::complex<float>* complexDataPoints = spectrumUpdateEvent->getFFTPoints();
+ const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints();
+ const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints();
+ const gruel::high_res_timer_type dataTimestamp = spectrumUpdateEvent->getDataTimestamp();
+ const bool repeatDataFlag = spectrumUpdateEvent->getRepeatDataFlag();
+ const bool lastOfMultipleUpdatesFlag = spectrumUpdateEvent->getLastOfMultipleUpdateFlag();
+ const gruel::high_res_timer_type generatedTimestamp = spectrumUpdateEvent->getEventGeneratedTimestamp();
+ double* realTimeDomainDataPoints = (double*)spectrumUpdateEvent->getRealTimeDomainPoints();
+ double* imagTimeDomainDataPoints = (double*)spectrumUpdateEvent->getImagTimeDomainPoints();
+
+ std::vector<double*> timeDomainDataPoints;
+ timeDomainDataPoints.push_back(realTimeDomainDataPoints);
+ timeDomainDataPoints.push_back(imagTimeDomainDataPoints);
+
+ // REMEMBER: The dataTimestamp is NOT valid when the repeat data flag is true...
+ ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints);
+
+ // Calculate the Magnitude of the complex point
+ const std::complex<float>* complexDataPointsPtr = complexDataPoints+numFFTDataPoints/2;
+ double* realFFTDataPointsPtr = _realFFTDataPoints;
+
+ double sumMean = 0.0;
+ double localPeakAmplitude = -HUGE_VAL;
+ double localPeakFrequency = 0.0;
+ const double fftBinSize = (_stopFrequency-_startFrequency) /
+ static_cast<double>(numFFTDataPoints);
+
+ // Run this twice to perform the fftshift operation on the data here as well
+ std::complex<float> scaleFactor = std::complex<float>((float)numFFTDataPoints);
+ for(uint64_t point = 0; point < numFFTDataPoints/2; point++){
+ std::complex<float> pt = (*complexDataPointsPtr) / scaleFactor;
+ *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20);
+
+ if(*realFFTDataPointsPtr > localPeakAmplitude) {
+ localPeakFrequency = static_cast<float>(point) * fftBinSize;
+ localPeakAmplitude = *realFFTDataPointsPtr;
+ }
+ sumMean += *realFFTDataPointsPtr;
+
+ complexDataPointsPtr++;
+ realFFTDataPointsPtr++;
+ }
+
+ // This loop takes the first half of the input data and puts it in the
+ // second half of the plotted data
+ complexDataPointsPtr = complexDataPoints;
+ for(uint64_t point = 0; point < numFFTDataPoints/2; point++){
+ std::complex<float> pt = (*complexDataPointsPtr) / scaleFactor;
+ *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20);
+
+ if(*realFFTDataPointsPtr > localPeakAmplitude) {
+ localPeakFrequency = static_cast<float>(point) * fftBinSize;
+ localPeakAmplitude = *realFFTDataPointsPtr;
+ }
+ sumMean += *realFFTDataPointsPtr;
+
+ complexDataPointsPtr++;
+ realFFTDataPointsPtr++;
+ }
+
+ // Don't update the averaging history if this is repeated data
+ if(!repeatDataFlag){
+ _AverageHistory(_realFFTDataPoints);
+
+ // Only use the local info if we are not repeating data
+ _peakAmplitude = localPeakAmplitude;
+ _peakFrequency = localPeakFrequency;
+
+ // calculate the spectral mean
+ // +20 because for the comparison below we only want to throw out bins
+ // that are significantly higher (and would, thus, affect the mean more)
+ const double meanAmplitude = (sumMean / numFFTDataPoints) + 20.0;
+
+ // now throw out any bins higher than the mean
+ sumMean = 0.0;
+ uint64_t newNumDataPoints = numFFTDataPoints;
+ for(uint64_t number = 0; number < numFFTDataPoints; number++){
+ if (_realFFTDataPoints[number] <= meanAmplitude)
+ sumMean += _realFFTDataPoints[number];
+ else
+ newNumDataPoints--;
+ }
+
+ if (newNumDataPoints == 0) // in the odd case that all
+ _noiseFloorAmplitude = meanAmplitude; // amplitudes are equal!
+ else
+ _noiseFloorAmplitude = sumMean / newNumDataPoints;
+ }
+
+ if(lastOfMultipleUpdatesFlag){
+ int tabindex = SpectrumTypeTab->currentIndex();
+ if(tabindex == d_plot_fft) {
+ _frequencyDisplayPlot->PlotNewData(_averagedValues, numFFTDataPoints,
+ _noiseFloorAmplitude, _peakFrequency,
+ _peakAmplitude, d_update_time);
+ }
+ if(tabindex == d_plot_time) {
+ _timeDomainDisplayPlot->PlotNewData(timeDomainDataPoints,
+ numTimeDomainDataPoints,
+ d_update_time);
+ }
+ if(tabindex == d_plot_constellation) {
+ _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints,
+ imagTimeDomainDataPoints,
+ numTimeDomainDataPoints,
+ d_update_time);
+ }
+
+ // Don't update the repeated data for the waterfall
+ if(!repeatDataFlag){
+ if(tabindex == d_plot_waterfall) {
+ _waterfallDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints,
+ d_update_time, dataTimestamp,
+ spectrumUpdateEvent->getDroppedFFTFrames());
+ }
+ }
+
+ // Tell the system the GUI has been updated
+ if(_systemSpecifiedFlag){
+ _system->SetLastGUIUpdateTime(generatedTimestamp);
+ _system->DecrementPendingGUIUpdateEvents();
+ }
+ }
+}
+
+void
+SpectrumDisplayForm::resizeEvent( QResizeEvent *e )
+{
+ QSize s;
+ s.setWidth(FrequencyPlotDisplayFrame->width());
+ s.setHeight(FrequencyPlotDisplayFrame->height());
+ emit _frequencyDisplayPlot->resizeSlot(&s);
+
+ s.setWidth(TimeDomainDisplayFrame->width());
+ s.setHeight(TimeDomainDisplayFrame->height());
+ emit _timeDomainDisplayPlot->resizeSlot(&s);
+
+ s.setWidth(WaterfallPlotDisplayFrame->width());
+ s.setHeight(WaterfallPlotDisplayFrame->height());
+ emit _waterfallDisplayPlot->resizeSlot(&s);
+
+ s.setWidth(ConstellationDisplayFrame->width());
+ s.setHeight(ConstellationDisplayFrame->height());
+ emit _constellationDisplayPlot->resizeSlot(&s);
+}
+
+void
+SpectrumDisplayForm::customEvent( QEvent * e)
+{
+ if(e->type() == QEvent::User+3){
+ if(_systemSpecifiedFlag){
+ WindowComboBox->setCurrentIndex(_system->GetWindowType());
+ FFTSizeComboBox->setCurrentIndex(_system->GetFFTSizeIndex());
+ }
+
+ waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value());
+ waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value());
+
+ // Clear any previous display
+ Reset();
+ }
+ else if(e->type() == 10005){
+ SpectrumUpdateEvent* spectrumUpdateEvent = (SpectrumUpdateEvent*)e;
+ newFrequencyData(spectrumUpdateEvent);
+ }
+ else if(e->type() == 10008){
+ setWindowTitle(((SpectrumWindowCaptionEvent*)e)->getLabel());
+ }
+ else if(e->type() == 10009){
+ Reset();
+ if(_systemSpecifiedFlag){
+ _system->ResetPendingGUIUpdateEvents();
+ }
+ }
+ else if(e->type() == 10010){
+ _startFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStartFrequency();
+ _stopFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStopFrequency();
+ _centerFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetCenterFrequency();
+
+ UseRFFrequenciesCB(UseRFFrequenciesCheckBox->isChecked());
+ }
+}
+
+void
+SpectrumDisplayForm::UpdateGuiTimer()
+{
+ // This is called by the displayTimer and redraws the canvases of
+ // all of the plots.
+ _frequencyDisplayPlot->canvas()->update();
+ _waterfallDisplayPlot->canvas()->update();
+ _timeDomainDisplayPlot->canvas()->update();
+ _constellationDisplayPlot->canvas()->update();
+}
+
+
+void
+SpectrumDisplayForm::AvgLineEdit_valueChanged( int value )
+{
+ SetAverageCount(value);
+}
+
+
+void
+SpectrumDisplayForm::MaxHoldCheckBox_toggled( bool newState )
+{
+ MaxHoldResetBtn->setEnabled(newState);
+ _frequencyDisplayPlot->SetMaxFFTVisible(newState);
+ MaxHoldResetBtn_clicked();
+}
+
+
+void
+SpectrumDisplayForm::MinHoldCheckBox_toggled( bool newState )
+{
+ MinHoldResetBtn->setEnabled(newState);
+ _frequencyDisplayPlot->SetMinFFTVisible(newState);
+ MinHoldResetBtn_clicked();
+}
+
+
+void
+SpectrumDisplayForm::MinHoldResetBtn_clicked()
+{
+ _frequencyDisplayPlot->ClearMinData();
+ _frequencyDisplayPlot->replot();
+}
+
+
+void
+SpectrumDisplayForm::MaxHoldResetBtn_clicked()
+{
+ _frequencyDisplayPlot->ClearMaxData();
+ _frequencyDisplayPlot->replot();
+}
+
+
+void
+SpectrumDisplayForm::TabChanged(int index)
+{
+ // This might be dangerous to call this with NULL
+ resizeEvent(NULL);
+}
+
+void
+SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency,
+ const double newStartFrequency,
+ const double newStopFrequency)
+{
+ double fdiff;
+ if(UseRFFrequenciesCheckBox->isChecked()) {
+ fdiff = newCenterFrequency;
+ }
+ else {
+ fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency));
+ }
+
+ if(fdiff > 0) {
+ std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
+ std::string strtime[4] = {"sec", "ms", "us", "ns"};
+ double units10 = floor(log10(fdiff));
+ double units3 = std::max(floor(units10 / 3.0), 0.0);
+ double units = pow(10, (units10-fmod(units10, 3.0)));
+ int iunit = static_cast<int>(units3);
+
+ _startFrequency = newStartFrequency;
+ _stopFrequency = newStopFrequency;
+ _centerFrequency = newCenterFrequency;
+
+ _frequencyDisplayPlot->SetFrequencyRange(_startFrequency,
+ _stopFrequency,
+ _centerFrequency,
+ UseRFFrequenciesCheckBox->isChecked(),
+ units, strunits[iunit]);
+ _waterfallDisplayPlot->SetFrequencyRange(_startFrequency,
+ _stopFrequency,
+ _centerFrequency,
+ UseRFFrequenciesCheckBox->isChecked(),
+ units, strunits[iunit]);
+ _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency,
+ units, strtime[iunit]);
+ }
+}
+
+int
+SpectrumDisplayForm::GetAverageCount()
+{
+ return _historyVector->size();
+}
+
+void
+SpectrumDisplayForm::SetAverageCount(const int newCount)
+{
+ if(newCount > -1){
+ if(newCount != static_cast<int>(_historyVector->size())){
+ std::vector<double*>::iterator pos;
+ while(newCount < static_cast<int>(_historyVector->size())){
+ pos = _historyVector->begin();
+ delete[] (*pos);
+ _historyVector->erase(pos);
+ }
+
+ while(newCount > static_cast<int>(_historyVector->size())){
+ _historyVector->push_back(new double[_numRealDataPoints]);
+ }
+ AverageDataReset();
+ }
+ }
+}
+
+void
+SpectrumDisplayForm::_AverageHistory(const double* newBuffer)
+{
+ if(_numRealDataPoints > 0){
+ if(_historyVector->size() > 0){
+ memcpy(_historyVector->operator[](_historyEntry), newBuffer,
+ _numRealDataPoints*sizeof(double));
+
+ // Increment the next location to store data
+ _historyEntryCount++;
+ if(_historyEntryCount > static_cast<int>(_historyVector->size())){
+ _historyEntryCount = _historyVector->size();
+ }
+ _historyEntry += 1;
+ _historyEntry = _historyEntry % _historyVector->size();
+
+ // Total up and then average the values
+ double sum;
+ for(uint64_t location = 0; location < _numRealDataPoints; location++){
+ sum = 0;
+ for(int number = 0; number < _historyEntryCount; number++){
+ sum += _historyVector->operator[](number)[location];
+ }
+ _averagedValues[location] = sum/static_cast<double>(_historyEntryCount);
+ }
+ }
+ else{
+ memcpy(_averagedValues, newBuffer, _numRealDataPoints*sizeof(double));
+ }
+ }
+}
+
+void
+SpectrumDisplayForm::ResizeBuffers( const uint64_t numFFTDataPoints,
+ const uint64_t /*numTimeDomainDataPoints*/ )
+{
+ // Convert from Complex to Real for certain Displays
+ if(_numRealDataPoints != numFFTDataPoints){
+ _numRealDataPoints = numFFTDataPoints;
+ delete[] _realFFTDataPoints;
+ delete[] _averagedValues;
+
+ _realFFTDataPoints = new double[_numRealDataPoints];
+ _averagedValues = new double[_numRealDataPoints];
+ memset(_realFFTDataPoints, 0x0, _numRealDataPoints*sizeof(double));
+
+ const int historySize = _historyVector->size();
+ SetAverageCount(0); // Clear the existing history
+ SetAverageCount(historySize);
+
+ Reset();
+ }
+}
+
+void
+SpectrumDisplayForm::Reset()
+{
+ AverageDataReset();
+
+ _waterfallDisplayPlot->Reset();
+}
+
+
+void
+SpectrumDisplayForm::AverageDataReset()
+{
+ _historyEntry = 0;
+ _historyEntryCount = 0;
+
+ memset(_averagedValues, 0x0, _numRealDataPoints*sizeof(double));
+
+ MaxHoldResetBtn_clicked();
+ MinHoldResetBtn_clicked();
+}
+
+
+void
+SpectrumDisplayForm::closeEvent( QCloseEvent *e )
+{
+ if(_systemSpecifiedFlag){
+ _system->SetWindowOpenFlag(false);
+ }
+
+ qApp->processEvents();
+
+ QWidget::closeEvent(e);
+}
+
+
+void
+SpectrumDisplayForm::WindowTypeChanged( int newItem )
+{
+ if(_systemSpecifiedFlag){
+ _system->SetWindowType(newItem);
+ }
+}
+
+
+void
+SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag )
+{
+ SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
+}
+
+
+void
+SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue )
+{
+ if(newValue > WaterfallMinimumIntensityWheel->value()){
+ WaterfallMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0));
+ }
+ else{
+ WaterfallMaximumIntensityWheel->setValue(WaterfallMinimumIntensityWheel->value());
+ }
+
+ _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(),
+ WaterfallMaximumIntensityWheel->value());
+}
+
+
+void
+SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue )
+{
+ if(newValue < WaterfallMaximumIntensityWheel->value()){
+ WaterfallMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0));
+ }
+ else{
+ WaterfallMinimumIntensityWheel->setValue(WaterfallMaximumIntensityWheel->value());
+ }
+
+ _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(),
+ WaterfallMaximumIntensityWheel->value());
+}
+
+void
+SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString )
+{
+ if(_systemSpecifiedFlag){
+ _system->SetFFTSize(fftSizeString.toLong());
+ }
+}
+
+
+void
+SpectrumDisplayForm::WaterfallAutoScaleBtnCB()
+{
+ double minimumIntensity = _noiseFloorAmplitude - 5;
+ if(minimumIntensity < WaterfallMinimumIntensityWheel->minValue()){
+ minimumIntensity = WaterfallMinimumIntensityWheel->minValue();
+ }
+ WaterfallMinimumIntensityWheel->setValue(minimumIntensity);
+ double maximumIntensity = _peakAmplitude + 10;
+ if(maximumIntensity > WaterfallMaximumIntensityWheel->maxValue()){
+ maximumIntensity = WaterfallMaximumIntensityWheel->maxValue();
+ }
+ WaterfallMaximumIntensityWheel->setValue(maximumIntensity);
+ waterfallMaximumIntensityChangedCB(maximumIntensity);
+}
+
+void
+SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType )
+{
+ QColor lowIntensityColor;
+ QColor highIntensityColor;
+ if(newType == WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){
+ // Select the Low Intensity Color
+ lowIntensityColor = _waterfallDisplayPlot->GetUserDefinedLowIntensityColor();
+ if(!lowIntensityColor.isValid()){
+ lowIntensityColor = Qt::black;
+ }
+ QMessageBox::information(this, "Low Intensity Color Selection", "In the next window, select the low intensity color for the waterfall display", QMessageBox::Ok);
+ lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this);
+
+ // Select the High Intensity Color
+ highIntensityColor = _waterfallDisplayPlot->GetUserDefinedHighIntensityColor();
+ if(!highIntensityColor.isValid()){
+ highIntensityColor = Qt::white;
+ }
+ QMessageBox::information(this, "High Intensity Color Selection", "In the next window, select the high intensity color for the waterfall display", QMessageBox::Ok);
+ highIntensityColor = QColorDialog::getColor(highIntensityColor, this);
+ }
+
+ _waterfallDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor);
+}
+
+void
+SpectrumDisplayForm::ToggleTabFrequency(const bool state)
+{
+ if(state == true) {
+ if(d_plot_fft == -1) {
+ SpectrumTypeTab->addTab(FrequencyPage, "Frequency Display");
+ d_plot_fft = SpectrumTypeTab->count()-1;
+ }
+ }
+ else {
+ SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(FrequencyPage));
+ d_plot_fft = -1;
+ }
+}
+
+void
+SpectrumDisplayForm::ToggleTabWaterfall(const bool state)
+{
+ if(state == true) {
+ if(d_plot_waterfall == -1) {
+ SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display");
+ d_plot_waterfall = SpectrumTypeTab->count()-1;
+ }
+ }
+ else {
+ SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage));
+ d_plot_waterfall = -1;
+ }
+}
+
+void
+SpectrumDisplayForm::ToggleTabTime(const bool state)
+{
+ if(state == true) {
+ if(d_plot_time == -1) {
+ SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display");
+ d_plot_time = SpectrumTypeTab->count()-1;
+ }
+ }
+ else {
+ SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(TimeDomainPage));
+ d_plot_time = -1;
+ }
+}
+
+void
+SpectrumDisplayForm::ToggleTabConstellation(const bool state)
+{
+ if(state == true) {
+ if(d_plot_constellation == -1) {
+ SpectrumTypeTab->addTab(ConstellationPage, "Constellation Display");
+ d_plot_constellation = SpectrumTypeTab->count()-1;
+ }
+ }
+ else {
+ SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage));
+ d_plot_constellation = -1;
+ }
+}
+
+
+void
+SpectrumDisplayForm::SetTimeDomainAxis(double min, double max)
+{
+ _timeDomainDisplayPlot->setYaxis(min, max);
+}
+
+void
+SpectrumDisplayForm::SetConstellationAxis(double xmin, double xmax,
+ double ymin, double ymax)
+{
+ _constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax);
+}
+
+void
+SpectrumDisplayForm::SetConstellationPenSize(int size)
+{
+ _constellationDisplayPlot->set_pen_size( size );
+}
+
+void
+SpectrumDisplayForm::SetFrequencyAxis(double min, double max)
+{
+ _frequencyDisplayPlot->set_yaxis(min, max);
+}
+
+void
+SpectrumDisplayForm::SetUpdateTime(double t)
+{
+ d_update_time = t;
+ // QTimer class takes millisecond input
+ displayTimer->start(d_update_time*1000);
+}
+
+void
+SpectrumDisplayForm::onFFTPlotPointSelected(const QPointF p)
+{
+ emit plotPointSelected(p, 1);
+}
+
+void
+SpectrumDisplayForm::onWFallPlotPointSelected(const QPointF p)
+{
+ emit plotPointSelected(p, 2);
+}
+
+void
+SpectrumDisplayForm::onTimePlotPointSelected(const QPointF p)
+{
+ emit plotPointSelected(p, 3);
+}
+
+void
+SpectrumDisplayForm::onConstPlotPointSelected(const QPointF p)
+{
+ emit plotPointSelected(p, 4);
+}
diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h
new file mode 100644
index 000000000..63dd304d5
--- /dev/null
+++ b/gr-qtgui/lib/spectrumdisplayform.h
@@ -0,0 +1,139 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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.
+ */
+
+#ifndef SPECTRUM_DISPLAY_FORM_H
+#define SPECTRUM_DISPLAY_FORM_H
+
+#include "spectrumdisplayform.ui.h"
+
+class SpectrumGUIClass;
+#include <SpectrumGUIClass.h>
+
+#include <SpectrumGUIClass.h>
+#include <FrequencyDisplayPlot.h>
+#include <WaterfallDisplayPlot.h>
+#include <TimeDomainDisplayPlot.h>
+#include <ConstellationDisplayPlot.h>
+#include <QValidator>
+#include <QTimer>
+#include <vector>
+
+class SpectrumDisplayForm : public QWidget, public Ui::SpectrumDisplayForm
+{
+ Q_OBJECT
+
+ public:
+ SpectrumDisplayForm(QWidget* parent = 0);
+ ~SpectrumDisplayForm();
+
+ void setSystem( SpectrumGUIClass * newSystem, const uint64_t numFFTDataPoints,
+ const uint64_t numTimeDomainDataPoints );
+
+ int GetAverageCount();
+ void SetAverageCount( const int newCount );
+ void Reset();
+ void AverageDataReset();
+ void ResizeBuffers( const uint64_t numFFTDataPoints,
+ const uint64_t numTimeDomainDataPoints );
+
+public slots:
+ void resizeEvent( QResizeEvent * e );
+ void customEvent( QEvent * e );
+ void AvgLineEdit_valueChanged( int valueString );
+ void MaxHoldCheckBox_toggled( bool newState );
+ void MinHoldCheckBox_toggled( bool newState );
+ void MinHoldResetBtn_clicked();
+ void MaxHoldResetBtn_clicked();
+ void TabChanged(int index);
+
+ void SetFrequencyRange( const double newCenterFrequency,
+ const double newStartFrequency,
+ const double newStopFrequency );
+ void closeEvent( QCloseEvent * e );
+ void WindowTypeChanged( int newItem );
+ void UseRFFrequenciesCB( bool useRFFlag );
+ void waterfallMaximumIntensityChangedCB(double);
+ void waterfallMinimumIntensityChangedCB(double);
+ void WaterfallIntensityColorTypeChanged(int);
+ void WaterfallAutoScaleBtnCB();
+ void FFTComboBoxSelectedCB(const QString&);
+
+ void ToggleTabFrequency(const bool state);
+ void ToggleTabWaterfall(const bool state);
+ void ToggleTabTime(const bool state);
+ void ToggleTabConstellation(const bool state);
+
+ void SetTimeDomainAxis(double min, double max);
+ void SetConstellationAxis(double xmin, double xmax,
+ double ymin, double ymax);
+ void SetConstellationPenSize(int size);
+ void SetFrequencyAxis(double min, double max);
+ void SetUpdateTime(double t);
+
+private slots:
+ void newFrequencyData( const SpectrumUpdateEvent* );
+ void UpdateGuiTimer();
+
+ void onFFTPlotPointSelected(const QPointF p);
+ void onWFallPlotPointSelected(const QPointF p);
+ void onTimePlotPointSelected(const QPointF p);
+ void onConstPlotPointSelected(const QPointF p);
+
+signals:
+ void plotPointSelected(const QPointF p, int type);
+
+private:
+ void _AverageHistory( const double * newBuffer );
+
+ int _historyEntryCount;
+ int _historyEntry;
+ std::vector<double*>* _historyVector;
+ double* _averagedValues;
+ uint64_t _numRealDataPoints;
+ double* _realFFTDataPoints;
+ QIntValidator* _intValidator;
+ FrequencyDisplayPlot* _frequencyDisplayPlot;
+ WaterfallDisplayPlot* _waterfallDisplayPlot;
+ TimeDomainDisplayPlot* _timeDomainDisplayPlot;
+ ConstellationDisplayPlot* _constellationDisplayPlot;
+ SpectrumGUIClass* _system;
+ bool _systemSpecifiedFlag;
+ double _centerFrequency;
+ double _startFrequency;
+ double _noiseFloorAmplitude;
+ double _peakFrequency;
+ double _peakAmplitude;
+ double _stopFrequency;
+
+ //SpectrumUpdateEvent _lastSpectrumEvent;
+
+ // whether or not to use a particular display
+ int d_plot_fft;
+ int d_plot_waterfall;
+ int d_plot_time;
+ int d_plot_constellation;
+
+ QTimer *displayTimer;
+ double d_update_time;
+};
+
+#endif /* SPECTRUM_DISPLAY_FORM_H */
diff --git a/gr-qtgui/lib/spectrumdisplayform.ui b/gr-qtgui/lib/spectrumdisplayform.ui
new file mode 100644
index 000000000..049d4ffeb
--- /dev/null
+++ b/gr-qtgui/lib/spectrumdisplayform.ui
@@ -0,0 +1,756 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SpectrumDisplayForm</class>
+ <widget class="QWidget" name="SpectrumDisplayForm">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>712</width>
+ <height>560</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Spectrum Display</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="3">
+ <widget class="QComboBox" name="FFTSizeComboBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>120</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <item>
+ <property name="text">
+ <string>1024</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>2048</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>4096</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>8192</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>16384</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>32768</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLabel" name="FFTSizeLabel">
+ <property name="text">
+ <string>FFT Size:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="UseRFFrequenciesCheckBox">
+ <property name="text">
+ <string>Display RF Frequencies</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="WindowLbl">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Window:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="WindowComboBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>120</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>9</pointsize>
+ </font>
+ </property>
+ <item>
+ <property name="text">
+ <string>Hamming</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Hann</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Blackman</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Rectangular</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Kaiser</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Blackman-harris</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0" colspan="4">
+ <widget class="QTabWidget" name="SpectrumTypeTab">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="FrequencyPage">
+ <attribute name="title">
+ <string>Frequency Display</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QFrame" name="FrequencyPlotDisplayFrame">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>617</width>
+ <height>400</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>1</width>
+ <height>1</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="MaxHoldCheckBox">
+ <property name="text">
+ <string>Max Hold</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="MinHoldCheckBox">
+ <property name="text">
+ <string>Min Hold</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="MaxHoldResetBtn">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLabel" name="AvgLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>62</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Average</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QPushButton" name="MinHoldResetBtn">
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QSpinBox" name="AvgLineEdit"/>
+ </item>
+ <item row="1" column="2">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>200</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="WaterfallPage">
+ <attribute name="title">
+ <string>Waterfall Display</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QLabel" name="textLabel1">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Intensity Display:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QwtWheel" name="WaterfallMaximumIntensityWheel">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="mouseTracking">
+ <bool>true</bool>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::WheelFocus</enum>
+ </property>
+ <property name="valid">
+ <bool>true</bool>
+ </property>
+ <property name="totalAngle">
+ <double>200.000000000000000</double>
+ </property>
+ <property name="viewAngle">
+ <double>20.000000000000000</double>
+ </property>
+ <property name="mass">
+ <double>0.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="WaterfallMaximumIntensityLabel">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>100 dB</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="4">
+ <widget class="QFrame" name="WaterfallPlotDisplayFrame">
+ <property name="minimumSize">
+ <size>
+ <width>617</width>
+ <height>338</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QwtWheel" name="WaterfallMinimumIntensityWheel">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="valid">
+ <bool>true</bool>
+ </property>
+ <property name="totalAngle">
+ <double>200.000000000000000</double>
+ </property>
+ <property name="viewAngle">
+ <double>20.000000000000000</double>
+ </property>
+ <property name="mass">
+ <double>0.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QLabel" name="WaterfallMinimumIntensityLabel">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>-100 dB</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QPushButton" name="WaterfallAutoScaleBtn">
+ <property name="maximumSize">
+ <size>
+ <width>80</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Scales the Intensity to the current data extremes.</string>
+ </property>
+ <property name="text">
+ <string>Auto Scale</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="WaterfallIntensityComboBox">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <item>
+ <property name="text">
+ <string>Color</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>White Hot</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Black Hot</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Incandescent</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>User Defined</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="TimeDomainPage">
+ <attribute name="title">
+ <string>Time Domain Display</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <widget class="QFrame" name="TimeDomainDisplayFrame">
+ <property name="minimumSize">
+ <size>
+ <width>617</width>
+ <height>404</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="ConstellationPage">
+ <attribute name="title">
+ <string>Constellation Display</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_5">
+ <item row="0" column="0">
+ <widget class="QFrame" name="ConstellationDisplayFrame">
+ <property name="minimumSize">
+ <size>
+ <width>617</width>
+ <height>406</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
+ <customwidgets>
+ <customwidget>
+ <class>QwtWheel</class>
+ <extends>QWidget</extends>
+ <header>qwt_wheel.h</header>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>SpectrumTypeTab</tabstop>
+ <tabstop>UseRFFrequenciesCheckBox</tabstop>
+ <tabstop>FFTSizeComboBox</tabstop>
+ <tabstop>WaterfallMaximumIntensityWheel</tabstop>
+ <tabstop>WaterfallMinimumIntensityWheel</tabstop>
+ </tabstops>
+ <includes>
+ <include location="global">SpectrumGUIClass.h</include>
+ <include location="global">FrequencyDisplayPlot.h</include>
+ <include location="global">WaterfallDisplayPlot.h</include>
+ <include location="global">TimeDomainDisplayPlot.h</include>
+ <include location="global">qvalidator.h</include>
+ <include location="global">vector</include>
+ <include location="local">qwt_wheel.h</include>
+ </includes>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>MaxHoldCheckBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>MaxHoldCheckBox_toggled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>22</x>
+ <y>324</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>MaxHoldResetBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>MaxHoldResetBtn_clicked()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>107</x>
+ <y>324</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>MinHoldCheckBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>MinHoldCheckBox_toggled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>22</x>
+ <y>349</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>MinHoldResetBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>MinHoldResetBtn_clicked()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>107</x>
+ <y>349</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>WindowComboBox</sender>
+ <signal>activated(int)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>WindowTypeChanged(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>UseRFFrequenciesCheckBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>UseRFFrequenciesCB(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>WaterfallMaximumIntensityWheel</sender>
+ <signal>valueChanged(double)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>waterfallMaximumIntensityChangedCB(double)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>217</x>
+ <y>44</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>WaterfallMinimumIntensityWheel</sender>
+ <signal>valueChanged(double)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>waterfallMinimumIntensityChangedCB(double)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>217</x>
+ <y>349</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>FFTSizeComboBox</sender>
+ <signal>activated(QString)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>FFTComboBoxSelectedCB(QString)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>WaterfallAutoScaleBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>WaterfallAutoScaleBtnCB()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>22</x>
+ <y>349</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>WaterfallIntensityComboBox</sender>
+ <signal>activated(int)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>WaterfallIntensityColorTypeChanged(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>92</x>
+ <y>44</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>SpectrumTypeTab</sender>
+ <signal>currentChanged(int)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>TabChanged(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>314</x>
+ <y>189</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>316</x>
+ <y>217</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>AvgLineEdit</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SpectrumDisplayForm</receiver>
+ <slot>AvgLineEdit_valueChanged(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>604</x>
+ <y>421</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>328</x>
+ <y>260</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc
new file mode 100644
index 000000000..c650cd3eb
--- /dev/null
+++ b/gr-qtgui/lib/timedisplayform.cc
@@ -0,0 +1,177 @@
+/* -*- 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.
+ */
+
+#include <cmath>
+#include <QColorDialog>
+#include <QMessageBox>
+#include <timedisplayform.h>
+#include <iostream>
+
+TimeDisplayForm::TimeDisplayForm(int nplots, QWidget* parent)
+ : QWidget(parent)
+{
+ _systemSpecifiedFlag = false;
+ _intValidator = new QIntValidator(this);
+ _intValidator->setBottom(0);
+
+ _layout = new QGridLayout(this);
+ _timeDomainDisplayPlot = new TimeDomainDisplayPlot(nplots, this);
+ _layout->addWidget(_timeDomainDisplayPlot, 0, 0);
+
+ _numRealDataPoints = 1024;
+
+ setLayout(_layout);
+
+ Reset();
+
+ // Create a timer to update plots at the specified rate
+ displayTimer = new QTimer(this);
+ connect(displayTimer, SIGNAL(timeout()), this, SLOT(updateGuiTimer()));
+
+ connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
+ this, SLOT(onTimePlotPointSelected(const QPointF)));
+}
+
+TimeDisplayForm::~TimeDisplayForm()
+{
+ // Qt deletes children when parent is deleted
+
+ // Don't worry about deleting Display Plots - they are deleted when parents are deleted
+ delete _intValidator;
+
+ displayTimer->stop();
+ delete displayTimer;
+}
+
+void
+TimeDisplayForm::newData( const TimeUpdateEvent* spectrumUpdateEvent)
+{
+ const std::vector<double*> timeDomainDataPoints = spectrumUpdateEvent->getTimeDomainPoints();
+ const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints();
+
+ _timeDomainDisplayPlot->PlotNewData(timeDomainDataPoints,
+ numTimeDomainDataPoints,
+ d_update_time);
+}
+
+void
+TimeDisplayForm::resizeEvent( QResizeEvent *e )
+{
+ QSize s = size();
+ emit _timeDomainDisplayPlot->resizeSlot(&s);
+}
+
+void
+TimeDisplayForm::customEvent( QEvent * e)
+{
+ if(e->type() == 10005) {
+ TimeUpdateEvent* timeUpdateEvent = (TimeUpdateEvent*)e;
+ newData(timeUpdateEvent);
+ }
+ //else if(e->type() == 10008){
+ //setWindowTitle(((SpectrumWindowCaptionEvent*)e)->getLabel());
+ //}
+ //else if(e->type() == 10009){
+ //Reset();
+ //if(_systemSpecifiedFlag){
+ // _system->ResetPendingGUIUpdateEvents();
+ //}
+ //}
+}
+
+void
+TimeDisplayForm::updateGuiTimer()
+{
+ _timeDomainDisplayPlot->canvas()->update();
+}
+
+void
+TimeDisplayForm::onTimePlotPointSelected(const QPointF p)
+{
+ emit plotPointSelected(p, 3);
+}
+
+void
+TimeDisplayForm::setFrequencyRange(const double newCenterFrequency,
+ const double newStartFrequency,
+ const double newStopFrequency)
+{
+ double fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency));
+
+ if(fdiff > 0) {
+ std::string strtime[4] = {"sec", "ms", "us", "ns"};
+ double units10 = floor(log10(fdiff));
+ double units3 = std::max(floor(units10 / 3.0), 0.0);
+ double units = pow(10, (units10-fmod(units10, 3.0)));
+ int iunit = static_cast<int>(units3);
+
+ _startFrequency = newStartFrequency;
+ _stopFrequency = newStopFrequency;
+
+ _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency,
+ units, strtime[iunit]);
+ }
+}
+
+void
+TimeDisplayForm::Reset()
+{
+}
+
+
+void
+TimeDisplayForm::closeEvent( QCloseEvent *e )
+{
+ //if(_systemSpecifiedFlag){
+ // _system->SetWindowOpenFlag(false);
+ //}
+
+ qApp->processEvents();
+
+ QWidget::closeEvent(e);
+}
+
+void
+TimeDisplayForm::setTimeDomainAxis(double min, double max)
+{
+ _timeDomainDisplayPlot->setYaxis(min, max);
+}
+
+void
+TimeDisplayForm::setUpdateTime(double t)
+{
+ d_update_time = t;
+ // QTimer class takes millisecond input
+ displayTimer->start(d_update_time*1000);
+}
+
+void
+TimeDisplayForm::setTitle(int which, QString title)
+{
+ _timeDomainDisplayPlot->setTitle(which, title);
+}
+
+void
+TimeDisplayForm::setColor(int which, QString color)
+{
+ _timeDomainDisplayPlot->setColor(which, color);
+}
diff --git a/gr-qtgui/lib/timedisplayform.h b/gr-qtgui/lib/timedisplayform.h
new file mode 100644
index 000000000..dd3f62a83
--- /dev/null
+++ b/gr-qtgui/lib/timedisplayform.h
@@ -0,0 +1,85 @@
+/* -*- 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 TIME_DISPLAY_FORM_H
+#define TIME_DISPLAY_FORM_H
+
+#include <spectrumUpdateEvents.h>
+#include <FrequencyDisplayPlot.h>
+#include <WaterfallDisplayPlot.h>
+#include <TimeDomainDisplayPlot.h>
+#include <ConstellationDisplayPlot.h>
+#include <QtGui/QApplication>
+#include <QtGui/QGridLayout>
+#include <QValidator>
+#include <QTimer>
+#include <vector>
+
+class TimeDisplayForm : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ TimeDisplayForm(int nplots=1, QWidget* parent = 0);
+ ~TimeDisplayForm();
+
+ void Reset();
+
+public slots:
+ void resizeEvent( QResizeEvent * e );
+ void customEvent( QEvent * e );
+ void setFrequencyRange( const double newCenterFrequency,
+ const double newStartFrequency,
+ const double newStopFrequency );
+ void closeEvent( QCloseEvent * e );
+
+ void setTimeDomainAxis(double min, double max);
+
+ void setUpdateTime(double t);
+
+ void setTitle(int which, QString title);
+ void setColor(int which, QString color);
+
+private slots:
+ void newData( const TimeUpdateEvent* );
+ void updateGuiTimer();
+
+ void onTimePlotPointSelected(const QPointF p);
+
+signals:
+ void plotPointSelected(const QPointF p, int type);
+
+private:
+ uint64_t _numRealDataPoints;
+ QIntValidator* _intValidator;
+
+ QGridLayout *_layout;
+ TimeDomainDisplayPlot* _timeDomainDisplayPlot;
+ bool _systemSpecifiedFlag;
+ double _startFrequency;
+ double _stopFrequency;
+
+ QTimer *displayTimer;
+ double d_update_time;
+};
+
+#endif /* TIME_DISPLAY_FORM_H */
diff --git a/gr-qtgui/lib/waterfallGlobalData.cc b/gr-qtgui/lib/waterfallGlobalData.cc
new file mode 100644
index 000000000..f64ed14f1
--- /dev/null
+++ b/gr-qtgui/lib/waterfallGlobalData.cc
@@ -0,0 +1,230 @@
+#ifndef WATERFALL_GLOBAL_DATA_CPP
+#define WATERFALL_GLOBAL_DATA_CPP
+
+#include <waterfallGlobalData.h>
+#include <cstdio>
+
+WaterfallData::WaterfallData(const double minimumFrequency,
+ const double maximumFrequency,
+ const uint64_t fftPoints,
+ const unsigned int historyExtent)
+#if QWT_VERSION < 0x060000
+ : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */,
+ maximumFrequency - minimumFrequency /* WIDTH */,
+ static_cast<double>(historyExtent)/* HEIGHT */))
+#else
+ : QwtRasterData()
+#endif
+{
+ _intensityRange = QwtDoubleInterval(-200.0, 0.0);
+
+ _fftPoints = fftPoints;
+ _historyLength = historyExtent;
+
+ _spectrumData = new double[_fftPoints * _historyLength];
+
+#if QWT_VERSION >= 0x060000
+ setInterval(Qt::XAxis, QwtInterval(minimumFrequency, maximumFrequency));
+ setInterval(Qt::YAxis, QwtInterval(0, historyExtent));
+ setInterval(Qt::ZAxis, QwtInterval(-200, 0.0));
+#endif
+
+ Reset();
+}
+
+WaterfallData::~WaterfallData()
+{
+ delete[] _spectrumData;
+}
+
+void WaterfallData::Reset()
+{
+ memset(_spectrumData, 0x0, _fftPoints*_historyLength*sizeof(double));
+
+ _numLinesToUpdate = -1;
+}
+
+void WaterfallData::Copy(const WaterfallData* rhs)
+{
+#if QWT_VERSION < 0x060000
+ if((_fftPoints != rhs->GetNumFFTPoints()) ||
+ (boundingRect() != rhs->boundingRect()) ){
+ _fftPoints = rhs->GetNumFFTPoints();
+ setBoundingRect(rhs->boundingRect());
+ delete[] _spectrumData;
+ _spectrumData = new double[_fftPoints * _historyLength];
+ }
+#else
+ if(_fftPoints != rhs->GetNumFFTPoints()) {
+ _fftPoints = rhs->GetNumFFTPoints();
+ delete[] _spectrumData;
+ _spectrumData = new double[_fftPoints * _historyLength];
+ }
+#endif
+
+ Reset();
+ SetSpectrumDataBuffer(rhs->GetSpectrumDataBuffer());
+ SetNumLinesToUpdate(rhs->GetNumLinesToUpdate());
+
+#if QWT_VERSION < 0x060000
+ setRange(rhs->range());
+#else
+ setInterval(Qt::XAxis, rhs->interval(Qt::XAxis));
+ setInterval(Qt::YAxis, rhs->interval(Qt::YAxis));
+ setInterval(Qt::ZAxis, rhs->interval(Qt::ZAxis));
+#endif
+}
+
+void WaterfallData::ResizeData(const double startFreq,
+ const double stopFreq,
+ const uint64_t fftPoints)
+{
+#if QWT_VERSION < 0x060000
+ if((fftPoints != GetNumFFTPoints()) ||
+ (boundingRect().width() != (stopFreq - startFreq)) ||
+ (boundingRect().left() != startFreq)){
+
+ setBoundingRect(QwtDoubleRect(startFreq, 0,
+ stopFreq-startFreq,
+ boundingRect().height()));
+ _fftPoints = fftPoints;
+ delete[] _spectrumData;
+ _spectrumData = new double[_fftPoints * _historyLength];
+ }
+
+#else
+ if((fftPoints != GetNumFFTPoints()) ||
+ (interval(Qt::XAxis).width() != (stopFreq - startFreq)) ||
+ (interval(Qt::XAxis).minValue() != startFreq)){
+
+ setInterval(Qt::XAxis, QwtInterval(startFreq, stopFreq));
+
+ _fftPoints = fftPoints;
+ delete[] _spectrumData;
+ _spectrumData = new double[_fftPoints * _historyLength];
+ }
+#endif
+
+ Reset();
+}
+
+QwtRasterData *WaterfallData::copy() const
+{
+#if QWT_VERSION < 0x060000
+ WaterfallData* returnData = new WaterfallData(boundingRect().left(),
+ boundingRect().right(),
+ _fftPoints, _historyLength);
+#else
+ WaterfallData* returnData = new WaterfallData(interval(Qt::XAxis).minValue(),
+ interval(Qt::XAxis).maxValue(),
+ _fftPoints, _historyLength);
+#endif
+
+ returnData->Copy(this);
+ return returnData;
+}
+
+
+#if QWT_VERSION < 0x060000
+QwtDoubleInterval WaterfallData::range() const
+{
+ return _intensityRange;
+}
+
+void WaterfallData::setRange(const QwtDoubleInterval& newRange)
+{
+ _intensityRange = newRange;
+}
+
+#endif
+
+
+double WaterfallData::value(double x, double y) const
+{
+ double returnValue = 0.0;
+
+#if QWT_VERSION < 0x060000
+ const unsigned int intY = static_cast<unsigned int>((1.0 - (y/boundingRect().height())) *
+ static_cast<double>(_historyLength-1));
+ const unsigned int intX = static_cast<unsigned int>((((x - boundingRect().left()) / boundingRect().width()) *
+ static_cast<double>(_fftPoints-1)) + 0.5);
+#else
+ double height = interval(Qt::YAxis).maxValue();
+ double left = interval(Qt::XAxis).minValue();
+ double right = interval(Qt::XAxis).maxValue();
+ double ylen = static_cast<double>(_historyLength-1);
+ double xlen = static_cast<double>(_fftPoints-1);
+ const unsigned int intY = static_cast<unsigned int>((1.0 - y/height) * ylen);
+ const unsigned int intX = static_cast<unsigned int>((((x - left) / (right-left)) * xlen) + 0.5);
+#endif
+
+ const int location = (intY * _fftPoints) + intX;
+ if((location > -1) && (location < static_cast<int64_t>(_fftPoints * _historyLength))){
+ returnValue = _spectrumData[location];
+ }
+
+ return returnValue;
+}
+
+uint64_t WaterfallData::GetNumFFTPoints() const
+{
+ return _fftPoints;
+}
+
+void WaterfallData::addFFTData(const double* fftData,
+ const uint64_t fftDataSize,
+ const int droppedFrames){
+ if(fftDataSize == _fftPoints){
+ int64_t heightOffset = _historyLength - 1 - droppedFrames;
+ uint64_t drawingDroppedFrames = droppedFrames;
+
+ // Any valid data rolled off the display so just fill in zeros and write new data
+ if(heightOffset < 0){
+ heightOffset = 0;
+ drawingDroppedFrames = static_cast<uint64_t>(_historyLength-1);
+ }
+
+ // Copy the old data over if any available
+ if(heightOffset > 0){
+ memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints],
+ heightOffset * _fftPoints * sizeof(double)) ;
+ }
+
+ if(drawingDroppedFrames > 0){
+ // Fill in zeros data for dropped data
+ memset(&_spectrumData[heightOffset * _fftPoints], 0x00,
+ static_cast<int64_t>(drawingDroppedFrames) * _fftPoints * sizeof(double));
+ }
+
+ // add the new buffer
+ memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData,
+ _fftPoints*sizeof(double));
+ }
+}
+
+double* WaterfallData::GetSpectrumDataBuffer() const
+{
+ return _spectrumData;
+}
+
+void WaterfallData::SetSpectrumDataBuffer(const double* newData)
+{
+ memcpy(_spectrumData, newData, _fftPoints * _historyLength * sizeof(double));
+}
+
+int WaterfallData::GetNumLinesToUpdate() const
+{
+ return _numLinesToUpdate;
+}
+
+void WaterfallData::SetNumLinesToUpdate(const int newNum)
+{
+ _numLinesToUpdate = newNum;
+}
+
+void WaterfallData::IncrementNumLinesToUpdate()
+{
+ _numLinesToUpdate++;
+}
+
+#endif /* WATERFALL_GLOBAL_DATA_CPP */
diff --git a/gr-qtgui/lib/waterfallGlobalData.h b/gr-qtgui/lib/waterfallGlobalData.h
new file mode 100644
index 000000000..928c3b175
--- /dev/null
+++ b/gr-qtgui/lib/waterfallGlobalData.h
@@ -0,0 +1,59 @@
+#ifndef WATERFALL_GLOBAL_DATA_HPP
+#define WATERFALL_GLOBAL_DATA_HPP
+
+#include <qwt_raster_data.h>
+#include <inttypes.h>
+
+#if QWT_VERSION >= 0x060000
+#include <qwt_point_3d.h> // doesn't seem necessary, but is...
+#include <qwt_compat.h>
+#endif
+
+class WaterfallData: public QwtRasterData
+{
+public:
+ WaterfallData(const double, const double, const uint64_t, const unsigned int);
+ virtual ~WaterfallData();
+
+ virtual void Reset();
+ virtual void Copy(const WaterfallData*);
+
+ virtual void ResizeData(const double, const double, const uint64_t);
+
+ virtual QwtRasterData *copy() const;
+
+#if QWT_VERSION < 0x060000
+ virtual QwtDoubleInterval range() const;
+ virtual void setRange(const QwtDoubleInterval&);
+#endif
+
+ virtual double value(double x, double y) const;
+
+ virtual uint64_t GetNumFFTPoints()const;
+ virtual void addFFTData(const double*, const uint64_t, const int);
+
+ virtual double* GetSpectrumDataBuffer()const;
+ virtual void SetSpectrumDataBuffer(const double*);
+
+ virtual int GetNumLinesToUpdate()const;
+ virtual void SetNumLinesToUpdate(const int);
+ virtual void IncrementNumLinesToUpdate();
+
+protected:
+
+ double* _spectrumData;
+ uint64_t _fftPoints;
+ uint64_t _historyLength;
+ int _numLinesToUpdate;
+
+#if QWT_VERSION < 0x060000
+ QwtDoubleInterval _intensityRange;
+#else
+ QwtInterval _intensityRange;
+#endif
+
+private:
+
+};
+
+#endif /* WATERFALL_GLOBAL_DATA_HPP */
diff --git a/gr-qtgui/python/CMakeLists.txt b/gr-qtgui/python/CMakeLists.txt
new file mode 100644
index 000000000..582285808
--- /dev/null
+++ b/gr-qtgui/python/CMakeLists.txt
@@ -0,0 +1,46 @@
+# Copyright 2010-2012 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)
+
+list(APPEND GR_TEST_PYTHON_DIRS
+ ${CMAKE_BINARY_DIR}/gr-qtgui/python
+ ${CMAKE_BINARY_DIR}/gr-qtgui/swig
+)
+list(APPEND GR_TEST_TARGET_DEPS gnuradio-qtgui)
+
+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)
+ GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${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
new file mode 100644
index 000000000..c7024e4f7
--- /dev/null
+++ b/gr-qtgui/python/__init__.py
@@ -0,0 +1,30 @@
+#
+# 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.
+#
+
+'''
+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 *
+import qtgui_swig as qtgui # to preserve the old interface
diff --git a/gr-qtgui/python/qa_qtgui.py b/gr-qtgui/python/qa_qtgui.py
new file mode 100755
index 000000000..562706701
--- /dev/null
+++ b/gr-qtgui/python/qa_qtgui.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+from gnuradio import gr, gr_unittest
+import qtgui_swig
+
+class test_qtgui(gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test01 (self):
+ # Test to make sure we can instantiate the sink
+ self.qtsnk = qtgui_swig.sink_c(1024, gr.firdes.WIN_BLACKMAN_hARRIS,
+ 0, 1, "Test",
+ True, True, True, True)
+
+ def test02 (self):
+ # Test to make sure we can instantiate the sink
+ self.qtsnk = qtgui_swig.sink_f(1024, gr.firdes.WIN_BLACKMAN_hARRIS,
+ 0, 1, "Test",
+ True, True, True, True)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(test_qtgui, "test_qtgui.xml")
diff --git a/gr-qtgui/swig/CMakeLists.txt b/gr-qtgui/swig/CMakeLists.txt
new file mode 100644
index 000000000..a1f70240c
--- /dev/null
+++ b/gr-qtgui/swig/CMakeLists.txt
@@ -0,0 +1,57 @@
+# 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
+ ${GR_QTGUI_INCLUDE_DIRS}
+ ${GNURADIO_CORE_SWIG_INCLUDE_DIRS}
+ ${GRUEL_INCLUDE_DIRS}
+ ${QWT_INCLUDE_DIRS}
+ ${QT_INCLUDE_DIRS}
+ ${Boost_INCLUDE_DIRS}
+)
+
+set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/qtgui_swig_doc.i)
+set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include)
+
+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
+ ${CMAKE_CURRENT_BINARY_DIR}/qtgui_swig_doc.i
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
+ COMPONENT "qtgui_swig"
+)
diff --git a/gr-qtgui/swig/__init__.py b/gr-qtgui/swig/__init__.py
new file mode 100644
index 000000000..e52e326cb
--- /dev/null
+++ b/gr-qtgui/swig/__init__.py
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+# The presence of this file turns this directory into a Python package
+
+from qtgui_swig import *
diff --git a/gr-qtgui/swig/qtgui_sink_c.i b/gr-qtgui/swig/qtgui_sink_c.i
new file mode 100644
index 000000000..65e7d1c82
--- /dev/null
+++ b/gr-qtgui/swig/qtgui_sink_c.i
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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 "gnuradio.i"
+
+%{
+#include <qtgui_sink_c.h>
+%}
+
+GR_SWIG_BLOCK_MAGIC(qtgui,sink_c)
+
+qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
+ double fc=0, double bw=1.0,
+ const std::string &name="Display",
+ bool plotfreq=true, bool plotwaterfall=true,
+ bool plottime=true, bool plotconst=true,
+ QWidget *parent=NULL);
+
+class qtgui_sink_c : public gr_block
+{
+private:
+ friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent);
+ qtgui_sink_c (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent);
+
+public:
+ void exec_();
+ PyObject* pyqwidget();
+
+ void set_frequency_range(const double centerfreq,
+ const double bandwidth);
+ void set_time_domain_axis(double min, double max);
+ void set_constellation_axis(double xmin, double xmax,
+ double ymin, double ymax);
+ void set_frequency_axis(double min, double max);
+ void set_constellation_pen_size(int size);
+ void set_update_time(double t);
+};
diff --git a/gr-qtgui/swig/qtgui_sink_f.i b/gr-qtgui/swig/qtgui_sink_f.i
new file mode 100644
index 000000000..b07eaa9ec
--- /dev/null
+++ b/gr-qtgui/swig/qtgui_sink_f.i
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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 "gnuradio.i"
+
+%{
+#include <qtgui_sink_f.h>
+%}
+
+GR_SWIG_BLOCK_MAGIC(qtgui,sink_f)
+
+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=false,
+ QWidget *parent=NULL);
+
+class qtgui_sink_f : public gr_block
+{
+private:
+ friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent);
+ qtgui_sink_f (int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ bool plotfreq, bool plotwaterfall,
+ bool plottime, bool plotconst,
+ QWidget *parent);
+
+public:
+ void exec_();
+ PyObject* pyqwidget();
+
+ void set_frequency_range(const double centerfreq,
+ const double bandwidth);
+ void set_time_domain_axis(double min, double max);
+ void set_constellation_axis(double xmin, double xmax,
+ double ymin, double ymax);
+ void set_frequency_axis(double min, double max);
+ void set_constellation_pen_size(int size);
+ void set_update_time(double t);
+};
diff --git a/gr-qtgui/swig/qtgui_swig.i b/gr-qtgui/swig/qtgui_swig.i
new file mode 100644
index 000000000..0d77e22da
--- /dev/null
+++ b/gr-qtgui/swig/qtgui_swig.i
@@ -0,0 +1,38 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,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 "gnuradio.i"
+
+//load generated python docstrings
+%include "qtgui_swig_doc.i"
+
+%{
+#include "qtgui_sink_c.h"
+#include "qtgui_sink_f.h"
+#include "qtgui_time_sink_c.h"
+#include "qtgui_time_sink_f.h"
+%}
+
+%include "qtgui_sink_c.i"
+%include "qtgui_sink_f.i"
+%include "qtgui_time_sink_c.i"
+%include "qtgui_time_sink_f.i"
diff --git a/gr-qtgui/swig/qtgui_time_sink_c.i b/gr-qtgui/swig/qtgui_time_sink_c.i
new file mode 100644
index 000000000..b78ca5386
--- /dev/null
+++ b/gr-qtgui/swig/qtgui_time_sink_c.i
@@ -0,0 +1,56 @@
+/* -*- 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.
+ */
+
+%include "gnuradio.i"
+
+%{
+#include <qtgui_time_sink_c.h>
+%}
+
+GR_SWIG_BLOCK_MAGIC(qtgui,time_sink_c)
+
+qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw,
+ const std::string &name,
+ int nconnections=1,
+ QWidget *parent=NULL);
+
+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,
+ 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);
+
+public:
+ void exec_();
+ PyObject* pyqwidget();
+
+ void set_time_domain_axis(double min, double max);
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+};
diff --git a/gr-qtgui/swig/qtgui_time_sink_f.i b/gr-qtgui/swig/qtgui_time_sink_f.i
new file mode 100644
index 000000000..9d59f9364
--- /dev/null
+++ b/gr-qtgui/swig/qtgui_time_sink_f.i
@@ -0,0 +1,56 @@
+/* -*- 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.
+ */
+
+%include "gnuradio.i"
+
+%{
+#include <qtgui_time_sink_f.h>
+%}
+
+GR_SWIG_BLOCK_MAGIC(qtgui,time_sink_f)
+
+qtgui_time_sink_f_sptr qtgui_make_time_sink_f(int size, double bw,
+ const std::string &name,
+ int nconnections=1,
+ QWidget *parent=NULL);
+
+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,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent);
+ qtgui_time_sink_f(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+
+public:
+ void exec_();
+ PyObject* pyqwidget();
+
+ void set_time_domain_axis(double min, double max);
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+};