Re: [Discuss-gnuradio] Compiling QT C++ programs with GNU Radio

2019-10-09 Thread Moses Browne Mwakyanjala
Hello Nick,
Thanks.
I will have a look.

Regards,
Moses.

On Tue, Oct 8, 2019 at 10:59 PM Nick Foster  wrote:

> Maybe I'm just confused, then. You weren't clear about the problem you're
> experiencing, or what you've tried to resolve it. It sounded in your
> initial email like you just don't know how to build a CMake project (using
> "g++", for instance, is not how that works). Further leading me to think
> this was that you apparently are doing this compilation in-tree, in
> gr-qtgui/examples, which isn't a good place for user projects.
>
> The CMakeLists.txt you attached appears to be designed for in-tree
> compilation. This means your project would always have to be compiled along
> with your own custom branch of Gnuradio, which I'm almost positive is not
> what you actually want to do. The out-of-tree module template includes all
> of the CMake commands necessary to compile and link your own project
> outside the Gnuradio source tree. It should serve as a much better starting
> point for your project than the CMakeLists.txt that you attached, which
> lacks the necessary find_package calls to properly find and link to
> Gnuradio (and any other libraries you might use). You'll want to take a
> look at the toplevel CMakeLists.txt in the out-of-tree template as well as
> the one in lib/, which you'll want to modify to produce an executable
> instead of a library for your project.
>
> You could also look at the CMake files from other standalone Gnuradio
> applications for inspiration, such as gqrx.
>
> Nick
>
> On Tue, Oct 8, 2019 at 12:55 PM Moses Browne Mwakyanjala <
> mbkit...@gmail.com> wrote:
>
>> Hello Nick,
>> As I have mentioned in my previous email, I know how to use CMake as I
>> have already made a lot of OOTs before. Please understand that I'm not
>> trying to build an OOT. In the program, a top_block_sptr object (think
>> of it as a C++ based flowgraph) object is initialized with signal
>> generators and qt graphics. The Qt event loop initializes the flowgraph (an
>> object called 'mywindow'), makes signal/slot connections and runs it. You
>> can also have a look at the CMakeList.txt file I attached. It doesn't look
>> like the traditional OOT makefiles.
>>
>> Regards,
>>
>> Moses.
>>
>>
>> On Tue, Oct 8, 2019 at 9:21 PM Nick Foster  wrote:
>>
>>> Within the "out of tree module" link I sent is basic information on how
>>> to compile an application using CMake.
>>>
>>> https://wiki.gnuradio.org/index.php/OutOfTreeModules#Using_CMake
>>>
>>>
>>> On Tue, Oct 8, 2019 at 12:05 PM Moses Browne Mwakyanjala <
>>> mbkit...@gmail.com> wrote:
>>>
 Hello Nick,
 Thanks for your email.
 I have created the OOTs already. What I'm trying to do it to integrate
 my OOTs in a QT C++ application (something akin to Gqrx).
 You could see what I'm trying to do from the example source code I
 attached.

 Regards,
 Moses.

 On Tue, Oct 8, 2019 at 8:56 PM Nick Foster 
 wrote:

> I think you should read up on creating out-of-tree GNURadio modules:
>
> https://wiki.gnuradio.org/index.php/OutOfTreeModules
>
> Nick
>
> On Tue, Oct 8, 2019 at 11:44 AM Moses Browne Mwakyanjala <
> mbkit...@gmail.com> wrote:
>
>> Hello all,
>> I'm trying to implement an easy-to-use QT-based receiver in GNU
>> Radio. As a starting point, I would like to compile a C++ example
>> (attached) under /gnuradio/gr-qtgui/examples/c++ . This example program
>> generates a noisy sine wave and displays on some qt gui qwidgets. I was
>> able to compile and run the program a couple of years ago. 
>> Unfortunately, I
>> can't remember what I did as the whole process was trial and error. I 
>> have
>> tried both "make" and "g++" without any luck. Please don't hesitate to 
>> ask
>> for more information.
>> All help is highly appreciated.
>> Best regards,
>> Moses.
>> ___
>> Discuss-gnuradio mailing list
>> Discuss-gnuradio@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Compiling QT C++ programs with GNU Radio

2019-10-08 Thread Nick Foster
Maybe I'm just confused, then. You weren't clear about the problem you're
experiencing, or what you've tried to resolve it. It sounded in your
initial email like you just don't know how to build a CMake project (using
"g++", for instance, is not how that works). Further leading me to think
this was that you apparently are doing this compilation in-tree, in
gr-qtgui/examples, which isn't a good place for user projects.

The CMakeLists.txt you attached appears to be designed for in-tree
compilation. This means your project would always have to be compiled along
with your own custom branch of Gnuradio, which I'm almost positive is not
what you actually want to do. The out-of-tree module template includes all
of the CMake commands necessary to compile and link your own project
outside the Gnuradio source tree. It should serve as a much better starting
point for your project than the CMakeLists.txt that you attached, which
lacks the necessary find_package calls to properly find and link to
Gnuradio (and any other libraries you might use). You'll want to take a
look at the toplevel CMakeLists.txt in the out-of-tree template as well as
the one in lib/, which you'll want to modify to produce an executable
instead of a library for your project.

You could also look at the CMake files from other standalone Gnuradio
applications for inspiration, such as gqrx.

Nick

On Tue, Oct 8, 2019 at 12:55 PM Moses Browne Mwakyanjala 
wrote:

> Hello Nick,
> As I have mentioned in my previous email, I know how to use CMake as I
> have already made a lot of OOTs before. Please understand that I'm not
> trying to build an OOT. In the program, a top_block_sptr object (think of
> it as a C++ based flowgraph) object is initialized with signal generators
> and qt graphics. The Qt event loop initializes the flowgraph (an object
> called 'mywindow'), makes signal/slot connections and runs it. You can also
> have a look at the CMakeList.txt file I attached. It doesn't look like the
> traditional OOT makefiles.
>
> Regards,
>
> Moses.
>
>
> On Tue, Oct 8, 2019 at 9:21 PM Nick Foster  wrote:
>
>> Within the "out of tree module" link I sent is basic information on how
>> to compile an application using CMake.
>>
>> https://wiki.gnuradio.org/index.php/OutOfTreeModules#Using_CMake
>>
>>
>> On Tue, Oct 8, 2019 at 12:05 PM Moses Browne Mwakyanjala <
>> mbkit...@gmail.com> wrote:
>>
>>> Hello Nick,
>>> Thanks for your email.
>>> I have created the OOTs already. What I'm trying to do it to integrate
>>> my OOTs in a QT C++ application (something akin to Gqrx).
>>> You could see what I'm trying to do from the example source code I
>>> attached.
>>>
>>> Regards,
>>> Moses.
>>>
>>> On Tue, Oct 8, 2019 at 8:56 PM Nick Foster  wrote:
>>>
 I think you should read up on creating out-of-tree GNURadio modules:

 https://wiki.gnuradio.org/index.php/OutOfTreeModules

 Nick

 On Tue, Oct 8, 2019 at 11:44 AM Moses Browne Mwakyanjala <
 mbkit...@gmail.com> wrote:

> Hello all,
> I'm trying to implement an easy-to-use QT-based receiver in GNU Radio.
> As a starting point, I would like to compile a C++ example (attached) 
> under
> /gnuradio/gr-qtgui/examples/c++ . This example program generates a noisy
> sine wave and displays on some qt gui qwidgets. I was able to compile and
> run the program a couple of years ago. Unfortunately, I can't remember 
> what
> I did as the whole process was trial and error. I have tried both "make"
> and "g++" without any luck. Please don't hesitate to ask for
> more information.
> All help is highly appreciated.
> Best regards,
> Moses.
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>

___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Compiling QT C++ programs with GNU Radio

2019-10-08 Thread Moses Browne Mwakyanjala
Hello Nick,
As I have mentioned in my previous email, I know how to use CMake as I have
already made a lot of OOTs before. Please understand that I'm not trying to
build an OOT. In the program, a top_block_sptr object (think of it as a C++
based flowgraph) object is initialized with signal generators and qt
graphics. The Qt event loop initializes the flowgraph (an object called
'mywindow'), makes signal/slot connections and runs it. You can also have a
look at the CMakeList.txt file I attached. It doesn't look like the
traditional OOT makefiles.

Regards,

Moses.


On Tue, Oct 8, 2019 at 9:21 PM Nick Foster  wrote:

> Within the "out of tree module" link I sent is basic information on how to
> compile an application using CMake.
>
> https://wiki.gnuradio.org/index.php/OutOfTreeModules#Using_CMake
>
>
> On Tue, Oct 8, 2019 at 12:05 PM Moses Browne Mwakyanjala <
> mbkit...@gmail.com> wrote:
>
>> Hello Nick,
>> Thanks for your email.
>> I have created the OOTs already. What I'm trying to do it to integrate my
>> OOTs in a QT C++ application (something akin to Gqrx).
>> You could see what I'm trying to do from the example source code I
>> attached.
>>
>> Regards,
>> Moses.
>>
>> On Tue, Oct 8, 2019 at 8:56 PM Nick Foster  wrote:
>>
>>> I think you should read up on creating out-of-tree GNURadio modules:
>>>
>>> https://wiki.gnuradio.org/index.php/OutOfTreeModules
>>>
>>> Nick
>>>
>>> On Tue, Oct 8, 2019 at 11:44 AM Moses Browne Mwakyanjala <
>>> mbkit...@gmail.com> wrote:
>>>
 Hello all,
 I'm trying to implement an easy-to-use QT-based receiver in GNU Radio.
 As a starting point, I would like to compile a C++ example (attached) under
 /gnuradio/gr-qtgui/examples/c++ . This example program generates a noisy
 sine wave and displays on some qt gui qwidgets. I was able to compile and
 run the program a couple of years ago. Unfortunately, I can't remember what
 I did as the whole process was trial and error. I have tried both "make"
 and "g++" without any luck. Please don't hesitate to ask for
 more information.
 All help is highly appreciated.
 Best regards,
 Moses.
 ___
 Discuss-gnuradio mailing list
 Discuss-gnuradio@gnu.org
 https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

>>>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Compiling QT C++ programs with GNU Radio

2019-10-08 Thread Nick Foster
Within the "out of tree module" link I sent is basic information on how to
compile an application using CMake.

https://wiki.gnuradio.org/index.php/OutOfTreeModules#Using_CMake


On Tue, Oct 8, 2019 at 12:05 PM Moses Browne Mwakyanjala 
wrote:

> Hello Nick,
> Thanks for your email.
> I have created the OOTs already. What I'm trying to do it to integrate my
> OOTs in a QT C++ application (something akin to Gqrx).
> You could see what I'm trying to do from the example source code I
> attached.
>
> Regards,
> Moses.
>
> On Tue, Oct 8, 2019 at 8:56 PM Nick Foster  wrote:
>
>> I think you should read up on creating out-of-tree GNURadio modules:
>>
>> https://wiki.gnuradio.org/index.php/OutOfTreeModules
>>
>> Nick
>>
>> On Tue, Oct 8, 2019 at 11:44 AM Moses Browne Mwakyanjala <
>> mbkit...@gmail.com> wrote:
>>
>>> Hello all,
>>> I'm trying to implement an easy-to-use QT-based receiver in GNU Radio.
>>> As a starting point, I would like to compile a C++ example (attached) under
>>> /gnuradio/gr-qtgui/examples/c++ . This example program generates a noisy
>>> sine wave and displays on some qt gui qwidgets. I was able to compile and
>>> run the program a couple of years ago. Unfortunately, I can't remember what
>>> I did as the whole process was trial and error. I have tried both "make"
>>> and "g++" without any luck. Please don't hesitate to ask for
>>> more information.
>>> All help is highly appreciated.
>>> Best regards,
>>> Moses.
>>> ___
>>> Discuss-gnuradio mailing list
>>> Discuss-gnuradio@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>>
>>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Compiling QT C++ programs with GNU Radio

2019-10-08 Thread Moses Browne Mwakyanjala
Hello Nick,
Thanks for your email.
I have created the OOTs already. What I'm trying to do it to integrate my
OOTs in a QT C++ application (something akin to Gqrx).
You could see what I'm trying to do from the example source code I
attached.

Regards,
Moses.

On Tue, Oct 8, 2019 at 8:56 PM Nick Foster  wrote:

> I think you should read up on creating out-of-tree GNURadio modules:
>
> https://wiki.gnuradio.org/index.php/OutOfTreeModules
>
> Nick
>
> On Tue, Oct 8, 2019 at 11:44 AM Moses Browne Mwakyanjala <
> mbkit...@gmail.com> wrote:
>
>> Hello all,
>> I'm trying to implement an easy-to-use QT-based receiver in GNU Radio. As
>> a starting point, I would like to compile a C++ example (attached) under
>> /gnuradio/gr-qtgui/examples/c++ . This example program generates a noisy
>> sine wave and displays on some qt gui qwidgets. I was able to compile and
>> run the program a couple of years ago. Unfortunately, I can't remember what
>> I did as the whole process was trial and error. I have tried both "make"
>> and "g++" without any luck. Please don't hesitate to ask for
>> more information.
>> All help is highly appreciated.
>> Best regards,
>> Moses.
>> ___
>> Discuss-gnuradio mailing list
>> Discuss-gnuradio@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Compiling QT C++ programs with GNU Radio

2019-10-08 Thread Nick Foster
I think you should read up on creating out-of-tree GNURadio modules:

https://wiki.gnuradio.org/index.php/OutOfTreeModules

Nick

On Tue, Oct 8, 2019 at 11:44 AM Moses Browne Mwakyanjala 
wrote:

> Hello all,
> I'm trying to implement an easy-to-use QT-based receiver in GNU Radio. As
> a starting point, I would like to compile a C++ example (attached) under
> /gnuradio/gr-qtgui/examples/c++ . This example program generates a noisy
> sine wave and displays on some qt gui qwidgets. I was able to compile and
> run the program a couple of years ago. Unfortunately, I can't remember what
> I did as the whole process was trial and error. I have tried both "make"
> and "g++" without any luck. Please don't hesitate to ask for
> more information.
> All help is highly appreciated.
> Best regards,
> Moses.
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


[Discuss-gnuradio] Compiling QT C++ programs with GNU Radio

2019-10-08 Thread Moses Browne Mwakyanjala
Hello all,
I'm trying to implement an easy-to-use QT-based receiver in GNU Radio. As a
starting point, I would like to compile a C++ example (attached) under
/gnuradio/gr-qtgui/examples/c++ . This example program generates a noisy
sine wave and displays on some qt gui qwidgets. I was able to compile and
run the program a couple of years ago. Unfortunately, I can't remember what
I did as the whole process was trial and error. I have tried both "make"
and "g++" without any luck. Please don't hesitate to ask for
more information.
All help is highly appreciated.
Best regards,
Moses.
# 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
)

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"
)
/*
 * 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()
{