commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10792 - gnuradio/branches/developers/trondeau/qtdevel


From: trondeau
Subject: [Commit-gnuradio] r10792 - gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib
Date: Wed, 8 Apr 2009 18:49:55 -0600 (MDT)

Author: trondeau
Date: 2009-04-08 18:49:55 -0600 (Wed, 08 Apr 2009)
New Revision: 10792

Modified:
   gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.cc
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h
Log:
This holds the Python-C++ interface magic to export a pointer to the QWidget 
that will allow other QWidget's to add this as a child, even in PyQt projects 
in Python. This takes a parent in the contstructor, too, but does not work with 
PyQt.

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 00:48:17 UTC (rev 10791)
+++ gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui.i     
2009-04-09 00:49:55 UTC (rev 10792)
@@ -29,25 +29,26 @@
 
 GR_SWIG_BLOCK_MAGIC(qtgui,sink_c)
 
-  qtgui_sink_c_sptr qtgui_make_sink_c (PyObject *parent,
-                                      int fftsize, int wintype,
+  qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
                                       float fmin=-0.5, float fmax=0.5,
-                                      const std::string &name="Display");
+                                      const std::string &name="Display",
+                                      QWidget *parent=NULL);
 
 class qtgui_sink_c : public gr_block
 {
 private:
-  friend qtgui_sink_c_sptr qtgui_make_sink_c (PyObject *parent,
-                                             int fftsize, int wintype,
+  friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
                                              float fmin, float fmax,
-                                             const std::string &name);
-  qtgui_sink_c (PyObject *parent,
-               int fftsize, int wintype,
+                                             const std::string &name,
+                                             QWidget *parent=NULL);
+  qtgui_sink_c (int fftsize, int wintype,
                float fmin, float fmax,
-               const std::string &name);
+               const std::string &name,
+               QWidget *parent);
 
 public:
   void exec_();
+  PyObject* pyqwidget();
 };
 
 

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.cc 
    2009-04-09 00:48:17 UTC (rev 10791)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.cc 
    2009-04-09 00:49:55 UTC (rev 10792)
@@ -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,29 +31,35 @@
 #include <QTimer>
 
 qtgui_sink_c_sptr
-qtgui_make_sink_c (PyObject *parent, int fftsize, int wintype,
-                  float fmin, float fmax, const std::string &name)
+qtgui_make_sink_c (int fftsize, int wintype,
+                  float fmin, float fmax,
+                  const std::string &name,
+                  QWidget *parent)
 {
-  return qtgui_sink_c_sptr (new qtgui_sink_c (parent, fftsize, wintype,
-                                             fmin, fmax, name));
+  return qtgui_sink_c_sptr (new qtgui_sink_c (fftsize, wintype,
+                                             fmin, fmax, name,
+                                             parent));
 }
 
-qtgui_sink_c::qtgui_sink_c (PyObject *parent, int fftsize, int wintype,
-                           float fmin, float fmax, const std::string &name)
+qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype,
+                           float fmin, float fmax,
+                           const std::string &name,
+                           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_fmin(fmin), d_fmax(fmax), d_name(name)
+    d_fmin(fmin), d_fmax(fmax), d_name(name),
+    d_parent(parent)
 {
-  d_parent = (QWidget*)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);
 
@@ -72,7 +78,6 @@
   delete d_object;
   delete [] d_fftdata;
   delete [] d_residbuf;
-  delete d_main_gui;
   delete d_fft;
 }
 
@@ -106,7 +111,7 @@
   d_main_gui->SetFFTSize(d_fftsize);
   d_main_gui->SetWindowType((int)d_wintype);
 
-  d_main_gui->OpenSpectrumWindow(NULL);
+  d_main_gui->OpenSpectrumWindow(d_parent);
 
   d_object = new qtgui_obj(d_qApplication);
   qApp->postEvent(d_object, new qtgui_event(&d_pmutex));
@@ -119,7 +124,20 @@
   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::fft(const gr_complex *data_in, int size, gr_complex *data_out)
 {

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 00:48:17 UTC (rev 10791)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/qtgui_sink_c.h  
    2009-04-09 00:49:55 UTC (rev 10792)
@@ -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
  * 
@@ -34,26 +34,25 @@
 class qtgui_sink_c;
 typedef boost::shared_ptr<qtgui_sink_c> qtgui_sink_c_sptr;
 
-qtgui_sink_c_sptr qtgui_make_sink_c (PyObject *parent, 
-                                    int fftsize, int wintype,
+qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
                                     float fmin=-0.5, float fmax=0.5,
-                                    const std::string &name="Display");
+                                    const std::string &name="Spectrum Display",
+                                    QWidget *parent=NULL);
 
 class qtgui_sink_c : public gr_block
 {
 private:
-  friend qtgui_sink_c_sptr qtgui_make_sink_c (PyObject *parent, 
-                                             int fftsize, int wintype,
+  friend qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype,
                                              float fmin, float fmax,
-                                             const std::string &name);
-  qtgui_sink_c (PyObject *parent, 
-               int fftsize, int wintype,
+                                             const std::string &name,
+                                             QWidget *parent);
+  qtgui_sink_c (int fftsize, int wintype,
                float fmin, float fmax, 
-               const std::string &name);
+               const std::string &name,
+               QWidget *parent);
 
   void initialize();
 
-  QWidget *d_parent;  
   int d_fftsize;
   gr_firdes::win_type d_wintype;
   std::vector<float> d_window;
@@ -70,7 +69,8 @@
   int d_index;
   gr_complex *d_residbuf;
 
-  SpectrumGUIClass *d_main_gui; 
+  QWidget *d_parent;
+  SpectrumGUIClass *d_main_gui;
 
   void windowreset();
   void buildwindow();
@@ -82,10 +82,13 @@
   void exec_();
   void lock();
   void unlock();
+  QWidget*  qwidget();
+  PyObject* pyqwidget();
 
   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,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]