[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 05/09: qtgui: added C++-only QTGUI applicat
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 05/09: qtgui: added C++-only QTGUI application example. |
Date: |
Tue, 26 Apr 2016 00:41:05 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 9db614d652ca5065599d4282bd43a3b3fd0e9d12
Author: Tom Rondeau <address@hidden>
Date: Mon Apr 18 17:31:13 2016 -0400
qtgui: added C++-only QTGUI application example.
---
gr-qtgui/CMakeLists.txt | 1 +
gr-qtgui/examples/c++/CMakeLists.txt | 49 ++++++++++++++
gr-qtgui/examples/c++/display_qt.cc | 126 +++++++++++++++++++++++++++++++++++
gr-qtgui/examples/c++/display_qt.h | 77 +++++++++++++++++++++
4 files changed, 253 insertions(+)
diff --git a/gr-qtgui/CMakeLists.txt b/gr-qtgui/CMakeLists.txt
index 8fc49a0..ad10363 100644
--- a/gr-qtgui/CMakeLists.txt
+++ b/gr-qtgui/CMakeLists.txt
@@ -109,6 +109,7 @@ CPACK_COMPONENT("qtgui_swig"
add_subdirectory(include/gnuradio/qtgui)
add_subdirectory(lib)
add_subdirectory(doc)
+add_subdirectory(examples/c++)
if(ENABLE_PYTHON)
add_subdirectory(grc)
add_subdirectory(swig)
diff --git a/gr-qtgui/examples/c++/CMakeLists.txt
b/gr-qtgui/examples/c++/CMakeLists.txt
new file mode 100644
index 0000000..ad84287
--- /dev/null
+++ b/gr-qtgui/examples/c++/CMakeLists.txt
@@ -0,0 +1,49 @@
+# Copyright 2016 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_directories(
+ ${GR_QTGUI_INCLUDE_DIRS}
+ ${GR_ANALOG_INCLUDE_DIRS}
+ ${GR_FILTER_INCLUDE_DIRS}
+ ${GR_BLOCKS_INCLUDE_DIRS}
+ ${GR_FFT_INCLUDE_DIRS}
+ ${GNURADIO_RUNTIME_INCLUDE_DIRS}
+ ${QT_INCLUDE_DIRS}
+ ${Boost_INCLUDE_DIRS}
+)
+
+list(APPEND QTGUI_LIBRARIES
+ gnuradio-qtgui
+ gnuradio-analog
+ gnuradio-filter
+ gnuradio-blocks
+ gnuradio-fft
+ gnuradio-runtime
+ ${QWT_LIBRARY_DIRS}
+)
+
+QT4_WRAP_CPP(qtgui_moc_sources display_qt.h)
+add_executable(display_qt display_qt.cc ${qtgui_moc_sources})
+target_link_libraries(display_qt ${QTGUI_LIBRARIES})
+
+INSTALL(TARGETS
+ display_qt
+ DESTINATION ${GR_PKG_QTGUI_EXAMPLES_DIR}
+ COMPONENT "qtgui_examples"
+)
diff --git a/gr-qtgui/examples/c++/display_qt.cc
b/gr-qtgui/examples/c++/display_qt.cc
new file mode 100644
index 0000000..9d990b2
--- /dev/null
+++ b/gr-qtgui/examples/c++/display_qt.cc
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2016 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 "display_qt.h"
+
+mywindow::mywindow()
+ : QWidget()
+{
+ // We'll use a horizontal layout of two QTabWidgets
+ layout = new QHBoxLayout();
+
+ // Create the tab widgets
+ tab0 = new QTabWidget();
+ tab1 = new QTabWidget();
+
+ // Add the tab widgets to the layou
+ layout->addWidget(tab0);
+ layout->addWidget(tab1);
+
+ // Set the layout as the main widget's layou
+ setLayout(layout);
+
+ // Simple resizing of the app
+ resize(2000,800);
+
+ // sample rate
+ int rate = 48000;
+
+ // Create the GNU Radio top block
+ tb = make_top_block("display_qt");
+
+ // Source will be sine wave in noise
+ src0 = analog::sig_source_f::make(rate, analog::GR_SIN_WAVE, 1500, 1);
+ src1 = analog::noise_source_f::make(analog::GR_GAUSSIAN, 0.1);
+
+ // Combine signal and noise; add throttle
+ src = blocks::add_ff::make();
+ thr = blocks::throttle::make(sizeof(float), rate);
+
+ // Create the QTGUI sinks
+ // Time, Freq, Waterfall, and Histogram sinks
+ tsnk = qtgui::time_sink_f::make(1024, rate, "", 1);
+ fsnk = qtgui::freq_sink_f::make(1024, fft::window::WIN_HANN,
+ 0, rate, "", 1);
+ wsnk = qtgui::waterfall_sink_f::make(1024, fft::window::WIN_HANN,
+ 0, rate, "", 1);
+ hsnk = qtgui::histogram_sink_f::make(1024, 100, -2, 2, "", 1);
+
+ // Turn off the legend on these plots
+ tsnk->disable_legend();
+ fsnk->disable_legend();
+ hsnk->disable_legend();
+
+ // Connect the graph
+ tb->connect(src0, 0, src, 0);
+ tb->connect(src1, 0, src, 1);
+ tb->connect(src, 0, thr, 0);
+ tb->connect(thr, 0, tsnk, 0);
+ tb->connect(thr, 0, fsnk, 0);
+ tb->connect(thr, 0, wsnk, 0);
+ tb->connect(thr, 0, hsnk, 0);
+
+ // Get the raw QWidget objects from the GNU Radio blocks
+ qtgui_time_sink_win = tsnk->qwidget();
+ qtgui_freq_sink_win = fsnk->qwidget();
+ qtgui_waterfall_sink_win = wsnk->qwidget();
+ qtgui_histogram_sink_win = hsnk->qwidget();
+
+ // Plug the widgets into the tabs
+ tab0->addTab(qtgui_time_sink_win, "Time");
+ tab0->addTab(qtgui_histogram_sink_win, "Hist");
+ tab1->addTab(qtgui_freq_sink_win, "Freq");
+ tab1->addTab(qtgui_waterfall_sink_win, "Waterfall");
+}
+
+mywindow::~mywindow()
+{
+}
+
+void
+mywindow::start()
+{
+ tb->start();
+}
+
+void
+mywindow::quitting()
+{
+ tb->stop();
+ tb->wait();
+}
+
+int main(int argc, char **argv)
+{
+ // The global QT application
+ QApplication app(argc, argv);
+
+ mywindow *w = new mywindow();
+
+ QObject::connect(&app, SIGNAL(aboutToQuit()),
+ w, SLOT(quitting()));
+
+ w->start(); // Start the flowgraph
+ w->show(); // show the window
+ app.exec(); // run the QT executor loop
+
+ return 0;
+}
diff --git a/gr-qtgui/examples/c++/display_qt.h
b/gr-qtgui/examples/c++/display_qt.h
new file mode 100644
index 0000000..97c46c1
--- /dev/null
+++ b/gr-qtgui/examples/c++/display_qt.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2016 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.
+ */
+
+// Q_MOC_RUN is a workaround for a QT4 + Boost version issue
+#ifndef Q_MOC_RUN
+#include <gnuradio/top_block.h>
+#include <gnuradio/analog/sig_source_f.h>
+#include <gnuradio/analog/noise_source_f.h>
+#include <gnuradio/blocks/add_ff.h>
+#include <gnuradio/blocks/throttle.h>
+#include <gnuradio/qtgui/time_sink_f.h>
+#include <gnuradio/qtgui/freq_sink_f.h>
+#include <gnuradio/qtgui/waterfall_sink_f.h>
+#include <gnuradio/qtgui/histogram_sink_f.h>
+#include <gnuradio/fft/window.h>
+#endif
+
+#include <QWidget>
+#include <QHBoxLayout>
+#include <QTabWidget>
+
+using namespace gr;
+
+class mywindow : public QWidget
+{
+ Q_OBJECT
+
+private:
+ QHBoxLayout *layout;
+ QTabWidget *tab0;
+ QTabWidget *tab1;
+ QWidget* qtgui_time_sink_win;
+ QWidget* qtgui_freq_sink_win;
+ QWidget* qtgui_waterfall_sink_win;
+ QWidget* qtgui_histogram_sink_win;
+
+#ifndef Q_MOC_RUN
+ top_block_sptr tb;
+ analog::sig_source_f::sptr src0;
+ analog::noise_source_f::sptr src1;
+ blocks::add_ff::sptr src;
+ blocks::throttle::sptr thr;
+ qtgui::time_sink_f::sptr tsnk;
+ qtgui::freq_sink_f::sptr fsnk;
+ qtgui::waterfall_sink_f::sptr wsnk;
+ qtgui::histogram_sink_f::sptr hsnk;
+#endif
+
+public slots:
+ // Stop the topblock before shutting down the window
+ void quitting();
+
+public:
+ mywindow();
+ virtual ~mywindow();
+
+ // call start() on the topblock
+ void start();
+};
- [Commit-gnuradio] [gnuradio] branch master updated (ece754f -> 6a33fff), git, 2016/04/25
- [Commit-gnuradio] [gnuradio] 02/09: added a gr-preferences getter, git, 2016/04/25
- [Commit-gnuradio] [gnuradio] 01/09: Merge pull request #1 from gnuradio/master, git, 2016/04/25
- [Commit-gnuradio] [gnuradio] 03/09: Completely refactored windows audio sink to use multiple buffers, eliminates skipping sounds when nperiods and period_time are set within reason. Default values should work fine for most. Set verbose=true to see additional info. output device can be set to either the ordinal number of the device to use, or the string name of the device. Setting a string in verbose mode will also display a list of choices in the console on run, git, 2016/04/25
- [Commit-gnuradio] [gnuradio] 06/09: Merge remote-tracking branch 'gnieboer/windows_audio', git, 2016/04/25
- [Commit-gnuradio] [gnuradio] 05/09: qtgui: added C++-only QTGUI application example.,
git <=
- [Commit-gnuradio] [gnuradio] 07/09: Merge remote-tracking branch 'mmueller/udp_source_add_payload_buffer_gr_pref', git, 2016/04/25
- [Commit-gnuradio] [gnuradio] 09/09: Merge remote-tracking branch 'tom/qtgui_c++_example', git, 2016/04/25
- [Commit-gnuradio] [gnuradio] 04/09: qtgui: more appropriate doxygen link., git, 2016/04/25
- [Commit-gnuradio] [gnuradio] 08/09: Merge branch 'maint', git, 2016/04/25