[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10796 - gnuradio/branches/developers/trondeau/qtdevel
From: |
trondeau |
Subject: |
[Commit-gnuradio] r10796 - gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib |
Date: |
Wed, 8 Apr 2009 19:59:02 -0600 (MDT) |
Author: trondeau
Date: 2009-04-08 19:59:02 -0600 (Wed, 08 Apr 2009)
New Revision: 10796
Modified:
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.cc
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.h
Log:
fixing float sink to behave like the complex sink
Modified:
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i
===================================================================
--- gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i
2009-04-09 01:33:32 UTC (rev 10795)
+++ gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i
2009-04-09 01:59:02 UTC (rev 10796)
@@ -40,7 +40,7 @@
friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
float fmin, float fmax,
const std::string &name,
- QWidget *parent=NULL);
+ QWidget *parent);
qtgui_sink_c (int fftsize, int wintype,
float fmin, float fmax,
const std::string &name,
@@ -58,24 +58,25 @@
GR_SWIG_BLOCK_MAGIC(qtgui,sink_f)
-qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize,
- const std::vector<float> &window,
- float fmin, float fmax,
- const std::string &name="Display");
+qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
+ float fmin=-0.5, float fmax=0.5,
+ const std::string &name="Display",
+ QWidget *parent=NULL);
class qtgui_sink_f : public gr_block
{
private:
- friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize,
- const std::vector<float> &window,
- float fmin, float fmax,
- const std::string &name);
- qtgui_sink_f (int fftsize,
- const std::vector<float> &window,
+ friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
+ float fmin, float fmax,
+ const std::string &name,
+ QWidget *parent);
+ qtgui_sink_f (int fftsize, int wintype,
float fmin, float fmax,
- const std::string &name);
-
+ const std::string &name,
+ QWidget *parent);
+
public:
- void start_app();
+ void exec_();
+ PyObject* pyqwidget();
};
Modified:
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h
===================================================================
---
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h
2009-04-09 01:33:32 UTC (rev 10795)
+++
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h
2009-04-09 01:59:02 UTC (rev 10796)
@@ -88,7 +88,6 @@
QApplication *d_qApplication;
qtgui_obj *d_object;
-
int general_work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
Modified:
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.cc
===================================================================
---
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.cc
2009-04-09 01:33:32 UTC (rev 10795)
+++
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.cc
2009-04-09 01:59:02 UTC (rev 10796)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -31,39 +31,53 @@
#include <QTimer>
qtgui_sink_f_sptr
-qtgui_make_sink_f (int fftsize, const std::vector<float> &window,
- float fmin, float fmax, const std::string &name)
+qtgui_make_sink_f (int fftsize, int wintype,
+ float fmin, float fmax,
+ const std::string &name,
+ QWidget *parent)
{
- return qtgui_sink_f_sptr (new qtgui_sink_f (fftsize, window, fmin, fmax,
name));
+ return qtgui_sink_f_sptr (new qtgui_sink_f (fftsize, wintype,
+ fmin, fmax, name,
+ parent));
}
-qtgui_sink_f::qtgui_sink_f (int fftsize, const std::vector<float> &window,
- float fmin, float fmax, const std::string &name)
+qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype,
+ float fmin, float fmax,
+ const std::string &name,
+ 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_window(window),
- d_fmin(fmin), d_fmax(fmax), d_name(name)
+ d_fftsize(fftsize),
+ d_wintype((gr_firdes::win_type)(wintype)),
+ d_fmin(fmin), d_fmax(fmax), d_name(name),
+ d_parent(parent)
{
d_main_gui = NULL;
pthread_mutex_init(&d_pmutex, NULL);
lock();
- d_shift = true; // Perform fftshift operation; this is usually desired when
plotting
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
d_fft = new gri_fft_complex (d_fftsize, true);
- fftdata = new gr_complex[d_fftsize];
+ d_fftdata = new gr_complex[d_fftsize];
d_index = 0;
d_residbuf = new float[d_fftsize];
+
+ buildwindow();
+
+ initialize();
}
qtgui_sink_f::~qtgui_sink_f()
{
- delete [] fftdata;
+ delete d_object;
+ delete [] d_fftdata;
delete [] d_residbuf;
- delete d_main_gui;
delete d_fft;
}
@@ -78,22 +92,51 @@
}
void
-qtgui_sink_f::start_app()
+qtgui_sink_f::initialize()
{
- d_qApplication = new QApplication(0, NULL);
+ 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_fmin, d_fmax);
+ d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize,
+ d_fmin, d_fmax);
d_main_gui->SetDisplayTitle(d_name);
- d_main_gui->OpenSpectrumWindow(NULL);
+ d_main_gui->SetFFTSize(d_fftsize);
+ d_main_gui->SetWindowType((int)d_wintype);
- qtgui_obj object(d_qApplication);
- qApp->postEvent(&object, new qtgui_event(&d_pmutex));
+ d_main_gui->OpenSpectrumWindow(d_parent);
+ d_object = new qtgui_obj(d_qApplication);
+ qApp->postEvent(d_object, new qtgui_event(&d_pmutex));
+}
+
+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::fft(const float *data_in, int size, gr_complex *data_out)
{
@@ -104,7 +147,7 @@
}
else {
gr_complex *dst = d_fft->get_inbuf();
- for (unsigned int i = 0; i < size; i++) // float to complex
conversion
+ for (int i = 0; i < size; i++) // float to complex conversion
dst[i] = data_in[i];
}
@@ -125,7 +168,55 @@
}
}
+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 the fftdata buffer; no need to preserve old data
+ delete [] d_fftdata;
+ d_fftdata = new gr_complex[newfftsize];
+
+ // 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,
@@ -147,19 +238,21 @@
if(d_index == d_fftsize) {
d_index = 0;
- fft(d_residbuf, d_fftsize, fftdata);
+ fft(d_residbuf, d_fftsize, d_fftdata);
- d_main_gui->UpdateWindow(true, fftdata, d_fftsize, d_residbuf, d_fftsize,
NULL, 0,
+ d_main_gui->UpdateWindow(true, d_fftdata, d_fftsize,
+ d_residbuf, d_fftsize, NULL, 0,
1.0/4.0, convert_to_timespec(0.0), true);
}
for(; i < noutput_items; i+=d_fftsize) {
if(noutput_items - i > d_fftsize) {
j += d_fftsize;
- fft(&in[i], d_fftsize, fftdata);
+ fft(&in[i], d_fftsize, d_fftdata);
- d_main_gui->UpdateWindow(true, fftdata, d_fftsize, &in[i], d_fftsize,
NULL, 0,
- 1.0/4.0, convert_to_timespec(0.0), true);
+ d_main_gui->UpdateWindow(true, d_fftdata, d_fftsize, &in[i],
+ d_fftsize, NULL, 0, 1.0/4.0,
+ convert_to_timespec(0.0), true);
}
}
Modified:
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.h
===================================================================
---
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.h
2009-04-09 01:33:32 UTC (rev 10795)
+++
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_f.h
2009-04-09 01:59:02 UTC (rev 10796)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,27 +24,38 @@
#define INCLUDED_QTGUI_SINK_F_H
#include <gr_block.h>
+#include <gr_firdes.h>
#include <gri_fft.h>
#include <qapplication.h>
#include <qtgui.h>
+#include <Python.h>
#include "SpectrumGUIClass.h"
class qtgui_sink_f;
typedef boost::shared_ptr<qtgui_sink_f> qtgui_sink_f_sptr;
-qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, const std::vector<float>
&window,
- float fmin=-0.5, float fmax=0.5, const
std::string &name="Display");
+qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
+ float fmin=-0.5, float fmax=0.5,
+ const std::string &name="Spectrum Display",
+ QWidget *parent=NULL);
class qtgui_sink_f : public gr_block
{
private:
- friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, const
std::vector<float> &window,
- float fmin, float fmax, const
std::string &name);
- qtgui_sink_f (int fftsize, const std::vector<float> &window,
- float fmin, float fmax, const std::string &name);
-
+ friend qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype,
+ float fmin, float fmax,
+ const std::string &name,
+ QWidget *parent);
+ qtgui_sink_f (int fftsize, int wintype,
+ float fmin, float fmax,
+ const std::string &name,
+ QWidget *parent);
+
+ void initialize();
+
int d_fftsize;
+ gr_firdes::win_type d_wintype;
std::vector<float> d_window;
float d_fmin;
float d_fmax;
@@ -54,23 +65,29 @@
bool d_shift;
gri_fft_complex *d_fft;
- gr_complex *fftdata;
+ gr_complex *d_fftdata;
int d_index;
float *d_residbuf;
+ QWidget *d_parent;
SpectrumGUIClass *d_main_gui;
+ void windowreset();
+ void buildwindow();
+ void fftresize();
void fft(const float *data_in, int size, gr_complex *data_out);
public:
~qtgui_sink_f();
- void start_app();
+ void exec_();
void lock();
void unlock();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
- QApplication *d_qApplication
-;
+ QApplication *d_qApplication;
+ qtgui_obj *d_object;
int general_work (int noutput_items,
gr_vector_int &ninput_items,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10796 - gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib,
trondeau <=