From 7ba2647977f9b302969208fa8548d1ca8dcddd4b Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 18 Apr 2011 23:07:31 -0400 Subject: gr-qtgui: adding copyright dates to qtgui files. --- gr-qtgui/lib/ConstellationDisplayPlot.cc | 22 ++++++++++++++++++++++ gr-qtgui/lib/ConstellationDisplayPlot.h | 22 ++++++++++++++++++++++ gr-qtgui/lib/FrequencyDisplayPlot.cc | 22 ++++++++++++++++++++++ gr-qtgui/lib/FrequencyDisplayPlot.h | 22 ++++++++++++++++++++++ gr-qtgui/lib/SpectrumGUIClass.cc | 22 ++++++++++++++++++++++ gr-qtgui/lib/SpectrumGUIClass.h | 22 ++++++++++++++++++++++ gr-qtgui/lib/TimeDomainDisplayPlot.cc | 22 ++++++++++++++++++++++ gr-qtgui/lib/TimeDomainDisplayPlot.h | 22 ++++++++++++++++++++++ gr-qtgui/lib/WaterfallDisplayPlot.cc | 22 ++++++++++++++++++++++ gr-qtgui/lib/WaterfallDisplayPlot.h | 22 ++++++++++++++++++++++ gr-qtgui/lib/spectrumdisplayform.cc | 22 ++++++++++++++++++++++ gr-qtgui/lib/spectrumdisplayform.h | 22 ++++++++++++++++++++++ 12 files changed, 264 insertions(+) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc index 75dbe9c37..7ec2db820 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.cc +++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.h b/gr-qtgui/lib/ConstellationDisplayPlot.h index bf4531e0a..e57149403 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.h +++ b/gr-qtgui/lib/ConstellationDisplayPlot.h @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc index 30b318184..4d60cd9be 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.h b/gr-qtgui/lib/FrequencyDisplayPlot.h index 7a207ab8d..6689703bc 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.h +++ b/gr-qtgui/lib/FrequencyDisplayPlot.h @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index 1a519591d..b472470c6 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/SpectrumGUIClass.h b/gr-qtgui/lib/SpectrumGUIClass.h index 48f45a0f5..ad06674f5 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.h +++ b/gr-qtgui/lib/SpectrumGUIClass.h @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index be25a6cde..86aa8533e 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h index 01338300c..328371e6a 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 2234f4238..52381a9f6 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/lib/WaterfallDisplayPlot.h index faa48d6aa..583bf9407 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.h +++ b/gr-qtgui/lib/WaterfallDisplayPlot.h @@ -1,3 +1,25 @@ +/* -*- 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 diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index 238c9889f..acc7a209d 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -1,3 +1,25 @@ +/* -*- 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. + */ + #include #include #include diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/lib/spectrumdisplayform.h index 860edf2d1..30303a36f 100644 --- a/gr-qtgui/lib/spectrumdisplayform.h +++ b/gr-qtgui/lib/spectrumdisplayform.h @@ -1,3 +1,25 @@ +/* -*- 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 -- cgit From c0692647cce3c136dee4d92f8e99a77539dbd0bd Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 21 Apr 2011 19:10:27 -0400 Subject: gr-qtgui: adding time-domain plot specific event updater. --- gr-qtgui/lib/spectrumUpdateEvents.cc | 56 ++++++++++++++++++++++++++++++++++++ gr-qtgui/lib/spectrumUpdateEvents.h | 26 +++++++++++++++++ 2 files changed, 82 insertions(+) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc index 53a205fb7..ab5ef3be5 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.cc +++ b/gr-qtgui/lib/spectrumUpdateEvents.cc @@ -177,4 +177,60 @@ SpectrumFrequencyRangeEvent::GetStopFrequency() const return _stopFrequency; } + +/***************************************************************************/ + +TimeUpdateEvent::TimeUpdateEvent(const gr_complex *timeDomainPoints, + const uint64_t numTimeDomainDataPoints, + const timespec dataTimestamp, + const bool repeatDataFlag) + : QEvent(QEvent::Type(10005)) +{ + if(numTimeDomainDataPoints < 1) { + _numTimeDomainDataPoints = 1; + } + else { + _numTimeDomainDataPoints = numTimeDomainDataPoints; + } + + _dataTimeDomainPoints = new gr_complex[_numTimeDomainDataPoints]; + memset(_dataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(gr_complex)); + if(numTimeDomainDataPoints > 0) { + memcpy(_dataTimeDomainPoints, timeDomainPoints, + numTimeDomainDataPoints*sizeof(gr_complex)); + } + + _dataTimestamp = dataTimestamp; + _repeatDataFlag = repeatDataFlag; +} + +TimeUpdateEvent::~TimeUpdateEvent() +{ + delete[] _dataTimeDomainPoints; +} + +const gr_complex* +TimeUpdateEvent::getTimeDomainPoints() const +{ + return _dataTimeDomainPoints; +} + +uint64_t +TimeUpdateEvent::getNumTimeDomainDataPoints() const +{ + return _numTimeDomainDataPoints; +} + +timespec +TimeUpdateEvent::getDataTimestamp() const +{ + return _dataTimestamp; +} + +bool +TimeUpdateEvent::getRepeatDataFlag() const +{ + return _repeatDataFlag; +} + #endif /* SPECTRUM_UPDATE_EVENTS_C */ diff --git a/gr-qtgui/lib/spectrumUpdateEvents.h b/gr-qtgui/lib/spectrumUpdateEvents.h index ccc072c3e..fcebd5d5a 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.h +++ b/gr-qtgui/lib/spectrumUpdateEvents.h @@ -6,6 +6,7 @@ #include #include #include +#include class SpectrumUpdateEvent:public QEvent{ @@ -89,4 +90,29 @@ private: }; +class TimeUpdateEvent: public QEvent +{ +public: + TimeUpdateEvent(const gr_complex *timeDomainPoints, + const uint64_t numTimeDomainDataPoints, + const timespec dataTimestamp, + const bool repeatDataFlag); + + ~TimeUpdateEvent(); + + const gr_complex *getTimeDomainPoints() const; + uint64_t getNumTimeDomainDataPoints() const; + timespec getDataTimestamp() const; + bool getRepeatDataFlag() const; + +protected: + +private: + gr_complex *_dataTimeDomainPoints; + uint64_t _numTimeDomainDataPoints; + timespec _dataTimestamp; + bool _repeatDataFlag; +}; + + #endif /* SPECTRUM_UPDATE_EVENTS_H */ -- cgit From f41530726eb2ef70a4683faa9f5e4760b67d7d5f Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 21 Apr 2011 19:11:03 -0400 Subject: gr-qtgui: adding time-domain only plotter. --- gr-qtgui/lib/qtgui_time_sink_c.cc | 178 +++++++++++++++++++++++++++++++++++++ gr-qtgui/lib/qtgui_time_sink_c.h | 83 ++++++++++++++++++ gr-qtgui/lib/timedisplayform.cc | 180 ++++++++++++++++++++++++++++++++++++++ gr-qtgui/lib/timedisplayform.h | 79 +++++++++++++++++ 4 files changed, 520 insertions(+) create mode 100644 gr-qtgui/lib/qtgui_time_sink_c.cc create mode 100644 gr-qtgui/lib/qtgui_time_sink_c.h create mode 100644 gr-qtgui/lib/timedisplayform.cc create mode 100644 gr-qtgui/lib/timedisplayform.h (limited to 'gr-qtgui/lib') 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..d6e6f0a13 --- /dev/null +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -0,0 +1,178 @@ +/* -*- 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 +#endif + +#include +#include +#include + +#include + +qtgui_time_sink_c_sptr +qtgui_make_time_sink_c (int size, double bw, + const std::string &name, + QWidget *parent) +{ + return gnuradio::get_initial_sptr(new qtgui_time_sink_c (size, bw, name, + parent)); +} + +qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, + const std::string &name, + QWidget *parent) + : gr_block ("time_sink_c", + gr_make_io_signature (1, -1, sizeof(gr_complex)), + gr_make_io_signature (0, 0, 0)), + d_size(size), d_bandwidth(bw), d_name(name), + d_parent(parent) +{ + d_main_gui = NULL; + + d_index = 0; + d_residbuf = new gr_complex[d_size]; + + initialize(); +} + +qtgui_time_sink_c::~qtgui_time_sink_c() +{ + delete d_main_gui; + delete [] d_residbuf; +} + +void +qtgui_time_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_size, 8191); + } +} + +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); + } + + /* + 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_size); + + d_main_gui->OpenSpectrumWindow(d_parent, + d_plotfreq, d_plotwaterfall, + d_plottime, d_plotconst); + */ + + d_main_gui = new TimeDisplayForm(d_parent); + + // initialize update time to 10 times a second + set_update_time(0.1); +} + + +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); +} + +int +qtgui_time_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]; + + for(int i=0; i < noutput_items; i+=d_size) { + unsigned int datasize = noutput_items - i; + unsigned int resid = d_size-d_index; + + // If we have enough input for one full FFT, do it + if(datasize >= resid) { + const timespec currentTime = get_highres_clock(); + + // 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; + + d_qApplication->postEvent(d_main_gui, + new TimeUpdateEvent(d_residbuf, d_size, + currentTime, true)); + } + // 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_time_sink_c.h b/gr-qtgui/lib/qtgui_time_sink_c.h new file mode 100644 index 000000000..8867fa48e --- /dev/null +++ b/gr-qtgui/lib/qtgui_time_sink_c.h @@ -0,0 +1,83 @@ +/* -*- 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 +#include +#include +#include +#include +#include + +class qtgui_time_sink_c; +typedef boost::shared_ptr qtgui_time_sink_c_sptr; + +qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, + const std::string &name, + QWidget *parent); + +class qtgui_time_sink_c : public gr_block +{ +private: + friend qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, + const std::string &name, + QWidget *parent); + qtgui_time_sink_c(int size, double bw, + const std::string &name, + QWidget *parent); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + + void initialize(); + + int d_size; + double d_bandwidth; + std::string d_name; + + int d_index; + gr_complex *d_residbuf; + + double d_update_time; + + QWidget *d_parent; + TimeDisplayForm *d_main_gui; + +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); + + 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_TIME_SINK_C_H */ diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc new file mode 100644 index 000000000..809c88a9b --- /dev/null +++ b/gr-qtgui/lib/timedisplayform.cc @@ -0,0 +1,180 @@ +/* -*- 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 +#include +#include +#include + +TimeDisplayForm::TimeDisplayForm(QWidget* parent) + : QWidget(parent) +{ + _systemSpecifiedFlag = false; + _intValidator = new QIntValidator(this); + _intValidator->setBottom(0); + _timeDomainDisplayPlot = new TimeDomainDisplayPlot(this); + + _numRealDataPoints = 1024; + + 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 gr_complex* timeDomainDataPoints = spectrumUpdateEvent->getTimeDomainPoints(); + const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints(); + const timespec generatedTimestamp = spectrumUpdateEvent->getDataTimestamp(); + + // FIXME: make time domain display take complex inputs + double *real = new double[numTimeDomainDataPoints]; + double *imag = new double[numTimeDomainDataPoints]; + for(uint64_t i = 0; i < numTimeDomainDataPoints; i++) { + real[i] = timeDomainDataPoints[i].real(); + imag[i] = timeDomainDataPoints[i].imag(); + } + + _timeDomainDisplayPlot->PlotNewData(real, imag, + numTimeDomainDataPoints, + d_update_time); + + // Tell the system the GUI has been updated + //if(_systemSpecifiedFlag){ + // _system->SetLastGUIUpdateTime(generatedTimestamp); + // _system->DecrementPendingGUIUpdateEvents(); + //} + + delete [] real; + delete [] imag; +} + +void +TimeDisplayForm::resizeEvent( QResizeEvent *e ) +{ + QSize s(0,0); + //s.setWidth(TimeDomainDisplayFrame->width()); + //s.setHeight(TimeDomainDisplayFrame->height()); + 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(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->set_yaxis(min, max); +} + +void +TimeDisplayForm::SetUpdateTime(double t) +{ + d_update_time = t; + // QTimer class takes millisecond input + displayTimer->start(d_update_time*1000); +} + diff --git a/gr-qtgui/lib/timedisplayform.h b/gr-qtgui/lib/timedisplayform.h new file mode 100644 index 000000000..2ba3a28c8 --- /dev/null +++ b/gr-qtgui/lib/timedisplayform.h @@ -0,0 +1,79 @@ +/* -*- 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 +#include +#include +#include +#include +#include +#include +#include +#include + +class TimeDisplayForm : public QWidget +{ + Q_OBJECT + + public: + TimeDisplayForm(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); + +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; + TimeDomainDisplayPlot* _timeDomainDisplayPlot; + bool _systemSpecifiedFlag; + double _startFrequency; + double _stopFrequency; + + QTimer *displayTimer; + double d_update_time; +}; + +#endif /* TIME_DISPLAY_FORM_H */ -- cgit From 75162ae5263e215ac99daa595b89ea6736a7c6dc Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 21 Apr 2011 19:13:50 -0400 Subject: gr-qtgui: adding .i file for time domain plot and updating Makefiles. --- gr-qtgui/lib/Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index 7dee39eb4..ae6041adb 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -49,11 +49,13 @@ libgnuradio_qtgui_la_SOURCES = \ 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_util.cc nodist_libgnuradio_qtgui_la_SOURCES=$(QMAKE_SOURCES) @@ -68,10 +70,12 @@ grinclude_HEADERS = \ highResTimeFunctions.h \ plot_waterfall.h \ spectrumdisplayform.h \ + timedisplayform.h \ SpectrumGUIClass.h \ spectrumUpdateEvents.h \ qtgui_sink_c.h \ qtgui_sink_f.h \ + qtgui_time_sink_c.h \ qtgui_util.h #QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -- cgit From 8b7b6e297e0d929aac2a604229a675d7fa46c3b1 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 23 Apr 2011 10:59:36 -0400 Subject: gr-qtgui: no need to check the version here since we require >4.4 --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 86aa8533e..9e7b796e8 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -144,13 +144,8 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) _sampleRate = 1; _resetXAxisPoints(); -#if QT_VERSION < 0x040000 _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); -#else - _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); -#endif _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); @@ -186,12 +181,12 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); } -TimeDomainDisplayPlot::~TimeDomainDisplayPlot(){ +TimeDomainDisplayPlot::~TimeDomainDisplayPlot() +{ delete[] _realDataPoints; delete[] _imagDataPoints; delete[] _xAxisPoints; - // _fft_plot_curves deleted when parent deleted // _zoomer and _panner deleted when parent deleted } -- cgit From ca8e6096da49c825c14ac05962bb7747f84c2ba6 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 23 Apr 2011 11:01:10 -0400 Subject: gr-qtgui: time domain sink now shows and receives updates. --- gr-qtgui/lib/Makefile.am | 1 + gr-qtgui/lib/qtgui_time_sink_c.h | 4 ++-- gr-qtgui/lib/timedisplayform.cc | 19 ++++++++----------- gr-qtgui/lib/timedisplayform.h | 3 +++ 4 files changed, 14 insertions(+), 13 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index ae6041adb..517a67097 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -30,6 +30,7 @@ AM_CPPFLAGS = -I. $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ # This is mostly to help make distcheck pass QMAKE_SOURCES = \ spectrumdisplayform.moc.cc \ + timedisplayform.moc.cc \ FrequencyDisplayPlot.moc.cc \ TimeDomainDisplayPlot.moc.cc \ WaterfallDisplayPlot.moc.cc \ diff --git a/gr-qtgui/lib/qtgui_time_sink_c.h b/gr-qtgui/lib/qtgui_time_sink_c.h index 8867fa48e..cdcf095ce 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.h +++ b/gr-qtgui/lib/qtgui_time_sink_c.h @@ -35,7 +35,7 @@ typedef boost::shared_ptr qtgui_time_sink_c_sptr; qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, const std::string &name, - QWidget *parent); + QWidget *parent=NULL); class qtgui_time_sink_c : public gr_block { @@ -45,7 +45,7 @@ private: QWidget *parent); qtgui_time_sink_c(int size, double bw, const std::string &name, - QWidget *parent); + QWidget *parent=NULL); void forecast(int noutput_items, gr_vector_int &ninput_items_required); diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc index 809c88a9b..e90eaab06 100644 --- a/gr-qtgui/lib/timedisplayform.cc +++ b/gr-qtgui/lib/timedisplayform.cc @@ -24,6 +24,7 @@ #include #include #include +#include TimeDisplayForm::TimeDisplayForm(QWidget* parent) : QWidget(parent) @@ -31,10 +32,15 @@ TimeDisplayForm::TimeDisplayForm(QWidget* parent) _systemSpecifiedFlag = false; _intValidator = new QIntValidator(this); _intValidator->setBottom(0); + + _layout = new QGridLayout(this); _timeDomainDisplayPlot = new TimeDomainDisplayPlot(this); + _layout->addWidget(_timeDomainDisplayPlot, 0, 0); _numRealDataPoints = 1024; - + + setLayout(_layout); + Reset(); // Create a timer to update plots at the specified rate @@ -75,12 +81,6 @@ TimeDisplayForm::newData( const TimeUpdateEvent* spectrumUpdateEvent) numTimeDomainDataPoints, d_update_time); - // Tell the system the GUI has been updated - //if(_systemSpecifiedFlag){ - // _system->SetLastGUIUpdateTime(generatedTimestamp); - // _system->DecrementPendingGUIUpdateEvents(); - //} - delete [] real; delete [] imag; } @@ -88,10 +88,7 @@ TimeDisplayForm::newData( const TimeUpdateEvent* spectrumUpdateEvent) void TimeDisplayForm::resizeEvent( QResizeEvent *e ) { - QSize s(0,0); - //s.setWidth(TimeDomainDisplayFrame->width()); - //s.setHeight(TimeDomainDisplayFrame->height()); - emit _timeDomainDisplayPlot->resizeSlot(&s); + emit _timeDomainDisplayPlot->resizeSlot(&size()); } void diff --git a/gr-qtgui/lib/timedisplayform.h b/gr-qtgui/lib/timedisplayform.h index 2ba3a28c8..947e28153 100644 --- a/gr-qtgui/lib/timedisplayform.h +++ b/gr-qtgui/lib/timedisplayform.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,8 @@ signals: private: uint64_t _numRealDataPoints; QIntValidator* _intValidator; + + QGridLayout *_layout; TimeDomainDisplayPlot* _timeDomainDisplayPlot; bool _systemSpecifiedFlag; double _startFrequency; -- cgit From 240ff2e7468d1651ad0b7557c061bb46aed8a4a3 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 23 Apr 2011 11:29:15 -0400 Subject: gr-qtgui: cleaning up; don't delete d_main_gui. --- gr-qtgui/lib/qtgui_time_sink_c.cc | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index d6e6f0a13..064463162 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -58,7 +58,7 @@ qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, qtgui_time_sink_c::~qtgui_time_sink_c() { - delete d_main_gui; + // d_main_gui is a qwidget destroyed with its parent delete [] d_residbuf; } @@ -83,21 +83,6 @@ qtgui_time_sink_c::initialize() 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_size); - - d_main_gui->OpenSpectrumWindow(d_parent, - d_plotfreq, d_plotwaterfall, - d_plottime, d_plotconst); - */ - d_main_gui = new TimeDisplayForm(d_parent); // initialize update time to 10 times a second -- cgit From bbb5e850224aca9dae15d24bd898cc56232327c9 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 23 Apr 2011 12:00:54 -0400 Subject: gr-qtgui: setting up ability to have multiple connections to the time sink. --- gr-qtgui/lib/qtgui_time_sink_c.cc | 34 +++++++++++++++++++++++----------- gr-qtgui/lib/qtgui_time_sink_c.h | 6 +++++- gr-qtgui/lib/spectrumUpdateEvents.cc | 4 ++-- gr-qtgui/lib/spectrumUpdateEvents.h | 3 ++- 4 files changed, 32 insertions(+), 15 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index 064463162..cff265835 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -33,25 +33,30 @@ 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, - parent)); + nconnections, parent)); } qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, const std::string &name, + int nconnections, QWidget *parent) : gr_block ("time_sink_c", - gr_make_io_signature (1, -1, sizeof(gr_complex)), + 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_parent(parent) + d_nconnections(nconnections), d_parent(parent) { d_main_gui = NULL; d_index = 0; - d_residbuf = new gr_complex[d_size]; + + for(int i = 0; i < d_nconnections; i++) { + d_residbufs.push_back(new gr_complex[d_size]); + } initialize(); } @@ -59,7 +64,9 @@ qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, qtgui_time_sink_c::~qtgui_time_sink_c() { // d_main_gui is a qwidget destroyed with its parent - delete [] d_residbuf; + for(int i = 0; i < d_nconnections; i++) { + delete [] d_residbufs[i]; + } } void @@ -129,7 +136,7 @@ qtgui_time_sink_c::general_work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int j=0; + int n=0, j=0; const gr_complex *in = (const gr_complex*)input_items[0]; for(int i=0; i < noutput_items; i+=d_size) { @@ -140,19 +147,24 @@ qtgui_time_sink_c::general_work (int noutput_items, if(datasize >= resid) { const timespec currentTime = get_highres_clock(); - // Fill up residbuf with d_fftsize number of items - memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*resid); + // Fill up residbufs with d_fftsize number of items + for(n = 0; n < d_nconnections; n++) { + memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid); + } + d_index = 0; j += resid; d_qApplication->postEvent(d_main_gui, - new TimeUpdateEvent(d_residbuf, d_size, + new TimeUpdateEvent(d_residbufs, d_size, currentTime, true)); } - // Otherwise, copy what we received into the residbuf for next time + // Otherwise, copy what we received into the residbufs for next time else { - memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*datasize); + for(n = 0; n < d_nconnections; n++) { + memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize); + } d_index += datasize; j += datasize; } diff --git a/gr-qtgui/lib/qtgui_time_sink_c.h b/gr-qtgui/lib/qtgui_time_sink_c.h index cdcf095ce..0c4e93803 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.h +++ b/gr-qtgui/lib/qtgui_time_sink_c.h @@ -35,6 +35,7 @@ typedef boost::shared_ptr qtgui_time_sink_c_sptr; qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, const std::string &name, + int nconnectons=1, QWidget *parent=NULL); class qtgui_time_sink_c : public gr_block @@ -42,9 +43,11 @@ class qtgui_time_sink_c : public gr_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); void forecast(int noutput_items, gr_vector_int &ninput_items_required); @@ -54,9 +57,10 @@ private: int d_size; double d_bandwidth; std::string d_name; + int d_nconnections; int d_index; - gr_complex *d_residbuf; + std::vector d_residbufs; double d_update_time; diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc index ab5ef3be5..7d297a0d2 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.cc +++ b/gr-qtgui/lib/spectrumUpdateEvents.cc @@ -180,7 +180,7 @@ SpectrumFrequencyRangeEvent::GetStopFrequency() const /***************************************************************************/ -TimeUpdateEvent::TimeUpdateEvent(const gr_complex *timeDomainPoints, +TimeUpdateEvent::TimeUpdateEvent(const std::vector &timeDomainPoints, const uint64_t numTimeDomainDataPoints, const timespec dataTimestamp, const bool repeatDataFlag) @@ -196,7 +196,7 @@ TimeUpdateEvent::TimeUpdateEvent(const gr_complex *timeDomainPoints, _dataTimeDomainPoints = new gr_complex[_numTimeDomainDataPoints]; memset(_dataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(gr_complex)); if(numTimeDomainDataPoints > 0) { - memcpy(_dataTimeDomainPoints, timeDomainPoints, + memcpy(_dataTimeDomainPoints, timeDomainPoints[0], numTimeDomainDataPoints*sizeof(gr_complex)); } diff --git a/gr-qtgui/lib/spectrumUpdateEvents.h b/gr-qtgui/lib/spectrumUpdateEvents.h index fcebd5d5a..1a92eefb5 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.h +++ b/gr-qtgui/lib/spectrumUpdateEvents.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -93,7 +94,7 @@ private: class TimeUpdateEvent: public QEvent { public: - TimeUpdateEvent(const gr_complex *timeDomainPoints, + TimeUpdateEvent(const std::vector &timeDomainPoints, const uint64_t numTimeDomainDataPoints, const timespec dataTimestamp, const bool repeatDataFlag); -- cgit From 01f44f64c916b4aa38bc81662d2c8b82c4cc0b57 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 23 Apr 2011 14:30:32 -0400 Subject: gr-qtgui: moving towards allowing time plot to have multiple connections. --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 66 ++++++++++++++++------------------- gr-qtgui/lib/TimeDomainDisplayPlot.h | 14 ++++---- gr-qtgui/lib/qtgui_time_sink_c.cc | 32 ++++++++++------- gr-qtgui/lib/qtgui_time_sink_c.h | 2 +- gr-qtgui/lib/spectrumUpdateEvents.cc | 22 ++++++++---- gr-qtgui/lib/spectrumUpdateEvents.h | 11 +++--- gr-qtgui/lib/spectrumdisplayform.cc | 12 ++++--- gr-qtgui/lib/timedisplayform.cc | 23 ++++-------- gr-qtgui/lib/timedisplayform.h | 2 +- 9 files changed, 94 insertions(+), 90 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 9e7b796e8..c9973fbc2 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -27,7 +27,7 @@ #include #include - +#include class TimePrecisionClass { @@ -92,16 +92,16 @@ private: std::string _unitType; }; -TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) +TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) + : QwtPlot(parent), _nplots(nplots) { timespec_reset(&_lastReplot); resize(parent->width(), parent->height()); _numPoints = 1024; - _realDataPoints = new double[_numPoints]; - _imagDataPoints = new double[_numPoints]; _xAxisPoints = new double[_numPoints]; + memset(_xAxisPoints, 0x0, _numPoints*sizeof(double)); _zoomer = new TimeDomainDisplayZoomer(canvas(), 0); _zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection); @@ -125,21 +125,20 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) set_yaxis(-2.0, 2.0); setAxisTitle(QwtPlot::yLeft, "Normalized Voltage"); + // Setup dataPoints and plot vectors // Automatically deleted when parent is deleted - _real_plot_curve = new QwtPlotCurve("Real Data"); - _real_plot_curve->attach(this); - _real_plot_curve->setPen(QPen(Qt::blue)); - _real_plot_curve->setRawData(_xAxisPoints, _realDataPoints, _numPoints); - - _imag_plot_curve = new QwtPlotCurve("Imaginary Data"); - _imag_plot_curve->attach(this); - _imag_plot_curve->setPen(QPen(Qt::magenta)); - _imag_plot_curve->setRawData(_xAxisPoints, _imagDataPoints, _numPoints); - // _imag_plot_curve->setVisible(false); - - memset(_realDataPoints, 0x0, _numPoints*sizeof(double)); - memset(_imagDataPoints, 0x0, _numPoints*sizeof(double)); - memset(_xAxisPoints, 0x0, _numPoints*sizeof(double)); + 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); + if(i == 0) + _plot_curve[i]->setPen(QPen(Qt::blue)); + else + _plot_curve[i]->setPen(QPen(Qt::red)); + _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints); + } _sampleRate = 1; _resetXAxisPoints(); @@ -183,8 +182,8 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) TimeDomainDisplayPlot::~TimeDomainDisplayPlot() { - delete[] _realDataPoints; - delete[] _imagDataPoints; + for(int i = 0; i < _nplots; i++) + delete [] _dataPoints[i]; delete[] _xAxisPoints; // _zoomer and _panner deleted when parent deleted @@ -216,8 +215,8 @@ TimeDomainDisplayPlot::resizeSlot( QSize *s ) resize(s->width(), s->height()); } -void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, - const double* imagDataPoints, +void TimeDomainDisplayPlot::PlotNewData(const int which, + const double* dataPoints, const int64_t numDataPoints, const double timeInterval) { @@ -227,33 +226,28 @@ void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, if(numDataPoints != _numPoints){ _numPoints = numDataPoints; - delete[] _realDataPoints; - delete[] _imagDataPoints; + delete[] _dataPoints[which]; + _dataPoints[which] = new double[_numPoints]; + delete[] _xAxisPoints; - _realDataPoints = new double[_numPoints]; - _imagDataPoints = new double[_numPoints]; _xAxisPoints = new double[_numPoints]; - _real_plot_curve->setRawData(_xAxisPoints, _realDataPoints, _numPoints); - _imag_plot_curve->setRawData(_xAxisPoints, _imagDataPoints, _numPoints); + _plot_curve[which]->setRawData(_xAxisPoints, _dataPoints[which], _numPoints); set_xaxis(0, numDataPoints); _resetXAxisPoints(); } - memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); - memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); + std::cout << "DisplayPlot: " << which << std::endl; + memcpy(_dataPoints[which], dataPoints, numDataPoints*sizeof(double)); + std::cout << "after" << std::endl; - _lastReplot = get_highres_clock(); + if(which == _nplots-1) + _lastReplot = get_highres_clock(); } } -void TimeDomainDisplayPlot::SetImaginaryDataVisible(const bool visibleFlag) -{ - _imag_plot_curve->setVisible(visibleFlag); -} - void TimeDomainDisplayPlot::_resetXAxisPoints() { double delt = 1.0/_sampleRate; diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h index 328371e6a..3a983a924 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -43,14 +44,12 @@ class TimeDomainDisplayPlot:public QwtPlot{ Q_OBJECT public: - TimeDomainDisplayPlot(QWidget*); + TimeDomainDisplayPlot(int nplots, QWidget*); virtual ~TimeDomainDisplayPlot(); - void PlotNewData(const double* realDataPoints, const double* imagDataPoints, + void PlotNewData(const int which, const double* dataPoints, const int64_t numDataPoints, const double timeInterval); - void SetImaginaryDataVisible(const bool); - virtual void replot(); void set_yaxis(double min, double max); @@ -74,8 +73,8 @@ protected: private: void _resetXAxisPoints(); - QwtPlotCurve* _real_plot_curve; - QwtPlotCurve* _imag_plot_curve; + int _nplots; + std::vector _plot_curve; QwtPlotPanner* _panner; QwtPlotZoomer* _zoomer; @@ -83,8 +82,7 @@ private: QwtDblClickPlotPicker *_picker; QwtPlotMagnifier *_magnifier; - double* _realDataPoints; - double* _imagDataPoints; + std::vector _dataPoints; double* _xAxisPoints; double _sampleRate; diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index cff265835..2c8ff86e5 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -48,14 +48,14 @@ qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, 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(nconnections), d_parent(parent) + 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 gr_complex[d_size]); + d_residbufs.push_back(new double[d_size]); } initialize(); @@ -90,7 +90,7 @@ qtgui_time_sink_c::initialize() d_qApplication = new QApplication(argc, argv); } - d_main_gui = new TimeDisplayForm(d_parent); + d_main_gui = new TimeDisplayForm(d_nconnections, d_parent); // initialize update time to 10 times a second set_update_time(0.1); @@ -148,22 +148,30 @@ qtgui_time_sink_c::general_work (int noutput_items, const timespec currentTime = get_highres_clock(); // Fill up residbufs with d_fftsize number of items - for(n = 0; n < d_nconnections; n++) { - memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid); + for(n = 0; n < d_nconnections; n+=2) { + 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_qApplication->postEvent(d_main_gui, + new TimeUpdateEvent(n, d_residbufs[n], d_size, + currentTime, true)); + //d_qApplication->postEvent(d_main_gui, + // new TimeUpdateEvent(n+1, d_residbufs[n+1], d_size, + // currentTime, true)); } d_index = 0; - j += resid; - - d_qApplication->postEvent(d_main_gui, - new TimeUpdateEvent(d_residbufs, d_size, - currentTime, true)); } // Otherwise, copy what we received into the residbufs for next time else { - for(n = 0; n < d_nconnections; n++) { - memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize); + for(n = 0; n < d_nconnections; n+=2) { + 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; diff --git a/gr-qtgui/lib/qtgui_time_sink_c.h b/gr-qtgui/lib/qtgui_time_sink_c.h index 0c4e93803..67687061b 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.h +++ b/gr-qtgui/lib/qtgui_time_sink_c.h @@ -60,7 +60,7 @@ private: int d_nconnections; int d_index; - std::vector d_residbufs; + std::vector d_residbufs; double d_update_time; diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc index 7d297a0d2..037225760 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.cc +++ b/gr-qtgui/lib/spectrumUpdateEvents.cc @@ -179,13 +179,15 @@ SpectrumFrequencyRangeEvent::GetStopFrequency() const /***************************************************************************/ - -TimeUpdateEvent::TimeUpdateEvent(const std::vector &timeDomainPoints, +#include +TimeUpdateEvent::TimeUpdateEvent(const int which, + const double *timeDomainPoints, const uint64_t numTimeDomainDataPoints, const timespec dataTimestamp, const bool repeatDataFlag) : QEvent(QEvent::Type(10005)) { + _which = which; if(numTimeDomainDataPoints < 1) { _numTimeDomainDataPoints = 1; } @@ -193,11 +195,11 @@ TimeUpdateEvent::TimeUpdateEvent(const std::vector &timeDomainPoint _numTimeDomainDataPoints = numTimeDomainDataPoints; } - _dataTimeDomainPoints = new gr_complex[_numTimeDomainDataPoints]; - memset(_dataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(gr_complex)); + _dataTimeDomainPoints = new double[_numTimeDomainDataPoints]; + memset(_dataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); if(numTimeDomainDataPoints > 0) { - memcpy(_dataTimeDomainPoints, timeDomainPoints[0], - numTimeDomainDataPoints*sizeof(gr_complex)); + memcpy(_dataTimeDomainPoints, timeDomainPoints, + numTimeDomainDataPoints*sizeof(double)); } _dataTimestamp = dataTimestamp; @@ -209,7 +211,13 @@ TimeUpdateEvent::~TimeUpdateEvent() delete[] _dataTimeDomainPoints; } -const gr_complex* +int +TimeUpdateEvent::which() const +{ + return _which; +} + +const double* TimeUpdateEvent::getTimeDomainPoints() const { return _dataTimeDomainPoints; diff --git a/gr-qtgui/lib/spectrumUpdateEvents.h b/gr-qtgui/lib/spectrumUpdateEvents.h index 1a92eefb5..09771571c 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.h +++ b/gr-qtgui/lib/spectrumUpdateEvents.h @@ -5,9 +5,7 @@ #include #include #include -#include #include -#include class SpectrumUpdateEvent:public QEvent{ @@ -94,14 +92,16 @@ private: class TimeUpdateEvent: public QEvent { public: - TimeUpdateEvent(const std::vector &timeDomainPoints, + TimeUpdateEvent(const int which, + const double *timeDomainPoints, const uint64_t numTimeDomainDataPoints, const timespec dataTimestamp, const bool repeatDataFlag); ~TimeUpdateEvent(); - const gr_complex *getTimeDomainPoints() const; + int which() const; + const double *getTimeDomainPoints() const; uint64_t getNumTimeDomainDataPoints() const; timespec getDataTimestamp() const; bool getRepeatDataFlag() const; @@ -109,7 +109,8 @@ public: protected: private: - gr_complex *_dataTimeDomainPoints; + int _which; + double *_dataTimeDomainPoints; uint64_t _numTimeDomainDataPoints; timespec _dataTimestamp; bool _repeatDataFlag; diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index acc7a209d..2c666871d 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -36,7 +36,7 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame); _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame); - _timeDomainDisplayPlot = new TimeDomainDisplayPlot(TimeDomainDisplayFrame); + _timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame); _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame); _numRealDataPoints = 1024; _realFFTDataPoints = new double[_numRealDataPoints]; @@ -232,11 +232,15 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate _peakAmplitude, d_update_time); } if(tabindex == d_plot_time) { - _timeDomainDisplayPlot->PlotNewData(realTimeDomainDataPoints, - imagTimeDomainDataPoints, + _timeDomainDisplayPlot->PlotNewData(0, + realTimeDomainDataPoints, numTimeDomainDataPoints, d_update_time); - } + _timeDomainDisplayPlot->PlotNewData(1, + imagTimeDomainDataPoints, + numTimeDomainDataPoints, + d_update_time); + } if(tabindex == d_plot_constellation) { _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints, imagTimeDomainDataPoints, diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc index e90eaab06..65940b013 100644 --- a/gr-qtgui/lib/timedisplayform.cc +++ b/gr-qtgui/lib/timedisplayform.cc @@ -26,7 +26,7 @@ #include #include -TimeDisplayForm::TimeDisplayForm(QWidget* parent) +TimeDisplayForm::TimeDisplayForm(int nplots, QWidget* parent) : QWidget(parent) { _systemSpecifiedFlag = false; @@ -34,8 +34,8 @@ TimeDisplayForm::TimeDisplayForm(QWidget* parent) _intValidator->setBottom(0); _layout = new QGridLayout(this); - _timeDomainDisplayPlot = new TimeDomainDisplayPlot(this); - _layout->addWidget(_timeDomainDisplayPlot, 0, 0); + _timeDomainDisplayPlot = new TimeDomainDisplayPlot(nplots, this); + _layout->addWidget(_timeDomainDisplayPlot, 0, 0, 100, 100); _numRealDataPoints = 1024; @@ -65,24 +65,15 @@ TimeDisplayForm::~TimeDisplayForm() void TimeDisplayForm::newData( const TimeUpdateEvent* spectrumUpdateEvent) { - const gr_complex* timeDomainDataPoints = spectrumUpdateEvent->getTimeDomainPoints(); + const int which = spectrumUpdateEvent->which(); + const double* timeDomainDataPoints = spectrumUpdateEvent->getTimeDomainPoints(); const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints(); const timespec generatedTimestamp = spectrumUpdateEvent->getDataTimestamp(); - - // FIXME: make time domain display take complex inputs - double *real = new double[numTimeDomainDataPoints]; - double *imag = new double[numTimeDomainDataPoints]; - for(uint64_t i = 0; i < numTimeDomainDataPoints; i++) { - real[i] = timeDomainDataPoints[i].real(); - imag[i] = timeDomainDataPoints[i].imag(); - } - _timeDomainDisplayPlot->PlotNewData(real, imag, + //std::cout << "TimeDisplayForm: which: " << which << std::endl; + _timeDomainDisplayPlot->PlotNewData(which, timeDomainDataPoints, numTimeDomainDataPoints, d_update_time); - - delete [] real; - delete [] imag; } void diff --git a/gr-qtgui/lib/timedisplayform.h b/gr-qtgui/lib/timedisplayform.h index 947e28153..888d28e21 100644 --- a/gr-qtgui/lib/timedisplayform.h +++ b/gr-qtgui/lib/timedisplayform.h @@ -39,7 +39,7 @@ class TimeDisplayForm : public QWidget Q_OBJECT public: - TimeDisplayForm(QWidget* parent = 0); + TimeDisplayForm(int nplots=1, QWidget* parent = 0); ~TimeDisplayForm(); void Reset(); -- cgit From 0877adb2e194c9dfad2484519b2979e2bed93958 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 23 Apr 2011 15:11:17 -0400 Subject: gr-qtgui: Passing vectors of data to update plot for stability; also moving responsibility of keeping track of plot updates out to qtgui_sink instead of inside plot qidget. --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 30 ++++++++-------------- gr-qtgui/lib/TimeDomainDisplayPlot.h | 4 +-- gr-qtgui/lib/qtgui_time_sink_c.cc | 24 +++++++++--------- gr-qtgui/lib/qtgui_time_sink_c.h | 3 +++ gr-qtgui/lib/spectrumUpdateEvents.cc | 48 ++++++++++------------------------- gr-qtgui/lib/spectrumUpdateEvents.h | 16 +++++------- gr-qtgui/lib/spectrumdisplayform.cc | 15 +++++------ gr-qtgui/lib/timedisplayform.cc | 8 +++--- 8 files changed, 57 insertions(+), 91 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index c9973fbc2..e3c773e4c 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -95,8 +95,6 @@ private: TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) : QwtPlot(parent), _nplots(nplots) { - timespec_reset(&_lastReplot); - resize(parent->width(), parent->height()); _numPoints = 1024; @@ -215,36 +213,30 @@ TimeDomainDisplayPlot::resizeSlot( QSize *s ) resize(s->width(), s->height()); } -void TimeDomainDisplayPlot::PlotNewData(const int which, - const double* dataPoints, +void TimeDomainDisplayPlot::PlotNewData(const std::vector dataPoints, const int64_t numDataPoints, const double timeInterval) { - if((numDataPoints > 0) && - (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { - + if((numDataPoints > 0)) { if(numDataPoints != _numPoints){ _numPoints = numDataPoints; - delete[] _dataPoints[which]; - _dataPoints[which] = new double[_numPoints]; - delete[] _xAxisPoints; _xAxisPoints = new double[_numPoints]; - - _plot_curve[which]->setRawData(_xAxisPoints, _dataPoints[which], _numPoints); + for(int i = 0; i < _nplots; i++) { + delete[] _dataPoints[i]; + _dataPoints[i] = new double[_numPoints]; + _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints); + } + set_xaxis(0, numDataPoints); - _resetXAxisPoints(); } - std::cout << "DisplayPlot: " << which << std::endl; - memcpy(_dataPoints[which], dataPoints, numDataPoints*sizeof(double)); - std::cout << "after" << std::endl; - - if(which == _nplots-1) - _lastReplot = get_highres_clock(); + for(int i = 0; i < _nplots; i++) { + memcpy(_dataPoints[i], dataPoints[i], numDataPoints*sizeof(double)); + } } } diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h index 3a983a924..fbfba584b 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -47,7 +47,7 @@ public: TimeDomainDisplayPlot(int nplots, QWidget*); virtual ~TimeDomainDisplayPlot(); - void PlotNewData(const int which, const double* dataPoints, + void PlotNewData(const std::vector dataPoints, const int64_t numDataPoints, const double timeInterval); virtual void replot(); @@ -87,8 +87,6 @@ private: double _sampleRate; - timespec _lastReplot; - int64_t _numPoints; }; diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index 2c8ff86e5..434a9dffc 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -142,26 +142,26 @@ qtgui_time_sink_c::general_work (int noutput_items, for(int i=0; i < noutput_items; i+=d_size) { unsigned int datasize = noutput_items - i; unsigned int resid = d_size-d_index; - - // If we have enough input for one full FFT, do it + + // If we have enough input for one full plot, do it if(datasize >= resid) { - const timespec currentTime = get_highres_clock(); + d_current_time = get_highres_clock(); - // Fill up residbufs with d_fftsize number of items + // Fill up residbufs with d_size number of items for(n = 0; n < d_nconnections; n+=2) { 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(diff_timespec(d_current_time, d_last_time) > d_update_time) { + d_last_time = d_current_time; d_qApplication->postEvent(d_main_gui, - new TimeUpdateEvent(n, d_residbufs[n], d_size, - currentTime, true)); - //d_qApplication->postEvent(d_main_gui, - // new TimeUpdateEvent(n+1, d_residbufs[n+1], d_size, - // currentTime, true)); + new TimeUpdateEvent(d_residbufs, d_size)); } - + d_index = 0; j += resid; } @@ -169,8 +169,8 @@ qtgui_time_sink_c::general_work (int noutput_items, else { for(n = 0; n < d_nconnections; n+=2) { 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_residbufs[n][d_index+k] = in[j+k].real(); + d_residbufs[n+1][d_index+k] = in[j+k].imag(); } } d_index += datasize; diff --git a/gr-qtgui/lib/qtgui_time_sink_c.h b/gr-qtgui/lib/qtgui_time_sink_c.h index 67687061b..be057d508 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.h +++ b/gr-qtgui/lib/qtgui_time_sink_c.h @@ -67,6 +67,9 @@ private: QWidget *d_parent; TimeDisplayForm *d_main_gui; + timespec d_current_time; + timespec d_last_time; + public: ~qtgui_time_sink_c(); void exec_(); diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc index 037225760..6730ae51d 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.cc +++ b/gr-qtgui/lib/spectrumUpdateEvents.cc @@ -180,14 +180,10 @@ SpectrumFrequencyRangeEvent::GetStopFrequency() const /***************************************************************************/ #include -TimeUpdateEvent::TimeUpdateEvent(const int which, - const double *timeDomainPoints, - const uint64_t numTimeDomainDataPoints, - const timespec dataTimestamp, - const bool repeatDataFlag) +TimeUpdateEvent::TimeUpdateEvent(const std::vector timeDomainPoints, + const uint64_t numTimeDomainDataPoints) : QEvent(QEvent::Type(10005)) { - _which = which; if(numTimeDomainDataPoints < 1) { _numTimeDomainDataPoints = 1; } @@ -195,29 +191,25 @@ TimeUpdateEvent::TimeUpdateEvent(const int which, _numTimeDomainDataPoints = numTimeDomainDataPoints; } - _dataTimeDomainPoints = new double[_numTimeDomainDataPoints]; - memset(_dataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); - if(numTimeDomainDataPoints > 0) { - memcpy(_dataTimeDomainPoints, timeDomainPoints, - numTimeDomainDataPoints*sizeof(double)); - } + _nplots = timeDomainPoints.size(); + for(size_t i = 0; i < _nplots; i++) { + _dataTimeDomainPoints.push_back(new double[_numTimeDomainDataPoints]); - _dataTimestamp = dataTimestamp; - _repeatDataFlag = repeatDataFlag; + if(numTimeDomainDataPoints > 0) { + memcpy(_dataTimeDomainPoints[i], timeDomainPoints[i], + numTimeDomainDataPoints*sizeof(double)); + } + } } TimeUpdateEvent::~TimeUpdateEvent() { - delete[] _dataTimeDomainPoints; -} - -int -TimeUpdateEvent::which() const -{ - return _which; + for(size_t i = 0; i < _nplots; i++) { + delete[] _dataTimeDomainPoints[i]; + } } -const double* +const std::vector TimeUpdateEvent::getTimeDomainPoints() const { return _dataTimeDomainPoints; @@ -229,16 +221,4 @@ TimeUpdateEvent::getNumTimeDomainDataPoints() const return _numTimeDomainDataPoints; } -timespec -TimeUpdateEvent::getDataTimestamp() const -{ - return _dataTimestamp; -} - -bool -TimeUpdateEvent::getRepeatDataFlag() const -{ - return _repeatDataFlag; -} - #endif /* SPECTRUM_UPDATE_EVENTS_C */ diff --git a/gr-qtgui/lib/spectrumUpdateEvents.h b/gr-qtgui/lib/spectrumUpdateEvents.h index 09771571c..a5e359a4c 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.h +++ b/gr-qtgui/lib/spectrumUpdateEvents.h @@ -5,6 +5,7 @@ #include #include #include +#include #include class SpectrumUpdateEvent:public QEvent{ @@ -92,16 +93,13 @@ private: class TimeUpdateEvent: public QEvent { public: - TimeUpdateEvent(const int which, - const double *timeDomainPoints, - const uint64_t numTimeDomainDataPoints, - const timespec dataTimestamp, - const bool repeatDataFlag); + TimeUpdateEvent(const std::vector timeDomainPoints, + const uint64_t numTimeDomainDataPoints); ~TimeUpdateEvent(); int which() const; - const double *getTimeDomainPoints() const; + const std::vector getTimeDomainPoints() const; uint64_t getNumTimeDomainDataPoints() const; timespec getDataTimestamp() const; bool getRepeatDataFlag() const; @@ -109,11 +107,9 @@ public: protected: private: - int _which; - double *_dataTimeDomainPoints; + size_t _nplots; + std::vector _dataTimeDomainPoints; uint64_t _numTimeDomainDataPoints; - timespec _dataTimestamp; - bool _repeatDataFlag; }; diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index 2c666871d..2d2d8648f 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -141,13 +141,17 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate //_lastSpectrumEvent = (SpectrumUpdateEvent)(*spectrumUpdateEvent); const std::complex* complexDataPoints = spectrumUpdateEvent->getFFTPoints(); const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints(); - const double* realTimeDomainDataPoints = spectrumUpdateEvent->getRealTimeDomainPoints(); - const double* imagTimeDomainDataPoints = spectrumUpdateEvent->getImagTimeDomainPoints(); const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints(); const timespec dataTimestamp = spectrumUpdateEvent->getDataTimestamp(); const bool repeatDataFlag = spectrumUpdateEvent->getRepeatDataFlag(); const bool lastOfMultipleUpdatesFlag = spectrumUpdateEvent->getLastOfMultipleUpdateFlag(); const timespec generatedTimestamp = spectrumUpdateEvent->getEventGeneratedTimestamp(); + double* realTimeDomainDataPoints = (double*)spectrumUpdateEvent->getRealTimeDomainPoints(); + double* imagTimeDomainDataPoints = (double*)spectrumUpdateEvent->getImagTimeDomainPoints(); + + std::vector 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); @@ -232,14 +236,9 @@ SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdate _peakAmplitude, d_update_time); } if(tabindex == d_plot_time) { - _timeDomainDisplayPlot->PlotNewData(0, - realTimeDomainDataPoints, + _timeDomainDisplayPlot->PlotNewData(timeDomainDataPoints, numTimeDomainDataPoints, d_update_time); - _timeDomainDisplayPlot->PlotNewData(1, - imagTimeDomainDataPoints, - numTimeDomainDataPoints, - d_update_time); } if(tabindex == d_plot_constellation) { _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints, diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc index 65940b013..368e47c95 100644 --- a/gr-qtgui/lib/timedisplayform.cc +++ b/gr-qtgui/lib/timedisplayform.cc @@ -65,13 +65,11 @@ TimeDisplayForm::~TimeDisplayForm() void TimeDisplayForm::newData( const TimeUpdateEvent* spectrumUpdateEvent) { - const int which = spectrumUpdateEvent->which(); - const double* timeDomainDataPoints = spectrumUpdateEvent->getTimeDomainPoints(); + const std::vector timeDomainDataPoints = spectrumUpdateEvent->getTimeDomainPoints(); const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints(); - const timespec generatedTimestamp = spectrumUpdateEvent->getDataTimestamp(); + const timespec generatedTimestamp = {0,0}; - //std::cout << "TimeDisplayForm: which: " << which << std::endl; - _timeDomainDisplayPlot->PlotNewData(which, timeDomainDataPoints, + _timeDomainDisplayPlot->PlotNewData(timeDomainDataPoints, numTimeDomainDataPoints, d_update_time); } -- cgit From 350611ddd9295ba8af6ea5913630ec0670208b43 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 23 Apr 2011 23:56:52 -0400 Subject: gr-qtgui: multiple connections working, each with their own color. --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 17 ++++++++++++----- gr-qtgui/lib/qtgui_time_sink_c.cc | 7 +++++-- gr-qtgui/lib/spectrumUpdateEvents.cc | 3 +-- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index e3c773e4c..70b11dd0e 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -27,6 +27,7 @@ #include #include +#include #include class TimePrecisionClass @@ -122,7 +123,16 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); set_yaxis(-2.0, 2.0); setAxisTitle(QwtPlot::yLeft, "Normalized Voltage"); - + + //QColor clr(Qt::blue); + QList 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); + + int ncolors = colors.size(); + // Setup dataPoints and plot vectors // Automatically deleted when parent is deleted for(int i = 0; i < _nplots; i++) { @@ -131,10 +141,7 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) _plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i))); _plot_curve[i]->attach(this); - if(i == 0) - _plot_curve[i]->setPen(QPen(Qt::blue)); - else - _plot_curve[i]->setPen(QPen(Qt::red)); + _plot_curve[i]->setPen(QPen(colors[i])); _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints); } diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index 434a9dffc..1cd391893 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -136,12 +136,13 @@ qtgui_time_sink_c::general_work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int n=0, j=0; - const gr_complex *in = (const gr_complex*)input_items[0]; + 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) { @@ -149,6 +150,7 @@ qtgui_time_sink_c::general_work (int noutput_items, // 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(); @@ -168,6 +170,7 @@ qtgui_time_sink_c::general_work (int noutput_items, // Otherwise, copy what we received into the residbufs for next time else { 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(); diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc index 6730ae51d..ae4caf31a 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.cc +++ b/gr-qtgui/lib/spectrumUpdateEvents.cc @@ -194,10 +194,9 @@ TimeUpdateEvent::TimeUpdateEvent(const std::vector timeDomainPoints, _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)); + _numTimeDomainDataPoints*sizeof(double)); } } } -- cgit From e251c885f19281ef918987e09c2aac1af6a952c2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 24 Apr 2011 00:31:39 -0400 Subject: gr-qtgui: provide function and slot for setting the labels of a time curve. --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 5 +++++ gr-qtgui/lib/TimeDomainDisplayPlot.h | 1 + gr-qtgui/lib/qtgui_time_sink_c.cc | 6 ++++++ gr-qtgui/lib/qtgui_time_sink_c.h | 1 + gr-qtgui/lib/timedisplayform.cc | 5 +++++ gr-qtgui/lib/timedisplayform.h | 2 ++ 6 files changed, 20 insertions(+) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 70b11dd0e..28cca3aaa 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -208,6 +208,11 @@ TimeDomainDisplayPlot::set_xaxis(double min, double max) _zoomer->setZoomBase(); } +void +TimeDomainDisplayPlot::set_title(int which, QString title) +{ + _plot_curve[which]->setTitle(title); +} void TimeDomainDisplayPlot::replot() { diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h index fbfba584b..bc8b0c862 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -54,6 +54,7 @@ public: void set_yaxis(double min, double max); void set_xaxis(double min, double max); + void set_title(int which, QString title); public slots: void resizeSlot( QSize *s ); diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index 1cd391893..e57ef011a 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -130,6 +130,12 @@ qtgui_time_sink_c::set_update_time(double 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()); +} + int qtgui_time_sink_c::general_work (int noutput_items, gr_vector_int &ninput_items, diff --git a/gr-qtgui/lib/qtgui_time_sink_c.h b/gr-qtgui/lib/qtgui_time_sink_c.h index be057d508..97c1d6e52 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.h +++ b/gr-qtgui/lib/qtgui_time_sink_c.h @@ -78,6 +78,7 @@ public: void set_time_domain_axis(double min, double max); void set_update_time(double t); + void set_title(int which, const std::string &title); QApplication *d_qApplication; diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc index 368e47c95..816331771 100644 --- a/gr-qtgui/lib/timedisplayform.cc +++ b/gr-qtgui/lib/timedisplayform.cc @@ -164,3 +164,8 @@ TimeDisplayForm::SetUpdateTime(double t) displayTimer->start(d_update_time*1000); } +void +TimeDisplayForm::SetTitle(int which, QString title) +{ + _timeDomainDisplayPlot->set_title(which, title); +} diff --git a/gr-qtgui/lib/timedisplayform.h b/gr-qtgui/lib/timedisplayform.h index 888d28e21..db2d58db7 100644 --- a/gr-qtgui/lib/timedisplayform.h +++ b/gr-qtgui/lib/timedisplayform.h @@ -56,6 +56,8 @@ public slots: void SetUpdateTime(double t); + void SetTitle(int which, QString title); + private slots: void newData( const TimeUpdateEvent* ); void UpdateGuiTimer(); -- cgit From 43a3a7296412dc52216e7f63856a86945f4ba438 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 24 Apr 2011 01:30:08 -0400 Subject: gr-qtgui: clean up --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 21 ++++++++++----------- gr-qtgui/lib/TimeDomainDisplayPlot.h | 8 ++++---- gr-qtgui/lib/spectrumdisplayform.cc | 5 ++++- gr-qtgui/lib/timedisplayform.cc | 10 +++++----- 4 files changed, 23 insertions(+), 21 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 28cca3aaa..ee13a7dce 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -117,14 +117,13 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) canvas()->setPalette(palette); setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); - set_xaxis(0, _numPoints); + setXaxis(0, _numPoints); setAxisTitle(QwtPlot::xBottom, "Time (sec)"); setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); - set_yaxis(-2.0, 2.0); - setAxisTitle(QwtPlot::yLeft, "Normalized Voltage"); - - //QColor clr(Qt::blue); + setYaxis(-2.0, 2.0); + setAxisTitle(QwtPlot::yLeft, "Amplitude"); + QList colors; colors << QColor(Qt::blue) << QColor(Qt::red) << QColor(Qt::green) << QColor(Qt::black) << QColor(Qt::cyan) << QColor(Qt::magenta) @@ -149,9 +148,9 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) _resetXAxisPoints(); _zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); + Qt::RightButton, Qt::ControlModifier); _zoomer->setMousePattern(QwtEventPattern::MouseSelect3, - Qt::RightButton); + Qt::RightButton); _panner = new QwtPlotPanner(canvas()); _panner->setAxisEnabled(QwtPlot::yRight, false); @@ -195,21 +194,21 @@ TimeDomainDisplayPlot::~TimeDomainDisplayPlot() } void -TimeDomainDisplayPlot::set_yaxis(double min, double max) +TimeDomainDisplayPlot::setYaxis(double min, double max) { setAxisScale(QwtPlot::yLeft, min, max); _zoomer->setZoomBase(); } void -TimeDomainDisplayPlot::set_xaxis(double min, double max) +TimeDomainDisplayPlot::setXaxis(double min, double max) { setAxisScale(QwtPlot::xBottom, min, max); _zoomer->setZoomBase(); } void -TimeDomainDisplayPlot::set_title(int which, QString title) +TimeDomainDisplayPlot::setTitle(int which, QString title) { _plot_curve[which]->setTitle(title); } @@ -242,7 +241,7 @@ void TimeDomainDisplayPlot::PlotNewData(const std::vector dataPoints, _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints); } - set_xaxis(0, numDataPoints); + setXaxis(0, numDataPoints); _resetXAxisPoints(); } diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h index bc8b0c862..1693e7537 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -52,11 +52,11 @@ public: virtual void replot(); - void set_yaxis(double min, double max); - void set_xaxis(double min, double max); - void set_title(int which, QString title); - public slots: + void setYaxis(double min, double max); + void setXaxis(double min, double max); + void setTitle(int which, QString title); + void resizeSlot( QSize *s ); void SetSampleRate(double sr, double units, const std::string &strunits); diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index 2d2d8648f..991f51f47 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -43,6 +43,9 @@ SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) _averagedValues = new double[_numRealDataPoints]; _historyVector = new std::vector; + _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 ); @@ -698,7 +701,7 @@ SpectrumDisplayForm::ToggleTabConstellation(const bool state) void SpectrumDisplayForm::SetTimeDomainAxis(double min, double max) { - _timeDomainDisplayPlot->set_yaxis(min, max); + _timeDomainDisplayPlot->setYaxis(min, max); } void diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc index 816331771..05baee7f9 100644 --- a/gr-qtgui/lib/timedisplayform.cc +++ b/gr-qtgui/lib/timedisplayform.cc @@ -35,7 +35,7 @@ TimeDisplayForm::TimeDisplayForm(int nplots, QWidget* parent) _layout = new QGridLayout(this); _timeDomainDisplayPlot = new TimeDomainDisplayPlot(nplots, this); - _layout->addWidget(_timeDomainDisplayPlot, 0, 0, 100, 100); + _layout->addWidget(_timeDomainDisplayPlot, 0, 0); _numRealDataPoints = 1024; @@ -67,7 +67,6 @@ TimeDisplayForm::newData( const TimeUpdateEvent* spectrumUpdateEvent) { const std::vector timeDomainDataPoints = spectrumUpdateEvent->getTimeDomainPoints(); const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints(); - const timespec generatedTimestamp = {0,0}; _timeDomainDisplayPlot->PlotNewData(timeDomainDataPoints, numTimeDomainDataPoints, @@ -77,7 +76,8 @@ TimeDisplayForm::newData( const TimeUpdateEvent* spectrumUpdateEvent) void TimeDisplayForm::resizeEvent( QResizeEvent *e ) { - emit _timeDomainDisplayPlot->resizeSlot(&size()); + QSize s = size(); + emit _timeDomainDisplayPlot->resizeSlot(&s); } void @@ -153,7 +153,7 @@ TimeDisplayForm::closeEvent( QCloseEvent *e ) void TimeDisplayForm::SetTimeDomainAxis(double min, double max) { - _timeDomainDisplayPlot->set_yaxis(min, max); + _timeDomainDisplayPlot->setYaxis(min, max); } void @@ -167,5 +167,5 @@ TimeDisplayForm::SetUpdateTime(double t) void TimeDisplayForm::SetTitle(int which, QString title) { - _timeDomainDisplayPlot->set_title(which, title); + _timeDomainDisplayPlot->setTitle(which, title); } -- cgit From 11de76b9214a59930ac8d8c031880b5bd293973d Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 24 Apr 2011 01:47:05 -0400 Subject: gr-qtgui: adding function and slot to set a time display curve's color. --- gr-qtgui/lib/TimeDomainDisplayPlot.cc | 9 ++++++++- gr-qtgui/lib/TimeDomainDisplayPlot.h | 1 + gr-qtgui/lib/qtgui_time_sink_c.cc | 6 ++++++ gr-qtgui/lib/qtgui_time_sink_c.h | 1 + gr-qtgui/lib/timedisplayform.cc | 6 ++++++ gr-qtgui/lib/timedisplayform.h | 1 + 6 files changed, 23 insertions(+), 1 deletion(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index ee13a7dce..f635a2b0c 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -213,6 +213,12 @@ 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(); @@ -221,7 +227,8 @@ void TimeDomainDisplayPlot::replot() void TimeDomainDisplayPlot::resizeSlot( QSize *s ) { - resize(s->width(), s->height()); + // -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 dataPoints, diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h index 1693e7537..4c7b1e319 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h @@ -56,6 +56,7 @@ 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, diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index e57ef011a..a1f0130ba 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -136,6 +136,12 @@ 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::general_work (int noutput_items, gr_vector_int &ninput_items, diff --git a/gr-qtgui/lib/qtgui_time_sink_c.h b/gr-qtgui/lib/qtgui_time_sink_c.h index 97c1d6e52..fd1637232 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.h +++ b/gr-qtgui/lib/qtgui_time_sink_c.h @@ -79,6 +79,7 @@ public: 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; diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc index 05baee7f9..c2bb9f75d 100644 --- a/gr-qtgui/lib/timedisplayform.cc +++ b/gr-qtgui/lib/timedisplayform.cc @@ -169,3 +169,9 @@ 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 index db2d58db7..1e2ad601b 100644 --- a/gr-qtgui/lib/timedisplayform.h +++ b/gr-qtgui/lib/timedisplayform.h @@ -57,6 +57,7 @@ public slots: void SetUpdateTime(double t); void SetTitle(int which, QString title); + void SetColor(int which, QString color); private slots: void newData( const TimeUpdateEvent* ); -- cgit From 83c1463ef9aa550d8c44cd259cf14dea433e1973 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 24 Apr 2011 01:59:10 -0400 Subject: gr-qtgui: making (somewhat more) consistent case for function names. --- gr-qtgui/lib/qtgui_time_sink_c.cc | 8 ++++---- gr-qtgui/lib/timedisplayform.cc | 14 +++++++------- gr-qtgui/lib/timedisplayform.h | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index a1f0130ba..c011e8297 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -120,26 +120,26 @@ qtgui_time_sink_c::pyqwidget() void qtgui_time_sink_c::set_time_domain_axis(double min, double max) { - d_main_gui->SetTimeDomainAxis(min, 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); + 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()); + 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()); + d_main_gui->setColor(which, color.c_str()); } int diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc index c2bb9f75d..cc4ac9951 100644 --- a/gr-qtgui/lib/timedisplayform.cc +++ b/gr-qtgui/lib/timedisplayform.cc @@ -45,7 +45,7 @@ TimeDisplayForm::TimeDisplayForm(int nplots, QWidget* parent) // Create a timer to update plots at the specified rate displayTimer = new QTimer(this); - connect(displayTimer, SIGNAL(timeout()), this, SLOT(UpdateGuiTimer())); + connect(displayTimer, SIGNAL(timeout()), this, SLOT(updateGuiTimer())); connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)), this, SLOT(onTimePlotPointSelected(const QPointF))); @@ -99,7 +99,7 @@ TimeDisplayForm::customEvent( QEvent * e) } void -TimeDisplayForm::UpdateGuiTimer() +TimeDisplayForm::updateGuiTimer() { _timeDomainDisplayPlot->canvas()->update(); } @@ -111,7 +111,7 @@ TimeDisplayForm::onTimePlotPointSelected(const QPointF p) } void -TimeDisplayForm::SetFrequencyRange(const double newCenterFrequency, +TimeDisplayForm::setFrequencyRange(const double newCenterFrequency, const double newStartFrequency, const double newStopFrequency) { @@ -151,13 +151,13 @@ TimeDisplayForm::closeEvent( QCloseEvent *e ) } void -TimeDisplayForm::SetTimeDomainAxis(double min, double max) +TimeDisplayForm::setTimeDomainAxis(double min, double max) { _timeDomainDisplayPlot->setYaxis(min, max); } void -TimeDisplayForm::SetUpdateTime(double t) +TimeDisplayForm::setUpdateTime(double t) { d_update_time = t; // QTimer class takes millisecond input @@ -165,13 +165,13 @@ TimeDisplayForm::SetUpdateTime(double t) } void -TimeDisplayForm::SetTitle(int which, QString title) +TimeDisplayForm::setTitle(int which, QString title) { _timeDomainDisplayPlot->setTitle(which, title); } void -TimeDisplayForm::SetColor(int which, QString color) +TimeDisplayForm::setColor(int which, QString color) { _timeDomainDisplayPlot->setColor(which, color); } diff --git a/gr-qtgui/lib/timedisplayform.h b/gr-qtgui/lib/timedisplayform.h index 1e2ad601b..1216a1ef5 100644 --- a/gr-qtgui/lib/timedisplayform.h +++ b/gr-qtgui/lib/timedisplayform.h @@ -47,21 +47,21 @@ class TimeDisplayForm : public QWidget public slots: void resizeEvent( QResizeEvent * e ); void customEvent( QEvent * e ); - void SetFrequencyRange( const double newCenterFrequency, + void setFrequencyRange( const double newCenterFrequency, const double newStartFrequency, const double newStopFrequency ); void closeEvent( QCloseEvent * e ); - void SetTimeDomainAxis(double min, double max); + void setTimeDomainAxis(double min, double max); - void SetUpdateTime(double t); + void setUpdateTime(double t); - void SetTitle(int which, QString title); - void SetColor(int which, QString color); + void setTitle(int which, QString title); + void setColor(int which, QString color); private slots: void newData( const TimeUpdateEvent* ); - void UpdateGuiTimer(); + void updateGuiTimer(); void onTimePlotPointSelected(const QPointF p); -- cgit From f11a20190f36d3f7864f932118d157425e988d0a Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 24 Apr 2011 02:45:38 -0400 Subject: gr-qtgui: Adding float interface to qtgui_time_sink and example program. --- gr-qtgui/lib/Makefile.am | 2 + gr-qtgui/lib/qtgui_time_sink_c.cc | 1 + gr-qtgui/lib/qtgui_time_sink_f.cc | 197 ++++++++++++++++++++++++++++++++++++++ gr-qtgui/lib/qtgui_time_sink_f.h | 92 ++++++++++++++++++ 4 files changed, 292 insertions(+) create mode 100644 gr-qtgui/lib/qtgui_time_sink_f.cc create mode 100644 gr-qtgui/lib/qtgui_time_sink_f.h (limited to 'gr-qtgui/lib') diff --git a/gr-qtgui/lib/Makefile.am b/gr-qtgui/lib/Makefile.am index 517a67097..72b4b1450 100644 --- a/gr-qtgui/lib/Makefile.am +++ b/gr-qtgui/lib/Makefile.am @@ -57,6 +57,7 @@ libgnuradio_qtgui_la_SOURCES = \ qtgui_sink_c.cc \ qtgui_sink_f.cc \ qtgui_time_sink_c.cc \ + qtgui_time_sink_f.cc \ qtgui_util.cc nodist_libgnuradio_qtgui_la_SOURCES=$(QMAKE_SOURCES) @@ -77,6 +78,7 @@ grinclude_HEADERS = \ qtgui_sink_c.h \ qtgui_sink_f.h \ qtgui_time_sink_c.h \ + qtgui_time_sink_f.h \ qtgui_util.h #QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index c011e8297..f3bc168b2 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -94,6 +94,7 @@ qtgui_time_sink_c::initialize() // initialize update time to 10 times a second set_update_time(0.1); + d_last_time = {0,0}; } 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..056e6e119 --- /dev/null +++ b/gr-qtgui/lib/qtgui_time_sink_f.cc @@ -0,0 +1,197 @@ +/* -*- 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 +#endif + +#include +#include +#include + +#include + +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_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(); +} + +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::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_size, 8191); + } +} + +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); + + // initialize update time to 10 times a second + set_update_time(0.1); + d_last_time = {0,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::general_work (int noutput_items, + gr_vector_int &ninput_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 = get_highres_clock(); + + // 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(diff_timespec(d_current_time, 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 + else { + 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; + } + } + + consume_each(j); + return j; +} diff --git a/gr-qtgui/lib/qtgui_time_sink_f.h b/gr-qtgui/lib/qtgui_time_sink_f.h new file mode 100644 index 000000000..d77a94ef1 --- /dev/null +++ b/gr-qtgui/lib/qtgui_time_sink_f.h @@ -0,0 +1,92 @@ +/* -*- 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 +#include +#include +#include +#include +#include + +class qtgui_time_sink_f; +typedef boost::shared_ptr qtgui_time_sink_f_sptr; + +qtgui_time_sink_f_sptr qtgui_make_time_sink_f(int size, double bw, + const std::string &name, + int nconnectons=1, + QWidget *parent=NULL); + +class qtgui_time_sink_f : public gr_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); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + + void initialize(); + + int d_size; + double d_bandwidth; + std::string d_name; + int d_nconnections; + + int d_index; + std::vector d_residbufs; + + double d_update_time; + + QWidget *d_parent; + TimeDisplayForm *d_main_gui; + + timespec d_current_time; + timespec 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 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_TIME_SINK_F_H */ -- cgit